Ejemplo n.º 1
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;
 }
Ejemplo 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;
 }