예제 #1
0
 function gzip()
 {
     $file = JRequest::getVar('file');
     //clean filepath
     $file = preg_replace('#[?\\#]+.*$#', '', $file);
     //check exists
     $filepath = T3Path::path(dirname($file)) . DS . basename($file);
     if (!is_file($filepath)) {
         echo "File {$file} {$filepath} not exist";
         return;
     }
     $type = strtolower(JRequest::getCmd('type', 'css'));
     //$type must be in css or js
     if (!in_array($type, array('css', 'js'))) {
         echo "Type {$type} not support";
         return;
     }
     //make sure the type of $file is the same with $type
     if (!preg_match('#\\.' . $type . '$#', $filepath)) {
         echo "Type {$type} not match";
         return;
     }
     jimport('joomla.filesystem.file');
     $data = @JFile::read($filepath);
     if (!$data) {
         echo "File {$filepath} empty";
         return;
     }
     if ($type == 'js') {
         $type = 'javascript';
     }
     JResponse::setHeader('Content-Type', "text/{$type};", true);
     //set cache time
     JResponse::setHeader('Cache-Control', "private", true);
     $offset = 365 * 24 * 60 * 60;
     //whenever the content is changed, the file name is changed also. Therefore we could set the cache time long.
     JResponse::setHeader('Expires', gmdate("D, d M Y H:i:s", time() + $offset) . " GMT", true);
     JResponse::allowCache(true);
     JResponse::setBody($data);
     echo JResponse::toString(1);
 }
예제 #2
0
 function getT3Themes($template)
 {
     $themes = array();
     $themes["engine.default"] = T3Path::path(T3_BASETHEME, false);
     $path = T3Path::path(T3_TEMPLATE_CORE) . DS . 'themes';
     $_themes = @JFolder::folders($path);
     if (is_array($_themes)) {
         foreach ($_themes as $theme) {
             $themes["core.{$theme}"] = T3Path::path(T3_TEMPLATE_CORE, false) . DS . 'themes' . DS . $theme;
         }
     }
     $path = T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'themes';
     if (is_dir($path)) {
         $_themes = @JFolder::folders($path);
         if (is_array($_themes)) {
             foreach ($_themes as $theme) {
                 $themes["local.{$theme}"] = T3Path::path(T3_TEMPLATE_LOCAL, false) . DS . 'themes' . DS . $theme;
             }
         }
     }
     return $themes;
 }
예제 #3
0
 /**
  * Popup prepare content method
  *
  * @param string $bodyContent  The body string content.
  *
  * @return string  The replaced body string content
  */
 function replaceContent($bodyContent)
 {
     // Build HTML params area
     $xmlFile = T3Path::path(T3_CORE) . DS . 'params' . DS . "jatoolbar.xml";
     if (!file_exists($xmlFile)) {
         return $bodyContent;
     }
     $str = "";
     $configform = JForm::getInstance('params', $xmlFile, array('control' => 'jform'));
     $fieldSets = $configform->getFieldsets('params');
     $html = '';
     foreach ($fieldSets as $name => $fieldSet) {
         $html .= '<div class="panel">
             <h3 id="jatoolbar-page" class="jpane-toggler title">
                 <a href="#"><span>' . JText::_($fieldSet->label) . '</span></a>
             </h3>';
         $html .= '
             <div class="jpane-slider content">
                 <fieldset class="panelform">';
         if (isset($fieldSet->description) && trim($fieldSet->description)) {
             $html .= '<div class="block-des">' . JText::_($fieldSet->description) . '</div>';
         }
         $html .= '    <ul class="adminformlist">';
         foreach ($configform->getFieldset($name) as $field) {
             $html .= '<li>';
             $html .= $field->label;
             $html .= $field->input;
             $html .= '</li>';
         }
         $html .= '</ul>
                 </fieldset>
             </div>
         </div>';
     }
     preg_match_all("/<div class=\"panel\">([\\s\\S]*?)<\\/div>/i", $bodyContent, $arr);
     $bodyContent = str_replace($arr[0][count($arr[0]) - 1] . '</div>', $arr[0][count($arr[0]) - 1] . '</div>' . $html, $bodyContent);
     return $bodyContent;
 }
예제 #4
0
 /**
  * Get theme path
  *
  * @param string $name   Theme name
  * @param bool   $local  Indicate theme is local or not
  *
  * @return string
  */
 public static function getThemePath($name, $local = true)
 {
     $path = T3Path::path(T3_TEMPLATE);
     // Check template use newest folder structure or not
     // If themes is exists, considered as template use newest folder structure
     if (@is_dir($path . DS . 'themes')) {
         $path .= DS . 'themes' . DS . $name;
     } else {
         if ($local) {
             $path .= DS . 'local' . DS . 'themes' . DS . $name;
         } else {
             $path .= DS . 'core' . DS . 'themes' . DS . $name;
         }
     }
     return $path;
 }
예제 #5
0
 function saveLayout()
 {
     global $mainframe;
     t3_import('core/admin/util');
     // Initialize some variables
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     //$json = JRequest::getVar('json');
     $json = JRequest::getString('json', '', 'default', 2);
     $data = json_decode($json);
     $data = str_replace(array("\\n", "\\t"), array("\n", "\t"), $data) . ' ';
     $data = str_replace('\\', '', $data);
     $template = JRequest::getCmd('template');
     $layout = JRequest::getCmd('layout');
     $errors = array();
     $result = array();
     if (!$template || !$layout) {
         $result['error'] = JText::_('No template specified or Layout name contains space or special chracters.');
         echo json_encode($result);
         exit;
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'etc' . DS . 'layouts' . DS . strtolower($layout) . '.xml';
     $file_core = T3Path::path(T3_TEMPLATE_CORE) . DS . 'etc' . DS . 'layouts' . DS . strtolower($layout) . '.xml';
     //get layouts from core
     $file_base = T3Path::path(T3_BASETHEME) . DS . 'etc' . DS . 'layouts' . DS . strtolower($layout) . '.xml';
     if (file_exists($file) || file_exists($file_core) || file_exists($file_base)) {
         $result['type'] = 'edit';
     } else {
         $result['type'] = 'new';
     }
     if (JFile::exists($file)) {
         @chmod($file, 0777);
     }
     $return = JFile::write($file, $data);
     // Try to make the params file unwriteable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         $errors[] = sprintf(JText::_('Could not make the %s file unwritable'), $file);
     }
     if (!$return) {
         $errors[] = JText::_('Operation Failed') . ': ' . JText::sprintf('Failed to open file for writing.', $file);
     }
     if ($errors) {
         $result['error'] = implode('<br/>', $errors);
     } else {
         if ($result['type'] == 'new') {
             $result['successful'] = sprintf(JText::_('Layout %s was successfully created!'), $layout);
         } else {
             $result['successful'] = sprintf(JText::_('SAVE %s LAYOUT SUCCESSFULLY'), $layout);
         }
         $result['layout'] = $layout;
     }
     echo json_encode($result);
     exit;
 }
예제 #6
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();
     }
 }
예제 #7
0
 /**
  * Get theme list
  *
  * @param string $template  Template name
  *
  * @return array  List of theme
  */
 function getT3Themes($template)
 {
     $themes = array();
     $themes["engine.default"] = T3Path::path(T3_BASETHEME, false);
     $path = T3Path::path(T3_TEMPLATE) . DS . 'themes';
     // Check if template use newest folder structure or not
     // If themes folder is exists in template folder, considered as template use newest folder structure
     if (@is_dir($path)) {
         $path = T3Path::path(T3_TEMPLATE, false) . DS . 'themes';
         $_themes = @JFolder::folders($path);
         if (is_array($_themes)) {
             foreach ($_themes as $theme) {
                 if ('.local' == substr($theme, -6)) {
                     $themes['local' . substr($theme, 0, -6)] = $path . DS . $theme;
                 } else {
                     $themes['core' . $theme] = $path . DS . $theme;
                 }
             }
         }
     } else {
         // Compatible: if template use
         $path = T3Path::path(T3_TEMPLATE_CORE) . DS . 'themes';
         $_themes = @JFolder::folders($path);
         if (is_array($_themes)) {
             foreach ($_themes as $theme) {
                 $themes["core.{$theme}"] = T3Path::path(T3_TEMPLATE_CORE, false) . DS . 'themes' . DS . $theme;
             }
         }
         $path = T3Path::path(T3_TEMPLATE_LOCAL) . DS . 'themes';
         if (is_dir($path)) {
             $_themes = @JFolder::folders($path);
             if (is_array($_themes)) {
                 foreach ($_themes as $theme) {
                     $themes["local.{$theme}"] = T3Path::path(T3_TEMPLATE_LOCAL, false) . DS . 'themes' . DS . $theme;
                 }
             }
         }
     }
     return $themes;
 }
예제 #8
0
 /**
  * Clean T3 cache
  * If $t3assets > 0,  deleted all cached content in defaultgroup
  * If $t3assets > 1,  deleted all cached content in assets group
  * If $t3assets > 2, deleted all cached content in css/js optimize folder
  *
  * @param int $t3assets    Level cache
  *
  * @return void
  */
 private function _clean($t3assets = 0)
 {
     $cache = $this->cache;
     // Clear cache in default group folder
     if ($t3assets > 0) {
         $cache->clean();
     }
     // Clear cache in assets folder
     if ($t3assets > 1) {
         $cache->clean(self::T3_CACHE_ASSETS);
     }
     if ($t3assets > 2) {
         //clean t3-assets folder, the cache for js/css
         $templates = T3Common::get_active_templates();
         //T3Common::log(var_export($templates, true));
         foreach ($templates as $template) {
             $file = T3Path::path("templates/{$template}") . DS . 'params.ini';
             if (is_file($file)) {
                 $content = file_get_contents($file);
                 $params = new JParameter($content);
                 $cache_path = $params->get('optimize_folder', 't3-assets');
                 $path = T3Path::path($cache_path);
                 //T3Common::log($path);
                 if (is_dir($path)) {
                     @JFolder::delete($path);
                 }
             }
         }
     }
 }
예제 #9
0
 /**
  * Get gfont path
  *
  * @param string $template  Template name
  * @param string $filename  Filename include extension
  * @param bool   $local     Indicate get local path or not
  *
  * @return mixed  Gfont file path if found, otherwise FALSE
  */
 function getFontPath($template, $filename = 'gfonts.dat', $local = false)
 {
     // Check to sure that template is using new folder structure
     // If etc folder exists, considered as template is using new folder structure
     $filepath = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'etc';
     if (@is_dir($filepath)) {
         $filepath .= DS . $filename;
     } else {
         // Template still use old folder structure
         $filepath = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'local' . DS . 'etc' . DS . $filename;
     }
     // Check file exists or not
     if (@is_file($filepath) || $local) {
         return $filepath;
     }
     // Check file in base-themes
     $filepath = T3Path::path(T3_BASETHEME) . DS . 'etc' . DS . $filename;
     if (@is_file($filepath)) {
         return $filepath;
     }
     // Can not find google font file
     return false;
 }
예제 #10
0
 function get_template_params()
 {
     static $params = null;
     if (!isset($params)) {
         $key = T3Cache::getProfileKey();
         $data = T3Cache::get_file($key);
         if ($data) {
             $params = new JParameter($data);
             return $params;
         }
         $profile = T3Common::get_active_profile();
         //Load global params
         $content = '';
         $file = T3Path::path(T3_TEMPLATE) . DS . 'params.ini';
         if (is_file($file)) {
             $content = file_get_contents($file);
         }
         //Load default profile setting
         $path = 'etc' . DS . 'profiles' . DS . 'default.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 .= "\n" . file_get_contents($file);
         }
         //Load all-pages profile setting
         $default_profile = T3Common::get_default_profile();
         if ($default_profile != 'default') {
             $path = 'etc' . DS . 'profiles' . DS . $default_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 .= "\n" . file_get_contents($file);
             }
         }
         //Load override profile setting
         if ($profile != $default_profile && $profile != 'default') {
             $path = 'etc' . DS . 'profiles' . DS . $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 .= "\n" . file_get_contents($file);
             }
         }
         $params = new JParameter($content);
         T3Cache::store_file($params->toString(), $key);
     }
     return $params;
 }
예제 #11
0
 /**
  * Load menu
  *
  * @param $menutype string
  *            Menu type name
  *
  * @return object Menu object
  */
 function loadMenu($menutype = null)
 {
     static $jamenu = null;
     if (!isset($jamenu)) {
         // Init menu
         // Main navigation
         $ja_menutype = $this->getMenuType($menutype);
         if ($ja_menutype && $ja_menutype != 'none') {
             //$japarams = new JParameter('');
             // Strict standards: Declaration of JParameter::loadSetupFile() should be compatible with that of JRegistry::loadSetupFile()
             $japarams = new JRegistry('');
             $japarams->set('menutype', $this->getParam('menutype', 'mainmenu'));
             $japarams->set('menu_images_align', 'left');
             $japarams->set('menu_images', 1);
             // 0: not show image, 1: show
             // image which set in menu
             // item
             $japarams->set('menu_background', 1);
             // 0: image, 1: background
             $japarams->set('mega-colwidth', 200);
             // Megamenu only: Default
             // column width
             $japarams->set('mega-style', 1);
             // Megamenu only: Menu style.
             $japarams->set('startlevel', $this->getParam('startlevel', 0));
             // Startlevel
             $japarams->set('endlevel', $this->getParam('endlevel', 0));
             // endlevel
             // $jamenu = $this->loadMenu($japarams, $ja_menutype);
         }
         // End for main navigation
         $file = T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$ja_menutype}.class.php";
         if (!is_file($file)) {
             return null;
         }
         include_once $file;
         $menuclass = "JAMenu{$ja_menutype}";
         $jamenu = new $menuclass($japarams);
         // assign template object
         $jamenu->_tmpl = $this;
         // load menu
         $jamenu->loadMenu();
         // check css/js file
         $this->addStylesheet(T3_TEMPLATE . "/css/menu/{$ja_menutype}.css");
         $this->addScript(T3_TEMPLATE . "/js/menu/{$ja_menutype}.js", true);
         $this->addCSS("/css/menu/{$ja_menutype}-ie.css", null, 'ie');
     }
     return $jamenu;
 }
예제 #12
0
    /**
     * Popup prepare content method
     *
     * @param 	string		The body string content.
     */
    function replaceContent($bodyContent)
    {
        // Build HTML params area
        $xmlFile = T3Path::path(T3_CORE) . DS . 'params' . DS . "params.xml";
        if (!file_exists($xmlFile)) {
            return $bodyContent;
        }
        $str = "";
        $xmlFile = JFile::read($xmlFile);
        preg_match_all("/<params([^>]*)>([\\s\\S]*?)<\\/params>/i", $xmlFile, $matches);
        foreach ($matches[0] as $v) {
            $v = preg_replace("/group=\"([\\s\\S]*?)\"/i", '', $v);
            $xmlstring = '<?xml version="1.0" encoding="utf-8"?>
							<metadata>
								<state>
									<name>Component</name>
									<description>Component Parameters</description>';
            $xmlstring .= $v;
            $xmlstring .= '</state>
							</metadata>';
            preg_match_all("/label=\"([\\s\\S]*?)\"/i", $v, $arr);
            $str .= '<div class="panel">
				<h3 id="mega-params-options" class="jpane-toggler title">
				<span>' . $arr[1][0] . '</span></h3>
				<div class="jpane-slider content" style="border-top: medium none; border-bottom: medium none; overflow: hidden; padding-top: 0px; padding-bottom: 0px;">
				' . $this->getSystemParams($xmlstring) . "</div></div>";
        }
        preg_match_all("/<div class=\"panel\">([\\s\\S]*?)<\\/div>/i", $bodyContent, $arr);
        $bodyContent = str_replace($arr[0][count($arr[0]) - 1] . '</div>', $arr[0][count($arr[0]) - 1] . '</div>' . $str, $bodyContent);
        return $bodyContent;
    }
예제 #13
0
 function clean($t3assets = false)
 {
     //clear T3 cache in cache folder
     $t3cache = T3Cache::getInstance();
     if (!$t3cache) {
         return false;
     }
     if ($t3assets > 0) {
         //clean content cache
         $cache = $t3cache->cache;
         $cache->clean();
     }
     //Clear css/js cached in t3-assets
     if ($t3assets > 1) {
         //Clear assets folder in cache
         $path = $t3cache->cache_assets_path();
         if (is_dir($path)) {
             @JFolder::delete($path);
         }
     }
     if ($t3assets > 2) {
         //clean t3-assets folder, the cache for js/css
         $params = T3Common::get_template_based_params();
         $cache_path = $params->get('optimize_folder', 't3-assets');
         $path = T3Path::path($cache_path);
         if (is_dir($path)) {
             @JFolder::delete($path);
         }
     }
 }
예제 #14
0
<?php 
if ($this->getParam('infomode', 1) == 1 && JRequest::getCmd('t3info')) {
    ?>
    <script type="text/javascript">
    var jalayout=<?php 
    echo json_encode($this->getLayoutXML());
    ?>
;
    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')) {
            ?>
예제 #15
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();
     }
 }
예제 #16
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;
 }
예제 #17
0
 /**
  * Clean T3 cache
  * If $t3assets > 0,  deleted all cached content in defaultgroup
  * If $t3assets > 1,  deleted all cached content in assets group
  * If $t3assets > 2, deleted all cached content in css/js optimize folder
  *
  * @param int $t3assets    Level cache
  *
  * @return void
  */
 private function _clean($t3assets = 0)
 {
     $cache = $this->cache;
     // Clear cache in default group folder
     if ($t3assets > 0) {
         $cache->clean();
     }
     // Clear cache in assets folder
     if ($t3assets > 1) {
         $cache->clean(self::T3_CACHE_ASSETS);
     }
     if ($t3assets > 2) {
         //clean t3-assets folder, the cache for js/css
         $templates = T3Common::get_active_templates();
         //T3Common::log(var_export($templates, true));
         foreach ($templates as $template) {
             $file = T3Path::path("templates/{$template}") . DS . 'params.ini';
             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);
                 }
                 $cache_path = $params->get('optimize_folder', 't3-assets');
                 $path = T3Path::path($cache_path);
                 //T3Common::log($path);
                 if (is_dir($path)) {
                     @JFolder::delete($path);
                 }
             }
         }
     }
 }
예제 #18
0
 function loadMenu($menutype = null)
 {
     static $jamenu = null;
     if (!isset($jamenu)) {
         //Init menu
         //Main navigation
         $ja_menutype = $this->getMenuType($menutype);
         if ($ja_menutype && $ja_menutype != 'none') {
             $japarams = new JParameter('');
             $japarams->set('menutype', $this->getParam('menutype', 'mainmenu'));
             $japarams->set('menu_images_align', 'left');
             $japarams->set('menu_images', 1);
             //0: not show image, 1: show image which set in menu item
             $japarams->set('menu_background', 1);
             //0: image, 1: background
             $japarams->set('mega-colwidth', 200);
             //Megamenu only: Default column width
             $japarams->set('mega-style', 1);
             //Megamenu only: Menu style.
             //$jamenu = $this->loadMenu($japarams, $ja_menutype);
         }
         //End for main navigation
         $file = T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$ja_menutype}.class.php";
         if (!is_file($file)) {
             return null;
         }
         require_once $file;
         $menuclass = "JAMenu{$ja_menutype}";
         $jamenu = new $menuclass($japarams);
         //assign template object
         $jamenu->_tmpl = $this;
         //load menu
         $jamenu->loadMenu();
         //check css/js file
         $this->addStylesheet(T3_TEMPLATE . "/css/menu/{$ja_menutype}.css");
         $this->addScript(T3_TEMPLATE . "/js/menu/{$ja_menutype}.js", true);
     }
     return $jamenu;
 }