/** gets the key used for storing page information * * @param int the nodeid * * @return string the cache key string */ protected function getPagingCacheKey($nodeid) { return 'vB_ArtPaging_' . $nodeid . '_' . vB5_User::getLanguageId(); }
/** * Renders the output after preperation. * @see vB5_Template::render() * * @param boolean Whether to suppress the HTML comment surrounding option (for JS, etc) * @param boolean true if we are rendering for a call to /ajax/render/ and we want CSS <link>s separate * * @return string */ public function render($isParentTemplate = true, $isAjaxTemplateRender = false) { static $user = false; if (!$user) { $user = vB5_User::instance(); } $config = vB5_Config::instance(); $this->register('user', $user, true); extract(self::$globalRegistered, EXTR_SKIP | EXTR_REFS); extract($this->registered, EXTR_OVERWRITE | EXTR_REFS); $baseurl = vB5_Template_Options::instance()->get('options.frontendurl'); $baseurl_core = vB5_Template_Options::instance()->get('options.bburl'); $baseurl_login = vB5_Template_Options::instance()->get('options.frontendurl_login'); $baseurl_data = vB5_String::parseUrl($baseurl); if (isset($baseurl_data['path'])) { $baseurl_path = $baseurl_data['path']; } $baseurl_path = isset($baseurl_path) ? $baseurl_path . (substr($baseurl_path, -1) != '/' ? '/' : '') : '/'; //same as cookie path $cookie_prefix = $config->cookie_prefix; $vboptions = vB5_Template_Options::instance()->getOptions(); $vboptions = $vboptions['options']; //this assumes that core is in the core directory which is not something we've generally assumed //however as noncollapsed mode look unlikely to be as useful as we thought, we'll start making that //assumption. However setting a seperate variable means we don't spread that assumption all through //the template code. $baseurl_cdn = $vboptions['cdnurl']; if ($baseurl_cdn) { $baseurl_corecdn = $baseurl_cdn . '/core'; } else { //if we haven't set a cdn url, then let's default to the actual site urls. $baseurl_cdn = $baseurl; $baseurl_corecdn = $baseurl_core; } $vbproducts = vB::getDatastore()->getValue('products'); $preferred_styleid = vB5_Template_Stylevar::instance()->getPreferredStyleId() > 0 ? vB5_Template_Stylevar::instance()->getPreferredStyleId() : $vboptions['styleid']; $preferred_languageid = vB5_User::getLanguageId() > 0 ? vB5_User::getLanguageId() : $vboptions['languageid']; $timenow = time(); self::$renderedTemplateNames[] = $this->template; // debug info for the templates that have been used if ($config->debug) { self::$renderedTemplates[] = array('templateName' => $this->template, 'isParentTemplate' => (bool) $isParentTemplate, 'indent' => str_repeat('|----', count(self::$renderedTemplatesStack))); self::$renderedTemplatesStack[] = $this->template; } // todo: remove this once we can remove notices from template code // allow developers to turn notices off for templates -- to avoid having them turn off notices entirely if ($config->no_template_notices) { $oldReporting = error_reporting(E_ALL & ~E_NOTICE); } if ($config->render_debug) { set_exception_handler(null); set_error_handler('vberror'); // Show which template is being rendered. echo 'Template: ' . $this->template . '<br />'; } $templateCache = vB5_Template_Cache::instance(); $templateCode = $templateCache->getTemplate($this->template); if (is_array($templateCode) and !empty($templateCode['textonly'])) { $final_rendered = $templateCode['placeholder']; } else { if ($templateCache->isTemplateText()) { @eval($templateCode); } else { if ($templateCode !== false) { @(include $templateCode); } } } if ($config->render_debug) { restore_error_handler(); restore_exception_handler(); } if ($config->no_template_notices) { error_reporting($oldReporting); } // always replace placeholder for templates, as they are process by levels $templateCache->replacePlaceholders($final_rendered); if ($isParentTemplate) { // we only replace phrases/urls/nodetext, insert javascript and stylesheets at the parent template $this->renderDelayed($final_rendered, $isAjaxTemplateRender); //Store the configuration information in the session if (!empty(vB5_Config::instance()->php_sessions)) { if (session_status() == PHP_SESSION_NONE) { $expires = vB5_Config::instance()->session_expires; if (!empty($expires) and intval($expires)) { session_cache_expire(intval($expires)); } session_start(); $_SESSION['languageid'] = $preferred_languageid; $_SESSION['userid'] = vB5_User::get('userid'); } } } // debug info for the templates that have been used if ($config->debug) { array_pop(self::$renderedTemplatesStack); } // add template name to HTML source for debugging if (!empty($vboptions['addtemplatename']) and $vboptions['addtemplatename']) { $final_rendered = "<!-- BEGIN: {$this->template} -->{$final_rendered}<!-- END: {$this->template} -->"; } return $final_rendered; }