/** * * 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; }