Пример #1
0
 /**
  * Add JA Extended menu parameter in administrator
  *
  * @param   JForm $form   The form to be altered.
  * @param   array $data   The associated data for the form
  *
  * @return  null
  */
 function onContentPrepareForm($form, $data)
 {
     if (defined('CANVAS_PLUGIN')) {
         if (CANVAS::detect() && ($form->getName() == 'com_templates.style' || $form->getName() == 'com_config.templates')) {
             $_form = clone $form;
             $_form->loadFile(CANVAS_PATH . '/params/template.xml', false);
             //custom config in custom/etc/assets.xml
             $cusXml = CANVASPath::getPath('etc/assets.xml');
             if ($cusXml && file_exists($cusXml)) {
                 $_form->loadFile($cusXml, true, '//config');
             }
             // extend parameters
             CANVASBot::prepareForm($form);
             //search for global parameters and store in user state
             $app = JFactory::getApplication();
             $gparams = array();
             foreach ($_form->getGroup('params') as $param) {
                 if ($_form->getFieldAttribute($param->fieldname, 'global', 0, 'params')) {
                     $gparams[] = $param->fieldname;
                 }
             }
             $this->gparams = $gparams;
         }
         $tmpl = CANVAS::detect() ? CANVAS::detect() : (CANVAS::getDefaultTemplate(true) ? CANVAS::getDefaultTemplate(true) : false);
         if ($tmpl) {
             $tplpath = JPATH_ROOT . '/templates/' . (is_object($tmpl) && !empty($tmpl->tplname) ? $tmpl->tplname : $tmpl);
             $formpath = $tplpath . '/etc/form/';
             JForm::addFormPath($formpath);
             $extended = $formpath . $form->getName() . '.xml';
             if (is_file($extended)) {
                 JFactory::getLanguage()->load('tpl_' . $tmpl, JPATH_SITE);
                 $form->loadFile($form->getName(), false);
             }
             // load extra fields for specified module in format com_modules.module.module_name.xml
             if ($form->getName() == 'com_modules.module') {
                 $module = isset($data->module) ? $data->module : '';
                 if (!$module) {
                     $jform = JFactory::getApplication()->input->get("jform", null, 'array');
                     $module = $jform['module'];
                 }
                 $extended = $formpath . $module . '.xml';
                 if (is_file($extended)) {
                     JFactory::getLanguage()->load('tpl_' . $tmpl, JPATH_SITE);
                     $form->loadFile($module, false);
                 }
             }
             //extend extra fields
             CANVASBot::extraFields($form, $data, $tplpath);
         }
     }
 }