/** * Dispatchs the request */ public function dispatch() { $this->variables = array_merge($this->variables, array('method' => $_SERVER['REQUEST_METHOD'])); $code = 404; foreach ($this->routes as $path => $action) { if (is_array($params = $this->routeMatch($path))) { list($ctrl, $action) = explode('#', $action); $ctrl_class = 'Controller\\' . $ctrl; /** @var Controller\Base $ctrl_inst */ $ctrl_inst = new $ctrl_class(); $ctrl_inst->setVariables($this->variables); try { if (method_exists($ctrl_inst, $action . 'Action')) { $template_params = $ctrl_inst->{$action . 'Action'}($params); } else { $template_params = array(); } $renderer = new TemplateRenderer($ctrl, $action); $renderer->renderWithLayout(array_merge($this->variables, $template_params ?: array())); return; } catch (Controller\Exception\Base $e) { break; } catch (\Exception $e) { file_put_contents('res/log/error.log', $e->getMessage()); $code = 500; break; } } } $renderer = new TemplateRenderer('Error', $code); $renderer->renderWithLayout($this->variables); }
private function view(Tracker_IDisplayTrackerLayout $layout) { $presenter = $this->presenter_builder->getPresenter($this->tracker); $this->displayHeader($layout, $presenter->title()); $this->renderer->renderToPage('admin-perms-tracker', $presenter); $this->displayFooter($layout); }
private function showAddPermissions($group_id) { $group = $this->user_group_factory->getForgeUserGroupById($group_id); $unused_permissions = $this->user_group_permissions_factory->getAllUnusedForgePermissionsForForgeUserGroup($group); $presenter = new Admin_PermissionDelegationPermissionsModalPresenter($group, $unused_permissions); $this->renderer->renderToPage('permissions_modal', $presenter); }
/** * Sets the template directory, please check * that the permissions are set correctly * @param string $dir - the template directory which contains the templates */ public function setTplDir($dir) { $dir = realpath($dir); if (!file_exists($dir) || !is_dir($dir)) { throw new Exception("This folder {$dir} does not exist!"); } TemplateRenderer::$tmp_dir = $dir; }
private function displayHeaderInArtifactLinkModal(Tracker_IFetchTrackerSwitcher $layout, Codendi_Request $request, PFUser $current_user, Tracker_Report $report, array $reports, $link_artifact_id) { $project = null; $artifact = Tracker_ArtifactFactory::instance()->getArtifactByid($link_artifact_id); if ($artifact) { $project = $artifact->getTracker()->getProject(); } $this->renderer->renderToPage('header_in_artifact_link_modal', new Tracker_Report_HeaderInArtifactLinkModalPresenter($GLOBALS['Language']->getText('plugin_tracker_report', 'current_report'), $layout->fetchTrackerSwitcher($current_user, '<br />', $project, $report->getTracker()), $this->getSelectReportUrl($request, $report), $this->getReportSelector($report, $reports))); }
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)); }
/** * @return Codendi_Mail */ public function buildEmail(Project $project, Notification $notification) { $mail = new Codendi_Mail(); $mail->setFrom(ForgeConfig::get('sys_noreply')); $mail->setBcc($this->getBcc($notification)); $mail->setTo(''); if ($project->getTruncatedEmailsUsage()) { $presenter = new MailPresenter($notification->getServiceName(), $notification->getGotoLink(), ForgeConfig::get('sys_fullname')); $mail->setSubject($this->renderer->renderToString(self::TRUNCATED_SUBJECT_TEMPLATE, $presenter)); $mail->setBodyHtml($this->renderer->renderToString(self::TRUNCATED_BODY_TEMPLATE, $presenter)); } else { if ($notification->hasHTMLBody()) { $mail->setBodyHtml($notification->getHTMLBody()); } if ($notification->hasTextBody()) { $mail->setBodyText($notification->getTextBody()); } $mail->setSubject($notification->getSubject()); } return $mail; }
/** * Returns a new Codendi_Mail. * * @return Codendi_Mail */ public function getMailNotificationProject($subject, $from, $to, $project) { $mail = new Codendi_Mail(); $cid_logo = $this->addLogoInAttachment($mail); $mail->setSubject($subject); $mail->setTo($to); $presenter = $this->mail_presenter_factory->createMailProjectNotificationPresenter($project, $cid_logo); $mail->setBodyHtml($this->renderer->renderToString($this->template, $presenter)); $mail->setBodyText($presenter->getMessageText()); $mail->setFrom($from); return $mail; }
private function buildEmail(Project $project, Notification $notification, MailEnhancer $mail_enhancer, $email) { $mail = $this->getMailSender(); $mail->setFrom(ForgeConfig::get('sys_noreply')); $mail->setTo($email); if ($project->getTruncatedEmailsUsage()) { $presenter = new MailPresenter($notification->getServiceName(), $notification->getGotoLink(), ForgeConfig::get('sys_fullname')); $mail->setSubject($this->renderer->renderToString(self::TRUNCATED_SUBJECT_TEMPLATE, $presenter)); $mail->setBodyHtml($this->renderer->renderToString(self::TRUNCATED_BODY_TEMPLATE, $presenter)); } else { $mail_enhancer->enhanceMail($mail); if ($notification->hasHTMLBody()) { $mail->setBodyHtml($notification->getHTMLBody()); } if ($notification->hasTextBody()) { $mail->setBodyText($notification->getTextBody()); } $mail->setSubject($notification->getSubject()); } return $mail; }
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); }
/** * @param Search_SearchQuery $query * @return Search_SearchResults */ private function doSearch(Search_SearchQuery $query) { $results = new Search_SearchResults(); $search = new Search_SearchPlugin($this->event_manager); $search->search($query, $results); if ($results->getResultsHtml() !== '') { return $results; } if (!isset($this->search_types[$query->getTypeOfSearch()])) { return $results; } $presenter = $this->search_types[$query->getTypeOfSearch()]->search($query, $results); if ($presenter) { if ($query->isAjax() && $query->getOffset() > 0) { $results->setResultsHtml($this->renderer->renderToString($presenter->getTemplate() . '-more', $presenter)); } else { $results->setResultsHtml($this->renderer->renderToString($presenter->getTemplate(), $presenter)); } } return $results; }
public function __construct($plugin_templates_dir) { parent::__construct($plugin_templates_dir); $this->template_engine = $this->buildTemplateEngine(); $this->template_loader = new MustacheLoader($this->plugin_templates_dir); }
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; }
protected function fetchTable() { return $this->renderer->renderToString('backlog', $this); }
protected function renderToString($template_name, $presenter) { return $this->renderer->renderToString($template_name, $presenter); }
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); }
/** * 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); }
/** * 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); }
public function getAllIncludesForHostname($hostname, array $project_names) { return $this->template_renderer->renderToString('gitolite-includes-for-hostname.conf', array("hostname" => $hostname, "project_names" => $project_names)); }
/** * Renders a partial template in View/. The view name must be underscore-prefixed * * @param string $name Like "controller/action" (will find View/controller/_action.php) * @param string[] $vars * @return string Rendered template */ function partial($name, $vars) { list($ctrl, $action) = explode('/', $name); $renderer = new TemplateRenderer($ctrl, '_' . $action); return $renderer->render($vars); }
private function render($template_name, $presenter) { $this->renderer->renderToPage($template_name, $presenter); }
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); }
/** * {@inheritdoc} */ public function add_lang(array $lang) { $this->renderer->add_lang($lang); }