Esempio n. 1
0
 /**
  * Render megamenu block
  *
  * @param   string  $position  The position of the modules to render
  * @param   array   $params    Associative array of values
  * @param   string  $content   Module content
  *
  * @return  string  The output of the script
  *
  * @since   11.1
  */
 public function render($info = null, $params = array(), $content = null)
 {
     T3::import('menu/t3bootstrap');
     // import the renderer
     $t3app = T3::getApp();
     $menutype = empty($params['menutype']) ? $t3app->getParam('mm_type', 'mainmenu') : $params['menutype'];
     JDispatcher::getInstance()->trigger('onT3BSMenu', array(&$menutype));
     $menu = new T3Bootstrap($menutype);
     return $menu->render(true);
 }
Esempio n. 2
0
 public static function display()
 {
     T3::import('menu/megamenu');
     $input = JFactory::getApplication()->input;
     //params
     $tplparams = T3::getTplParams();
     //menu type
     $menutype = $input->get('t3menu', 'mainmenu');
     //accessLevel
     $t3acl = (int) $input->get('t3acl', 1);
     $accessLevel = array(1, $t3acl);
     if (in_array(3, $accessLevel)) {
         $accessLevel[] = 2;
     }
     $accessLevel = array_unique($accessLevel);
     sort($accessLevel);
     //languages
     $languages = array(trim($input->get('t3lang', '*')));
     if ($languages[0] != '*') {
         $languages[] = '*';
     }
     //check config
     $currentconfig = $tplparams instanceof JRegistry ? json_decode($tplparams->get('mm_config', ''), true) : null;
     $mmkey = $menutype . ($t3acl == 1 ? '' : '-' . $t3acl);
     $mmconfig = array();
     if ($currentconfig) {
         for ($i = $t3acl; $i >= 1; $i--) {
             $tmmkey = $menutype . ($i == 1 ? '' : '-' . $i);
             if (isset($currentconfig[$tmmkey])) {
                 $mmconfig = $currentconfig[$tmmkey];
                 break;
             }
         }
     }
     if (!is_array($mmconfig)) {
         $mmconfig = array();
     }
     $mmconfig['editmode'] = true;
     $mmconfig['access'] = $accessLevel;
     $mmconfig['language'] = $languages;
     //build the menu
     $menu = new T3MenuMegamenu($menutype, $mmconfig);
     $buffer = $menu->render(true);
     // replace image path
     $base = JURI::base(true) . '/';
     $protocols = '[a-zA-Z0-9]+:';
     //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
     $regex = '#(src)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
     $buffer = preg_replace($regex, "\$1=\"{$base}\$2\"", $buffer);
     //remove invisibile content
     $buffer = preg_replace(array('@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu'), array('', ''), $buffer);
     //output the megamenu key to save
     echo $buffer . '<input id="megamenu-key" type="hidden" name="mmkey" value="' . $mmkey . '"/>';
 }
Esempio n. 3
0
 function onBeforeRender()
 {
     if (T3::detect()) {
         $japp = JFactory::getApplication();
         if ($japp->isAdmin()) {
             $t3app = T3::getApp();
             $t3app->addAssets();
         } else {
             $params = $japp->getTemplate(true)->params;
             if (defined('T3_THEMER') && $params->get('themermode', 1)) {
                 T3::import('admin/theme');
                 T3AdminTheme::addAssets();
             }
             //check for ajax action and render t3ajax type to before head type
             if (class_exists('T3Ajax')) {
                 T3Ajax::render();
             }
         }
     }
 }
Esempio n. 4
0
 public static function display()
 {
     T3::import('menu/megamenu');
     $input = JFactory::getApplication()->input;
     $menutype = $input->get('t3menu', 'mainmenu');
     $tplparams = $input->get('tplparams', '', 'raw');
     $currentconfig = $tplparams instanceof JRegistry ? json_decode($tplparams->get('mm_config', ''), true) : null;
     $mmconfig = $currentconfig && isset($currentconfig[$menutype]) ? $currentconfig[$menutype] : array();
     $mmconfig['editmode'] = true;
     $menu = new T3MenuMegamenu($menutype, $mmconfig);
     $buffer = $menu->render(true);
     // replace image path
     $base = JURI::base(true) . '/';
     $protocols = '[a-zA-Z0-9]+:';
     //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
     $regex = '#(src)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
     $buffer = preg_replace($regex, "\$1=\"{$base}\$2\"", $buffer);
     //remove invisibile content
     $buffer = preg_replace(array('@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu'), array('', ''), $buffer);
     echo $buffer;
 }
Esempio n. 5
0
<?php

/** 
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github 
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org 
 *------------------------------------------------------------------------------
 */
if (!class_exists('T3MenuMegamenuTpl', false)) {
    T3::import('menu/megamenu.tpl');
}
if (is_file(T3_TEMPLATE_PATH . '/html/megamenu.php')) {
    require_once T3_TEMPLATE_PATH . '/html/megamenu.php';
}
class T3MenuMegamenu
{
    /**
     * Internal variables
     */
    protected $_items = array();
    protected $children = array();
    protected $settings = null;
    protected $params = null;
    protected $menu = '';
    protected $active_id = 0;
Esempio n. 6
0
 /**
  * @param $js
  * @return string
  */
 public static function minifyJs($js)
 {
     T3::import('minify/' . self::$jstool);
     return call_user_func_array(array(self::$jstools[self::$jstool], 'minify'), array($js));
 }
Esempio n. 7
0
File: t3.php Progetto: lazarch/t3
 /**
  * Implement event onGetLayoutPath to return the layout which override by T3 & T3 templates
  * This event is fired by overriding ModuleHelper class
  * Return path to layout if found, false if not
  *
  * @param   string $module  The name of the module
  * @param   string $layout  The name of the module layout. If alternative
  *                           layout, in the form template:filename.
  *
  * @return  null
  */
 function onGetLayoutPath($module, $layout)
 {
     // Detect layout path in T3 themes
     if (defined('T3_PLUGIN') && T3::detect()) {
         T3::import('core/path');
         $tPath = T3Path::getPath('html/' . $module . '/' . $layout . '.php');
         if ($tPath) {
             return $tPath;
         }
     }
     return false;
 }
Esempio n. 8
0
 /**
  *
  * Show thememagic form
  */
 public static function thememagic($path)
 {
     $app = JFactory::getApplication();
     $isadmin = $app->isAdmin();
     $url = $isadmin ? JUri::root(true) . '/index.php' : JUri::current();
     $url .= (preg_match('/\\?/', $url) ? '&' : '?') . 'themer=1';
     // show thememagic form
     //todo: Need to optimize here
     $tplparams = JFactory::getApplication('site')->getTemplate(true)->params;
     $assetspath = T3_TEMPLATE_PATH;
     $themepath = $assetspath . '/less/themes';
     if (!class_exists('JRegistryFormatLESS')) {
         include_once T3_ADMIN_PATH . '/includes/format/less.php';
     }
     $themes = array();
     $jsondata = array();
     //push a default theme
     $tobj = new stdClass();
     $tobj->id = 'base';
     $tobj->title = JText::_('JDEFAULT');
     $themes['base'] = $tobj;
     $varfile = $assetspath . '/less/variables.less';
     if (file_exists($varfile)) {
         $params = new JRegistry();
         $params->loadString(JFile::read($varfile), 'LESS');
         $jsondata['base'] = $params->toArray();
     }
     if (JFolder::exists($themepath)) {
         $listthemes = JFolder::folders($themepath);
         if (count($listthemes)) {
             foreach ($listthemes as $theme) {
                 $varsfile = $themepath . '/' . $theme . '/variables-custom.less';
                 if (file_exists($varsfile)) {
                     $tobj = new stdClass();
                     $tobj->id = $theme;
                     $tobj->title = $theme;
                     //check for all less file in theme folder
                     $params = false;
                     $others = JFolder::files($themepath . '/' . $theme, '.less');
                     foreach ($others as $other) {
                         //get those developer custom values
                         if ($other == 'variables.less') {
                             $params = new JRegistry();
                             $params->loadString(JFile::read($themepath . '/' . $theme . '/variables.less'), 'LESS');
                         }
                         if ($other != 'variables-custom.less') {
                             $tobj->{$other} = true;
                             //JFile::read($themepath . '/' . $theme . '/' . $other);
                         }
                     }
                     $cparams = new JRegistry();
                     $cparams->loadString(JFile::read($varsfile), 'LESS');
                     if ($params) {
                         foreach ($cparams->toArray() as $key => $value) {
                             $params->set($key, $value);
                         }
                     } else {
                         $params = $cparams;
                     }
                     $themes[$theme] = $tobj;
                     $jsondata[$theme] = $params->toArray();
                 }
             }
         }
     }
     $langs = array('addTheme' => JText::_('T3_TM_ASK_ADD_THEME'), 'delTheme' => JText::_('T3_TM_ASK_DEL_THEME'), 'overwriteTheme' => JText::_('T3_TM_ASK_OVERWRITE_THEME'), 'correctName' => JText::_('T3_TM_ASK_CORRECT_NAME'), 'themeExist' => JText::_('T3_TM_EXISTED'), 'saveChange' => JText::_('T3_TM_ASK_SAVE_CHANGED'), 'previewError' => JText::_('T3_TM_PREVIEW_ERROR'), 'unknownError' => JText::_('T3_MSG_UNKNOWN_ERROR'), 'lblCancel' => JText::_('JCANCEL'), 'lblOk' => JText::_('T3_TM_LABEL_OK'), 'lblNo' => JText::_('JNO'), 'lblYes' => JText::_('JYES'), 'lblDefault' => JText::_('JDEFAULT'));
     //Keepalive
     $config = JFactory::getConfig();
     $lifetime = $config->get('lifetime') * 60000;
     $refreshTime = $lifetime <= 60000 ? 30000 : $lifetime - 60000;
     // Refresh time is 1 minute less than the liftime assined in the configuration.php file.
     // The longest refresh period is one hour to prevent integer overflow.
     if ($refreshTime > 3600000 || $refreshTime <= 0) {
         $refreshTime = 3600000;
     }
     $backurl = JFactory::getURI();
     $backurl->delVar('t3action');
     $backurl->delVar('t3task');
     if (!$isadmin) {
         $backurl->delVar('tm');
         $backurl->delVar('themer');
     }
     T3::import('depend/t3form');
     $form = new T3Form('thememagic.themer', array('control' => 't3form'));
     $form->load(JFile::read(JFile::exists(T3_TEMPLATE_PATH . '/thememagic.xml') ? T3_TEMPLATE_PATH . '/thememagic.xml' : T3_PATH . '/params/thememagic.xml'));
     $form->loadFile(T3_TEMPLATE_PATH . '/templateDetails.xml', true, '//config');
     $tplform = new T3Form('thememagic.overwrite', array('control' => 't3form'));
     $tplform->loadFile(T3_TEMPLATE_PATH . '/templateDetails.xml', true, '//config');
     $fieldSets = $form->getFieldsets('thememagic');
     $tplFieldSets = $tplform->getFieldsets('thememagic');
     $disabledFieldSets = array();
     foreach ($tplFieldSets as $name => $fieldSet) {
         if (isset($fieldSet->disabled)) {
             $disabledFieldSets[] = $name;
         }
     }
     include T3_ADMIN_PATH . '/admin/thememagic/thememagic.tpl.php';
     exit;
 }
Esempio n. 9
0
<?php

/** 
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github 
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org 
 *------------------------------------------------------------------------------
 */
// No direct access
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
T3::import('core/path');
T3::import('lessphp/' . T3_BASE_LESS_COMPILER);
Esempio n. 10
0
 /**
  * Special compilation for template.css file when development mode is on
  * @param $path
  * @return bool
  */
 public static function divide($path)
 {
     //check system
     self::requirement();
     $parser = new Less_Parser();
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $tpl = T3_TEMPLATE;
     $theme = $app->getTemplate(true)->params->get('theme');
     $is_rtl = $doc->direction == 'rtl' && strpos($path, 'rtl/') === false;
     $subdir = ($is_rtl ? 'rtl/' : '') . ($theme ? $theme . '/' : '');
     $topath = T3_DEV_FOLDER . '/' . $subdir;
     $tofile = null;
     $root = JUri::root(true);
     //pattern
     $rimport = '@^\\s*\\@import\\s+"([^"]*)"\\s*;@im';
     $rvarscheck = '@(base|base-bs3|bootstrap|' . preg_quote($tpl) . ')/less/(vars|variables|mixins)\\.less@';
     $rexcludepath = '@(base|base-bs3|bootstrap|' . preg_quote($tpl) . ')/less/@';
     $rimportvars = '@^\\s*\\@import\\s+".*(variables-custom|variables|vars|mixins)\\.less"\\s*;@im';
     $rsplitbegin = '@^\\s*\\#';
     $rsplitend = '[^\\s]*?\\s*{\\s*[\\r\\n]*\\s*content:\\s*"([^"]*)";\\s*[\\r\\n]*\\s*}@im';
     $rswitchrtl = '@/less/(themes/[^/]*/)?@';
     $kfilepath = 'less-file-path';
     $kvarsep = 'less-content-separator';
     $krtlsep = 'rtl-less-content';
     if ($topath) {
         if (!is_dir(JPATH_ROOT . '/' . $topath)) {
             JFolder::create(JPATH_ROOT . '/' . $topath);
         }
     }
     // check path
     $realpath = realpath(JPATH_ROOT . '/' . $path);
     if (!is_file($realpath)) {
         return;
     }
     // get file content
     $content = JFile::read($realpath);
     //remove vars.less
     if (preg_match($rexcludepath, $path)) {
         $content = preg_replace($rimportvars, '', $content);
     }
     // check and add theme less if not is theme less
     if ($theme && strpos($path, 'themes/') === false) {
         $themepath = 'themes/' . $theme . '/' . basename($path);
         if (is_file(T3_TEMPLATE_PATH . '/less/' . $themepath)) {
             $content = $content . "\n@import \"{$themepath}\"; \n\n";
         }
     }
     // split into array, separated by the import
     $split_contents = preg_split($rimport, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
     //check if we need to rebuild
     $rebuild = false;
     $vars_lm = $app->getUserState('vars_last_modified', 0);
     $file_lm = @filemtime(JPATH_ROOT . '/' . $path);
     //check for this file and rtl
     $cssfile = $topath . str_replace('/', '.', $path) . '.css';
     $css_lm = is_file(JPATH_ROOT . '/' . $cssfile) ? @filemtime(JPATH_ROOT . '/' . $cssfile) : -1;
     //rebuild?
     if ($css_lm < $vars_lm || $css_lm < $file_lm) {
         $rebuild = true;
     } else {
         $doc->addStylesheet($root . '/' . $cssfile);
     }
     //check for rebuild if this rtl overwrite file has just modified
     if (!$rebuild && $is_rtl) {
         $rtl_url = preg_replace('@/less/(themes/)?@', '/less/rtl/', $path);
         $rtl_lm = is_file(JPATH_ROOT . '/' . $rtl_url) ? @filemtime(JPATH_ROOT . '/' . $rtl_url) : 0;
         $rebuild = $css_lm < $rtl_lm;
     }
     if (!$rebuild) {
         $import = false;
         foreach ($split_contents as $chunk) {
             if ($import) {
                 $import = false;
                 $url = T3Path::cleanPath(dirname($path) . '/' . $chunk);
                 if (is_file(JPATH_ROOT . '/' . $url)) {
                     //$css_lm should be the same as templates.css
                     $file_lm = @filemtime(JPATH_ROOT . '/' . $url);
                     $theme_lm = -1;
                     $rtl_lm = -1;
                     $theme_rtl_lm = -1;
                     if ($theme && strpos($url, 'themes/') === false) {
                         $themepath = 'themes/' . $theme . '/' . basename($path);
                         if (is_file(T3_TEMPLATE_PATH . '/less/' . $themepath)) {
                             $theme_lm = @filemtime(T3_TEMPLATE_PATH . '/less/' . $themepath);
                         }
                         if ($is_rtl) {
                             $rtlthemepath = preg_replace($rswitchrtl, '/less/rtl/' . $theme . '/', $url);
                             if (is_file(JPATH_ROOT . '/' . $rtlthemepath)) {
                                 $theme_rtl_lm = @filemtime(JPATH_ROOT . '/' . $rtlthemepath);
                             }
                         }
                     }
                     if ($is_rtl) {
                         $rtl_url = preg_replace('@/less/(themes/)?@', '/less/rtl/', $url);
                         if (is_file(JPATH_ROOT . '/' . $rtl_url)) {
                             $rtl_lm = @filemtime(JPATH_ROOT . '/' . $rtl_url);
                         }
                     }
                     if (!is_file(JPATH_ROOT . '/' . $cssfile) || $css_lm < $vars_lm || $css_lm < $file_lm || $css_lm < $theme_lm || $css_lm < $rtl_lm || $css_lm < $theme_rtl_lm) {
                         $rebuild = true;
                         // rebuild for sure
                         break;
                         //no need further check
                     } else {
                         $doc->addStylesheet($root . '/' . $topath . str_replace('/', '.', $url) . '.css');
                     }
                 }
             } else {
                 $import = true;
             }
         }
     }
     // so, no need to rebuild?
     if (!$rebuild) {
         // add RTL css if needed
         if ($is_rtl) {
             $cssfile = $topath . str_replace('/', '.', str_replace('.less', '-rtl.less', $path)) . '.css';
             if (is_file(JPATH_ROOT . '/' . $cssfile)) {
                 $doc->addStylesheet($root . '/' . $cssfile);
             }
         }
         return false;
     }
     // variables & mixin
     $vars = self::getVars();
     $output = '';
     $importdirs = array();
     // iterate to each chunk and add separator mark
     $import = false;
     foreach ($split_contents as $chunk) {
         if ($import) {
             $import = false;
             $url = T3Path::cleanPath(dirname($path) . '/' . $chunk);
             // ignore vars.less and variables.less if they are in template folder
             // cause there may have other css less file with the same name (eg. font awesome)
             if (preg_match($rvarscheck, $url)) {
                 continue;
             }
             // remember this path when lookup for import
             $importdirs[dirname(JPATH_ROOT . '/' . $url)] = $root . '/' . dirname($url) . '/';
             $output .= "#{$kfilepath}{content: \"{$url}\";}\n@import \"{$chunk}\";\n\n";
             // check and add theme less
             if ($theme && strpos($url, 'themes/') === false) {
                 $theme_rel = 'themes/' . $theme . '/' . basename($url);
                 $theme_path = T3_TEMPLATE_PATH . '/less/' . $theme_rel;
                 if (is_file($theme_path)) {
                     $importdirs[dirname($theme_path)] = T3_TEMPLATE_URL . dirname($theme_rel) . '/';
                     $output .= "#{$kfilepath}{content: \"" . ('templates/' . T3_TEMPLATE . '/less/' . $theme_rel) . "\";}\n@import \"{$theme_rel}\";\n\n";
                 }
             }
         } else {
             $import = true;
             $chunk = trim($chunk);
             if ($chunk) {
                 $output .= "#{$kfilepath}{content: \"{$path}\";}\n{$chunk}\n\n";
             }
         }
     }
     // compile RTL overwrite when in RTL mode
     if ($is_rtl) {
         $rtlcontent = '';
         // import rtl override
         $import = false;
         foreach ($split_contents as $chunk) {
             if ($import) {
                 $import = false;
                 $url = T3Path::cleanPath(dirname($path) . '/' . $chunk);
                 // ignore vars.less and variables.less if they are in template folder
                 // cause there may have other css less file with the same name (eg. font awesome)
                 if (preg_match($rvarscheck, $url)) {
                     continue;
                 }
                 // process import file
                 $rtl_url = preg_replace('@/less/(themes/)?@', '/less/rtl/', $url);
                 // is there overwrite file?
                 if (!is_file(JPATH_ROOT . '/' . $rtl_url)) {
                     continue;
                 }
                 // process import file
                 $importcontent = JFile::read(JPATH_ROOT . '/' . $rtl_url);
                 if (preg_match($rexcludepath, $rtl_url)) {
                     $importcontent = preg_replace($rimportvars, '', $importcontent);
                 }
                 // remember this path when lookup for import
                 if (preg_match($rimport, $importcontent)) {
                     $importdirs[dirname(JPATH_ROOT . '/' . $rtl_url)] = $root . '/' . dirname($rtl_url) . '/';
                 }
                 $rtlcontent .= "\n{$importcontent}\n\n";
                 // rtl theme overwrite
                 if ($theme && strpos($url, 'themes/') === false) {
                     $rtlthemepath = preg_replace($rswitchrtl, '/less/rtl/' . $theme . '/', $url);
                     if (is_file(JPATH_ROOT . '/' . $rtlthemepath)) {
                         // process import file
                         $importcontent = JFile::read(JPATH_ROOT . '/' . $rtlthemepath);
                         $rtlcontent .= "\n{$importcontent}\n\n";
                         $importdirs[dirname(JPATH_ROOT . '/' . $rtlthemepath)] = $root . '/' . dirname($rtlthemepath) . '/';
                     }
                 }
             } else {
                 $import = true;
             }
         }
         // override in template for this file
         $rtlpath = preg_replace($rswitchrtl, '/less/rtl/', $path);
         if (is_file(JPATH_ROOT . '/' . $rtlpath)) {
             // process import file
             $importcontent = JFile::read(JPATH_ROOT . '/' . $rtlpath);
             $rtlcontent .= "\n{$importcontent}\n\n";
             $importdirs[dirname(JPATH_ROOT . '/' . $rtlpath)] = $root . '/' . dirname($rtlpath) . '/';
         }
         // rtl theme
         if ($theme) {
             $rtlthemepath = preg_replace($rswitchrtl, '/less/rtl/' . $theme . '/', $path);
             if (is_file(JPATH_ROOT . '/' . $rtlthemepath)) {
                 // process import file
                 $importcontent = JFile::read(JPATH_ROOT . '/' . $rtlthemepath);
                 $rtlcontent .= "\n{$importcontent}\n\n";
                 $importdirs[dirname(JPATH_ROOT . '/' . $rtlthemepath)] = $root . '/' . dirname($rtlthemepath) . '/';
             }
         }
         if ($rtlcontent) {
             //rtl content will be treat as a new file
             $rtlfile = str_replace('.less', '-rtl.less', $path);
             $output = $output . "\n#{$kfilepath}{content: \"{$rtlfile}\";}\n\n#{$krtlsep}{content: \"separator\";}\n\n{$rtlcontent}\n\n";
         }
     }
     // common place
     $importdirs[T3_TEMPLATE_PATH . '/less'] = T3_TEMPLATE_URL . '/less/';
     // myself
     $importdirs[dirname(JPATH_ROOT . '/' . $path)] = $root . '/' . dirname($path) . '/';
     // compile less to css using lessphp
     $parser->SetImportDirs($importdirs);
     $parser->SetFileInfo(JPATH_ROOT . '/' . $path, $root . '/' . dirname($path) . '/');
     $source = $vars . "\n#{$kvarsep}{content: \"separator\";}\n" . $output;
     $parser->parse($source);
     $output = $parser->getCss();
     //use cssjanus to transform the content
     if ($is_rtl) {
         if ($rtlcontent) {
             $output = preg_split($rsplitbegin . $krtlsep . $rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
             $rtlcontent = isset($output[2]) ? $output[2] : false;
             $output = $output[0];
         }
         T3::import('jacssjanus/ja.cssjanus');
         $output = JACSSJanus::transform($output, true);
         if ($rtlcontent) {
             $output = $output . "\n" . $rtlcontent;
         }
     }
     //update path and store to files
     $split_contents = preg_split($rsplitbegin . $kfilepath . $rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
     $file_contents = array();
     $file = $path;
     //default
     $relpath = JURI::base(true) . '/' . dirname($file);
     $isfile = false;
     foreach ($split_contents as $chunk) {
         if ($isfile) {
             $isfile = false;
             $file = $chunk;
             $relpath = $topath ? T3Path::relativePath($topath, dirname($file)) : JURI::base(true) . '/' . dirname($file);
         } else {
             $file_contents[$file] = (isset($file_contents[$file]) ? $file_contents[$file] : '') . "\n" . ($file ? T3Path::updateUrl($chunk, $relpath) : $chunk) . "\n\n";
             $isfile = true;
         }
     }
     if (!empty($file_contents)) {
         // remove the duplicate clearfix at the beginning
         $split_contents = preg_split($rsplitbegin . $kvarsep . $rsplitend, reset($file_contents));
         // ignore first one, it's clearfix
         if (is_array($split_contents)) {
             array_shift($split_contents);
         }
         $file_contents[key($file_contents)] = implode("\n", $split_contents);
         //output the file to content and add to document
         foreach ($file_contents as $file => $content) {
             $cssfile = $topath . str_replace('/', '.', $file) . '.css';
             JFile::write(JPATH_ROOT . '/' . $cssfile, $content);
             $doc->addStylesheet($root . '/' . $cssfile);
         }
     }
 }
Esempio n. 11
0
/**
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org
 *------------------------------------------------------------------------------
 */
// No direct access
defined('_JEXEC') or die;
T3::import('core/template');
jimport('joomla.utilities.utility');
/**
 * T3Template class provides extended template tools used for T3 framework
 *
 * @package T3
 */
class T3TemplateLayout extends T3Template
{
    protected $_block = null;
    /**
     * Class constructor
     * @param  object  $template  Current template instance
     */
    public function __construct($template = null)
    {
Esempio n. 12
0
 /**
  * Update head - detect if devmode or themermode is enabled and less file existed, use less file instead of css
  */
 function updateHead()
 {
     // As Joomla 3.0 bootstrap is buggy, we will not use it
     // We also prevent both Joomla bootstrap and T3 bootsrap are loaded
     $t3bootstrap = false;
     $jabootstrap = false;
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $doc = JFactory::getDocument();
         $scripts = array();
         foreach ($doc->_scripts as $url => $script) {
             if (strpos($url, T3_URL . '/bootstrap/js/bootstrap.js') !== false) {
                 $t3bootstrap = true;
                 if ($jabootstrap) {
                     //we already have the Joomla bootstrap and we also replace to T3 bootstrap
                     continue;
                 }
             }
             if (preg_match('@media/jui/js/bootstrap(.min)?.js@', $url)) {
                 if ($t3bootstrap) {
                     //we have T3 bootstrap, no need to add Joomla bootstrap
                     continue;
                 } else {
                     $scripts[T3_URL . '/bootstrap/js/bootstrap.js'] = $script;
                 }
                 $jabootstrap = true;
             } else {
                 $scripts[$url] = $script;
             }
         }
         $doc->_scripts = $scripts;
     }
     // end update javascript
     $devmode = $this->getParam('devmode', 0);
     $themermode = $this->getParam('themermode', 1) && defined('T3_THEMER');
     $theme = $this->getParam('theme', '');
     $minify = $this->getParam('minify', 0);
     // not in devmode and in default theme, do nothing
     if (!$devmode && !$themermode && !$theme && !$minify) {
         return;
     }
     $doc = JFactory::getDocument();
     $root = JURI::root(true);
     $regex = '#' . T3_TEMPLATE_URL . '/css/([^/]*)\\.css((\\?|\\#).*)?$#i';
     $stylesheets = array();
     foreach ($doc->_styleSheets as $url => $css) {
         // detect if this css in template css
         if (preg_match($regex, $url, $match)) {
             $fname = $match[1];
             if ($devmode || $themermode) {
                 if (is_file(T3_TEMPLATE_PATH . '/less/' . $fname . '.less')) {
                     if ($themermode) {
                         $newurl = T3_TEMPLATE_URL . '/less/' . $fname . '.less';
                         $css['mime'] = 'text/less';
                     } else {
                         $newurl = JURI::current() . '?t3action=lessc&amp;s=templates/' . T3_TEMPLATE . '/less/' . $fname . '.less';
                     }
                     $stylesheets[$newurl] = $css;
                     continue;
                 }
             } else {
                 if ($theme) {
                     if (is_file(T3_TEMPLATE_PATH . '/css/themes/' . $theme . '/' . $fname . '.css')) {
                         $newurl = T3_TEMPLATE_URL . '/css/themes/' . $theme . '/' . $fname . '.css';
                         $stylesheets[$newurl] = $css;
                         continue;
                     }
                 }
             }
         }
         $stylesheets[$url] = $css;
     }
     // update back
     $doc->_styleSheets = $stylesheets;
     //only check for minify if devmode is disabled
     if (!$devmode && $minify) {
         T3::import('core/minify');
         T3Minify::optimizecss($this);
     }
 }
Esempio n. 13
0
    public static function addAssets()
    {
        $japp = JFactory::getApplication();
        $user = JFactory::getUser();
        //do nothing when site is offline and user has not login (the offline page is only show login form)
        if ($japp->getCfg('offline') && !$user->authorise('core.login.offline')) {
            return;
        }
        $jdoc = JFactory::getDocument();
        $params = $japp->getTemplate(true)->params;
        if (defined('T3_THEMER') && $params->get('themermode', 1)) {
            $jdoc->addStyleSheet(T3_URL . '/css/thememagic.css');
            $jdoc->addScript(T3_URL . '/js/thememagic.js');
            $theme = $params->get('theme');
            $params = new JRegistry();
            $themeinfo = new stdClass();
            if ($theme) {
                $themepath = T3_TEMPLATE_PATH . '/less/themes/' . $theme;
                if (file_exists($themepath . '/variables-custom.less')) {
                    if (!class_exists('JRegistryFormatLESS')) {
                        include_once T3_ADMIN_PATH . '/includes/format/less.php';
                    }
                    //default variables
                    $varfile = T3_TEMPLATE_PATH . '/less/variables.less';
                    if (file_exists($varfile)) {
                        $params->loadString(JFile::read($varfile), 'LESS');
                        //get all less files in "theme" folder
                        $others = JFolder::files($themepath, '.less');
                        foreach ($others as $other) {
                            //get those developer custom values
                            if ($other == 'variables.less') {
                                $devparams = new JRegistry();
                                $devparams->loadString(JFile::read($themepath . '/variables.less'), 'LESS');
                                //overwrite the default variables
                                foreach ($devparams->toArray() as $key => $value) {
                                    $params->set($key, $value);
                                }
                            }
                            //ok, we will import it later
                            if ($other != 'variables-custom.less' && $other != 'variables.less') {
                                $themeinfo->{$other} = true;
                            }
                        }
                        //load custom variables
                        $cparams = new JRegistry();
                        $cparams->loadString(JFile::read($themepath . '/variables-custom.less'), 'LESS');
                        //and overwrite those defaults variables
                        foreach ($cparams->toArray() as $key => $value) {
                            $params->set($key, $value);
                        }
                    }
                }
            }
            $cache = array();
            // a little security
            if ($user->authorise('core.manage', 'com_templates') || isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], JUri::base() . 'administrator') !== false) {
                T3::import('core/path');
                $baseurl = JUri::base();
                //should we provide a list of less path
                foreach (array(T3_TEMPLATE_PATH . '/less', T3_PATH . '/bootstrap/less', T3_PATH . '/less') as $lesspath) {
                    if (is_dir($lesspath)) {
                        $lessfiles = JFolder::files($lesspath, '.less', true, true);
                        if (is_array($lessfiles)) {
                            foreach ($lessfiles as $less) {
                                $path = ltrim(str_replace(array(JPATH_ROOT, '\\'), array('', '/'), $less), '/');
                                $path = T3Path::cleanPath($path);
                                $fullurl = $baseurl . preg_replace('@(\\+)|(/+)@', '/', $path);
                                $cache[$fullurl] = JFile::read($less);
                            }
                        }
                    }
                }
            }
            $jdoc->addScriptDeclaration('
				var T3Theme = window.T3Theme || {};
				T3Theme.vars = ' . json_encode($params->toArray()) . ';
				T3Theme.others = ' . json_encode($themeinfo) . ';
				T3Theme.theme = \'' . $theme . '\';
				T3Theme.template = \'' . T3_TEMPLATE . '\';
				T3Theme.base = \'' . JURI::base() . '\';
				T3Theme.cache = ' . json_encode($cache) . ';
				if(typeof less != \'undefined\'){
					
					//we need to build one - cause the js will have unexpected behavior
					try{
						if(window.parent != window && 
							window.parent.T3Theme && 
							window.parent.T3Theme.applyLess){
							
							window.parent.T3Theme.applyLess(true);
						} else {
							less.refresh();
						}
					} catch(e){

					}
				}');
        }
    }
Esempio n. 14
0
 /**
  * Render megamenu block, then push the output into megamenu renderer to display
  *
  * @param   string  $position  The position of the modules to render
  * @param   array   $params    Associative array of values
  * @param   string  $content   Module content
  *
  * @return  string  The output of the script
  *
  * @since   11.1
  */
 public function render($info = null, $params = array(), $content = null)
 {
     T3::import('menu/megamenu');
     $t3app = T3::getApp();
     //we will check from params
     $menutype = empty($params['menutype']) ? empty($params['name']) ? $t3app->getParam('mm_type', 'mainmenu') : $params['name'] : $params['menutype'];
     $currentconfig = json_decode($t3app->getParam('mm_config', ''), true);
     //force to array
     if (!is_array($currentconfig)) {
         $currentconfig = (array) $currentconfig;
     }
     //get user access levels
     $viewLevels = JFactory::getUser()->getAuthorisedViewLevels();
     $mmkey = $menutype;
     $mmconfig = array();
     if (!empty($currentconfig)) {
         //find best fit configuration based on view level
         $vlevels = array_merge($viewLevels);
         if (is_array($vlevels) && in_array(3, $vlevels)) {
             //we assume, if a user is special, they should be registered also
             $vlevels[] = 2;
         }
         $vlevels = array_unique($vlevels);
         rsort($vlevels);
         if (!is_array($vlevels)) {
             $vlevels = array();
         }
         $vlevels[] = '';
         // extend a blank, default key
         // check if available configuration for language override
         $langcode = JFactory::getDocument()->language;
         $shortlangcode = substr($langcode, 0, 2);
         $types = array($menutype . '-' . $langcode, $menutype . '-' . $shortlangcode, $menutype);
         foreach ($types as $type) {
             foreach ($vlevels as $vlevel) {
                 $key = $type . ($vlevel !== '' ? '-' . $vlevel : '');
                 if (isset($currentconfig[$key])) {
                     $mmkey = $key;
                     $menutype = $type;
                     break 2;
                 } else {
                     if (isset($currentconfig[$type])) {
                         $mmkey = $menutype = $type;
                         break 2;
                     }
                 }
             }
         }
         if (isset($currentconfig[$mmkey])) {
             $mmconfig = $currentconfig[$mmkey];
             if (!is_array($mmconfig)) {
                 $mmconfig = array();
             }
         }
     }
     JDispatcher::getInstance()->trigger('onT3Megamenu', array(&$menutype, &$mmconfig, &$viewLevels));
     $mmconfig['access'] = $viewLevels;
     $menu = new T3MenuMegamenu($menutype, $mmconfig, $t3app->_tpl->params);
     $t3app->setBuffer($menu->render(true), 'megamenu', empty($params['name']) ? null : $params['name'], null);
     return '';
 }
Esempio n. 15
0
<?php

/**
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org
 *------------------------------------------------------------------------------
 */
if (!class_exists('T3BootstrapTpl', false)) {
    T3::import('menu/t3bootstrap.tpl');
}
class T3Bootstrap
{
    /**
     * Internal variables
     */
    protected $menutype;
    protected $menu;
    /**
     * @param string $menutype
     */
    function __construct($menutype = 'mainmenu')
    {
        $this->menutype = $menutype;
        $this->menu = '';
Esempio n. 16
0
 public static function afterInit()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $tplparams = $app->getTemplate(true)->params;
     if (!$app->isAdmin()) {
         // check if need update megamenu configuration
         if ($tplparams->get('mm_config_needupdate')) {
             T3::import('menu/megamenu');
             T3::import('admin/megamenu');
             $currentconfig = @json_decode($tplparams->get('mm_config', ''), true);
             if (!is_array($currentconfig)) {
                 $currentconfig = array();
             } else {
                 $menuassoc = T3AdminMegamenu::menus();
                 $menulangs = array();
                 $menutypes = array();
                 foreach ($menuassoc as $key => $massoc) {
                     $menutypes[] = $massoc->value;
                     $menulangs[$massoc->value] = $massoc->language;
                 }
             }
             foreach ($currentconfig as $menukey => $mmconfig) {
                 if (!is_array($mmconfig)) {
                     continue;
                 }
                 $menutype = $menukey;
                 if (!in_array($menutype, $menutypes) && preg_match('@(-(\\d))+$@', $menukey, $match)) {
                     $menutype = preg_replace('@(-(\\d))+$@', '', $menutype);
                     $access = explode('-', $match[0]);
                     $access[] = 1;
                     $access = array_filter($access);
                     $access = array_unique($access);
                     $mmconfig['access'] = $access;
                 }
                 if (!in_array($menutype, $menutypes)) {
                     continue;
                 }
                 $mmconfig['language'] = $menulangs[$menutype];
                 $menu = new T3MenuMegamenu($menutype, $mmconfig);
                 $children = $menu->get('children');
                 //remove additional settings
                 unset($mmconfig['language']);
                 unset($mmconfig['access']);
                 foreach ($mmconfig as $item => $setting) {
                     if (is_array($setting) && isset($setting['sub'])) {
                         $sub =& $setting['sub'];
                         $id = (int) substr($item, 5);
                         // remove item-
                         $modify = false;
                         if (!isset($children[$id]) || !count($children[$id])) {
                             //check and remove any empty row
                             for ($j = 0; $j < count($sub['rows']); $j++) {
                                 $remove = true;
                                 for ($k = 0; $k < count($sub['rows'][$j]); $k++) {
                                     if (isset($sub['rows'][$j][$k]['position'])) {
                                         $remove = false;
                                         break;
                                     }
                                 }
                                 if ($remove) {
                                     $modify = true;
                                     unset($sub['rows'][$j]);
                                 }
                             }
                             if ($modify) {
                                 $sub['rows'] = array_values($sub['rows']);
                                 //re-index
                                 $mmconfig[$item]['sub'] = $sub;
                             }
                             continue;
                         }
                         $items = array();
                         foreach ($sub['rows'] as $row) {
                             foreach ($row as $col) {
                                 if (!isset($col['position'])) {
                                     $items[] = $col['item'];
                                 }
                             }
                         }
                         // update the order of items
                         $_items = array();
                         $_itemsids = array();
                         $firstitem = 0;
                         foreach ($children[$id] as $child) {
                             $_itemsids[] = (int) $child->id;
                             if (!$firstitem) {
                                 $firstitem = (int) $child->id;
                             }
                             if (in_array($child->id, $items)) {
                                 $_items[] = (int) $child->id;
                             }
                         }
                         // $_items[0] = $firstitem;
                         if (empty($_items) || $_items[0] != $firstitem) {
                             if (count($_items) == count($items)) {
                                 $_items[0] = $firstitem;
                             } else {
                                 array_splice($_items, 0, 0, $firstitem);
                             }
                         }
                         // no need update config for this item
                         if ($items == $_items) {
                             continue;
                         }
                         // update back to setting
                         $i = 0;
                         $c = count($_items);
                         for ($j = 0; $j < count($sub['rows']); $j++) {
                             for ($k = 0; $k < count($sub['rows'][$j]); $k++) {
                                 if (!isset($sub['rows'][$j][$k]['position'])) {
                                     $sub['rows'][$j][$k]['item'] = $i < $c ? $_items[$i++] : "";
                                 }
                             }
                         }
                         //update - add new rows for new items - at the first rows
                         if (!empty($_items) && count($items) == 0) {
                             $modify = true;
                             array_unshift($sub['rows'], array(array('item' => $_items[0], 'width' => 12)));
                         }
                         //check and remove any empty row
                         for ($j = 0; $j < count($sub['rows']); $j++) {
                             $remove = true;
                             for ($k = 0; $k < count($sub['rows'][$j]); $k++) {
                                 if (isset($sub['rows'][$j][$k]['position']) || in_array($sub['rows'][$j][$k]['item'], $_itemsids)) {
                                     $remove = false;
                                     break;
                                 }
                             }
                             if ($remove) {
                                 $modify = true;
                                 unset($sub['rows'][$j]);
                             }
                         }
                         if ($modify) {
                             $sub['rows'] = array_values($sub['rows']);
                             //re-index
                         }
                         $mmconfig[$item]['sub'] = $sub;
                     }
                 }
                 $currentconfig[$menukey] = $mmconfig;
             }
             // update  megamenu back to other template styles parameter
             $mm_config = json_encode($currentconfig);
             // update megamenu back to current template style parameter
             $template = $app->getTemplate(true);
             $params = $template->params;
             $params->set('mm_config', $mm_config);
             $template->params = $params;
             //update the cache
             T3::setTemplate(T3_TEMPLATE, $params);
             //get all other styles that have the same template
             $db = JFactory::getDBO();
             $query = $db->getQuery(true);
             $query->select('*')->from('#__template_styles')->where('template=' . $db->quote(T3_TEMPLATE))->where('client_id=0');
             $db->setQuery($query);
             $themes = $db->loadObjectList();
             //update all global parameters
             foreach ($themes as $theme) {
                 $registry = new JRegistry();
                 $registry->loadString($theme->params);
                 $registry->set('mm_config', $mm_config);
                 //overwrite with new value
                 $registry->set('mm_config_needupdate', "");
                 //overwrite with new value
                 $query = $db->getQuery(true);
                 $query->update('#__template_styles')->set('params =' . $db->quote($registry->toString()))->where('id =' . (int) $theme->id);
                 $db->setQuery($query);
                 $db->execute();
             }
             // force reload cache template
             $cache = JFactory::getCache('com_templates', '');
             $cache->clean();
         }
     }
 }
Esempio n. 17
0
 /**
  * Default fallback function if CC API fails
  * @param string $js
  * @return string
  */
 protected function _fallback($js)
 {
     //T3 Framework
     T3::import('minify/jsmin');
     return JSMin::minify($js);
 }
Esempio n. 18
0
/** 
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github 
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org 
 *------------------------------------------------------------------------------
 */
// No direct access
defined('_JEXEC') or die;
T3::import('lessphp/less/less');
/**
 * T3LessCompiler class compile less
 *
 * @package T3
 */
// prevent over max_nesting config in some case
@ini_set('xdebug.max_nesting_level', 120);
class T3LessCompiler
{
    public static function compile($source, $importdirs)
    {
        $parser = new Less_Parser();
        $parser->SetImportDirs($importdirs);
        $parser->parse($source);
        $output = $parser->getCss();
Esempio n. 19
0
<?php

/**
 * @package     Joomla.Platform
 * @subpackage  Document
 *
 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
defined('JPATH_PLATFORM') or die;
/**
 * JDocument Megamenu renderer - this is a placeholder for menumenurender
 */
T3::import('renderer/megamenurender');
class JDocumentRendererMegamenu extends JDocumentRendererMegamenuRender
{
    /**
     * Render megamenu block
     *
     * @param   string  $position  The position of the modules to render
     * @param   array   $params    Associative array of values
     * @param   string  $content   Module content
     *
     * @return  string  The output of the script
     *
     * @since   11.1
     */
    public function render($info = null, $params = array(), $content = null)
    {
        $params['return_result'] = true;
        return parent::render($info, $params, $content);
Esempio n. 20
0
 /**
  * function loadParam
  * load and re-render parameters
  *
  * @return render success or not
  */
 function renderAdmin()
 {
     $frwXml = T3_ADMIN_PATH . '/' . T3_ADMIN . '.xml';
     $tplXml = T3_TEMPLATE_PATH . '/templateDetails.xml';
     $cusXml = T3Path::getPath('etc/assets.xml');
     $jtpl = T3_ADMIN_PATH . '/admin/tpls/default.php';
     if (file_exists($tplXml) && file_exists($jtpl)) {
         T3::import('depend/t3form');
         //get the current joomla default instance
         $form = JForm::getInstance('com_templates.style', 'style', array('control' => 'jform', 'load_data' => true));
         //wrap
         $form = new T3Form($form);
         //remove all fields from group 'params' and reload them again in right other base on template.xml
         $form->removeGroup('params');
         //load the template
         $form->loadFile(T3_PATH . '/params/template.xml');
         //overwrite / extend with params of template
         $form->loadFile($tplXml, true, '//config');
         //overwrite / extend with custom config in custom/etc/assets.xml
         if ($cusXml && file_exists($cusXml)) {
             $form->loadFile($cusXml, true, '//config');
         }
         // extend parameters
         T3Bot::prepareForm($form);
         $xml = JFactory::getXML($tplXml);
         $fxml = JFactory::getXML($frwXml);
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('id, title')->from('#__template_styles')->where('template=' . $db->quote(T3_TEMPLATE));
         $db->setQuery($query);
         $styles = $db->loadObjectList();
         foreach ($styles as $key => &$style) {
             $style->title = ucwords(str_replace('_', ' ', $style->title));
         }
         $session = JFactory::getSession();
         $t3lock = $session->get('T3.t3lock', 'overview_params');
         $session->set('T3.t3lock', null);
         $input = JFactory::getApplication()->input;
         include $jtpl;
         /*
         //search for global parameters
         $japp = JFactory::getApplication();
         $pglobals = array();
         foreach($form->getGroup('params') as $param){
         	if($form->getFieldAttribute($param->fieldname, 'global', 0, 'params')){
         		$pglobals[] = array('name' => $param->fieldname, 'value' => $form->getValue($param->fieldname, 'params')); 
         	}
         }
         $japp->setUserState('oparams', $pglobals);
         */
         return true;
     }
     return false;
 }
Esempio n. 21
0
<?php

/** 
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github 
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org 
 *------------------------------------------------------------------------------
 */
T3::import('admin/layout');
?>

<!-- LAYOUT CONFIGURATION PANEL -->
<div id="t3-admin-layout" class="t3-admin-layout hide">
	<div class="t3-admin-inline-nav clearfix">
		<div class="t3-admin-layout-row-mode clearfix">
			<ul class="t3-admin-layout-modes nav nav-tabs">
				<li class="t3-admin-layout-mode-structure active"><a href="" title="<?php 
echo JText::_('T3_LAYOUT_MODE_STRUCTURE');
?>
"><?php 
echo JText::_('T3_LAYOUT_MODE_STRUCTURE');
?>
</a></li>
				<li class="t3-admin-layout-mode-layout"><a href="" title="<?php 
echo JText::_('T3_LAYOUT_MODE_LAYOUT');
Esempio n. 22
0
 function compileCss($path, $topath = '')
 {
     $app = JFactory::getApplication();
     $tpl = T3_TEMPLATE;
     $theme = $app->getUserState('vars_theme');
     $tofile = null;
     //pattern
     $rcomment = '@/\\*[^*]*\\*+([^/][^*]*\\*+)*/@';
     $rspace = '@[\\r?\\n]{2,}@';
     $rimport = '@^\\s*\\@import\\s+"([^"]*)"\\s*;@im';
     $rvarscheck = '@(base|bootstrap|' . preg_quote($tpl) . ')/less/(vars|variables|mixins)\\.less@';
     $rexcludepath = '@(base|bootstrap|' . preg_quote($tpl) . ')/less/@';
     $rimportvars = '@^\\s*\\@import\\s+".*(variables-custom|variables|vars|mixins)\\.less"\\s*;@im';
     $rsplitbegin = '@^\\s*\\#';
     $rsplitend = '[^\\s]*?\\s*{\\s*[\\r\\n]*\\s*content:\\s*"([^"]*)";\\s*[\\r\\n]*\\s*}@im';
     $kfilepath = 'less-file-path';
     $kvarsep = 'less-content-separator';
     $krtlsep = 'rtl-less-content';
     if ($topath) {
         $tofile = JPATH_ROOT . '/' . $topath;
         if (!is_dir(dirname($tofile))) {
             JFolder::create(dirname($tofile));
         }
     }
     // check path
     $realpath = realpath(JPATH_ROOT . '/' . $path);
     if (!is_file($realpath)) {
         return;
     }
     // get file content
     $content = JFile::read($realpath);
     // remove comments? - we should keep comment for rtl flip
     //$content = preg_replace($rcomment, '', $content);
     // split into array, separated by the import
     $arr = preg_split($rimport, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
     // check and add theme less if not is theme less
     if ($theme && strpos($path, 'themes/') === false) {
         $themepath = 'themes/' . $theme . '/' . basename($path);
         if (is_file(T3_TEMPLATE_PATH . '/less/' . $themepath)) {
             $arr[] = $themepath;
             $arr[] = '';
         }
     }
     // variables & mixin
     $vars = $this->getVars();
     $importdirs = array();
     // compile chunk
     $import = false;
     $output = '';
     foreach ($arr as $s) {
         if ($import) {
             $import = false;
             $url = T3Path::cleanPath(dirname($path) . '/' . $s);
             // ignore vars.less and variables.less if they are in template folder
             // cause there may have other css less file with the same name (eg. font awesome)
             if (preg_match($rvarscheck, $url)) {
                 continue;
             }
             // process import file
             $importcontent = JFile::read(JPATH_ROOT . '/' . $url);
             if (preg_match($rexcludepath, $url)) {
                 $importcontent = preg_replace($rimportvars, '', $importcontent);
             }
             // remember this path when lookup for import
             if (preg_match($rimport, $importcontent)) {
                 $importdirs[] = dirname(JPATH_ROOT . '/' . $url);
             }
             $output .= "#{$kfilepath}{content: \"{$url}\";}\n{$importcontent}\n\n";
         } else {
             $import = true;
             $s = trim($s);
             if ($s) {
                 $output .= "#{$kfilepath}{content: \"{$path}\";}\n{$s}\n\n";
             }
         }
     }
     $rtlcontent = '';
     $is_rtl = $app->getUserState('DIRECTION') == 'rtl' && strpos($path, 'rtl/') === false;
     // convert to RTL if using RTL
     if ($is_rtl) {
         // import rtl override
         // check override for import
         $import = false;
         foreach ($arr as $s) {
             if ($import) {
                 $import = false;
                 $url = T3Path::cleanPath(dirname($path) . '/' . $s);
                 // ignore vars.less and variables.less if they are in template folder
                 // cause there may have other css less file with the same name (eg. font awesome)
                 if (preg_match($rvarscheck, $url)) {
                     continue;
                 }
                 // process import file
                 $url = preg_replace('/\\/less\\/(themes\\/)?/', '/less/rtl/', $url);
                 if (!is_file(JPATH_ROOT . '/' . $url)) {
                     continue;
                 }
                 // process import file
                 $importcontent = JFile::read(JPATH_ROOT . '/' . $url);
                 if (preg_match($rexcludepath, $url)) {
                     $importcontent = preg_replace($rimportvars, '', $importcontent);
                 }
                 // remember this path when lookup for import
                 if (preg_match($rimport, $importcontent)) {
                     $importdirs[] = dirname(JPATH_ROOT . '/' . $url);
                 }
                 $rtlcontent .= "#{$kfilepath}-rtl{content: \"{$url}\";}\n{$importcontent}\n\n";
             } else {
                 $import = true;
             }
         }
         // override in template for this file
         $rtlpath = preg_replace('/\\/less\\/(themes\\/[^\\/]*\\/)?/', '/less/rtl/', $path);
         if (is_file(JPATH_ROOT . '/' . $rtlpath)) {
             // process import file
             $importcontent = JFile::read(JPATH_ROOT . '/' . $rtlpath);
             $rtlcontent .= "#{$kfilepath}-rtl{content: \"{$rtlpath}\";}\n{$importcontent}\n\n";
         }
         // rtl theme
         if ($theme) {
             $rtlthemepath = preg_replace('/\\/less\\/(themes\\/[^\\/]*\\/)?/', '/less/rtl/' . $theme . '/', $path);
             if (is_file(JPATH_ROOT . '/' . $rtlthemepath)) {
                 // process import file
                 $importcontent = JFile::read(JPATH_ROOT . '/' . $rtlthemepath);
                 $rtlcontent .= "#{$kfilepath}-rtl{content: \"{$rtlthemepath}\";}\n{$importcontent}\n\n";
             }
         }
         if ($rtlcontent) {
             $output = $output . "#{$krtlsep}{content: \"separator\";}\n\n{$rtlcontent}\n\n";
         }
     }
     $importdirs[] = dirname($realpath);
     $importdirs[] = T3_TEMPLATE_PATH . '/less/';
     $this->setImportDir($importdirs);
     $this->setPreserveComments(true);
     $source = $vars . "\n#{$kvarsep}{content: \"separator\";}\n" . $output;
     // compile less to css using lessphp
     $output = $this->compile($source);
     $arr = preg_split($rsplitbegin . $kfilepath . $rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
     $output = '';
     $file = '';
     $isfile = false;
     foreach ($arr as $s) {
         if ($isfile) {
             $isfile = false;
             $file = $s;
             $relpath = $topath ? T3Path::relativePath(dirname($topath), dirname($file)) : JURI::base(true) . '/' . dirname($file);
         } else {
             $output .= ($file ? T3Path::updateUrl($s, $relpath) : $s) . "\n\n";
             $isfile = true;
         }
     }
     // remove the dupliate clearfix at the beggining if not bootstrap.css file
     if (strpos($path, $tpl . '/less/bootstrap.less') === false) {
         $arr = preg_split($rsplitbegin . $kvarsep . $rsplitend, $output);
         // ignore first one, it's clearfix
         if (is_array($arr)) {
             array_shift($arr);
         }
         $output = implode("\n", $arr);
     } else {
         $output = preg_replace($rsplitbegin . $kvarsep . $rsplitend, '', $output);
     }
     if ($is_rtl) {
         if ($rtlcontent) {
             $output = preg_split($rsplitbegin . $krtlsep . $rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
             $rtlcontent = isset($output[2]) ? $output[2] : false;
             $output = $output[0];
         }
         T3::import('jacssjanus/ja.cssjanus');
         $output = JACSSJanus::transform($output, true);
         if ($rtlcontent) {
             $output = $output . "\n" . $rtlcontent;
         }
     }
     //remove comments and clean up
     $output = preg_replace($rcomment, '', $output);
     $output = preg_replace($rspace, "\n\n", $output);
     if ($tofile) {
         $ret = JFile::write($tofile, $output);
         @chmod($tofile, 0644);
         return $ret;
     }
     return $output;
 }
Esempio n. 23
0
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github 
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org 
 *------------------------------------------------------------------------------
 */
// No direct access
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
if (!class_exists('lessc')) {
    T3::import('lessphp/lessc.inc');
}
T3::import('core/path');
/**
 * T3Less class compile less
 *
 * @package T3
 */
class T3Less extends lessc
{
    public static function getInstance()
    {
        static $t3less = null;
        if (!$t3less) {
            $t3less = new T3Less();
        }
        return $t3less;
    }
Esempio n. 24
0
/**
 *------------------------------------------------------------------------------
 * @package       T3 Framework for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github
 *                & Google group to become co-author)
 * @Google group: https://groups.google.com/forum/#!forum/t3fw
 * @Link:         http://t3-framework.org
 *------------------------------------------------------------------------------
 */
// No direct access
defined('_JEXEC') or die;
T3::import('lessphp/lessc.inc');
/**
 * T3LessCompiler class compile less
 *
 * @package T3
 */
class T3LessCompiler
{
    public static function compile($source, $path, $todir, $importdirs)
    {
        // call Less to compile
        $parser = new lessc();
        $parser->setImportDir(array_keys($importdirs));
        $parser->setPreserveComments(true);
        $output = $parser->compile($source);
        // update url
 /**
  * Update head - detect if devmode or themermode is enabled and less file existed, use less file instead of css
  * We also detect and update jQuery, Bootstrap to use T3 assets
  *
  * @return  null
  */
 function updateHead()
 {
     //state parameters
     $devmode = $this->getParam('devmode', 0);
     $themermode = $this->getParam('themermode', 1) && defined('T3_THEMER');
     $theme = $this->getParam('theme', '');
     $minify = $this->getParam('minify', 0);
     $minifyjs = $this->getParam('minify_js', 0);
     // detect RTL
     $doc = JFactory::getDocument();
     $dir = $doc->direction;
     $is_rtl = $dir == 'rtl';
     // As Joomla 3.0 bootstrap is buggy, we will not use it
     // We also prevent both Joomla bootstrap and T3 bootsrap are loaded
     // And upgrade jquery as our Framework require jquery 1.7+ if we are loading jquery from google
     $scripts = array();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $t3bootstrap = false;
         $jabootstrap = false;
         foreach ($doc->_scripts as $url => $script) {
             if (strpos($url, T3_URL . '/bootstrap/js/bootstrap.js') !== false) {
                 $t3bootstrap = true;
                 if ($jabootstrap) {
                     //we already have the Joomla bootstrap and we also replace to T3 bootstrap
                     continue;
                 }
             }
             if (preg_match('@media/jui/js/bootstrap(.min)?.js@', $url)) {
                 if ($t3bootstrap) {
                     //we have T3 bootstrap, no need to add Joomla bootstrap
                     continue;
                 } else {
                     $scripts[T3_URL . '/bootstrap/js/bootstrap.js'] = $script;
                 }
                 $jabootstrap = true;
             } else {
                 $scripts[$url] = $script;
             }
         }
         $doc->_scripts = $scripts;
         $scripts = array();
     }
     // VIRTUE MART / JSHOPPING compatible
     foreach ($doc->_scripts as $url => $script) {
         $replace = false;
         if (strpos($url, '//ajax.googleapis.com/ajax/libs/jquery/') !== false && preg_match_all('@/jquery/(\\d+(\\.\\d+)*)?/@msU', $url, $jqver) || preg_match_all('@(^|\\/)jquery([-_]*(\\d+(\\.\\d+)+))?(\\.min)?\\.js@i', $url, $jqver)) {
             $idx = strpos($url, '//ajax.googleapis.com/ajax/libs/jquery/') !== false ? 1 : 3;
             if (is_array($jqver) && isset($jqver[$idx]) && isset($jqver[$idx][0])) {
                 $jqver = explode('.', $jqver[$idx][0]);
                 if (isset($jqver[0]) && (int) $jqver[0] <= 1 && isset($jqver[1]) && (int) $jqver[1] < 7) {
                     $scripts[T3_URL . '/js/jquery-1.11.2' . ($devmode ? '' : '.min') . '.js'] = $script;
                     $replace = true;
                 }
             }
         }
         if (!$replace) {
             $scripts[$url] = $script;
         }
     }
     $doc->_scripts = $scripts;
     // end update javascript
     //Update css/less based on devmode and themermode
     $root = JURI::root(true);
     $current = JURI::current();
     // $regex       = '@' . preg_quote(T3_TEMPLATE_REL) . '/css/(rtl/)?(.*)\.css((\?|\#).*)?$@i';
     $regex = '@' . preg_quote(T3_TEMPLATE_REL) . '/(.*)\\.css((\\?|\\#).*)?$@i';
     $stylesheets = array();
     foreach ($doc->_styleSheets as $url => $css) {
         // detect if this css in template css
         if (preg_match($regex, $url, $match)) {
             $fname = $match[1];
             // remove rtl
             $fname = preg_replace('@(^|/)rtl/@mi', '\\1', $fname);
             // remove local
             $fname = preg_replace('@^local/@mi', '', $fname);
             // if (($devmode || $themermode) && is_file(T3_TEMPLATE_PATH . '/less/' . $fname . '.less')) {
             if ($devmode || $themermode) {
                 // less file
                 $lfname = preg_replace('@(^|/)css/@mi', '\\1less/', $fname);
                 if (is_file(T3_TEMPLATE_PATH . '/' . $lfname . '.less')) {
                     if ($themermode) {
                         $newurl = T3_TEMPLATE_URL . '/' . $lfname . '.less';
                         $css['mime'] = 'text/less';
                     } else {
                         T3::import('core/less');
                         $newurl = T3Less::buildCss(T3Path::cleanPath(T3_TEMPLATE_REL . '/' . $lfname . '.less'), true);
                     }
                     $stylesheets[$newurl] = $css;
                     continue;
                 }
             }
             $uri = null;
             // detect css available base on direction & theme
             if ($is_rtl && $theme) {
                 // rtl css file
                 $altfname = preg_replace('@(^|/)css/@mi', '\\1css/rtl/' . $theme . '/', $fname);
                 $uri = T3Path::getUrl($altfname . '.css');
             }
             if (!$uri && $is_rtl) {
                 $altfname = preg_replace('@(^|/)css/@mi', '\\1css/rtl/', $fname);
                 $uri = T3Path::getUrl($altfname . '.css');
             }
             if (!$uri && $theme) {
                 $altfname = preg_replace('@(^|/)css/@mi', '\\1css/themes/' . $theme . '/', $fname);
                 $uri = T3Path::getUrl($altfname . '.css');
             }
             if (!$uri) {
                 $uri = T3Path::getUrl($fname . '.css');
             }
             if ($uri) {
                 $stylesheets[$uri] = $css;
             }
             continue;
         }
         $stylesheets[$url] = $css;
     }
     // update back
     $doc->_styleSheets = $stylesheets;
     //only check for minify if devmode is disabled
     if (!$devmode && ($minify || $minifyjs)) {
         T3::import('core/minify');
         if ($minify) {
             T3Minify::optimizecss($this);
         }
         if ($minifyjs) {
             T3Minify::optimizejs($this);
         }
     }
 }
Esempio n. 26
0
 public static function megamenu()
 {
     self::cloneParam('t3menu');
     JFactory::getLanguage()->load('tpl_' . T3_TEMPLATE, JPATH_SITE);
     if (!defined('T3')) {
         die(json_encode(array('error' => JText::_('T3_MSG_PLUGIN_NOT_READY'))));
     }
     $action = JFactory::getApplication()->input->get('t3task', '');
     if (empty($action)) {
         die(json_encode(array('error' => JText::_('T3_MSG_UNKNOW_ACTION'))));
     }
     if ($action != 'display') {
         $user = JFactory::getUser();
         if (!$user->authorise('core.manage', 'com_templates')) {
             die(json_encode(array('error' => JText::_('T3_MSG_NO_PERMISSION'))));
         }
     }
     T3::import('admin/megamenu');
     if (method_exists('T3AdminMegamenu', $action)) {
         T3AdminMegamenu::$action();
         exit;
     } else {
         die(json_encode(array('error' => JText::_('T3_MSG_UNKNOW_ACTION'))));
     }
 }
Esempio n. 27
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  */
 function getInput()
 {
     $this->loadAsset();
     T3::import('admin/layout');
     return $this->getPositions();
 }
Esempio n. 28
0
 /**
  * @param   string  $path    file path of less file to compile
  * @param   string  $topath  file path of output css file
  * @return  bool|mixed       compile result or the css compiled content
  */
 public static function compileCss($path, $topath = '', $split = false, $list = null)
 {
     $fromdir = dirname($path);
     $app = JFactory::getApplication();
     $is_rtl = $app->getUserState('current_direction') == 'rtl';
     if (empty($list)) {
         $list = self::parse($path);
     }
     if (empty($list)) {
         return false;
     }
     // join $list
     $content = '';
     $importdirs = array();
     $todir = $topath ? dirname($topath) : $fromdir;
     if (!is_dir(JPATH_ROOT . '/' . $todir)) {
         JFolder::create(JPATH_ROOT . '/' . $todir);
     }
     $importdirs[JPATH_ROOT . '/' . $fromdir] = './';
     foreach ($list as $f => $import) {
         if ($import) {
             $importdirs[JPATH_ROOT . '/' . dirname($f)] = self::relativePath($fromdir, dirname($f));
             $content .= "\n#" . self::$kfilepath . "{content: \"{$f}\";}\n";
             // $content .= "@import \"$import\";\n\n";
             if (is_file(JPATH_ROOT . '/' . $f)) {
                 $less_content = file_get_contents(JPATH_ROOT . '/' . $f);
                 // remove vars/mixins for template & t3 less
                 if (preg_match('@' . preg_quote(T3_TEMPLATE_REL, '@') . '/@i', $f) || preg_match('@' . preg_quote(T3_REL, '@') . '/@i', $f)) {
                     $less_content = preg_replace(self::$rimportvars, '', $less_content);
                 }
                 self::$_path = T3Path::relativePath($fromdir, dirname($f)) . '/';
                 $less_content = preg_replace_callback(self::$rimport, array('T3Less', 'cb_import_path'), $less_content);
                 $content .= $less_content;
             }
         } else {
             $content .= "\n#" . self::$kfilepath . "{content: \"{$path}\";}\n";
             $content .= $f . "\n\n";
         }
     }
     // get vars
     $vars_files = explode('|', self::getVars('urls'));
     // build source
     $source = '';
     // build import vars
     foreach ($vars_files as $var) {
         $var_file = T3Path::relativePath($fromdir, $var);
         $source .= "@import \"" . $var_file . "\";\n";
     }
     // less content
     $source .= "\n#" . self::$kvarsep . "{content: \"separator\";}\n" . $content;
     // call Less to compile,
     // temporary compile into source path, then update url to destination later
     try {
         $output = T3LessCompiler::compile($source, $importdirs);
     } catch (Exception $e) {
         // echo 'Caught exception: ',  $e->getMessage(), "\n";
         throw new Exception($path . "<br />\n" . $e->getMessage());
     }
     // process content
     //use cssjanus to transform the content
     if ($is_rtl) {
         $output = preg_split(self::$rsplitbegin . self::$krtlsep . self::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
         $rtlcontent = isset($output[2]) ? $output[2] : false;
         $output = $output[0];
         T3::import('jacssjanus/ja.cssjanus');
         $output = JACSSJanus::transform($output, true);
         // join with rtl content
         if ($rtlcontent) {
             $output = $output . "\n" . $rtlcontent;
         }
     }
     // skip duplicate clearfix
     $arr = preg_split(self::$rsplitbegin . self::$kvarsep . self::$rsplitend, $output, 2);
     if (preg_match('/bootstrap.less/', $path)) {
         $output = implode("\n", $arr);
     } else {
         $output = count($arr) > 1 ? $arr[1] : $arr[0];
     }
     //remove comments and clean up
     $output = preg_replace(self::$rcomment, '', $output);
     $output = preg_replace(self::$rspace, "\n\n", $output);
     // update url for output
     $file_contents = self::updateUrl($output, $path, $todir, $split);
     // split if needed
     if ($split) {
         if (!empty($file_contents)) {
             //output the file to content and add to document
             foreach ($file_contents as $file => $content) {
                 if ($file) {
                     $content = trim($content);
                     $filename = str_replace('/', '.', $file) . '.css';
                     JFile::write(JPATH_ROOT . '/' . $todir . '/' . $filename, $content);
                 }
             }
         }
     } else {
         if ($topath) {
             JFile::write(JPATH_ROOT . '/' . $topath, $file_contents);
         } else {
             return $output;
         }
     }
     // write to path
     return true;
 }
Esempio n. 29
0
 /**
  * get T3Template object for frontend
  * @param $tpl
  * @return bool
  */
 public static function getSite($tpl)
 {
     //when on site, the JDocumentHTML parameter must be pass
     if (empty($tpl)) {
         return false;
     }
     $type = 'Template' . JFactory::getApplication()->input->getCmd('t3tp', '');
     T3::import('core/' . $type);
     // create global t3 template object
     $class = 'T3' . $type;
     return new $class($tpl);
 }
Esempio n. 30
0
 /**
  * Render megamenu block
  *
  * @param   string  $position  The position of the modules to render
  * @param   array   $params    Associative array of values
  * @param   string  $content   Module content
  *
  * @return  string  The output of the script
  *
  * @since   11.1
  */
 public function render($info = null, $params = array(), $content = null)
 {
     T3::import('menu/megamenu');
     $t3app = T3::getApp();
     //we will check from params
     $menutype = empty($params['menutype']) ? $t3app->getParam('mm_type', 'mainmenu') : $params['menutype'];
     $currentconfig = json_decode($t3app->getParam('mm_config', ''), true);
     //force to array
     if (!is_array($currentconfig)) {
         $currentconfig = (array) $currentconfig;
     }
     //get user access levels
     $viewLevels = JFactory::getUser()->getAuthorisedViewLevels();
     $mmkey = $menutype;
     $mmconfig = array();
     if (!empty($currentconfig)) {
         //find best fit configuration based on view level
         $vlevels = array_merge($viewLevels);
         if (is_array($vlevels) && in_array(3, $vlevels)) {
             //we assume, if a user is special, they should be registered also
             $vlevels[] = 2;
         }
         $vlevels = array_unique($vlevels);
         rsort($vlevels);
         if (is_array($vlevels) && count($vlevels)) {
             //should check for special view level first
             if (in_array(3, $vlevels)) {
                 array_unshift($vlevels, 3);
             }
             $found = false;
             foreach ($vlevels as $vlevel) {
                 $mmkey = $menutype . '-' . $vlevel;
                 if (isset($currentconfig[$mmkey])) {
                     $found = true;
                     break;
                 }
             }
             //fallback
             if (!$found) {
                 $mmkey = $menutype;
             }
         }
         // check if available configuration for language override
         $langcode = substr(JFactory::getDocument()->language, 0, 2);
         $langtype = $menutype . '-' . $langcode;
         $langkey = $langtype . str_replace($menutype, '', $mmkey);
         if (isset($currentconfig[$langkey])) {
             $mmkey = $langkey;
             $menutype = $langtype;
         } else {
             if (isset($currentconfig[$langtype])) {
                 $mmkey = $menutype = $langtype;
             }
         }
         if (isset($currentconfig[$mmkey])) {
             $mmconfig = $currentconfig[$mmkey];
             if (!is_array($mmconfig)) {
                 $mmconfig = array();
             }
         }
     }
     JDispatcher::getInstance()->trigger('onT3Megamenu', array(&$menutype, &$mmconfig, &$viewLevels));
     $mmconfig['access'] = $viewLevels;
     $menu = new T3MenuMegamenu($menutype, $mmconfig, $t3app->_tpl->params);
     return $menu->render(true);
 }