/** * Singleton call for creating the instance * Creates a new instance if it does not already exist * * @return Core $instance - The instance */ public function instance() { if (self::$instance != null) { return self::$instance; } return self::$instance = new TemplateRenderer(); }
private function _getShowCase($genre, $page = 0, $size = 4) { $books = $this->_getBooksByGenre($genre, $page, $size); $num_books = Core::instance()->getDb()->countBookyByGenre($genre); if (count($books) == 0) { return null; } $args = array('books' => $books, 'style' => 'showcase', 'text_details' => i('To the details'), 'navigation' => true, 'prev_hidden' => $num_books <= $size, 'next_hidden' => count($books) < $size, 'config' => urlencode(json_encode(array('page' => $page, 'size' => $size, 'request' => Controller::instance()->getViewUrl() . '&ajax=1&ajax_fn=nextShowcasePage&page={%page%}&size={%size%}&genre=' . $genre)))); return TemplateRenderer::instance()->extendedRender('theme/templates/snippets/showcase.html', $args); }
public function tesRendermenue() { $renderer = TemplateRenderer::instance(); $naviArray[] = array("link" => "index.php?view=home", "icon" => "icon_house_alt", "cls" => 'stdanimation', "label" => "Home"); $naviArray[] = array("link" => "index.php?view=profile", "icon" => "icon_profile", "cls" => 'stdanimation', "label" => "Profile"); $naviArray[] = array("link" => "index.php?view=categories", "icon" => "icon_tag", "cls" => 'stdanimation', "label" => "Categories"); $naviArray[] = array("link" => "index.php?view=shoppingcart", "icon" => "icon_cart", "cls" => 'stdanimation', "label" => "Shopping Cart"); $naviArray[] = array("link" => "index.php?view=wishlist", "icon" => "icon_gift", "cls" => 'stdanimation', "label" => "Wishlist"); $naviArray[] = array("link" => "index.php?view=hotlist", "icon" => "icon_grid-2x2", "cls" => 'stdanimation', "label" => "Hotlist"); $renderer->extendedRender(realpath('../theme/templates/test.html'), array('entries' => $naviArray)); }
public function render() { $page_size = 10; $query = isset($_REQUEST['query']) ? $_REQUEST['query'] : null; $cat = isset($_REQUEST['cat']) ? $_REQUEST['cat'] : null; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 0; $result = $this->_getSearchResult($query, $cat, $page, $page_size); $args = array('books' => $result['books'], 'text_details' => i('To the details')); $content = TemplateRenderer::instance()->extendedRender('theme/templates/snippets/booklist.html', $args); $pagination = Utilities::pagination($page, $result['total'], $page_size, '?view=search&query=' . $query . '&cat' . $cat . '&page={page}'); $args = array('title' => i('We found following books for you'), 'result' => $content, 'pagination' => $pagination); return TemplateRenderer::instance()->extendedRender('theme/templates/views/search.html', $args); }
public function render() { if ($this->isAjaxRequest()) { $response = $this->renderAjax(); header('Content-Type: text/json; charset=utf-8'); return $response; } $args = array('WWWROOT' => WWWROOT, 'WWWTHEME' => WWWTHEME, 'WWWCSS' => WWWCSS, 'WWWJS' => WWWJS, 'header' => $this->viewlets['header']->render(), 'navi' => $this->viewlets['navi']->render(), 'footer' => $this->viewlets['footer']->render(), 'view_content' => $this->view->render()); header('Content-Type: text/html; charset=utf-8'); return TemplateRenderer::instance()->extendedRender('theme/templates/index.html', $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' => '<<', 'link' => Utilities::templateReplace($link, array('page' => 0)), 'current' => false), 'links' => $links, 'end' => array('label' => '>>', '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; }
public function render() { $result = $this->_getSearchResult($_REQUEST['query'], $_REQUEST['cat']); $args = array('title' => 'Search', 'result' => $result); return TemplateRenderer::instance()->extendedRender('theme/templates/views/search.html', $args); }
/** * Loads the correct template diractory in the Template renderer * and initiates the PHP-session */ private function __construct() { session_start(); TemplateRenderer::instance()->setTplDir(TEMPLATE_TMP_DIR); }
/** * Calls the render method of the Current view * and renders the main page with tha data from * the viewlets. * This method sets the header of the page. * - text/json for ajax requests * - text/html for normal requests * */ public function render() { if ($this->isAjaxRequest()) { header('Content-Type: text/json; charset=utf-8'); $response = $this->renderAjax(); return $response; } $args = array('WWWROOT' => WWWROOT, 'WWWTHEME' => WWWTHEME, 'WWWCSS' => WWWCSS, 'WWWJS' => WWWJS, 'view_content' => $this->view->render()); foreach ($this->viewlets as $key => $viewlet) { $args[$key] = $viewlet->render(); } header('Content-Type: text/html; charset=utf-8'); return TemplateRenderer::instance()->extendedRender('theme/templates/index.html', $args); }