<?php /* # ------------------------------------------------------------------------ # JA T3v2 Plugin - Template framework for Joomla 1.5 # ------------------------------------------------------------------------ # Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved. # @license - GNU/GPL V2, http://www.gnu.org/licenses/gpl2.html. For details # on licensing, Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html. # Author: JoomlArt.com # Websites: http://www.joomlart.com - http://www.joomlancers.com. # ------------------------------------------------------------------------ */ if (!($mobile = T3Common::mobile_device_detect())) { return; } $handheld_view = $this->getParam('ui'); $switch_to = $handheld_view == 'desktop' ? 'default' : 'desktop'; $text = $handheld_view == 'desktop' ? 'Mobile Version' : 'Desktop Version'; ?> <a class="ja-tool-switchlayout" href="<?php echo JURI::base(); ?> ?ui=<?php echo $switch_to; ?> " title="<?php echo JText::_($text); ?> "><span><?php
/** * Implement after route event * * @return null */ function onAfterRoute() { // Load t3 language file for front-end & template admin. //$this->loadLanguage(null, JPATH_ADMINISTRATOR); //this language should be loaded by joomla $lang = JFactory::getLanguage(); $lang->load('plg_system_jat3', JPATH_ADMINISTRATOR); t3import('core.framework'); $app = JFactory::getApplication('administrator'); if ($app->isAdmin()) { t3import('core.admin.util'); // Clean cache if there's something changed backend if (JRequest::getCmd('jat3action') || in_array(JRequest::getCmd('task'), array('save', 'delete', 'remove', 'apply', 'publish', 'unpublish'))) { if (JRequest::getCmd('jat3action')) { //if template parameter updated => clear cache t3import('core.cache'); T3Cache::clean(2); } else { $params = T3Common::get_template_based_params(); $cache = $params->get('cache'); if ($cache) { //if other update: clear cache if cache is enabled t3import('core.cache'); T3Cache::clean(1); } } } if (JAT3_AdminUtil::checkPermission()) { if (JAT3_AdminUtil::checkCondition_for_Menu()) { JHTML::stylesheet(JURI::root() . T3_CORE . '/element/assets/css/japaramhelper.css'); JHTML::script(JURI::root() . T3_CORE . '/element/assets/js/japaramhelper.js', true); } if (JRequest::getCmd('jat3type') == 'plugin') { $action = JRequest::getCmd('jat3action'); t3import('core.ajax'); $obj = new JAT3_Ajax(); if ($action && method_exists($obj, $action)) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); $obj->{$action}(); } return; } //Load moontools library JHtml::_('behavior.framework'); if (!T3Common::detect()) { return; } JAT3_AdminUtil::loadStyle(); JAT3_AdminUtil::loadScipt(); return; } elseif (JRequest::getCmd('jat3type') == 'plugin') { $result['error'] = 'Session has expired. Please login before continuing.'; echo json_encode($result); exit; } return; } if (!$app->isAdmin() && T3Common::detect()) { $action = JRequest::getCmd('jat3action'); // Process request ajax like action - public if ($action) { t3import('core.ajaxsite'); if (method_exists('T3AjaxSite', $action)) { T3AjaxSite::$action(); $app->close(); //exit after finish action } } // Load core library T3Framework::t3_init($this->plgParams); // Init T3Engine // Get list templates $themes = T3Common::get_active_themes(); $path = T3Path::getInstance(); // Path in t3 engine // Active themes path if ($themes && count($themes)) { foreach ($themes as $theme) { if ($theme[0] == 'engine') { $path->addPath($theme[0] . '.' . $theme[1], T3Path::path(T3_BASE . '/base-themes/' . $theme[1]), T3Path::url(T3_BASE . '/base-themes/' . $theme[1])); } elseif ($theme[0] == 'template') { $path->addPath($theme[0] . '.' . $theme[1], T3Path::path(T3_TEMPLATE), T3Path::url(T3_TEMPLATE)); } else { $themepath = T3Path::path(T3_TEMPLATE) . DS . 'themes'; // Check if template use newest folder structure or not // If themes folder is exists in template folder, consider as template use newst folder structure if (@is_dir($themepath)) { $path->addPath($theme[0] . '.' . $theme[1], T3Path::path(T3_TEMPLATE) . DS . 'themes' . DS . $theme[1], T3Path::url(T3_TEMPLATE) . "/themes/{$theme[1]}"); } else { // Compatible: if template use older folder structure, try to use it $path->addPath($theme[0] . '.' . $theme[1], T3Path::path(T3_TEMPLATE) . DS . $theme[0] . DS . 'themes' . DS . $theme[1], T3Path::url(T3_TEMPLATE) . "/{$theme[0]}/themes/{$theme[1]}"); } } } } // Disable editor if website is access by iphone & handheld $device = T3Common::mobile_device_detect(); if ($device == 'iphone' || $device == 'handheld') { $config = JFactory::getConfig(); $config->set('editor', 'none'); } T3Framework::init_layout(); } }
/** * 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; }
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()); */ }
} $component = JComponentHelper::getComponent(JEV_COM_COMPONENT); $component->params =& $newparams; $isMobile = $browser->isMobile(); // Joomla isMobile method doesn't identify all android phones if (!$isMobile && isset($_SERVER['HTTP_USER_AGENT'])) { if (stripos($_SERVER['HTTP_USER_AGENT'], 'android') > 0 || stripos($_SERVER['HTTP_USER_AGENT'], 'blackberry') > 0) { $isMobile = true; } else { if (stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') > 0 || stripos($_SERVER['HTTP_USER_AGENT'], 'ipod') > 0) { $isMobile = true; } } } $params = JComponentHelper::getParams(JEV_COM_COMPONENT); if ($isMobile || strpos(JFactory::getApplication()->getTemplate(), 'mobile_') === 0 || class_exists("T3Common") && class_exists("T3Parameter") && T3Common::mobile_device_detect() || JRequest::getVar("jEV", "") == "smartphone") { if (!$params->get("disablesmartphone")) { JRequest::setVar("jevsmartphone", 1); if (JFolder::exists(JEV_VIEWS . "/smartphone")) { JRequest::setVar("jEV", "smartphone"); } $params->set('iconicwidth', 485); $params->set('extpluswidth', 485); $params->set('ruthinwidth', 485); } } // See http://www.php.net/manual/en/timezones.php $tz = $params->get("icaltimezonelive", ""); if ($tz != "" && is_callable("date_default_timezone_set")) { $timezone = date_default_timezone_get(); date_default_timezone_set($tz);
/** * Get active layout name * * @return string */ public static function get_active_layout() { //return T3Parameter::_getParam('layouts'); $params = T3Common::get_template_params(); $device = T3Common::mobile_device_detect(); if (!$device) { //desktop // Get from override profile $active_profile = T3Common::get_active_profile(); $default_profile = T3Common::get_default_profile(); if ($active_profile != $default_profile && $active_profile != 'default') { $file = self::getFilePath($active_profile, 'profiles'); if (is_file($file)) { $content = file_get_contents($file); // $params = new JParameter($content); // Strict standards: Declaration of JParameter::loadSetupFile() should be compatible with that of JRegistry::loadSetupFile() $params = $content; if (!$content instanceof JRegistry) { $params = new JRegistry($content); } $layout = $params->get('desktop_layout', ''); if (T3Common::layout_exists($layout)) { return $layout; } } } // Cannot get from override profile for this page, get from usersetting $layout = T3Parameter::_getParam('layouts', ''); if (T3Common::layout_exists($layout)) { return $layout; } // Get default $layout = $params->get('desktop_layout', ''); if (!T3Common::layout_exists($layout)) { $params = T3Common::get_template_params(); $layout = $params->get('desktop_layout', ''); if (!T3Common::layout_exists($layout)) { $layout = 'default'; } } } else { $layout = $params->get($device . '_layout', ''); if (!$layout) { $layout = $params->get('handheld_layout', ''); } if ($layout == -1) { //disable => use layout from desktop $device = ''; $layout = $params->get('desktop_layout', ''); if (!T3Common::layout_exists($layout)) { $layout = 'default'; } } elseif ($layout == 1) { //default => use layout from t3 engine $layout = $device; if (!T3Common::layout_exists($layout)) { $layout = 'handheld'; } } elseif (!T3Common::layout_exists($layout)) { $layout = 'handheld'; } } return $layout; }
?> <?php $blocks = T3Common::node_children($this->getBlocksXML('head'), 'block'); foreach ($blocks as $block) { $this->showBlock($block); } ?> <?php echo $this->showBlock('css'); ?> </head> <body id="bd" class="<?php if (!T3Common::mobile_device_detect()) { ?> bd<?php } ?> <?php echo $this->getBodyClass(); ?> "> <a name="Top" id="Top"></a> <div id="ja-wrapper"> <?php $blks =& $this->getBlocksXML('top'); $blocks =& T3Common::node_children($blks, 'block');
function get_active_layout() { //return T3Parameter::_getParam('layouts'); $params = T3Common::get_template_params(); $device = T3Common::mobile_device_detect(); if (!$device) { //desktop //get from override profile $active_profile = T3Common::get_active_profile(); $default_profile = T3Common::get_default_profile(); if ($active_profile != $default_profile && $active_profile != 'default') { $path = 'etc' . DS . 'profiles' . DS . $active_profile . '.ini'; $file = T3Path::path(T3_TEMPLATE_LOCAL) . DS . $path; if (!is_file($file)) { $file = T3Path::path(T3_TEMPLATE_CORE) . DS . $path; } if (is_file($file)) { $content = file_get_contents($file); $params = new JParameter($content); $layout = $params->get('desktop_layout', ''); if (T3Common::layout_exists($layout)) { return $layout; } } } //cannot get from override profile for this page, get from usersetting $layout = T3Parameter::get('layouts', ''); if (T3Common::layout_exists($layout)) { return $layout; } //get default $layout = $params->get('desktop_layout', ''); if (!T3Common::layout_exists($layout)) { $layout = 'default'; } } else { $layout = $params->get($device . '_layout', ''); if (!$layout) { $layout = $params->get('handheld_layout', ''); } if ($layout == -1) { //disable => use layout from desktop $device = ''; $layout = $params->get('desktop_layout', ''); if (!T3Common::layout_exists($layout)) { $layout = 'default'; } } else { if ($layout == 1) { //default => use layout from t3 engine $layout = $device; if (!T3Common::layout_exists($layout)) { $layout = 'handheld'; } } else { if (!T3Common::layout_exists($layout)) { $layout = 'handheld'; } } } } return $layout; }
/** * Get configured main width * * @return string Main width */ function getMainWidth() { if (T3Common::mobile_device_detect()) { return false; } // get screen size setting $screen = $this->getParam('screen', 'reset'); if ($screen == 'reset') { $screen = $this->getParam('setting_screen', 'wide'); } // echo "[$screen]"; switch ($screen) { case 'auto': $screen_width = '95%'; break; case 'fixed': $screen_width = $this->getParam('screen_fixed_width', '980px'); if (is_numeric($screen_width)) { if (100 > (int) $screen_width) { $screen_width = $screen_width . '%'; } else { $screen_width = $screen_width . 'px'; } } break; case 'narrow': $screen_width = '770px'; break; case 'wide': default: $screen_width = '950px'; break; } return $screen_width; }
// we need to get it from the menu item itself $menu = JFactory::getApplication()->getMenu()->getActive(); if ($menu) { $newparams->def('page_heading', $newparams->get('page_title', $menu->title)); } else { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $newparams->def('page_heading', $params->get('page_title')); } $component =& JComponentHelper::getComponent(JEV_COM_COMPONENT); $component->params =& $newparams; $isMobile = $browser->isMobile(); } else { $isMobile = $browser->_mobile; } $params = JComponentHelper::getParams(JEV_COM_COMPONENT); if ($isMobile || strpos(JFactory::getApplication()->getTemplate(), 'mobile_') === 0 || class_exists("T3Common") && T3Common::mobile_device_detect()) { JRequest::setVar("jevsmartphone", 1); if (JFolder::exists(JEV_VIEWS . "/smartphone")) { //JRequest::setVar("jEV","smartphone"); } $params->set('iconicwidth', 485); $params->set('extpluswidth', 485); $params->set('ruthinwidth', 485); } // See http://www.php.net/manual/en/timezones.php $tz = $params->get("icaltimezonelive", ""); if ($tz != "" && is_callable("date_default_timezone_set")) { $timezone = date_default_timezone_get(); date_default_timezone_set($tz); $registry->setValue("jevents.timezone", $timezone); }