Example #1
0
 /**
  * Method to preprocess the form
  *
  * @param   JForm   $form   A form object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @since   3.2
  * @throws  Exception if there is an error loading the form.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.path');
     $lang = JFactory::getLanguage();
     $module = $this->getState()->get('module.name');
     $basePath = JPATH_BASE;
     $formFile = JPath::clean($basePath . '/modules/' . $module . '/' . $module . '.xml');
     // Load the core and/or local language file(s).
     $lang->load($module, $basePath, null, false, true) || $lang->load($module, $basePath . '/modules/' . $module, null, false, true);
     if (file_exists($formFile)) {
         // Get the module form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         // Attempt to load the xml file.
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the default advanced params
     JForm::addFormPath(JPATH_BASE . '/components/com_config/model/form');
     $form->loadFile('modules_advanced', false);
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Example #2
0
 /**
  * Method to preprocess the form
  *
  * @param   JForm   $form   A form object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  Plugin group to load
  *
  * @return  void
  *
  * @since   3.2
  * @throws	Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $lang = JFactory::getLanguage();
     $template = JFactory::getApplication()->getTemplate();
     jimport('joomla.filesystem.path');
     // Load the core and/or local language file(s).
     $lang->load('tpl_' . $template, JPATH_BASE, null, false, true) || $lang->load('tpl_' . $template, JPATH_BASE . '/templates/' . $template, null, false, true);
     // Look for com_config.xml, which contains fileds to display
     $formFile = JPath::clean(JPATH_BASE . '/templates/' . $template . '/com_config.xml');
     if (!file_exists($formFile)) {
         // If com_config.xml not found, fall back to templateDetails.xml
         $formFile = JPath::clean(JPATH_BASE . '/templates/' . $template . '/templateDetails.xml');
     }
     if (file_exists($formFile)) {
         // Get the template form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Attempt to load the xml file.
     if (!($xml = simplexml_load_file($formFile))) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }