2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * hold PMA\Template class
11 if (! defined('PHPMYADMIN')) {
18 * Handle front end templating
25 protected $name = null;
27 const BASE_PATH
= 'templates/';
30 * Template constructor
32 * @param string $name Template name
34 protected function __construct($name)
42 * @param string $name Template name
46 public static function get($name)
48 return new Template($name);
52 * Remove whitespaces between tags and innerHTML
54 * @param string $content HTML to perform the trim method
58 public static function trim($content)
60 $regexp = '/(<[^\/][^>]+>)\s+|\s+(<\/)/';
62 return preg_replace($regexp, "$1$2", $content);
68 * @param array $data Variables to provides for template
69 * @param bool $trim Trim content
73 public function render($data = array(), $trim = true)
75 $template = static::BASE_PATH
. $this->name
. '.phtml';
79 if (file_exists($template)) {
82 throw new \
LogicException(
83 'The template "' . $template . '" not found.'
87 $content = Template
::trim(ob_get_clean());
89 $content = ob_get_clean();
93 } catch (\LogicException
$e) {
95 throw new \
LogicException($e->getMessage());