/** * Constructor * * @param $template string * Template name * * @return void */ function __construct($template = null) { $this->template = T3_ACTIVE_TEMPLATE; $this->_params = T3Parameter::getInstance(); $this->_theme_info = T3Common::get_active_themes_info(); if ($template) { $this->_tpl = $template; $this->_extend(array($template)); } }
/** * Get page key from URI, browser (version), params (cookie params) * * @return mixed NULL if devmode/noncache or string key code */ public static function getPageKey() { static $key = null; if ($key) { return $key; } // No cache in devmode $t3cache = T3Cache::getT3Cache(); if ($t3cache->_devmode) { return null; } // No cache when disable T3 cache $config = T3Common::get_template_based_params(); if ($config->get('cache', 0) == 0) { return null; } // TODO: need to move in cache page code at the end of onAfterRender $mainframe = JFactory::getApplication(); $messages = $mainframe->getMessageQueue(); // Ignore cache when there're some message if (is_array($messages) && count($messages)) { return null; } // If user log-in, ignore cache $user = JFactory::getUser(); if (!$user->get('guest') || $_SERVER['REQUEST_METHOD'] != 'GET') { return null; } // If ie6, ignore cache $isIE6 = T3Template::isIE6(); if ($isIE6) { return null; } // Don't cache when offline $cfg = JFactory::getConfig(); if ($cfg->get('offline')) { return null; } $uri = JRequest::getURI(); //$browser = T3Common::getBrowserSortName() . "-" . T3Common::getBrowserMajorVersion(); $mobile = T3Common::mobile_device_detect(); $params = T3Parameter::getInstance(); $cparams = ''; foreach ($params->_params_cookie as $k => $v) { $cparams .= $k . "=" . $v . '&'; } //$key = "page - URI: $uri; Browser: $browser; Params: $cparams"; $key = "page - URI: {$uri}; Mobile: {$mobile}; Params: {$cparams}"; //T3Common::log($key . ' ' . T3Common::getBrowserSortName() . "-" . T3Common::getBrowserMajorVersion()); return $key; }
/** * Set value to parameter * * @param string $param Parameter name * @param string $value Setted value * * @return void */ function _setParam($param, $value) { $params = T3Parameter::getInstance(); return $params->setParam($param, $value); }
function isRTL() { $doc =& JFactory::getDocument(); $params =& T3Parameter::getInstance(); return $doc->direction == 'rtl' || $params->getParam('direction', 'ltr') == 'rtl'; }
function getPageKey() { static $key = null; if ($key) { return $key; } $t3cache = T3Cache::getInstance(); if ($t3cache->_devmode) { return null; } //no cache in devmode $mainframe =& JFactory::getApplication(); $messages = $mainframe->getMessageQueue(); // Ignore cache when there're some message if (is_array($messages) && count($messages)) { $key = null; return null; } $user =& JFactory::getUser(); if ($user->get('aid') || $_SERVER['REQUEST_METHOD'] != 'GET') { $key = null; return null; //no cache for page } $string = 'page'; $uri = JRequest::getURI(); //t3import ('core.libs.Browser'); //$browser = new Browser(); //$string .= $browser->getBrowser().":".$browser->getVersion(); $browser = T3Common::getBrowserSortName() . "-" . T3Common::getBrowserMajorVersion(); $params = T3Parameter::getInstance(); $cparams = ''; foreach ($params->_params_cookie as $k => $v) { $cparams .= $k . "=" . $v . '&'; } $string = "page - URI: {$uri}; Browser: {$browser}; Params: {$cparams}"; $key = md5($string); //Insert into cache db /* $query = "insert `#__t3_cache` (`key`, `raw`, `uri`, `browser`, `params`, `counter`) values('$key', '$string', '$uri', '$browser', '$cparams', 1) ON DUPLICATE KEY UPDATE `counter`=`counter`+1;"; $db =& JFactory::getDBO(); @$db->setQuery( $query ); @$db->query(); */ return $key; }
function getKey($name, $level = 10) { //$uri = JURI::getInstance(); //$string = $uri->getQuery(); $string = $name; if ($level > 0) { $string .= JRequest::getURI(); } if ($level > 1) { $params = T3Parameter::getInstance(); $string .= T3_TOOL_THEMES . "=" . $params->getParam(T3_TOOL_THEMES); $string .= T3_TOOL_LAYOUTS . "=" . $params->getParam(T3_TOOL_LAYOUTS); } if ($level > 2) { t3import('core.libs.Browser'); $browser = new Browser(); $string .= $browser->getBrowser() . ":" . $browser->getVersion(); } if ($level > 3) { $params = T3Parameter::getInstance(); foreach ($params->_params_cookie as $k => $v) { $string .= $k . "=" . $v; } } return md5($string); }