function onAfterRender() { $app = JFactory::getApplication(); t3import('core.admin.util'); $util = new JAT3_AdminUtil(); if ($app->isAdmin()) { ob_start(); $util->show_button_clearCache(); $content = ob_get_clean(); $buffer = JResponse::getBody(); $buffer = preg_replace('/<\\/body>/', $content . "\n</body>", $buffer); JResponse::setBody($buffer); } if ($util->checkPermission()) { if (JAT3_AdminUtil::checkCondition_for_Menu()) { // HTML= Parser lib require_once T3Path::path(T3_CORE) . DS . 'libs' . DS . "html_parser.php"; $_body = JResponse::getBody(); require_once T3Path::path(T3_CORE) . DS . 'admin' . DS . "util.php"; // Replace content $jat3core = new JAT3_AdminUtil(); $_body = $jat3core->replaceContent($_body); if ($_body) { JResponse::setBody($_body); } } } if (!T3Common::detect()) { return; } if ($util->checkPermission()) { if ($util->checkCondition()) { $params = T3Path::path(T3_CORE) . DS . 'admin' . DS . 'index.php'; if (file_exists($params)) { ob_start(); include $params; $content = ob_get_clean(); $buffer = JResponse::getBody(); $buffer = preg_replace('/<\\/body>/', $content . "\n</body>", $buffer); JResponse::setBody($buffer); } } return; } if (!$app->isAdmin()) { //Expires date set to very long //JResponse::setHeader( 'Expires', gmdate( 'D, d M Y H:i:s', time() + 3600000 ) . ' GMT', true ); //JResponse::setHeader( 'Last-Modified', gmdate( 'D, d M Y H:i:s', time()) . ' GMT', true ); JResponse::setHeader('Expires', '', true); JResponse::setHeader('Cache-Control', 'private', true); //Update cache in case of the whole page is cached $key = T3Cache::getPageKey(); if (($data = T3Cache::get($key)) && !preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) { $buffer = JResponse::getBody(); T3Cache::store($buffer, $key); } } }
/** * * JT3 Framework render */ public function render() { $replace = array(); $matches = array(); parent::loadLayout(); $data = $this->_html; if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data, $matches)) { $cache_exclude = parent::getParam('cache_exclude'); $cache_exclude = new JRegistry($cache_exclude); $nc_com = explode(',', $cache_exclude->get('component')); $nc_pos = explode(',', $cache_exclude->get('position')); $replace = array(); $matches[0] = array_reverse($matches[0]); $matches[1] = array_reverse($matches[1]); $matches[2] = array_reverse($matches[2]); $count = count($matches[1]); $option = JRequest::getCmd('option'); $headindex = -1; //for none cache items $nonecachesearch = array(); $nonecachereplace = array(); //search for item load in template (css, images, js) $regex = '/(href|src)=("|\')([^"\']*\\/templates\\/' . T3_ACTIVE_TEMPLATE . '\\/([^"\']*))\\2/'; for ($i = 0; $i < $count; $i++) { $attribs = JUtility::parseAttributes($matches[2][$i]); $type = $matches[1][$i]; $name = isset($attribs['name']) ? $attribs['name'] : null; //no cache => no cache for all jdoc include except head //cache: exclude modules positions & components listed in cache exclude param //check if head if ($type == 'head') { $headindex = $i; } else { $content = parent::getBuffer($type, $name, $attribs); $renderer = $this->loadRenderer('module'); $poweradmin = JRequest::getCmd('poweradmin', 0); $vsm_changeposition = JRequest::getCmd('vsm_changeposition', 0); //Add a div wrapper for showing block information if ($poweradmin == 1) { //If the page requested to render position only if ($vsm_changeposition == 1) { if ($type == 'modules') { $content = '<div class="jsn-element-container_inner">' . '<div class="jsn-poweradmin-position clearafter" id="' . $name . '-jsnposition"> <p>' . $name . '</p> </div> </div> '; } else { if ($type == 'module') { $key = "mod.{$name}"; } else { if ($type == 'component') { $content = '<div class="jsn-component-container" id="jsnrender-component"><div class="jsn-show-component-container"><p>' . parent::getTitle() . '</p></div></div>'; } else { $key = "{$type}.{$name}"; } } } } else { if ($type == 'modules') { $buffer = ''; foreach (JModuleHelper::getModules($name) as $mod) { $buffer .= '<div class="poweradmin-module-item" id="' . $mod->id . '-jsnposition" ><div id="moduleid-' . $mod->id . '-content">' . $renderer->render($mod, $attribs) . '</div></div>'; } $content = '<div class="jsn-element-container_inner">' . '<div class="jsn-poweradmin-position clearafter" id="' . $name . '-jsnposition"> ' . $buffer . ' </div> </div> '; } else { if ($type == 'module') { $key = "mod.{$name}"; } else { if ($type == 'component') { $app = JFactory::getApplication(); $itemid = JRequest::getVar('itemid', ''); $menu = $app->getMenu(); if ($itemid) { $menuItem = $menu->getItem($itemid); } else { $menuItem = $menu->getActive(); } $uri = JURI::getInstance(); $route = JRouter::getInstance('site'); $params = $route->parse($uri); if (empty($params['id']) && !empty($menuItem->id)) { $uri->parse($menuItem->link); $params = $route->parse($uri); } if (!empty($params['option'])) { $key = array_search($params['option'], array('', 'com_content', 'com_categories', 'com_banner', 'com_weblinks', 'com_contact', 'com_newsfeeds', 'com_search', 'com_redirect')); if ($key) { if (!empty($params['id'])) { if ($params['view'] == 'category') { $editLink = 'option=com_categories&task=category.edit&id=' . $params['id'] . '&extension=' . $params['option'] . '&tmpl=component'; $task = 'category.apply'; } else { switch ($key) { case 1: //com_content $editLink = 'option=com_content&task=article.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'article.apply'; break; case 2: //com_categories $editLink = 'option=com_categories&task=category.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'category.apply'; break; case 3: if ($params['view'] == 'client') { $editLink = 'option=com_banners&task=client.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'client.apply'; } else { $editLink = 'option=com_banners&task=banner.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'bannber.apply'; } break; case 4: $editLink = 'option=com_weblinks&task=weblink.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'weblink.apply'; break; case 5: $editLink = 'option=com_contact&task=contact.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'contact.apply'; break; case 6: $editLink = 'option=com_newsfeeds&task=newsfeed.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'newsfeed.apply'; break; case 7: $editLink = 'option=com_search&task=search.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'search.apply'; break; case 8: $editLink = 'option=com_redirect&task=link.edit&id=' . $params['id'] . '&tmpl=component'; $task = 'link.apply'; break; } } } else { $editLink = 'option=com_menus&task=item.edit&id=' . $menuItem->id . '&tmpl=component'; $task = 'item.save'; } } else { //in feature $editLink = ''; $task = ''; } } else { $editLink = ''; $task = ''; } $content = '<div class="jsn-component-container" id="jsnrender-component">' . '<div class="jsn-show-component-container">' . '<div class="jsn-show-component">' . '<span id="tableshow" itemid="' . $menuItem->id . '" editlink="' . base64_encode($editLink) . '" title="' . parent::getTitle() . '" task="' . $task . '"></span>' . '</div>' . '</div>' . $content . '</div>'; } else { $key = "{$type}.{$name}"; } } } } } //process url $content = preg_replace_callback($regex, array($this, 'processReplateURL'), $content); } if (!parent::getParam('cache') || $type == 'head' || $type == 'modules' && in_array($name, $nc_pos) || $type == 'component' && in_array($option, $nc_com)) { $replace[$i] = $matches[0][$i]; $nonecachesearch[] = $replace[$i]; $nonecachereplace[] = $content; } else { $replace[$i] = $content; } } //update head if ($headindex > -1) { T3Head::proccess(); $head = parent::getBuffer('head'); $replace[$headindex] = $head; } //replace all cache content $data = str_replace($matches[0], $replace, $data); //update cache $key = T3Cache::getPageKey(); if ($key) { T3Cache::store($data, $key); } //replace none cache content $data = str_replace($nonecachesearch, $nonecachereplace, $data); } else { $token = JUtility::getToken(); $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#'; $replacement = '<input type="hidden" name="' . $token . '" value="1" />'; $data = preg_replace($search, $replacement, $data); } echo $data; }
function render() { $replace = array(); $matches = array(); $data = $this->_html; if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data, $matches)) { $cache_exclude = $this->getParam('cache_exclude'); $cache_exclude = new JParameter($cache_exclude); $nc_com = explode(',', $cache_exclude->get('component')); $nc_pos = explode(',', $cache_exclude->get('position')); $replace = array(); $matches[0] = array_reverse($matches[0]); $matches[1] = array_reverse($matches[1]); $matches[2] = array_reverse($matches[2]); $count = count($matches[1]); $option = JRequest::getCmd('option'); $headindex = -1; //for none cache items $nonecachesearch = array(); $nonecachereplace = array(); //search for item load in template (css, images, js) $regex = '/(href|src)=("|\')([^"\']*\\/templates\\/' . T3_ACTIVE_TEMPLATE . '\\/([^"\']*))\\2/'; for ($i = 0; $i < $count; $i++) { $attribs = JUtility::parseAttributes($matches[2][$i]); $type = $matches[1][$i]; $name = isset($attribs['name']) ? $attribs['name'] : null; //no cache => no cache for all jdoc include except head //cache: exclude modules positions & components listed in cache exclude param //check if head if ($type == 'head') { $headindex = $i; } else { $content = $this->getBuffer($type, $name, $attribs); //Add a div wrapper for showing block information if ($this->getParam('infomode', 1) == 1 && JRequest::getCmd('t3info')) { if ($type == 'modules') { $key = "pos.{$name}"; } else { if ($type == 'module') { $key = "mod.{$name}"; } else { if ($type == 'component') { $key = "content"; } else { $key = "{$type}.{$name}"; } } } $content = "<div id=\"jainfo-pos-{$key}\" class=\"jainfo-pos-{$type}\">{$content}</div>"; } //process url $content = preg_replace_callback($regex, array($this, 'processReplateURL'), $content); } if (!$this->getParam('cache') || $type == 'head' || $type == 'modules' && in_array($name, $nc_pos) || $type == 'component' && in_array($option, $nc_com)) { $replace[$i] = $matches[0][$i]; $nonecachesearch[] = $replace[$i]; $nonecachereplace[] = $content; } else { $replace[$i] = $content; } } //update head if ($headindex > -1) { T3Head::proccess(); $head = $this->getBuffer('head'); $replace[$headindex] = $head; } //replace all cache content $data = str_replace($matches[0], $replace, $data); //update cache $key = T3Cache::getPageKey(); if ($key) { T3Cache::store($data, $key); } //replace none cache content $data = str_replace($nonecachesearch, $nonecachereplace, $data); } else { $token = JUtility::getToken(); $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#'; $replacement = '<input type="hidden" name="' . $token . '" value="1" />'; $data = preg_replace($search, $replacement, $data); } echo $data; }