Exemplo n.º 1
0
 /**
  * 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;
 }