Esempio n. 1
0
 function replaceToolbar($body)
 {
     $t3toolbar = T3_ADMIN_PATH . '/admin/tpls/toolbar.php';
     $input = JFactory::getApplication()->input;
     if (file_exists($t3toolbar) && class_exists('JToolBar')) {
         //get the existing toolbar html
         jimport('joomla.language.help');
         $params = T3::getTplParams();
         $toolbar = JToolBar::getInstance('toolbar')->render('toolbar');
         $helpurl = JHelp::createURL($input->getCmd('view') == 'template' ? 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT' : 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_STYLES_EDIT');
         $helpurl = htmlspecialchars($helpurl, ENT_QUOTES);
         //render our toolbar
         ob_start();
         include $t3toolbar;
         $t3toolbar = ob_get_clean();
         //replace it
         $body = str_replace($toolbar, $t3toolbar, $body);
     }
     return $body;
 }
Esempio n. 2
0
 /**
  *
  * Show thememagic form
  */
 public static function thememagic($path)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $isadmin = $app->isAdmin();
     if ($isadmin) {
         $tplparams = T3::getTplParams();
     } else {
         $tplparams = $app->getTemplate(true)->params;
     }
     $url = $isadmin ? JUri::root(true) . '/index.php' : JUri::current();
     $url .= (preg_match('/\\?/', $url) ? '&' : '?') . 'themer=1';
     $url .= $tplparams->get('theme', -1) != -1 ? '&t3style=' . $tplparams->get('theme') : '';
     if ($isadmin) {
         $url .= '&t3tmid=' . $input->getCmd('id');
     }
     $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;
                         }
                     }
                     $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. 3
0
 /**
  *
  * Show thememagic form
  */
 public static function megamenu()
 {
     $tplparams = T3::getTplParams();
     $url = JFactory::getURI();
     $url->delVar('t3action');
     $url->delVar('t3task');
     $referer = $url->toString();
     $template = T3_TEMPLATE;
     $styleid = JFactory::getApplication()->input->getCmd('id');
     $mm_type = $tplparams && $tplparams instanceof JRegistry ? $tplparams->get('mm_type', '') : null;
     //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;
     }
     //check config
     $currentconfig = $tplparams && $tplparams instanceof JRegistry ? $tplparams->get('mm_config', '') : null;
     if (!$currentconfig) {
         $currentconfig = '"{}"';
     }
     include T3_ADMIN_PATH . '/admin/megamenu/megamenu.tpl.php';
     exit;
 }
Esempio n. 4
0
 /**
  * Compile LESS to CSS for a specific theme or all themes
  * @param  string  $theme  the specific theme
  */
 public static function compileAll($theme = null)
 {
     $params = T3::getTplParams();
     JFactory::getApplication()->setUserState('current_template_params', $params);
     // get files need to compile
     $files = array();
     $toPath = T3Path::getLocalPath('', true);
     // t3 core plugin files
     $t3files = array('less/frontend-edit.less', 'less/legacy-grid.less', 'less/legacy-navigation.less', 'less/megamenu.less', 'less/off-canvas.less');
     // all less file in the template folder
     $lessFiles = JFolder::files(T3_TEMPLATE_PATH, '.less', true, true, array('rtl', 'themes', '.svn', 'CVS', '.DS_Store', '__MACOSX'));
     $relLessFiles = array();
     $importedFiles = array();
     foreach ($lessFiles as $file) {
         $file = str_replace('\\', '/', $file);
         $lessContent = file_get_contents($file);
         $rel = ltrim(str_replace(T3_TEMPLATE_PATH, '', $file), '/');
         $reldir = dirname($rel);
         $ignore = true;
         if (preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $lessContent, $matches)) {
             foreach ($matches[1] as $if) {
                 $if = T3Path::cleanPath($reldir . '/' . $if);
                 if (!in_array($if, $importedFiles)) {
                     $importedFiles[] = $if;
                 }
                 // check if this file import anything in main less folder. if yes, put it in the compile list
                 if (preg_match('@^less/@', $if)) {
                     $ignore = false;
                 }
             }
         }
         if (!$ignore) {
             $relLessFiles[] = $rel;
         }
     }
     $lessFiles = $relLessFiles;
     // ignore files which are imported in other file
     foreach ($lessFiles as $f) {
         if (!in_array($f, $importedFiles) && !preg_match('@^less/(themes|rtl)/@i', $f)) {
             $files[] = $f;
         }
     }
     //build t3files
     foreach ($t3files as $key => $file) {
         if (in_array($file, $files)) {
             unset($t3files[$key]);
         }
     }
     // build default
     if (!$theme || $theme == 'default') {
         self::buildVars('', 'ltr');
         // compile all less files in template "less" folder
         foreach ($files as $lessPath) {
             $cssPath = self::getOutputCssPath($lessPath);
             self::compileCss(T3_TEMPLATE_REL . '/' . $lessPath, $toPath . $cssPath);
         }
         // if the template not overwrite the t3 core, we will compile those missing files
         if (!empty($t3files)) {
             foreach ($t3files as $lessPath) {
                 $cssPath = self::getOutputCssPath($lessPath);
                 self::compileCss(T3_REL . '/' . $lessPath, $toPath . $cssPath);
             }
         }
     }
     // build themes
     if (!$theme) {
         // get themes
         $themes = JFolder::folders(T3_TEMPLATE_PATH . '/less/themes');
     } else {
         $themes = $theme != 'default' ? (array) $theme : array();
     }
     if (is_array($themes)) {
         foreach ($themes as $t) {
             self::buildVars($t, 'ltr');
             // compile
             foreach ($files as $lessPath) {
                 $cssPath = self::getOutputCssPath($lessPath, $t);
                 self::compileCss(T3_TEMPLATE_REL . '/' . $lessPath, $toPath . $cssPath);
             }
             if (!empty($t3files)) {
                 foreach ($t3files as $lessPath) {
                     $cssPath = self::getOutputCssPath($lessPath, $t);
                     self::compileCss(T3_REL . '/' . $lessPath, $toPath . $cssPath);
                 }
             }
         }
     }
     // compile rtl css
     if ($params && $params->get('build_rtl', 0)) {
         // compile default
         if (!$theme || $theme == 'default') {
             self::buildVars('', 'rtl');
             // compile
             foreach ($files as $lessPath) {
                 $cssPath = self::getOutputCssPath($lessPath, '', true);
                 self::compileCss(T3_TEMPLATE_REL . '/' . $lessPath, $toPath . $cssPath);
             }
             if (!empty($t3files)) {
                 foreach ($t3files as $lessPath) {
                     $cssPath = self::getOutputCssPath($lessPath, '', true);
                     self::compileCss(T3_REL . '/' . $lessPath, $toPath . $cssPath);
                 }
             }
         }
         if (is_array($themes)) {
             // rtl for themes
             foreach ($themes as $t) {
                 self::buildVars($t, 'rtl');
                 // compile
                 foreach ($files as $lessPath) {
                     $cssPath = self::getOutputCssPath($lessPath, $t, true);
                     self::compileCss(T3_TEMPLATE_REL . '/' . $lessPath, $toPath . $cssPath);
                 }
                 if (!empty($t3files)) {
                     foreach ($t3files as $lessPath) {
                         $cssPath = self::getOutputCssPath($lessPath, $t, true);
                         self::compileCss(T3_REL . '/' . $lessPath, $toPath . $cssPath);
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
0
File: less.php Progetto: pryspry/t3
 /**
  * Compile LESS to CSS for a specific theme or all themes
  * @param  string  $theme  the specific theme
  */
 public static function compileAll($theme = null)
 {
     $params = T3::getTplParams();
     JFactory::getApplication()->setUserState('current_template_params', $params);
     // get files need to compile
     $files = array();
     $lesspath = T3_TEMPLATE_REL . '/less/';
     $csspath = T3Path::getLocalPath('css/', true);
     $fullpath = JPath::clean(JPATH_ROOT . '/' . $lesspath);
     // t3 core plugin files
     $t3files = array('frontend-edit', 'legacy-grid', 'legacy-navigation', 'megamenu', 'off-canvas');
     // all less file in less folders
     $lessFiles = JFolder::files($fullpath, '.less', true, true, array('rtl', 'themes', '.svn', 'CVS', '.DS_Store', '__MACOSX'));
     $lessContent = '';
     $relLessFiles = array();
     foreach ($lessFiles as $file) {
         $lessContent .= JFile::read($file) . "\n";
         $relLessFiles[] = ltrim(str_replace($fullpath, '', $file), '/\\');
     }
     $lessFiles = $relLessFiles;
     // get files imported in this list
     if (preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $lessContent, $matches)) {
         foreach ($lessFiles as $f) {
             if (!in_array($f, $matches[1])) {
                 $files[] = substr($f, 0, -5);
             }
         }
         //build t3files
         foreach ($t3files as $key => $file) {
             if (in_array($file, $files)) {
                 unset($t3files[$key]);
             }
         }
     }
     // build default
     if (!$theme || $theme == 'default') {
         self::buildVars('', 'ltr');
         // compile all less files in template "less" folder
         foreach ($files as $file) {
             self::compileCss($lesspath . $file . '.less', $csspath . $file . '.css');
         }
         // if the template not overwrite the t3 core, we will compile those missing files
         if (!empty($t3files)) {
             foreach ($t3files as $file) {
                 self::compileCss(T3_REL . '/less/' . $file . '.less', $csspath . $file . '.css');
             }
         }
     }
     // build themes
     if (!$theme) {
         // get themes
         $themes = JFolder::folders(JPATH_ROOT . '/' . $lesspath . '/themes');
     } else {
         $themes = $theme != 'default' ? (array) $theme : array();
     }
     if (is_array($themes)) {
         foreach ($themes as $t) {
             self::buildVars($t, 'ltr');
             // compile
             foreach ($files as $file) {
                 self::compileCss($lesspath . $file . '.less', $csspath . 'themes/' . $t . '/' . $file . '.css');
             }
             if (!empty($t3files)) {
                 foreach ($t3files as $file) {
                     self::compileCss(T3_REL . '/less/' . $file . '.less', $csspath . 'themes/' . $t . '/' . $file . '.css');
                 }
             }
         }
     }
     // compile rtl css
     if ($params && $params->get('build_rtl', 0)) {
         // compile default
         if (!$theme || $theme == 'default') {
             self::buildVars('', 'rtl');
             // compile
             foreach ($files as $file) {
                 self::compileCss($lesspath . $file . '.less', $csspath . 'rtl/' . $file . '.css');
             }
             if (!empty($t3files)) {
                 foreach ($t3files as $file) {
                     self::compileCss(T3_REL . '/less/' . $file . '.less', $csspath . 'rtl/' . $file . '.css');
                 }
             }
         }
         if (is_array($themes)) {
             // rtl for themes
             foreach ($themes as $t) {
                 self::buildVars($t, 'rtl');
                 // compile
                 foreach ($files as $file) {
                     self::compileCss($lesspath . $file . '.less', $csspath . 'rtl/' . $t . '/' . $file . '.css');
                 }
                 if (!empty($t3files)) {
                     foreach ($t3files as $file) {
                         self::compileCss(T3_REL . '/less/' . $file . '.less', $csspath . 'rtl/' . $t . '/' . $file . '.css');
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
 public static function compileAll($theme = null)
 {
     $less = self::getInstance();
     // compile all css files
     $files = array();
     $lesspath = 'templates/' . T3_TEMPLATE . '/less/';
     $csspath = 'templates/' . T3_TEMPLATE . '/css/';
     $fullpath = JPath::clean(JPATH_ROOT . '/' . $lesspath);
     // get files need to compile
     $lessFiles = JFolder::files($fullpath, '.less', true, true, array('rtl', 'themes', '.svn', 'CVS', '.DS_Store', '__MACOSX'));
     $relLessFiles = array();
     $lessContent = '';
     foreach ($lessFiles as $file) {
         $lessContent .= JFile::read($file) . "\n";
         $relLessFiles[] = ltrim(str_replace($fullpath, '', $file), '/\\');
     }
     $lessFiles = $relLessFiles;
     // get files imported in this list
     if (preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $lessContent, $matches)) {
         foreach ($lessFiles as $f) {
             if (!in_array($f, $matches[1])) {
                 $files[] = substr($f, 0, -5);
             }
         }
     }
     // build default
     if (!$theme || $theme == 'default') {
         self::buildVars('', 'ltr');
         // compile default
         foreach ($files as $file) {
             $less->compileCss($lesspath . $file . '.less', $csspath . $file . '.css');
         }
     }
     // build themes
     if (!$theme) {
         // get themes
         $themes = JFolder::folders(JPATH_ROOT . '/' . $lesspath . '/themes');
     } else {
         $themes = $theme != 'default' ? (array) $theme : array();
     }
     if (is_array($themes)) {
         foreach ($themes as $t) {
             self::buildVars($t, 'ltr');
             // compile
             foreach ($files as $file) {
                 $less->compileCss($lesspath . $file . '.less', $csspath . 'themes/' . $t . '/' . $file . '.css');
             }
         }
     }
     // compile rtl css
     $tplparams = T3::getTplParams();
     if ($tplparams && $tplparams->get('build_rtl', 0)) {
         // compile default
         if (!$theme || $theme == 'default') {
             self::buildVars('', 'rtl');
             foreach ($files as $file) {
                 $less->compileCss($lesspath . $file . '.less', $csspath . 'rtl/' . $file . '.css');
             }
         }
         if (is_array($themes)) {
             // rtl for themes
             foreach ($themes as $t) {
                 self::buildVars($t, 'rtl');
                 // compile
                 foreach ($files as $file) {
                     $less->compileCss($lesspath . $file . '.less', $csspath . 'rtl/' . $t . '/' . $file . '.css');
                 }
             }
         }
     }
 }