Exemple #1
0
 /**
  * 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();
     }
 }
Exemple #2
0
 /**
  * Use a shorter and readable filename. use version to tell the browser that the file content is change.
  * Read content from array of files $files and write to one cached file if need update $needupdate or cached file not exists
  *
  * @param array  $files       List of file
  * @param string $ext         Extension
  * @param bool   $needupdate  Indicate need to update file or not
  *
  * @return The new file url
  */
 public static function store_file2($files, $ext, $needupdate)
 {
     $cache_path = T3Parameter::_getParam('optimize_folder', 't3-assets');
     $optimize_level = T3Parameter::_getParam('optimize_' . $ext, 1);
     $path = T3Path::path($cache_path);
     if (!is_dir($path)) {
         if (!@JFolder::create($path)) {
             return false;
             //cannot create cache folder for js/css optimize
         }
     }
     if (!is_file($path . DS . 'index.html')) {
         $indexcontent = '<html><body></body></html>';
         if (!@JFile::write($path . DS . 'index.html', $indexcontent)) {
             return false;
             //cannot create blank index.html to prevent list files
         }
     }
     static $filemap = array();
     //data.php contain filename maps
     $datafile = $path . '/data.php';
     if (is_file($datafile)) {
         include_once $datafile;
     }
     //get a salt
     if (!isset($filemap['salt']) || !$filemap['salt']) {
         $filemap['salt'] = rand();
     }
     //build destination file
     $file = md5($filemap['salt'] . serialize($files));
     $filename = $ext . '_' . substr($file, 0, 5) . ".{$ext}";
     $destfile = $path . DS . $filename;
     //re-populate $needupdate in case $destfile exists & keep original (not minify)
     if ($optimize_level == 1 && is_file($destfile)) {
         foreach ($files as $f) {
             if (@filemtime($f[0]) > @filemtime($destfile)) {
                 $needupdate = true;
                 break;
             }
         }
     }
     //check if need update
     if (!$needupdate && is_file($destfile)) {
         $fileversion = isset($filemap[$ext]) && isset($filemap[$ext][$file]) ? $filemap[$ext][$file] : 1;
         $fileversion = $fileversion == 1 ? "" : "?v=" . $filemap[$ext][$file];
         if ($optimize_level < 3) {
             return T3Path::url($cache_path) . '/' . $filename . $fileversion;
         } else {
             $url = "jat3action=gzip&amp;jat3type={$ext}&amp;jat3file=" . urlencode($cache_path . '/' . $filename);
             // Fix when enable languagefilter plugin
             $url = self::buildURL($url);
             return $url;
         }
     }
     //get files content
     $content = '';
     foreach ($files as $f) {
         $media = count($f) > 2 ? trim($f[2]['media']) : "";
         if ($ext == 'css') {
             if ($optimize_level == 1) {
                 $content .= "@import url(\"{$f[1]}\") {$media};\n";
             } elseif (!empty($media)) {
                 $content .= "/* " . substr(basename($f[0]), 33) . " */\n" . "@media " . $f[2]['media'] . " {\n" . @JFile::read($f[0]) . "\n}\n\n";
             } else {
                 $content .= "/* " . substr(basename($f[0]), 33) . " */\n" . @JFile::read($f[0]) . "\n\n";
             }
         } else {
             $content .= "/* " . basename($f[0]) . " */\n" . @JFile::read($f[0]) . ";\n\n";
         }
     }
     if (!isset($filemap[$ext])) {
         $filemap[$ext] = array();
     }
     if (!isset($filemap[$ext][$file])) {
         $filemap[$ext][$file] = 0;
         //store file version
     }
     //update file version
     $filemap[$ext][$file] = $filemap[$ext][$file] + 1;
     $fileversion = $filemap[$ext][$file] == 1 ? "" : "?v=" . $filemap[$ext][$file];
     //update datafile
     $filemapdata = '<?php $filemap = ' . var_export($filemap, true) . '; ?>';
     @JFile::write($datafile, $filemapdata);
     //create new file
     if (!@JFile::write($destfile, $content)) {
         return false;
         // Cannot create file
     }
     //return result
     //check if need compress
     if ($optimize_level == 3) {
         //compress
         $url = "jat3action=gzip&amp;jat3type={$ext}&amp;jat3file=" . urlencode($cache_path . '/' . $filename);
         // Fix when enable languagefilter plugin
         $url = self::buildURL($url);
         return $url;
     }
     return T3Path::url($cache_path) . '/' . $filename . $fileversion;
 }
Exemple #3
0
 function onAfterRoute()
 {
     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
                 t3_import('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
                     t3_import('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)) {
                     $obj->{$action}();
                 }
                 return;
             }
             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) {
                 $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]}");
             }
         }
         //add default & base theme path
         //if isRTL, auto add rtl theme
         if (T3Common::isRTL() && is_dir(T3Path::path(T3_TEMPLATE_CORE . '/themes/default-rtl'))) {
             $path->addPath('core.default-rtl', T3Path::path(T3_TEMPLATE_CORE . '/themes/default-rtl'), T3Path::url(T3_TEMPLATE_CORE . '/themes/default-rtl'));
         }
         $path->addPath('template.default', T3Path::path(T3_TEMPLATE), T3Path::url(T3_TEMPLATE));
         if (T3Common::isRTL() && is_dir(T3Path::path(T3_BASETHEME . '-rtl'))) {
             $path->addPath('engine.default-rtl', T3Path::path(T3_BASETHEME . '-rtl'), T3Path::url(T3_BASETHEME . '-rtl'));
         }
         $path->addPath('engine.default', T3Path::path(T3_BASETHEME), T3Path::url(T3_BASETHEME));
         T3Framework::init_layout();
     }
 }
Exemple #4
0
    ?>
;
    var t3info='<?php 
    echo JRequest::getCmd('t3info');
    ?>
';
    </script>
    <?php 
    if (is_dir(T3Path::path('layoutinfo', true))) {
        ?>
        <link type="text/css" rel="stylesheet" href="<?php 
        echo T3Path::url('layoutinfo/style.css', true);
        ?>
" />
        <script type="text/javascript" src="<?php 
        echo T3Path::url('layoutinfo/script.js', true);
        ?>
"></script>
    <?php 
    } else {
        ?>
        <?php 
        if (T3Path::getPath('layoutinfo')) {
            ?>
        <link type="text/css" rel="stylesheet" href="<?php 
            echo T3Path::getUrl('layoutinfo/style.css');
            ?>
" />
        <script type="text/javascript" src="<?php 
            echo T3Path::getUrl('layoutinfo/script.js');
            ?>