function render() { // call the render method in the main view class... it will take care of sending the headers // for us and so on... parent::render(); // if there is no resource to send... then we can quit right away! if ($this->_resource == null) { return; } // let's see if we really need to send some data or not... // send also some headers that will help caching, if configured to do so $config =& Config::getConfig(); $useCaching = $config->getValue('resource_server_http_cache_enabled'); if ($useCaching) { // send the "Last-Modified" header $resDate = $this->_resource->getTimestamp(); $lastModified = $resDate->getDate(DATE_FORMAT_UNIXTIME); $cacheLifetime = $config->getValue('resource_server_http_cache_lifetime', DEFAULT_HTTP_CACHE_LIFETIME); // check if we have to resent the data and if not, then we're done! if (HttpCache::httpConditional($lastModified, $cacheLifetime)) { exit; } } // if we need to send something, then let's do it now and finish if ($this->_mode == RESOURCE_VIEW_MODE_PREVIEW) { print $this->_resource->getPreview(); } elseif ($this->_mode == RESOURCE_VIEW_MODE_MEDIUM) { print $this->_resource->getMediumSizePreview(); } else { while ($chunk =& $this->_resource->getDataChunk(RESOURCE_DEFAULT_CHUNK_SIZE)) { echo $chunk; } } return true; }
function render() { // set the view character set based on the default locale $this->_getLocale(); $this->setCharset($this->_locale->getCharset()); $sendOutput = true; // check if support for conditional HTTP requests is enabled $config =& Config::getConfig(); if ($config->getValue("template_http_cache_enabled")) { // some debug information $timestamp = $this->_template->getCreationTimestamp(); // and now send the correct headers if (HttpCache::httpConditional($timestamp, $this->getCacheTimeSeconds())) { $sendOutput = false; } header("Last-Modified: " . gmdate('D, d M Y H:i:s', $timestamp) . ' GMT'); } else { $sendOutput = true; } if ($sendOutput) { View::render(); $this->sendUncachedOutput(); } }
/** * Renders the view using the Smarty template object that we created in the constructor. This method * sends data to the client so it should be called as the last bit of code in our custom classes * extending SmartyView. * * It has no paramaters and returns nothing. */ function render() { // the View class also needs to do some things... parent::render(); $sendOutput = true; // check if plog is configured to use conditional http headers and stuff like // that... Also, use the HttpCache class to determine whether we should send the // content or not if ($this->isTemplateHttpCacheEnabled() && $this->isCached()) { // some debug information $timestamp = $this->_template->getCreationTimestamp(); // and now send the correct headers if (HttpCache::httpConditional($timestamp, $this->getCacheTimeSeconds())) { $sendOutput = false; } $header = "Last-Modified: " . gmdate('D, d M Y H:i:s', $timestamp) . ' GMT'; header($header); } else { // send the results if needed $sendOutput = true; } if ($sendOutput) { // pass all the values to the template object $this->_template->assign($this->_params->getAsArray()); // and finally send the contents of the template print $this->_template->fetch($this->getSmartyViewId()); } }