예제 #1
0
 function t3_init()
 {
     t3import('core.parameter');
     t3import('core.extendable');
     t3import('core.template');
     t3import('core.basetemplate');
     t3import('core.cache');
     t3import('core.head');
     t3import('core.hook');
     t3import('core.joomla.view');
     if (!class_exists('JModuleHelper', false)) {
         t3import('core.joomla.modulehelper');
     }
     t3import('core.joomla.pagination');
     //Load template language
     $this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
     $params = T3Common::get_template_based_params();
     //instance cache object.
     $devmode = $params ? $params->get('devmode', '0') == '1' : false;
     T3Cache::getInstance($devmode);
     //Check if enable T3 info mode. Enable by default (if not set)
     if ($params->get('infomode', 1) == 1) {
         if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp')) {
             JRequest::setVar('t3info', JRequest::getCmd('tp'));
         }
     }
     $key = T3Cache::getPageKey();
     $data = null;
     $user =& JFactory::getUser();
     if (!$devmode && JRequest::getCmd('cache') != 'no') {
         T3Cache::setCaching(true);
         JResponse::allowCache(true);
     }
     $data = T3Cache::get($key);
     if ($data) {
         if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
             $mainframe = JFactory::getApplication();
             $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);
             JResponse::setBody($data);
             echo JResponse::toString($mainframe->getCfg('gzip'));
             if (JDEBUG) {
                 global $_PROFILER;
                 $_PROFILER->mark('afterCache');
                 echo implode('', $_PROFILER->getBuffer());
             }
             $mainframe->close();
         }
     }
     //Preload template
     t3import('core.preload');
     $preload = T3Preload::getInstance();
     $preload->load();
     $doc =& JFactory::getDocument();
     $t3 = T3Template::getInstance($doc);
     $t3->_html = $data;
 }
예제 #2
0
 function t3_init()
 {
     t3import('core.parameter');
     t3import('core.extendable');
     t3import('core.template');
     t3import('core.cache');
     t3import('core.head');
     t3import('core.hook');
     // Remove JDocumentHTML for compatible J1.6 & J1.7
     // if (!class_exists ('JDocumentHTML', false)) t3import ('core.joomla.documenthtml');
     if (!class_exists('JView', false)) {
         t3import('core.joomla.view');
     }
     if (!class_exists('JModuleHelper', false)) {
         t3import('core.joomla.modulehelper');
     }
     // if (! class_exists('JPagination', false)) t3import('core.joomla.pagination');
     //Load template language
     $this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
     $params = T3Common::get_template_based_params();
     //instance cache object.
     $devmode = $params ? $params->get('devmode', '0') == '1' : false;
     $t3cache = T3Cache::getT3Cache($devmode);
     //Check if enable T3 info mode. Enable by default (if not set)
     if ($params->get('infomode', 1) == 1) {
         if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) {
             JRequest::setVar('t3info', JRequest::getCmd('tp'));
         }
     }
     $key = T3Cache::getPageKey();
     $user =& JFactory::getUser();
     $data = null;
     if ($devmode || JRequest::getCmd('cache') == 'no') {
         $t3cache->setCaching(false);
         JResponse::allowCache(false);
     } else {
         $t3cache->setCaching(true);
         JResponse::allowCache(true);
     }
     // Get cache
     $data = $t3cache->get($key);
     if ($data) {
         $mainframe = JFactory::getApplication();
         // Check HTTP header
         $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false;
         $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
         $cache_time = (int) substr($data, 0, 20);
         $etag = md5($key);
         if ($if_modified_since && $if_none_match && $if_modified_since == $cache_time && $if_none_match == $etag) {
             header('HTTP/1.x 304 Not Modified', true);
             $mainframe->close();
         }
         $data = substr($data, 20);
         // Check cached data
         if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
             $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);
             JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $cache_time) . ' GMT', true);
             JResponse::setHeader('ETag', $etag, true);
             JResponse::setBody($data);
             echo JResponse::toString($mainframe->getCfg('gzip'));
             if (JDEBUG) {
                 global $_PROFILER;
                 $_PROFILER->mark('afterCache');
                 echo implode('', $_PROFILER->getBuffer());
             }
             $mainframe->close();
         }
     }
     //Preload template
     t3import('core.preload');
     $preload = T3Preload::getInstance();
     $preload->load();
     //$doc = JFactory::getDocument();
     //$t3 = T3Template::getInstance($doc);
     //$t3->_html = $data;
     // Disable joomla cache when browsing by device
     $device = T3Common::mobile_device_detect();
     if ($device !== 'false') {
         $conf = JFactory::getConfig();
         $conf->set('caching', 0);
     }
     // Separate cache when browsing in each device
     /*
     $app = JFactory::getApplication();
     $registeredurlparams = $app->get('registeredurlparams');
     if (empty($registeredurlparams)) {
         $registeredurlparams = new stdClass;
     }
     $registeredurlparams->device = 'CMD';
     $app->set('registeredurlparams', $registeredurlparams);
     JRequest::setVar('device', T3Common::mobile_device_detect());
     */
 }
예제 #3
0
 /**
  * Get list of themes
  *
  * @return array
  */
 public static function get_themes()
 {
     //get from preload object
     $themes = T3Preload::getObject('themes');
     if ($themes) {
         return $themes;
     }
     $path = T3Path::path(T3_TEMPLATE) . DS . 'themes';
     // Check if template use newest folder structure or not
     // If themes exists in template folder, considered as template use newest folder structure
     if (@is_dir($path)) {
         $themes['engine.default'] = array('engine', 'default');
         $themes['template.default'] = array('template', 'default');
         $theme_list = JFolder::folders($path);
         if (!empty($theme_list)) {
             foreach ($theme_list as $folder) {
                 $themes['core' . $folder] = array('core', $folder);
             }
         }
     } else {
         // Compatible: if template still use older folder structure, try to use it.
         $themes["engine.default"] = array('engine', 'default');
         $themes["template.default"] = array('template', 'default');
         $core_themes = is_dir(T3Path::path(T3_TEMPLATE_CORE) . DS . 'themes') ? @JFolder::folders(T3Path::path(T3_TEMPLATE_CORE) . DS . 'themes') : null;
         if ($core_themes) {
             foreach ($core_themes as $theme) {
                 $themes["core.{$theme}"] = array('core', $theme);
             }
         }
         $local_themes = is_dir(T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'themes') ? @JFolder::folders(T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'themes') : null;
         if ($local_themes) {
             foreach ($local_themes as $theme) {
                 $themes["local.{$theme}"] = array('local', $theme);
             }
         }
     }
     return $themes;
 }
예제 #4
0
 /**
  * Set object
  *
  * @param string $name    Object name
  * @param string $object  Instance of object
  *
  * @return void
  */
 function setObject($name, $object)
 {
     $template = T3_ACTIVE_TEMPLATE;
     $preload = T3Preload::getInstance();
     $preload->data[$template][$name] = $object;
     //$key = T3Parameter::getKey ('preload-'.$template, 0);
     $key = T3Cache::getPreloadKey($template);
     $t3cache = T3Cache::getT3Cache();
     $t3cache->storeObject($preload->data[$template], $key);
 }
예제 #5
0
 function get_themes()
 {
     //get from preload object
     $themes = T3Preload::getObject('themes');
     if ($themes) {
         return $themes;
     }
     $themes["engine.default"] = array('engine', 'default');
     $themes["template.default"] = array('template', 'default');
     $core_themes = is_dir(T3Path::path(T3_TEMPLATE_CORE) . DS . 'themes') ? @JFolder::folders(T3Path::path(T3_TEMPLATE_CORE) . DS . 'themes') : null;
     if ($core_themes) {
         foreach ($core_themes as $theme) {
             $themes["core.{$theme}"] = array('core', $theme);
         }
     }
     $local_themes = is_dir(T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'themes') ? @JFolder::folders(T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'themes') : null;
     if ($local_themes) {
         foreach ($local_themes as $theme) {
             $themes["local.{$theme}"] = array('local', $theme);
         }
     }
     return $themes;
 }