/**
  * Renders a template file
  * @params string $template - path of template file
  * @params assoc-array $args - associative array with the to be replaced values
  */
 public function render($template, $args)
 {
     if (!file_exists($template)) {
         throw new Exception('The template "' . $template . '" does not exist');
     }
     $html = Utilities::getFileContent($template);
     $html = Utilities::templateReplace($html, $args, static::$var_prefix, static::$var_suffix);
     return $html;
 }
 public static function translate($key, $args = array())
 {
     $inst = I18N::instance();
     if (!array_key_exists($key, static::$translations[static::$lang])) {
         $val = $key;
     } else {
         $val = static::$translations[static::$lang][$key];
     }
     $GLOBALS['debug'] = true;
     return Utilities::templateReplace($val, $args);
 }
 public static function pagination($current, $max, $page_size, $link, $prevnext = 2)
 {
     $min_page = $current - $prevnext;
     $max_page = ceil($max / $page_size);
     $start = max($min_page, 0);
     $end = (int) min($max_page, $start + 1 + 2 * $prevnext);
     $links = array();
     for ($now = $start; $now < $end; $now++) {
         $links[] = array('label' => $now + 1, 'link' => Utilities::templateReplace($link, array('page' => $now)), 'current' => $now == $current);
     }
     $args = array('start' => array('label' => '&lt;&lt;', 'link' => Utilities::templateReplace($link, array('page' => 0)), 'current' => false), 'links' => $links, 'end' => array('label' => '&gt;&gt;', 'link' => Utilities::templateReplace($link, array('page' => $end - 1)), 'current' => false), 'current' => $current, 'canPrev' => $current != 0 && $start != 0, 'canNext' => $current != $end - 1 && $end != $max_page);
     $pagination = TemplateRenderer::instance()->extendedRender('theme/templates/snippets/pagination.html', $args);
     return $pagination;
 }
 protected function _queryTemplate($template, $args)
 {
     return Utilities::templateReplace($template, $args, '{%', '%}');
 }