Esempio n. 1
0
 function buildCss($path)
 {
     $app = JFactory::getApplication();
     // get vars last-modified
     $vars_lm = $app->getUserState('vars_last_modified', 0);
     $theme = $app->getUserState('vars_theme', '');
     // less file last-modified
     $filepath = JPATH_ROOT . '/' . $path;
     $less_lm = filemtime($filepath);
     // get css cached file
     $cssfile = T3_DEV_FOLDER . '/' . ($theme ? $theme . '/' : '') . str_replace('/', '.', $path) . '.css';
     $cssurl = JURI::base(true) . '/' . $cssfile;
     $csspath = JPATH_ROOT . '/' . $cssfile;
     if (is_file($csspath) && filemtime($csspath) > $less_lm && filemtime($csspath) > $vars_lm) {
         return $cssurl;
     }
     // not cached, build & store it
     if (!$this->compileCss($path, $cssfile)) {
         T3::error(JText::sprintf('T3_MSG_DEVFOLDER_NOT_WRITABLE', T3_DEV_FOLDER));
     }
     return $cssurl;
 }
Esempio n. 2
0
 /**
  * initialize T3
  */
 public static function init($xml)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $coretheme = isset($xml->t3) && isset($xml->t3->base) ? trim((string) $xml->t3->base) : 'base';
     // check coretheme in media/t3/themes folder
     // if not exists, use default base theme in T3
     if (!$coretheme) {
         $coretheme = 'base';
     }
     foreach (array(T3_EX_BASE_PATH, T3_ADMIN_PATH) as $basedir) {
         if (is_dir($basedir . '/' . $coretheme)) {
             if (is_file($basedir . '/' . $coretheme . '/define.php')) {
                 include_once $basedir . '/' . $coretheme . '/define.php';
             }
             break;
         }
     }
     if (!defined('T3')) {
         // get ready for the t3 core base theme
         include_once T3_CORE_BASE_PATH . '/define.php';
     }
     if (!defined('T3')) {
         T3::error(JText::sprintf('T3_MSG_FAILED_INIT_BASE', $coretheme));
         exit;
     }
     define('T3_TEMPLATE', (string) $xml->tplname);
     define('T3_TEMPLATE_URL', JURI::root(true) . '/templates/' . T3_TEMPLATE);
     define('T3_TEMPLATE_PATH', str_replace('\\', '/', JPATH_ROOT) . '/templates/' . T3_TEMPLATE);
     define('T3_TEMPLATE_REL', 'templates/' . T3_TEMPLATE);
     define('T3_LOCAL_URL', T3_TEMPLATE_URL . '/' . T3_LOCAL_DIR);
     define('T3_LOCAL_PATH', T3_TEMPLATE_PATH . '/' . T3_LOCAL_DIR);
     define('T3_LOCAL_REL', T3_TEMPLATE_REL . '/' . T3_LOCAL_DIR);
     if ($input->getCmd('themer', 0)) {
         define('T3_THEMER', 1);
     }
     if (!$app->isAdmin()) {
         $params = $app->getTemplate(true)->params;
         define('T3_DEV_FOLDER', $params->get('t3-assets', 't3-assets') . '/dev');
         define('T3_DEV_MODE', $params->get('devmode', 0));
     } else {
         $params = self::getTemplate()->params;
         define('T3_DEV_FOLDER', $params->get('t3-assets', 't3-assets') . '/dev');
     }
     if (!is_dir(JPATH_ROOT . '/' . T3_DEV_FOLDER)) {
         jimport('joomla.filesystem.folder');
         JFolder::create(JPATH_ROOT . '/' . T3_DEV_FOLDER);
     }
     if ($input->getCmd('t3lock', '')) {
         JFactory::getSession()->set('T3.t3lock', $input->getCmd('t3lock', ''));
         $input->set('t3lock', null);
     }
     // load core library
     T3::import('core/path');
     T3::import('core/t3j');
     if (!$app->isAdmin()) {
         if (version_compare(JVERSION, '3.0', 'ge')) {
             // override core joomla class
             // JViewLegacy
             T3::register('JViewLegacy', T3_ADMIN_PATH . '/includes/joomla30/viewlegacy.php');
             T3::register('JViewHtml', T3_ADMIN_PATH . '/includes/joomla30/viewhtml.php');
             // JModuleHelper
             T3::register('JModuleHelper', T3_ADMIN_PATH . '/includes/joomla30/modulehelper.php');
             // JPagination
             T3::register('JPagination', T3_ADMIN_PATH . '/includes/joomla30/pagination.php');
             // Register T3 Layout File to put a t3 base layer for layout files
             T3::register('JLayoutFile', T3_ADMIN_PATH . '/includes/joomla25/layout/file.php');
         } else {
             // override core joomla class
             // JView
             T3::register('JView', T3_ADMIN_PATH . '/includes/joomla25/view.php', 'joomla.application.component.view');
             // JModuleHelper
             T3::register('JModuleHelper', T3_ADMIN_PATH . '/includes/joomla25/modulehelper.php', 'joomla.application.module.helper');
             // JPagination
             T3::register('JPagination', T3_ADMIN_PATH . '/includes/joomla25/pagination.php', 'joomla.html.pagination');
             //register layout
             T3::register('JLayout', T3_ADMIN_PATH . '/includes/joomla25/layout/layout.php');
             T3::register('JLayoutBase', T3_ADMIN_PATH . '/includes/joomla25/layout/base.php');
             T3::register('JLayoutFile', T3_ADMIN_PATH . '/includes/joomla25/layout/file.php');
             T3::register('JLayoutHelper', T3_ADMIN_PATH . '/includes/joomla25/layout/helper.php');
             T3::register('JHtmlBootstrap', T3_ADMIN_PATH . '/includes/joomla25/html/bootstrap.php');
             T3::register('JHtmlBehavior', T3_ADMIN_PATH . '/includes/joomla25/html/behavior.php');
             T3::register('JHtmlString', T3_ADMIN_PATH . '/includes/joomla25/html/string.php');
             T3::register('JHtmlJquery', T3_ADMIN_PATH . '/includes/joomla25/html/jquery.php');
             // load j25 compat language
             JFactory::getLanguage()->load('plg_system_t3.j25.compat', JPATH_ADMINISTRATOR);
         }
         // import renderer
         T3::import('renderer/pageclass');
         T3::import('renderer/megamenu');
         T3::import('renderer/t3bootstrap');
     } else {
     }
     // capture for tm=1 => show theme magic
     if ($input->getCmd('tm') == 1) {
         $input->set('t3action', 'theme');
         $input->set('t3task', 'thememagic');
     }
 }
Esempio n. 3
0
 /**
  * @param  string  $theme  template theme
  * @param  string  $dir    direction (ltr or rtl)
  * @return mixed
  */
 public static function buildVars($theme = null, $dir = null)
 {
     $app = JFactory::getApplication();
     $params = null;
     if ($app->isAdmin()) {
         $params = $app->getUserState('current_template_params');
     } else {
         $tpl = $app->getTemplate(true);
         $params = $tpl->params;
     }
     if (!$params) {
         T3::error(JText::_('T3_MSG_CANNOT_DETECT_TEMPLATE'));
         exit;
     }
     $responsive = $params->get('responsive', 1);
     // theme style
     if ($theme === null) {
         $theme = $params->get('theme');
     }
     // detect RTL
     if ($dir === null) {
         $doc = JFactory::getDocument();
         $dir = $doc->direction;
     }
     $app->setUserState('current_theme', $theme);
     $app->setUserState('current_direction', $dir);
     $app->setUserState('current_key_sufix', "_{$theme}_{$dir}");
     $path = T3_TEMPLATE_PATH . '/less/vars.less';
     if (!is_file($path)) {
         T3::error(JText::_('T3_MSG_LESS_NOT_VALID'));
         exit;
     }
     // force re-build less if switch responsive mode and get last modified time
     if ($responsive !== self::getState('current_responsive')) {
         self::setState('current_responsive', $responsive);
         $last_modified = time();
         touch($path, $last_modified);
     } else {
         $last_modified = filemtime($path);
     }
     $vars_content = file_get_contents($path);
     $vars_urls = array();
     preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $vars_content, $matches);
     if (count($matches[0])) {
         foreach ($matches[1] as $url) {
             $path = T3Path::cleanPath(T3_TEMPLATE_PATH . '/less/' . $url);
             if (file_exists($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 $vars_urls[] = T3Path::cleanPath(T3_TEMPLATE_REL . '/less/' . $url);
             }
         }
     }
     // add override variables
     $paths = array();
     if ($theme) {
         $paths[] = T3_TEMPLATE_REL . "/less/themes/{$theme}/variables.less";
         $paths[] = T3_TEMPLATE_REL . "/less/themes/{$theme}/variables-custom.less";
     }
     if ($dir == 'rtl') {
         $paths[] = T3_TEMPLATE_REL . "/less/rtl/variables.less";
         if ($theme) {
             $paths[] = T3_TEMPLATE_REL . "/less/rtl/themes/{$theme}/variables.less";
         }
     }
     if (!defined('T3_LOCAL_DISABLED')) {
         $paths[] = T3_LOCAL_REL . "/less/variables.less";
         if ($theme) {
             $paths[] = T3_LOCAL_REL . "/less/themes/{$theme}/variables.less";
             $paths[] = T3_LOCAL_REL . "/less/themes/{$theme}/variables-custom.less";
         }
         if ($dir == 'rtl') {
             $paths[] = T3_LOCAL_REL . "/less/rtl/variables.less";
             if ($theme) {
                 $paths[] = T3_LOCAL_REL . "/less/rtl/themes/{$theme}/variables.less";
             }
         }
     }
     if (!$responsive) {
         $paths[] = T3_REL . '/less/non-responsive-variables.less';
         $paths[] = T3_TEMPLATE_REL . '/less/non-responsive-variables.less';
     }
     foreach ($paths as $file) {
         if (is_file(JPATH_ROOT . '/' . $file)) {
             $last_modified = max($last_modified, filemtime(JPATH_ROOT . '/' . $file));
             $vars_urls[] = $file;
         }
     }
     if (self::getState('vars_last_modified') != $last_modified) {
         self::setState('vars_last_modified', $last_modified);
     }
     self::setState('vars_urls_content', implode('|', $vars_urls));
 }
Esempio n. 4
0
File: t3.php Progetto: Tommar/vino2
 /**
  * initialize T3
  */
 public static function init($xml)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $coretheme = isset($xml->t3) && isset($xml->t3->base) ? trim((string) $xml->t3->base) : 'base';
     // check coretheme in media/t3/themes folder
     // if not exists, use default base theme in T3
     if (!$coretheme) {
         $coretheme = 'base';
     }
     foreach (array(T3_EX_BASE_PATH, T3_ADMIN_PATH) as $basedir) {
         if (is_dir($basedir . '/' . $coretheme)) {
             if (is_file($basedir . '/' . $coretheme . '/define.php')) {
                 include_once $basedir . '/' . $coretheme . '/define.php';
             }
             break;
         }
     }
     if (!defined('T3')) {
         // get ready for the t3 core base theme
         include_once T3_CORE_BASE_PATH . '/define.php';
     }
     if (!defined('T3')) {
         T3::error(JText::sprintf('T3_MSG_FAILED_INIT_BASE', $coretheme));
         exit;
     }
     define('T3_TEMPLATE', $xml->tplname);
     define('T3_TEMPLATE_URL', JURI::root(true) . '/templates/' . T3_TEMPLATE);
     define('T3_TEMPLATE_PATH', JPATH_ROOT . '/templates/' . T3_TEMPLATE);
     define('T3_TEMPLATE_REL', 'templates/' . T3_TEMPLATE);
     if ($input->getCmd('themer', 0)) {
         define('T3_THEMER', 1);
     }
     if (!$app->isAdmin()) {
         $params = $app->getTemplate(true)->params;
         define('T3_DEV_FOLDER', $params->get('t3-assets', 't3-assets') . '/dev');
         define('T3_DEV_MODE', $params->get('devmode', 0));
     }
     if ($input->getCmd('t3lock', '')) {
         JFactory::getSession()->set('T3.t3lock', $input->getCmd('t3lock', ''));
         $input->set('t3lock', null);
     }
     // load core library
     T3::import('core/path');
     if (!$app->isAdmin()) {
         if (version_compare(JVERSION, '3.0', 'ge')) {
             // override core joomla class
             // JViewLegacy
             if (!class_exists('JViewLegacy', false)) {
                 T3::import('joomla30/viewlegacy');
             }
             // JModuleHelper
             if (!class_exists('JModuleHelper', false)) {
                 T3::import('joomla30/modulehelper');
             }
             // JPagination
             if (!class_exists('JPagination', false)) {
                 T3::import('joomla30/pagination');
             }
         } else {
             // override core joomla class
             // JView
             if (!class_exists('JView', false)) {
                 T3::import('joomla25/view');
             }
             // JModuleHelper
             if (!class_exists('JModuleHelper', false)) {
                 T3::import('joomla25/modulehelper');
             }
             // JPagination
             if (!class_exists('JPagination', false)) {
                 T3::import('joomla25/pagination');
             }
             //register layout
             JLoader::register('JLayout', T3_ADMIN_PATH . '/includes/joomla25/layout/layout.php');
             JLoader::register('JLayoutBase', T3_ADMIN_PATH . '/includes/joomla25/layout/base.php');
             JLoader::register('JLayoutFile', T3_ADMIN_PATH . '/includes/joomla25/layout/file.php');
             JLoader::register('JLayoutHelper', T3_ADMIN_PATH . '/includes/joomla25/layout/helper.php');
         }
         // import renderer
         T3::import('renderer/pageclass');
         T3::import('renderer/megamenu');
         T3::import('renderer/t3bootstrap');
     } else {
     }
     // capture for tm=1 => show theme magic
     if ($input->getCmd('tm') == 1) {
         $input->set('t3action', 'theme');
         $input->set('t3task', 'thememagic');
     }
 }
Esempio n. 5
0
 /**
  * @param  string  $theme  template theme
  * @param  string  $dir    direction (ltr or rtl)
  * @return mixed
  */
 public static function buildVars($theme = null, $dir = null)
 {
     $app = JFactory::getApplication();
     $path = T3_TEMPLATE_PATH . '/less/vars.less';
     if (!is_file($path)) {
         T3::error(JText::_('T3_MSG_LESS_NOT_VALID'));
         exit;
     }
     // get last-modified
     $last_modified = filemtime($path);
     $vars = JFile::read($path);
     preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $vars, $matches);
     if (count($matches[0])) {
         $vars = '';
         foreach ($matches[1] as $url) {
             $path = T3Path::cleanPath(T3_TEMPLATE_PATH . '/less/' . $url);
             if (file_exists($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 $vars .= JFile::read($path);
             }
         }
     }
     // theme style
     if ($theme === null) {
         $tpl = $app->getTemplate(true);
         $theme = $tpl->params->get('theme');
     }
     $app->setUserState('vars_theme', $theme);
     // detect RTL
     if ($dir === null) {
         $doc = JFactory::getDocument();
         $dir = $doc->direction;
     }
     $app->setUserState('DIRECTION', $dir);
     if ($theme) {
         // add theme variables.less and variables-custom.less
         foreach (array('variables.less', 'variables-custom.less') as $file) {
             $path = T3_TEMPLATE_PATH . '/less/themes/' . $theme . '/' . $file;
             if (is_file($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 $vars .= JFile::read($path);
             }
         }
     }
     // RTL variables
     $rtl = '';
     if ($dir == 'rtl') {
         // add rtl variables.less and rtl theme variables.less
         foreach (array('variables.less', $theme . '/variables.less') as $file) {
             $path = T3_TEMPLATE_PATH . '/less/rtl/' . $file;
             if (is_file($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 // append rtl file into vars
                 $vars .= JFile::read($path);
             }
         }
         $rtl = '_rtl';
     }
     if ($app->getUserState('vars_last_modified' . $rtl) != $last_modified . $theme . $rtl) {
         $app->setUserState('vars_last_modified' . $rtl, $last_modified . $theme . $rtl);
     }
     $app->setUserState('vars_content' . $rtl, $vars);
 }
Esempio n. 6
0
 /**
  * @param  string  $theme  template theme
  * @param  string  $dir    direction (ltr or rtl)
  * @return mixed
  */
 public static function buildVars($theme = null, $dir = null)
 {
     $app = JFactory::getApplication();
     $params = null;
     if ($app->isAdmin()) {
         $params = $app->getUserState('current_template_params');
     } else {
         $tpl = $app->getTemplate(true);
         $params = $tpl->params;
     }
     if (!$params) {
         T3::error(JText::_('T3_MSG_CANNOT_DETECT_TEMPLATE'));
         exit;
     }
     $responsive = $params->get('responsive', 1);
     // theme style
     if ($theme === null) {
         $theme = $params->get('theme');
     }
     // detect RTL
     if ($dir === null) {
         $doc = JFactory::getDocument();
         $dir = $doc->direction;
     }
     $app->setUserState('current_theme', $theme);
     $app->setUserState('current_direction', $dir);
     $app->setUserState('current_key_sufix', "_{$theme}_{$dir}");
     $path = T3_TEMPLATE_PATH . '/less/vars.less';
     if (!is_file($path)) {
         T3::error(JText::_('T3_MSG_LESS_NOT_VALID'));
         exit;
     }
     // force re-build less if switch responsive mode and get last modified time
     if ($responsive !== $app->getUserState('current_responsive')) {
         $app->setUserState('current_responsive', $responsive);
         $last_modified = time();
         touch($path, $last_modified);
     } else {
         $last_modified = filemtime($path);
     }
     $vars = JFile::read($path);
     preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $vars, $matches);
     if (count($matches[0])) {
         $vars = '';
         foreach ($matches[1] as $url) {
             $path = T3Path::cleanPath(T3_TEMPLATE_PATH . '/less/' . $url);
             if (file_exists($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 $vars .= JFile::read($path);
             }
         }
     }
     if ($theme) {
         // add theme variables.less and variables-custom.less
         foreach (array('variables.less', 'variables-custom.less') as $file) {
             $path = T3_TEMPLATE_PATH . '/less/themes/' . $theme . '/' . $file;
             if (is_file($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 $vars .= JFile::read($path);
             }
         }
     }
     // RTL variables
     $rtl = '';
     if ($dir == 'rtl') {
         // add rtl variables.less and rtl theme variables.less
         foreach (array('variables.less', $theme . '/variables.less') as $file) {
             $path = T3_TEMPLATE_PATH . '/less/rtl/' . $file;
             if (is_file($path)) {
                 $last_modified = max($last_modified, filemtime($path));
                 // append rtl file into vars
                 $vars .= JFile::read($path);
             }
         }
         $rtl = '_rtl';
     }
     // Non-responsive variables
     if (!$responsive) {
         $file = '/less/non-responsive-variables.less';
         $path = T3_PATH . $file;
         if (is_file($path)) {
             $last_modified = max($last_modified, filemtime($path));
             // append rtl file into vars
             $vars .= JFile::read($path);
         }
         $path = T3_TEMPLATE_PATH . $file;
         if (is_file($path)) {
             $last_modified = max($last_modified, filemtime($path));
             // append rtl file into vars
             $vars .= JFile::read($path);
         }
     }
     if (self::getState('vars_last_modified') != $last_modified) {
         self::setState('vars_last_modified', $last_modified);
     }
     self::setState('vars_content', $vars);
 }