/** */ function parse($name, $replace = [], $params = []) { if (!class_exists('Blitz')) { return $params['string']; } if ($params['string']) { $view = new Blitz(); $view->load($params['string']); return $view->parse($replace); } // TODO: test me and connect YF template loader }
static function returnError($e) { $template = new \Blitz(); $template->load(<<<BODY <html> \t<head> \t\t<title>Error {{ \$ErrorNum }}</title> \t</head> \t<body> \t\t<h3>{{ \$ErrorTitle }}</h3> \t\t<pre>{{ \$ErrorMessage }}</pre> \t</body> </html> BODY ); $template->display(array('ErrorNum' => $e->getCode(), 'ErrorTitle' => $e->getLine() . ' : ' . $e->getFile(), 'ErrorMessage' => $e->getMessage() . PHP_EOL . $e->getTraceAsString())); }
public function fetch($data) { $dirs = $this->get_dirs(isset($data['dir']) ? $data['dir'] : 0); $classes = array(); $T = new Blitz($this->template_dir . "tree/tree_relations.html"); $T->setGlobal(array("current_node" => $data['node_id'])); if (isset($data['message'])) { $T->setGlobal(array("glob_message" => $data['message'])); } if (isset($data['dir'])) { $T->setGlobal(array("current_dir" => $data['dir'])); $classes = $this->get_classes($data['dir']); } else { $T->setGlobal(array("dir_not_selected" => true)); } $current_relations = $this->get_relations($data['node_id']); $T->block("dirs", $dirs); $T->block("classes", $classes); $T->block("current_relations", $current_relations); echo $T->parse(); }
set_time_limit(0); define('RPP', 50); require_once dirname(__FILE__) . '/inc/config.inc'; $page = isset($_GET['p']) ? (int) $_GET['p'] : 1; $query = isset($_GET['q']) ? (string) $_GET['q'] : ''; $category = isset($_GET['cat']) ? (string) $_GET['cat'] : ''; $days = isset($_GET['d']) ? (int) $_GET['d'] : 0; $days = max($days, 0); $minsize = isset($_GET['minsize']) ? (string) $_GET['minsize'] : '0.1 GB'; if (!Searcher::correctHumanSize($minsize)) { $minsize = '0'; } $extsearch = isset($_GET['extsearch']) ? (bool) $_GET['extsearch'] : false; $nodirs = isset($_GET['nodirs']) ? (bool) $_GET['nodirs'] : false; $T = new Blitz(); $T->load(file_get_contents('tpl/index.tpl')); $tpl_values = array(); $tpl_values['page'] = $page; if ($query || $extsearch) { $tpl_values['query'] = htmlspecialchars($query); $tpl_values['extsearch'] = $extsearch; $tpl_values['nodirs'] = $nodirs; $categories = Searcher::getCategories($category, true); $tpl_values['categories'] = $categories; $tpl_values['days'] = $days; $tpl_values['minsize'] = $minsize; if ($query) { $searcher = new SphinxClient(); $searcher->setServer("localhost", 3312); $searcher->setMatchMode(SPH_MATCH_ALL);
public function show_main($data = false) { $current_node = array(); if ($data['tree_id']) { $current_node = $this->get_node($data['tree_id']); $current_node['parents'] = $this->get_parents($current_node['tree_parent'], $current_node['tree_id']); $current_node['groups'] = $this->get_groups($current_node['tree_group']); } else { $current_node['parents'] = $this->get_parents(); $current_node['groups'] = $this->get_groups(); } $current_tree = $this->get_tree(isset($current_node['tree_id']) ? $current_node['tree_id'] : 0, isset($current_node['tree_parent']) ? $current_node['tree_parent'] : 0); $T = new Blitz($_SERVER['DOCUMENT_ROOT'] . "/templates/admin/tree/index.html"); if (count($current_tree) == 0) { $T->block("current_tree", array("tree_message" => "Tree is empty.")); } else { #$T->setGlobal(array("current_node"=>$data['tree_id'],"current_parent"=>$data['tree_parent'])); $T->block("current_tree", array("tree_nodes" => $current_tree)); } $T->block("current_node", $current_node); if ($current_node['parents'] == false) { $T->block("current_node/parents_message"); } echo $T->parse(); }
<?php require_once '../blitz.class.php'; define('MICROTIME_START', microtime(TRUE)); error_reporting(E_ALL); ini_set('display_errors', 'On'); $fn = 'blitz/index.tpl'; $blitz = new Blitz($fn); //$blitz->force_compile = TRUE; //$blitz->compile_check = FALSE; $blitz->assign('a', 'value of $a'); $blitz->iterate('test'); echo '<b>' . $blitz->_fetch('test') . '</b>'; echo '<hr />' . (microtime(TRUE) - MICROTIME_START); echo '<hr />'; highlight_file($blitz->_get_compile_path($fn, '')); echo '<hr />'; highlight_file($blitz->template_dir . $fn); echo '<hr />'; highlight_file(__FILE__);
public function __construct() { parent::__construct(); //construct class }
public function __construct($tpl) { parent::Blitz(sprintf("%s/%s.html", Config::getInstance()->get(array("path", "template")), $tpl)); parent::setGlobal(Config::getInstance()->get(array("template"), array())); }