/** * Constructor of the class * * @param blogInfo A valid BlogInfo object representing the blog to which this View belongs * @param templateName A template name * @param cachingEnabled either SMARTY_VIEW_CACHE_ENABLED, SMARTY_VIEW_CACHED_DISABLED, SMARTY_VIEW_CACHE_CHECK. * If left as SMARTY_VIEW_CACHE_CHECK, the blog settings will checked to determine whether caching is enabled * or not. * @param data Data that will be used to generate a unique id for the cached view (it will be ignored * if caching is not enabled) */ function SmartyView($blogInfo, $templateName, $cachingEnabled = SMARTY_VIEW_CACHE_CHECK, $data = array()) { // parent constructor $this->View(); if ($cachingEnabled == SMARTY_VIEW_CACHE_CHECK) { // detect whether caching should be enabled or not $config =& Config::getConfig(); $cachingEnabled = $config->getValue("template_cache_enabled"); } // whether caching is enabled or not $this->_cachingEnabled = $cachingEnabled; // save the blogInfo object $this->_blogInfo = $blogInfo; // name of the tepmlate $this->_templateName = $templateName; // get the right CachedTemplate or Template object $blogSettings = $this->_blogInfo->getSettings(); $ts = new TemplateService(); if ($this->isCachingEnabled()) { // get a CachedTemplate object $this->_template = $ts->CachedTemplate($this->_templateName, $blogSettings->getValue('template'), $this->_blogInfo); // data used to calculate the view id $this->_data = $data; // and generate the right cache id for it $this->_data["blogId"] = $blogInfo->getId(); $this->_viewId = $this->generateCacheId(); } else { $this->_template = $ts->Template($this->_templateName, $blogSettings->getValue('template'), $this->_blogInfo); } }
function RssView($blogInfo, $profile, $data = array()) { $this->BlogView($blogInfo, "", SMARTY_VIEW_CACHE_CHECK, $data); $ts = new TemplateSetStorage(); if (!$ts->templateExists($this->_profile, 'rss')) { // if not, then we will use the default one $this->_profile = RSS_VIEW_DEFAULT_PROFILE; } // we need to overwrite the $this->_template object with the Template object of our choice... $this->_profile = $profile; $templateService = new TemplateService(); $this->_template = $templateService->CachedTemplate($this->_profile, 'rss', $this->_blogInfo); // set the correct content type $this->setContentType('text/xml'); }