function renderEntries(Search_ResultSet $entries) { global $tikipath; $smarty = new Smarty_Tiki(); if ($this->changeDelimiters) { $smarty->left_delimiter = '{{'; $smarty->right_delimiter = '}}'; } foreach ($this->data as $key => $value) { $smarty->assign($key, $value); } $smarty->assign('prefs', $GLOBALS['prefs']); $smarty->assign('user', $GLOBALS['user']); $smarty->assign('results', $entries); $smarty->assign('facets', array_map(function ($facet) { return array('name' => $facet->getName(), 'label' => $facet->getLabel(), 'options' => $facet->getOptions(), 'operator' => $facet->getOperator()); }, $entries->getFacets())); $smarty->assign('count', count($entries)); $smarty->assign('offset', $entries->getOffset()); $smarty->assign('offsetplusone', $entries->getOffset() + 1); $smarty->assign('offsetplusmaxRecords', $entries->getOffset() + $entries->getMaxRecords()); $smarty->assign('maxRecords', $entries->getMaxRecords()); $smarty->assign('id', $entries->getId()); $smarty->assign('tsOn', $entries->getTsOn()); return $smarty->fetch($this->templateFile); }
$this->url_overriding_prefix_stack[] = array($url_arguments_prefix . '-', $arguments_list); $this->url_overriding_prefix =& $this->url_overriding_prefix_stack[count($this->url_overriding_prefix_stack) - 1]; } function remove_request_overriders($url_arguments_prefix, $arguments_list) { $last_override_prefix = empty($this->url_overriding_prefix_stack) ? false : array_pop($this->url_overriding_prefix_stack); if (!is_array($last_override_prefix) || $url_arguments_prefix . '-' != $last_override_prefix[0]) { trigger_error('URL Overriding prefix stack is in a bad state', E_USER_ERROR); } $this->url_overriding_prefix =& $this->url_overriding_prefix_stack[count($this->url_overriding_prefix_stack) - 1]; } } if (!isset($tikidomain)) { $tikidomain = ''; } $smarty = new Smarty_Tiki($tikidomain); $smarty->loadFilter('pre', 'tr'); $smarty->loadFilter('pre', 'jq'); include_once 'lib/smarty_tiki/resource.tplwiki.php'; $smarty->registerResource('tplwiki', array('smarty_resource_tplwiki_source', 'smarty_resource_tplwiki_timestamp', 'smarty_resource_tplwiki_secure', 'smarty_resource_tplwiki_trusted')); include_once 'lib/smarty_tiki/resource.wiki.php'; $smarty->registerResource('wiki', array('smarty_resource_wiki_source', 'smarty_resource_wiki_timestamp', 'smarty_resource_wiki_secure', 'smarty_resource_wiki_trusted')); global $prefs; // Assign the prefs array in smarty, by reference $smarty->assignByRef('prefs', $prefs); if (!empty($prefs['log_tpl']) && $prefs['log_tpl'] === 'y') { $smarty->loadFilter('pre', 'log_tpl'); } if (!empty($prefs['feature_sefurl_filter']) && $prefs['feature_sefurl_filter'] === 'y') { require_once 'tiki-sefurl.php'; $smarty->registerFilter('output', 'filter_out_sefurl');
/** * @param $error_msg */ function check_smarty_syntax(&$error_msg) { global $tikidomain, $prefs, $smarty; $tikidomain = ''; // Initialize $prefs with some variables needed by the tra() function and smarty autosave plugin $prefs = array('lang_use_db' => 'n', 'language' => 'en', 'site_language' => 'en', 'feature_ajax' => 'n'); // Load Tiki Smarty $prefs['smarty_compilation'] = 'always'; $prefs['smarty_security'] = 'y'; $prefs['maxRecords'] = 25; $prefs['log_tpl'] = 'y'; $prefs['feature_sefurl_filter'] = 'y'; $prefs['site_layout'] = 'basic'; require_once 'vendor/smarty/smarty/libs/Smarty.class.php'; require_once 'lib/init/smarty.php'; // needed in Smarty_Tiki define('TIKI_PATH', getcwd()); require_once 'lib/core/TikiAddons.php'; require_once 'lib/smarty_tiki/prefilter.tr.php'; require_once 'lib/smarty_tiki/prefilter.jq.php'; require_once 'lib/smarty_tiki/prefilter.log_tpl.php'; $smarty = new Smarty_Tiki(); set_error_handler('check_smarty_syntax_error_handler'); $templates_dir = TIKI_PATH . '/templates'; $errors_found = false; $entries = array(); get_files_list($templates_dir, $entries, '/\\.tpl$/'); $nbEntries = count($entries); for ($i = 0; $i < $nbEntries; $i++) { display_progress_percentage($i, $nbEntries, '%d%% of files passed the Smarty syntax check'); if (strpos($entries[$i], 'tiki-mods.tpl') === false) { $template_file = substr($entries[$i], strlen($templates_dir) + 1); try { $_tpl = $smarty->createTemplate($template_file, null, null, null, false); $_tpl->compileTemplateSource(); } catch (Exception $e) { echo color("\nError: " . $e->getMessage(), 'red') . "\n"; $errors_found = true; } } } restore_error_handler(); echo "\n"; if ($errors_found) { die('Fix the Smarty errors and try again please.'); } }