public function build(Template $template, array $data = []) { $buffer = $template->getContent(); if (strpos($buffer, '@SET_LAYOUT') !== false) { $layoutTemp = explode("SET_LAYOUT '", $buffer)[1]; $layoutTemp = explode("';", $layoutTemp)[0]; $layout = new Template(); $layout->setFile(\Framework\Kernel::instance()->getApplicationRoot() . "/../App/Views/" . $layoutTemp . ".phtml"); $layoutContent = $layout->getContent(); $data = explode("\n", $buffer); $data[0] = ""; $buffer = implode("\n", $data); $buffer = str_replace("@BODY_SECTION", $buffer, $layoutContent); } $temp = $buffer; preg_match_all('/\\{{(.*?)\\}}/', $temp, $logic); foreach ($logic[1] as $key => $value) { $tmp = trim($value); $mustEcho = false; if (strpos($tmp, " ") === false && strpos($tmp, "--") === false && strpos($tmp, "++") === false && strpos($tmp, "=") === false && $tmp[0] === "\$") { $mustEcho = true; } $buffer = str_replace($logic[0][$key], ($mustEcho ? "<?=" : '<?php ') . $value . ' ?>', $buffer); } return $buffer; }
public function loadTemplateExtended(Template $template, &$globals) { if ($this->benchmarkRendering) { $this->Benchmark->start('load-template-extended-' . $template->getName()); } // if(!($templateFileCached = $this->TemplateCache->get('t:'.$template->getName()))) // { if (!$this->TemplateService->fileExists($template->getName())) { throw new TemplateEngineException("Template file not found for template name: " . $template->getName()); } $file = $this->TemplateService->resolveFile($template->getName()); $template->setFile($file->getLocalPath()); $this->Logger->debug("Loading template file: " . $template->getFile()); $this->loadTemplateContents($template, $globals); $this->Logger->debug('Parsing set blocks: ' . $template->getName()); if (preg_match_all("/\\{\\%\\s+(set|setGlobal|appendGlobal)\\s+([^\\%]+?)\\s+\\%\\}[\n\r\t]*(.*?)[\n\r\t]*\\{\\%\\s+end\\s+\\%\\}/s", $template->getContents(), $setMatches, PREG_SET_ORDER)) { $template->setSetMatches($setMatches); } else { $template->setSetMatches(array()); } // $this->TemplateCache->put('t:'.$template->getName(), $template, 0); // } else { // // $template->setFile($templateFileCached->getFile()); // $template->setSetMatches($templateFileCached->getSetMatches()); // $template->setContents($templateFileCached->getContents()); // // } $params = $template->getLocals(); $templateSetGlobals = array(); foreach ($template->getSetMatches() as $m) { $m[3] = $this->parseFormatVariables($m[3], $this->getConstants()); switch ($m[1]) { case 'set': if (array_key_exists($m[2], $params)) { continue; } $val = $this->parseFormatVariablesAndFilters($m[3], $params); $params[$m[2]] = $val; break; case 'setGlobal': $templateSetGlobals[$m[2]] = $m[3]; break; case 'appendGlobal': $val = $this->parseFormatVariablesAndFilters($m[3], $params); if (!array_key_exists($m[2], $globals)) { $templateSetGlobals[$m[2]] = $val; } else { $templateSetGlobals[$m[2]] = $globals[$m[2]]; $templateSetGlobals[$m[2]] .= $val; } break; } } // $this->Logger->debug(__CLASS__,$params); $template->setLocals($params); $template->setTemplateSetGlobals($templateSetGlobals); if (!empty($params['CacheTime'])) { $template->setCacheTime($params['CacheTime']); } if ($template->getCacheTime() > 0 && (empty($params['NoCache']) || StringUtils::strToBool($params['NoCache']) == false)) { // if this module is not marked as NoCache $template->setCacheable(true); } if ($this->benchmarkRendering) { $this->Benchmark->end('load-template-extended-' . $template->getName()); } return $template; }
<?php require_once '../Template.php'; $template = new Template(); /* or $template = new Template('index.phtml', '@layout.phtml'); */ $template->title = "Variable example"; $template->array = array('1' => "First array item", '2' => "Second array item", 'n' => "N-th array item"); $template->j = 5; //fluent interface $template->setFile('index.phtml')->setLayout('@layout.phtml')->render(); /* or $template->setup('index.phtml', '@layout.phtml')->render(); */
* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. */ /** Set flag that this is a parent file */ define("_VALID_UA", 1); require_once "config.inc.php"; require_once "include/page.inc.php"; require_once "include/db.functions.php"; require_once "include/export.inc.php"; require_once "include/rules/game.rules.php"; require_once "include/time.inc.php"; require_once "include/basic.lib.php"; require_once "include/movement.lib.php"; require_once "include/artefact.inc.php"; require_once "include/template.inc.php"; require_once "include/basic.lib.php"; page_start(); init_buildings(); init_defenseSystems(); init_resources(); init_units(); init_sciences(); $template = new Template(); $template->setFile('export.tmpl'); $content = export_switch(); $template->addVar('content', $content); $template->render(); page_end();
<h1>Nette\Templates\TemplateFilters::texyElements test</h1> <?php require_once '../../Nette/loader.php'; class MockTexy { function process($text, $singleLine = FALSE) { return '<...>'; } } /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); $template->setFile(dirname(__FILE__) . '/templates/texy-elements.phtml'); $template->registerFilter(array('Nette\\Templates\\TemplateFilters', 'texyElements')); $template->render();
<h1>Nette\Templates\TemplateFilters::netteLinks test</h1> <?php require_once '../../Nette/loader.php'; class MockPresenterComponent extends PresenterComponent { function link($destination, $args = array()) { $args = http_build_query($args); return "LINK({$destination} {$args})"; } } /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); //$template->setCacheStorage(new /*Nette\Caching\*/DummyStorage); $template->setFile(dirname(__FILE__) . '/templates/nette-links.phtml'); $template->registerFilter(array('Nette\\Templates\\TemplateFilters', 'netteLinks')); $template->registerHelper('escape', 'Nette\\Templates\\TemplateHelpers::escapeHtml'); $template->control = new MockPresenterComponent(); $template->render();
<h1>Nette\Templates\CurlyBracketsFilter & cache test</h1> <pre> <?php require_once '../../Nette/loader.php'; /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); $template->setFile(dirname(__FILE__) . '/templates/curly-brackets-cache.phtml'); $template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke'); $template->registerHelperLoader('Nette\\Templates\\TemplateHelpers::loader'); $template->title = 'Hello'; $template->id = 456; $template->render();
} extract($system->cache->c_get("XML", "xml-stats", array('xml_time' => $xml_time, '_CONFIG' => $_CONFIG)), EXTR_OVERWRITE); $system->xmlfix(); if (count($system->tpl) < 1) { die("Error, tpl not found"); } $tpl = new Template($system->_root . $_CONFIG['tpl'] . $system->tpl[$_SESSION['tplsl']]['name'] . "/"); if ($tpl->setFile('page', "main.tpl")) { $tpl->parseFile('page'); } else { if ($_SESSION['tplsl'] == $system->d_tpl) { die("Error, " . $system->_root . $_CONFIG['tpl'] . $system->tpl[$_SESSION['tplsl']]['name'] . "/main.tpl" . " not found"); } else { $_SESSION['tplsl'] = $system->d_tpl; $tpl = new Template($system->_root . $_CONFIG['tpl'] . $system->tpl[$_SESSION['tplsl']]['name'] . "/"); if ($tpl->setFile('page', "main.tpl")) { $tpl->parseFile('page'); } else { die("Error, " . $system->_root . $_CONFIG['tpl'] . $system->tpl[$_SESSION['tplsl']]['name'] . "/main.tpl" . " not found"); } } } $system->mods->load(); //------------------- $system->mods->getactive(&$tpl); if (!$_CONFIG['logo']) { $tpl->setParam('PAGE_logo', ""); } else { $tpl->setParam('PAGE_logo', "<img width=770 src=\"{$_CONFIG['logo']}\" alt=\"Logo\"/>"); } $fcss = new File($system->_root . $_CONFIG['tpl'] . $system->tpl[$_SESSION['tplsl']]['name'] . "/server_stats.css", 'r');
<h1>Nette\Templates\CurlyBracketsFilter & helpers test</h1> <?php require_once '../../Nette/loader.php'; /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ class MyHelper { protected $count = 0; public function invoke($s) { $this->count++; return strtolower($s) . " ({$this->count} times)"; } } Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); $template->setFile(dirname(__FILE__) . '/templates/curly-brackets-helpers.phtml'); $template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke'); $template->registerHelper('nl2br', 'nl2br'); $template->registerHelper('h1', array(new MyHelper(), 'invoke')); $template->registerHelper('h2', 'strtoupper'); $template->registerHelperLoader('Nette\\Templates\\TemplateHelpers::loader'); $template->hello = 'Hello World'; $template->date = strtotime('2008-01-02'); $template->render();
public function getTemplate($templateFile) { $template = new Template(); $template->registerFilter(new LatteFilter()); $template->setFile(dirname(__FILE__) . '/' . $this->getDriver() . '/templates/' . $templateFile . '.psql'); return $template; }
function page_finish($id = '') { $messageText = array('cookie' => array('title' => _('Cookie fehler'), 'msg' => _('Sie müssen 3rd party cookies erlauben.<br /><br /<a href="' . LOGIN_PATH . '">Hier gehts weiter zum Portal</a>')), 'default' => array('title' => _('Warnmeldung'), 'msg' => _('Es ist ein Fehler aufgetreten. Bitte erneut einloggen um weiterspielen zu können.')), 'db' => array('title' => _('Datenbank Fehler'), 'msg' => _('Es konnte keine Verbindung zur Datenbank hergestellt werden!<br />Bitte wende dich an einen Administrator oder versuche es später erneut.')), 'inaktiv' => array('title' => _('Inaktivität'), 'msg' => sprintf(_('Du warst für %s Minuten oder mehr inaktiv. Bitte log dich erneut ins Spiel ein um weiterspielen zu können.'), (int) (SESSION_MAX_LIFETIME / 60))), 'logout' => array('title' => _('Logout'), 'msg' => _('Du bist jetzt ausgeloggt und kannst den Browser schließen oder weitersurfen.<br /><br />Vielen Dank für das Spielen von Uga-Agga!')), 'wrongSessionID' => array('title' => _('Session Fehler'), 'msg' => _('Falsche oder ungültige SessionID.'))); $useAjax = Request::getVar('method', '') == 'ajax' ? true : false; if (!empty($id) && isset($messageText[$id])) { $message = $messageText[$id]; } else { $message = $messageText['default']; } $message['msg'] = $message['msg'] . '<br /><br /><a class="absolute" href="' . LOGIN_PATH . '">Hier gehts weiter zum Portal</a>'; @session_start(); @session_destroy(); if ($useAjax) { die(json_encode(array('mode' => 'finish', 'title' => $message['title'], 'msg' => $message['msg']))); } else { // load and open template $template = new Template(UA_GAME_DIR . '/templates/de_DE/uga/'); $template->setFile('finish.tmpl'); $template->addVars(array('gfx' => DEFAULT_GFX_PATH, 'login_path' => LOGIN_PATH, 'status_msg' => $message, 'time' => date("d.m.Y H:i:s"))); $template->render(); } die; }
$template->thisScript = $thisScript; $template->id = $transaction->id; $template->description = $transaction->description; $template->amount = $transaction->amount; $template->cleared = $transaction->cleared; $template->time = date('M j, Y g:i A', strtotime($transaction->time)); $template->setFile('templates/update-modal.phtml')->setLayout('templates/@null-layout.phtml')->render(); } elseif ($verb == 'deleteModal') { $transaction = $ledgerManager->retrieveTransaction($id); $template = new Template(); $template->thisScript = $thisScript; $template->id = $transaction->id; $template->description = $transaction->description; $template->amount = $transaction->amount; $template->time = date('M j, Y g:i A', strtotime($transaction->time)); $template->setFile('templates/delete-modal.phtml')->setLayout('templates/@null-layout.phtml')->render(); } else { echo '(nope)'; } } $logString = "[jart] verb: " . $verb . " duration: " . $duration . " in secs: " . (microtime(true) - $startTime); error_log($logString); function setupEnvironment() { try { $environmentFile = file_get_contents('env.setup'); } catch (Exception $e) { error_log('Mysql creds not determined, exiting'); exit(1); } return explode("\n", $environmentFile);
<h1>Nette\Templates\TemplateFilters::removePhp test</h1> <?php require_once '../../Nette/loader.php'; /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); //$template->setCacheStorage(new /*Nette\Caching\*/DummyStorage); $template->setFile(dirname(__FILE__) . '/templates/remove-php.phtml'); $template->registerFilter(array('Nette\\Templates\\TemplateFilters', 'removePhp')); $template->render();
/** * Method to prepare a new Tree Menu. * * This method processes items of a menu to prepare and return * the corresponding Tree Menu code. * * @access public * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newTreeMenu($menu_name = "") { if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) { $this->error("newTreeMenu: the first/last item of the menu '{$menu_name}' is not defined; please check if you have parsed its menu data."); return 0; } $this->_treeMenu[$menu_name] = ""; $img_space = $this->imgwww . "tree_space." . $this->treeMenuImagesType; $alt_space = " "; $img_vertline = $this->imgwww . "tree_vertline." . $this->treeMenuImagesType; $alt_vertline = "| "; $img_expand = $this->imgwww . "tree_expand." . $this->treeMenuImagesType; $alt_expand = "+-"; $img_expand_first = $this->imgwww . "tree_expand_first." . $this->treeMenuImagesType; $alt_expand_first = "+-"; $img_expand_corner = $this->imgwww . "tree_expand_corner." . $this->treeMenuImagesType; $alt_expand_corner = "+-"; $img_collapse = $this->imgwww . "tree_collapse." . $this->treeMenuImagesType; $alt_collapse = "--"; $img_collapse_first = $this->imgwww . "tree_collapse_first." . $this->treeMenuImagesType; $alt_collapse_first = "--"; $img_collapse_corner = $this->imgwww . "tree_collapse_corner." . $this->treeMenuImagesType; $alt_collapse_corner = "--"; $img_split = $this->imgwww . "tree_split." . $this->treeMenuImagesType; $alt_split = "|-"; $img_split_first = $this->imgwww . "tree_split_first." . $this->treeMenuImagesType; $alt_split_first = "|-"; $img_corner = $this->imgwww . "tree_corner." . $this->treeMenuImagesType; $alt_corner = "`-"; $img_folder_closed = $this->imgwww . "tree_folder_closed." . $this->treeMenuImagesType; $alt_folder_closed = "->"; $img_folder_open = $this->imgwww . "tree_folder_open." . $this->treeMenuImagesType; $alt_folder_open = "->"; $img_leaf = $this->imgwww . "tree_leaf." . $this->treeMenuImagesType; $alt_leaf = "->"; for ($i = 0; $i <= $this->_maxLevel[$menu_name]; $i++) { $levels[$i] = 0; } // Find last nodes of subtrees $last_level = $this->_maxLevel[$menu_name]; for ($i = $this->_lastItem[$menu_name]; $i >= $this->_firstItem[$menu_name]; $i--) { if ($this->tree[$i]["level"] < $last_level) { for ($j = $this->tree[$i]["level"] + 1; $j <= $this->_maxLevel[$menu_name]; $j++) { $levels[$j] = 0; } } if ($levels[$this->tree[$i]["level"]] == 0) { $levels[$this->tree[$i]["level"]] = 1; $this->tree[$i]["last_item"] = 1; } else { $this->tree[$i]["last_item"] = 0; } $last_level = $this->tree[$i]["level"]; } $toggle = ""; $toggle_function_name = "toggle" . $menu_name; for ($cnt = $this->_firstItem[$menu_name]; $cnt <= $this->_lastItem[$menu_name]; $cnt++) { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "\" class=\"{$menu_name}_treemenudiv\">\n"; // vertical lines from higher levels for ($i = 0; $i < $this->tree[$cnt]["level"] - 1; $i++) { if ($levels[$i] == 1) { $img = $img_vertline; $alt = $alt_vertline; } else { $img = $img_space; $alt = $alt_space; } $this->_treeMenu[$menu_name] .= "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img . "\" alt=\"" . $alt . "\" />"; } $not_a_leaf = $cnt < $this->_lastItem[$menu_name] && $this->tree[$cnt + 1]["level"] > $this->tree[$cnt]["level"]; if ($this->tree[$cnt]["last_item"] == 1) { // corner at end of subtree or t-split if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "')\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img_collapse_corner . "\" alt=\"" . $alt_collapse_corner . "\" /></a>"; } else { $this->_treeMenu[$menu_name] .= "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img_corner . "\" alt=\"" . $alt_corner . "\" />"; } $levels[$this->tree[$cnt]["level"] - 1] = 0; } else { if ($not_a_leaf) { if ($cnt == $this->_firstItem[$menu_name]) { $img = $img_collapse_first; $alt = $alt_collapse_first; } else { $img = $img_collapse; $alt = $alt_collapse; } $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "');\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img . "\" alt=\"" . $alt . "\" /></a>"; } else { if ($cnt == $this->_firstItem[$menu_name]) { $img = $img_split_first; $alt = $alt_split_first; } else { $img = $img_split; $alt = $alt_split; } $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "');\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img . "\" alt=\"" . $alt . "\" /></a>"; } $levels[$this->tree[$cnt]["level"] - 1] = 1; } if ($this->tree[$cnt]["parsed_link"] == "" || $this->tree[$cnt]["parsed_link"] == "#") { $a_href_open_img = ""; $a_href_close_img = ""; $a_href_open = "<a class=\"{$menu_name}_phplmnormal\">"; $a_href_close = "</a>"; } else { $a_href_open_img = "<a href=\"" . $this->tree[$cnt]["parsed_link"] . "\"" . $this->tree[$cnt]["parsed_title"] . $this->tree[$cnt]["parsed_target"] . ">"; $a_href_close_img = "</a>"; $a_href_open = "<a href=\"" . $this->tree[$cnt]["parsed_link"] . "\"" . $this->tree[$cnt]["parsed_title"] . $this->tree[$cnt]["parsed_target"] . " class=\"{$menu_name}_phplm\">"; $a_href_close = "</a>"; } if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= $a_href_open_img . "<img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "folder\" src=\"" . $img_folder_open . "\" alt=\"" . $alt_folder_open . "\" />" . $a_href_close_img; } else { if ($this->tree[$cnt]["parsed_icon"] != "") { $this->_treeMenu[$menu_name] .= $a_href_open_img . "<img align=\"top\" border=\"0\" src=\"" . $this->imgwww . $this->tree[$cnt]["parsed_icon"] . "\" width=\"" . $this->tree[$cnt]["iconwidth"] . "\" height=\"" . $this->tree[$cnt]["iconheight"] . "\" alt=\"" . $alt_leaf . "\" />" . $a_href_close_img; } else { $this->_treeMenu[$menu_name] .= $a_href_open_img . "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img_leaf . "\" alt=\"" . $alt_leaf . "\" />" . $a_href_close_img; } } $this->_treeMenu[$menu_name] .= " " . $a_href_open . $this->tree[$cnt]["text"] . $a_href_close . "\n"; $this->_treeMenu[$menu_name] .= "</div>\n"; if ($cnt < $this->_lastItem[$menu_name] && $this->tree[$cnt]["level"] < $this->tree[$cnt + 1]["level"]) { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "son\" class=\"{$menu_name}_treemenudiv\">\n"; if ($this->tree[$cnt]["expanded"] != 1) { $toggle .= "if (expand[" . $cnt . "] != 1) " . $toggle_function_name . "('" . $cnt . "');\n"; } else { $toggle .= "if (collapse[" . $cnt . "] == 1) " . $toggle_function_name . "('" . $cnt . "');\n"; } } if ($cnt > $this->_firstItem[$menu_name] && $this->tree[$cnt]["level"] > $this->tree[$cnt + 1]["level"]) { for ($i = max(1, $this->tree[$cnt + 1]["level"]); $i < $this->tree[$cnt]["level"]; $i++) { $this->_treeMenu[$menu_name] .= "</div>\n"; } } } /* // Some (old) browsers do not support the "white-space: nowrap;" CSS property... $this->_treeMenu[$menu_name] = "<table>\n" . "<tr>\n" . "<td class=\"phplmnormal\" nowrap=\"nowrap\">\n" . $this->_treeMenu[$menu_name] . "</td>\n" . "</tr>\n" . "</table>\n"; */ $t = new Template(); $t->setFile("tplfile", $this->libjsdir . "layerstreemenu.ijs"); $t->setVar(array("menu_name" => $menu_name, "toggle_function_name" => $toggle_function_name, "img_expand" => $img_expand, "img_expand_first" => $img_expand_first, "img_collapse" => $img_collapse, "img_collapse_first" => $img_collapse_first, "img_collapse_corner" => $img_collapse_corner, "img_folder_open" => $img_folder_open, "img_expand_corner" => $img_expand_corner, "img_folder_closed" => $img_folder_closed)); $toggle_function = $t->parse("out", "tplfile"); $toggle_function = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . $toggle_function . "// -->\n" . "</script>\n"; $toggle = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . "if ((DOM && !Opera56 && !Konqueror2) || IE4) {\n" . $toggle . "}\n" . "if (NS4) alert('Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\\nWe *strongly* suggest you to upgrade your browser.');\n" . "// -->\n" . "</script>\n"; $this->_treeMenu[$menu_name] = $toggle_function . "\n" . $this->_treeMenu[$menu_name] . "\n" . $toggle; return $this->_treeMenu[$menu_name]; }
public function renderDashboard() { $template = new Template(); $template->setFile(dirname(__FILE__) . '/templates/dashboard.phtml'); $template->render(); }
<h1>Nette\Templates\CurlyBracketsFilter & snippets test</h1> <pre> <?php require_once '../../Nette/loader.php'; /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ class MockControl extends Control { public function getSnippetId($name = NULL) { return 'sni__' . $name; } } function printSource($s) { echo $s; } Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); $template->setFile(dirname(__FILE__) . '/templates/curly-brackets-snippet.phtml'); $template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke'); $template->registerFilter('printSource'); $template->control = new MockControl(); $template->render();
* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. */ /** Set flag that this is a parent file */ define("_VALID_UA", 1); require_once "config.inc.php"; require_once "include/config.inc.php"; require_once "include/params.inc.php"; require_once "include/template.inc.php"; //messages $messageText = array('default' => _('Es ist ein Fehler aufgetreten. Bitte erneut einloggen um weiterspielen zu können.'), 'db' => _('Es konnte keine Verbindung zur Datenbank hergestellt werden!<br />Bitte wende dich an einen Administrator oder versuche es später erneut.'), 'inaktiv' => sprintf(_('Sie waren für %s Minuten oder mehr inaktiv. Bitte loggen sie sich erneut ins Spiel ein um weiterspielen zu können.'), (int) (SESSION_MAX_LIFETIME / 60)), 'logout' => _('Du bist jetzt ausgeloggt und kannst den Browser schließen oder weitersurfen.<br /><br />Vielen Dank für das Spielen von Uga-Agga!'), 'wrongSessionID' => _('Falsche oder ungültige SessionID.')); // load and open template $template = new Template(UA_GAME_DIR . '/templates/de_DE/uga/'); $template->setFile('finish.tmpl'); $id = Request::getVar('id', ''); if (!empty($id) && isset($messageText[$id])) { $message = $messageText[$id]; // Irgendwas zu tun bei bestimmten Meldungen? switch ($id) { case 'logout': @session_start(); @session_destroy(); break; } } else { $message = $messageText['default']; } $template->addVars(array('gfx' => DEFAULT_GFX_PATH, 'login_path' => LOGIN_PATH, 'status_msg' => $message, 'time' => date("d.m.Y H:i:s"))); $template->render();
/** * Method to prepare a new Horizontal Plain Menu. * * This method processes items of a menu to prepare and return * the corresponding Horizontal Plain Menu code. * * @access public * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newHorizontalPlainMenu($menu_name = "") { $horizontal_plain_menu_blck = ""; $t = new Template(); $t->setFile("tplfile", $this->horizontalPlainMenuTpl); $t->setBlock("tplfile", "template", "template_blck"); $t->setBlock("template", "horizontal_plain_menu_cell", "horizontal_plain_menu_cell_blck"); $t->setVar("horizontal_plain_menu_cell_blck", ""); $t->setBlock("horizontal_plain_menu_cell", "plain_menu_cell", "plain_menu_cell_blck"); $t->setVar("plain_menu_cell_blck", ""); for ($cnt = $this->_firstItem[$menu_name]; $cnt <= $this->_lastItem[$menu_name]; $cnt++) { if ($this->tree[$cnt]["level"] == 1 && $cnt > $this->_firstItem[$menu_name]) { $t->parse("horizontal_plain_menu_cell_blck", "horizontal_plain_menu_cell", true); $t->setVar("plain_menu_cell_blck", ""); } $nbsp = ""; for ($i = 1; $i < $this->tree[$cnt]["level"]; $i++) { $nbsp .= " "; } $t->setVar(array("nbsp" => $nbsp, "link" => $this->tree[$cnt]["parsed_link"], "title" => $this->tree[$cnt]["parsed_title"], "target" => $this->tree[$cnt]["parsed_target"], "text" => $this->tree[$cnt]["parsed_text"])); $t->parse("plain_menu_cell_blck", "plain_menu_cell", true); } $t->parse("horizontal_plain_menu_cell_blck", "horizontal_plain_menu_cell", true); $this->_horizontalPlainMenu[$menu_name] = $t->parse("template_blck", "template"); return $this->_horizontalPlainMenu[$menu_name]; }
<h1>Nette\Templates\CurlyBracketsFilter & inheritance test</h1> <pre> <?php require_once '../../Nette/loader.php'; /*use Nette\Debug;*/ /*use Nette\Environment;*/ /*use Nette\Templates\Template;*/ Environment::setVariable('tempDir', dirname(__FILE__) . '/tmp'); $template = new Template(); $template->setFile(dirname(__FILE__) . '/templates/curly-brackets-inheritance.child.phtml'); $template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke'); $template->people = array('John', 'Mary', 'Paul'); $template->render();