示例#1
0
 /**
  * Get list of theme name
  *
  * @return array
  */
 public static function get_active_themes()
 {
     static $_themes = null;
     if (!isset($_themes)) {
         $_themes = array();
         $themes = T3Parameter::_getParam('themes');
         // Active themes
         $themes = preg_split('/,/', $themes);
         for ($i = 0; $i < count($themes); $i++) {
             $themes[$i] = trim($themes[$i]);
             $theme = array();
             if (preg_match('/^(local)\\.(.*)$/', $themes[$i], $matches)) {
                 $theme[0] = $matches[1];
                 $theme[1] = $matches[2];
                 //$themes[$i] = array('local', $matches[1]);
             } elseif (preg_match('/^(core)\\.(.*)$/', $themes[$i], $matches)) {
                 $theme[0] = $matches[1];
                 $theme[1] = $matches[2];
                 //$themes[$i] = array('core', $matches[1]);
             } else {
                 $theme[0] = 'core';
                 $theme[1] = $themes[$i];
                 //$themes[$i] = array('core', $themes[$i]);
             }
             $path = self::getThemePath($theme[1], $theme[0] == 'local');
             if ($theme[1] && is_dir($path)) {
                 $_themes[] = $theme;
             }
         }
         //if (T3Common::isRTL()) $_themes[] = array('core', 'default-rtl');
         $_themes[] = array('template', 'default');
         //if (T3Common::isRTL()) $_themes[] = array('engine', 'default-rtl');
         $_themes[] = array('engine', 'default');
         //if isRTL, and -rtl theme exists then add this theme automatically, before add the current theme to active list
         if (T3Common::isRTL()) {
             $_themesrtl = array();
             foreach ($_themes as $theme) {
                 $themertl = array();
                 $themertl[0] = $theme[0] == 'template' ? 'core' : $theme[0];
                 $themertl[1] = $theme[1] . '-rtl';
                 //$path = T3Path::path(T3_TEMPLATE) . DS . $themertl[0] . DS . 'themes' . DS . $themertl[1];
                 $path = self::getThemePath($themertl[1], $themertl[0] == 'local');
                 if ($themertl[0] == 'engine' || is_dir($path)) {
                     $_themesrtl[] = $themertl;
                 }
             }
             $_themes = array_merge($_themesrtl, $_themes);
         }
     }
     return $_themes;
 }
示例#2
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();
     }
 }
示例#3
0
 /**
  * Execute css/js optimizing base on joomla document object
  *
  * @return void
  */
 public static function proccess()
 {
     $document = JFactory::getDocument();
     $urlPath = new T3Path();
     //proccess stylesheets
     $themes = T3Common::get_active_themes();
     //$themes[] = array('core', 'default'); //default now move to template root folder
     //$themes[] = array('engine', 'default');
     $themes = array_reverse($themes);
     $scripts = array();
     $css_urls = array();
     $css_urls['site'] = array();
     foreach ($themes as $theme) {
         $css_urls[$theme[0] . '.' . $theme[1]] = array();
     }
     foreach ($themes as $theme) {
         $css_urls[$theme[0] . '.' . $theme[1] . '-browser'] = array();
     }
     if (T3Common::isRTL()) {
         foreach ($themes as $theme) {
             $css_urls[$theme[0] . '.' . $theme[1] . '-rtl'] = array();
         }
     }
     //$bname = T3Common::getBrowserSortName();
     //$bver = T3Common::getBrowserMajorVersion();
     $optimize_css = T3Parameter::_getParam('optimize_css', 2);
     $optimize_js = T3Parameter::_getParam('optimize_js', 2);
     foreach ($document->_styleSheets as $strSrc => $strAttr) {
         $path = T3Head::cleanUrl($strSrc);
         if (!$path || !preg_match('#\\.css$#', $path)) {
             //External url
             $css_urls['site'][] = array('', $strSrc);
             continue;
         }
         $intemplate = false;
         if (preg_match('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', $path)) {
             $path = preg_replace('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', '', $path);
             $intemplate = true;
         }
         $paths = array();
         //$paths[] = array ('', $path, $strSrc); //The third element is the original url
         $paths[] = array('', $path);
         // Fix when source code in subfolder
         //if ($intemplate) {
         //only load other css files if in T3v2 template
         $ext = '';
         if (preg_match('#\\.[^.]+$#', $path, $matches)) {
             $ext = $matches[0];
         }
         //if ($ext) {
         //$paths[] = array('-browser', str_replace($ext, "-$bname$ext", $path));
         //$paths[] = array('-browser', str_replace($ext, "-$bname$bver$ext", $path));
         //if (T3Common::isRTL()) {
         //$paths[] = array('-rtl', str_replace($ext, "-rtl$ext", $path));
         //$paths[] = array('-rtl', str_replace($ext, "-$bname-rtl$ext", $path));
         //$paths[] = array('-rtl', str_replace($ext, "-$bname$bver-rtl$ext", $path));
         //}
         //}
         if ($ext && T3Common::isRTL()) {
             $paths[] = array('-rtl', str_replace($ext, "-rtl{$ext}", $path));
         }
         //}
         foreach ($paths as $path) {
             //
             if ($intemplate) {
                 $urls = $urlPath->get($path[1], true);
                 if ($urls) {
                     foreach ($urls as $theme => $url) {
                         $url[] = $strAttr;
                         $css_urls[$theme . $path[0]][$url[0]] = $url;
                     }
                 }
             } else {
                 if (is_file(T3Path::path($path[1]))) {
                     $css_urls['site'][T3Path::path($path[1])] = array(T3Path::path($path[1]), count($path) > 2 ? $path[2] : T3Path::url($path[1]), $strAttr);
                     //use original url ($path[2]) if exists
                 }
             }
         }
     }
     // Remove current stylesheets
     $document->_styleSheets = array();
     foreach ($document->_scripts as $strSrc => $strType) {
         $srcurl = T3Head::cleanUrl($strSrc);
         if (!$srcurl || !preg_match('#\\.js$#', $srcurl)) {
             $scrips[] = array('', $strSrc);
             continue;
         }
         if (preg_match('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', $srcurl)) {
             //in template
             $srcurl = preg_replace('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', '', $srcurl);
             $path = str_replace('/', DS, $srcurl);
             $url = $urlPath->get($path);
             if ($url) {
                 $scrips[] = $url;
             }
         } else {
             // Don't read file content => keep original link
             if ($optimize_js < 1) {
                 $scrips[] = array('', $strSrc);
                 continue;
             }
             $path = str_replace('/', DS, $srcurl);
             $scrips[] = array(JPATH_SITE . DS . $path, JURI::base(true) . '/' . $srcurl);
         }
     }
     //remove current scripts
     $document->_scripts = array();
     $tmp_css_urls = false;
     do {
         $tmp_css_urls = T3Head::optimizecss($css_urls);
     } while ($tmp_css_urls === false);
     $css_urls = $tmp_css_urls;
     //if ($url) $css_urls = array(array(array('', $url)));
     //re-add stylesheet to head
     foreach ($css_urls as $urls) {
         foreach ($urls as $url) {
             if (count($url) > 2) {
                 $attrs = $url[2];
                 $document->addStylesheet($url[1], $attrs['mime'], $attrs['media'], $attrs['attribs']);
             } else {
                 $document->addStylesheet($url[1]);
             }
         }
     }
     $tmp_scrips = false;
     do {
         $tmp_scrips = T3Head::optimizejs($scrips);
     } while ($tmp_scrips === false);
     $scrips = $tmp_scrips;
     //re-add stylesheet to head
     foreach ($scrips as $url) {
         $document->addScript($url[1]);
     }
 }
示例#4
0
 /**
  * Render conditional css link
  *
  * @param array $cond_css
  *   Conditional css list that each element contain 2 sub-elements:
  *   - URL link
  *   - Attributes of css link, it is associate array with 3 keys
  *     + mine:  link type attribute
  *     + media: link media attibute
  *     + attribs: other attributes
  *
  * @return string
  */
 function renderConditionalCSS($condCss)
 {
     $data = "\n";
     $urlPath = new T3Path();
     foreach ($condCss as $css) {
         // Get url path & link attributes
         $url = preg_replace('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', '', $css['url']);
         $paths = $urlPath->get($url, true);
         if ($paths) {
             $media = $css['media'];
             $cond = $css['condition'];
             $type = $css['type'];
             // Generate links
             $paths = array_reverse($paths);
             foreach ($paths as $path) {
                 $data .= "<!--[if {$cond}]><link href=\"{$path[1]}\" type=\"{$type}\" rel=\"stylesheet\" ";
                 if (!empty($media)) {
                     $data .= "media=\"{$media}\" ";
                 }
                 $data .= "/><![endif]--> \n";
                 // Check and add rtl file
                 $rtl_path = str_replace('.css', '-rtl.css', $path[0]);
                 if (T3Common::isRTL() && is_file($rtl_path)) {
                     $rtl_path = str_replace('.css', '-rtl.css', $path[1]);
                     $data .= "<!--[if {$cond}]><link href=\"{$rtl_path}\" type=\"{$type}\" rel=\"stylesheet\" ";
                     if (!empty($media)) {
                         $data .= "media=\"{$media}\" ";
                     }
                     $data .= "/><![endif]--> \n";
                 }
             }
         }
     }
     return $data;
 }
示例#5
0
 function proccess()
 {
     $document =& JFactory::getDocument();
     //proccess stylesheets
     $themes = T3Common::get_active_themes();
     //$themes[] = array('core', 'default'); //default now move to template root folder
     //$themes[] = array('engine', 'default');
     $themes = array_reverse($themes);
     $scripts = array();
     $css_urls = array();
     $css_urls['site'] = array();
     foreach ($themes as $theme) {
         $css_urls[$theme[0] . '.' . $theme[1]] = array();
     }
     foreach ($themes as $theme) {
         $css_urls[$theme[0] . '.' . $theme[1] . '-browser'] = array();
     }
     if (T3Common::isRTL()) {
         foreach ($themes as $theme) {
             $css_urls[$theme[0] . '.' . $theme[1] . '-rtl'] = array();
         }
     }
     $bname = T3Common::getBrowserSortName();
     $bver = T3Common::getBrowserMajorVersion();
     $optimize_css = T3Parameter::get('optimize_css', 2);
     $optimize_js = T3Parameter::get('optimize_js', 2);
     foreach ($document->_styleSheets as $strSrc => $strAttr) {
         $path = T3Head::cleanUrl($strSrc);
         if (!$path) {
             //External url
             $css_urls['site'][] = array('', $strSrc);
             continue;
         }
         $intemplate = false;
         if (preg_match('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', $path)) {
             $path = preg_replace('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', '', $path);
             $intemplate = true;
         }
         /*
         if (!$intemplate && $optimize_css < 2) // don't read file content => keep original link
         {
         	$css_urls['site'][] = array ('', $strSrc);
         	continue;
         }
         */
         $paths = array();
         $paths[] = array('', $path, $strSrc);
         //The third element is the original url
         //if ($intemplate) {
         //only load other css files if in T3v2 template
         $ext = '';
         if (preg_match('#\\.[^.]+$#', $path, $matches)) {
             $ext = $matches[0];
         }
         //$file_info = pathinfo($path);
         //$ext = $file_info['extension'];
         if ($ext) {
             $paths[] = array('-browser', str_replace($ext, "-{$bname}{$ext}", $path));
             $paths[] = array('-browser', str_replace($ext, "-{$bname}{$bver}{$ext}", $path));
             if (T3Common::isRTL()) {
                 $paths[] = array('-rtl', str_replace($ext, "-rtl{$ext}", $path));
                 $paths[] = array('-rtl', str_replace($ext, "-{$bname}-rtl{$ext}", $path));
                 $paths[] = array('-rtl', str_replace($ext, "-{$bname}{$bver}-rtl{$ext}", $path));
             }
         }
         //}
         foreach ($paths as $path) {
             //
             if ($intemplate) {
                 if ($urls = T3Path::get($path[1], true)) {
                     foreach ($urls as $theme => $url) {
                         $css_urls[$theme . $path[0]][$url[0]] = $url;
                     }
                 }
             } else {
                 if (is_file(T3Path::path($path[1]))) {
                     $css_urls['site'][T3Path::path($path[1])] = array(T3Path::path($path[1]), count($path) > 2 ? $path[2] : T3Path::url($path[1]));
                 }
                 //use original url ($path[2]) if exists
             }
         }
     }
     //remove current stylesheets
     $document->_styleSheets = array();
     foreach ($document->_scripts as $strSrc => $strType) {
         $srcurl = T3Head::cleanUrl($strSrc);
         if (!$srcurl) {
             $scrips[] = array('', $strSrc);
             continue;
         }
         if (preg_match('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', $srcurl)) {
             //in template
             $srcurl = preg_replace('/^templates\\/' . T3_ACTIVE_TEMPLATE . '\\//', '', $srcurl);
             $path = str_replace('/', DS, $srcurl);
             if ($url = T3Path::get($path)) {
                 $scrips[] = $url;
             }
         } else {
             if ($optimize_js < 1) {
                 $scrips[] = array('', $strSrc);
                 continue;
             }
             $path = str_replace('/', DS, $srcurl);
             $scrips[] = array(JPATH_SITE . DS . $path, JURI::base(true) . '/' . $srcurl);
         }
     }
     //remove current scripts
     $document->_scripts = array();
     $css_urls = T3Head::optimizecss($css_urls);
     //if ($url) $css_urls = array(array(array('', $url)));
     //re-add stylesheet to head
     foreach ($css_urls as $urls) {
         foreach ($urls as $url) {
             $document->addStylesheet($url[1]);
         }
     }
     $scrips = T3Head::optimizejs($scrips);
     //re-add stylesheet to head
     foreach ($scrips as $url) {
         $document->addScript($url[1]);
     }
 }
示例#6
0
if ((int) $showItem > $total_items) {
    $showItem = $total_items;
}
if ($total_items && (int) $startItem >= $total_items) {
    $startItem = (int) $total_items - 1;
}
//Fix error show limitted items
$folder = null;
$target = 'target="_' . $params->get('open_target', 'parent') . '"';
$app = JFactory::getApplication();
$template_name = $app->getTemplate();
$jdoc = JFactory::getDocument();
$direction = "";
if ($t3_exists) {
    $t = T3Common::isRTL();
    $direction = T3Common::isRTL() ? "rtl" : "ltr";
} else {
    $direction = $jdoc->getDirection();
}
if ($source == 'images' && !empty($list)) {
    $images = $list['mainImageArray'];
    $titles = isset($list['title']) ? $list['title'] : array();
    $captionsArray = $list['captionsArray'];
    $urls = $list['urls'];
    $targets = $list['targets'];
    $thumbArray = $list['thumbArray'];
    require JModuleHelper::getLayoutPath($module->module, 'default');
    unset($list);
    ?>
<script type="text/javascript">
	var Ja_direction = '';