/** * function loadParam * load and re-render parameters * * @return render success or not */ function renderAdmin() { $frwXml = CANVAS_ADMIN_PATH . '/' . CANVAS_ADMIN . '.xml'; $tplXml = CANVAS_TEMPLATE_PATH . '/templateDetails.xml'; $cusXml = CANVASPath::getPath('etc/assets.xml'); $jtpl = CANVAS_ADMIN_PATH . '/admin/tpls/default.php'; if (file_exists($tplXml) && file_exists($jtpl)) { CANVAS::import('depend/canvasform'); //get the current joomla default instance $form = JForm::getInstance('com_templates.style', 'style', array('control' => 'jform', 'load_data' => true)); //wrap $form = new CANVASForm($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(CANVAS_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 CANVASBot::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(CANVAS_TEMPLATE)); $db->setQuery($query); $styles = $db->loadObjectList(); foreach ($styles as $key => &$style) { $style->title = ucwords(str_replace('_', ' ', $style->title)); } $session = JFactory::getSession(); $canvaslock = $session->get('CANVAS.canvaslock', 'overview_params'); $session->set('CANVAS.canvaslock', 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; }
/** * * Show thememagic form */ public static function thememagic($path) { $app = JFactory::getApplication(); $input = $app->input; $isadmin = $app->isAdmin(); if ($isadmin) { $tplparams = CANVAS::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 ? '&canvasstyle=' . $tplparams->get('theme') : ''; if ($isadmin) { $url .= '&canvastmid=' . $input->getCmd('id'); } $assetspath = CANVAS_TEMPLATE_PATH; $themepath = $assetspath . '/less/themes'; if (!class_exists('JRegistryFormatLESS')) { include_once CANVAS_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::_('CANVAS_TM_ASK_ADD_THEME'), 'delTheme' => JText::_('CANVAS_TM_ASK_DEL_THEME'), 'overwriteTheme' => JText::_('CANVAS_TM_ASK_OVERWRITE_THEME'), 'correctName' => JText::_('CANVAS_TM_ASK_CORRECT_NAME'), 'themeExist' => JText::_('CANVAS_TM_EXISTED'), 'saveChange' => JText::_('CANVAS_TM_ASK_SAVE_CHANGED'), 'previewError' => JText::_('CANVAS_TM_PREVIEW_ERROR'), 'unknownError' => JText::_('CANVAS_MSG_UNKNOWN_ERROR'), 'lblCancel' => JText::_('JCANCEL'), 'lblOk' => JText::_('CANVAS_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('canvasaction'); $backurl->delVar('canvastask'); if (!$isadmin) { $backurl->delVar('tm'); $backurl->delVar('themer'); } CANVAS::import('depend/canvasform'); $form = new CANVASForm('thememagic.themer', array('control' => 'canvasform')); $form->load(JFile::read(JFile::exists(CANVAS_TEMPLATE_PATH . '/thememagic.xml') ? CANVAS_TEMPLATE_PATH . '/thememagic.xml' : CANVAS_PATH . '/params/thememagic.xml')); $form->loadFile(CANVAS_TEMPLATE_PATH . '/templateDetails.xml', true, '//config'); $tplform = new CANVASForm('thememagic.overwrite', array('control' => 'canvasform')); $tplform->loadFile(CANVAS_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 CANVAS_ADMIN_PATH . '/admin/thememagic/thememagic.tpl.php'; exit; }