Пример #1
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since    3.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'jevents')
 {
     // Association content items
     $app = JFactory::getApplication();
     $assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_article');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
Пример #2
0
 protected function preprocessForm(JForm $form, $data, $groups = '')
 {
     $obj = is_array($data) ? JArrayHelper::toObject($data, 'JObject') : $data;
     if (isset($obj->alias) && $obj->id > 0) {
         $form->setFieldAttribute('type', 'readonly', 'true');
     }
     parent::preprocessForm($form, $data);
 }
Пример #3
0
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $parts = explode('.', JFactory::getApplication()->input->getCmd('context', $this->getState('field.context')));
     $component = $parts[0];
     if (isset($data->type)) {
         $this->loadTypeForms($form, $data->type, $component);
         $form->setFieldAttribute('type', 'component', $component);
         // Setting the context for the category field
         $cat = JCategories::getInstance(str_replace('com_', '', $component));
         if ($cat && $cat->get('root')->hasChildren()) {
             $form->setFieldAttribute('catid', 'extension', $component);
         } else {
             $form->removeField('catid');
         }
         // Not alowed to change the type of an existing record
         if ($data->id) {
             $form->setFieldAttribute('type', 'readonly', 'true');
         }
     }
     $form->setFieldAttribute('type', 'component', $component);
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #4
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   1.6
  * @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();
     $clientId = $this->getState('item.client_id');
     $module = $this->getState('item.module');
     $client = JApplicationHelper::getClientInfo($clientId);
     $formFile = JPath::clean($client->path . '/modules/' . $module . '/' . $module . '.xml');
     // Load the core and/or local language file(s).
     $lang->load($module, $client->path, null, false, true) || $lang->load($module, $client->path . '/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'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/extension/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
         }
     }
     // Load the default advanced params
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/models/forms');
     $form->loadFile('advanced', false);
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #5
0
 /**
  * Method to preprocess the form.
  *
  * @param   JForm   $form    A JForm object.
  * @param   mixed   $data    The data expected for the form.
  * @param   string  $groups  The name of the plugin group to import.
  *
  * @return  void
  *
  * @see     JFormField
  * @since   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.path');
     // Initialise variables.
     $lang = JFactory::getLanguage();
     $extension = $this->getState('category.extension');
     $component = $this->getState('category.component');
     $section = $this->getState('category.section');
     // Get the component form if it exists
     jimport('joomla.filesystem.path');
     $name = 'category' . ($section ? '.' . $section : '');
     // Looking first in the component models/forms folder
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/models/forms/{$name}.xml");
     // Old way: looking in the component folder
     if (!file_exists($path)) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/{$name}.xml");
     }
     if (file_exists($path)) {
         $lang->load($component, JPATH_BASE, null, false, false);
         $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false);
         if (!$form->loadFile($path, false)) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Try to find the component helper.
     $eName = str_replace('com_', '', $component);
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/helpers/category.php");
     if (file_exists($path)) {
         require_once $path;
         $cName = ucfirst($eName) . ucfirst($section) . 'HelperCategory';
         if (class_exists($cName) && is_callable(array($cName, 'onPrepareForm'))) {
             $lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, $lang->getDefault(), false, false);
             call_user_func_array(array($cName, 'onPrepareForm'), array(&$form));
             // Check for an error.
             if ($form instanceof Exception) {
                 $this->setError($form->getMessage());
                 return false;
             }
         }
     }
     // Set the access control rules field component value.
     $form->setFieldAttribute('rules', 'component', $component);
     $form->setFieldAttribute('rules', 'section', $name);
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #6
0
Файл: item.php Проект: akksi/jcg
 /**
  * @param	object	$form	A form object.
  * @param	mixed	$data	The data expected for the form.
  *
  * @return	void
  * @since	1.6
  * @throws	Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // Initialise variables.
     $link = $this->getState('item.link');
     $type = $this->getState('item.type');
     $formFile = false;
     // Initialise form with component view params if available.
     if ($type == 'component') {
         $link = htmlspecialchars_decode($link);
         // Parse the link arguments.
         $args = array();
         parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args);
         // Confirm that the option is defined.
         $option = '';
         $base = '';
         if (isset($args['option'])) {
             // The option determines the base path to work with.
             $option = $args['option'];
             $base = JPATH_SITE . '/components/' . $option;
         }
         // Confirm a view is defined.
         $formFile = false;
         if (isset($args['view'])) {
             $view = $args['view'];
             // Determine the layout to search for.
             if (isset($args['layout'])) {
                 $layout = $args['layout'];
             } else {
                 $layout = 'default';
             }
             $formFile = false;
             // Check for the layout XML file. Use standard xml file if it exists.
             $path = JPath::clean($base . '/views/' . $view . '/tmpl/' . $layout . '.xml');
             if (JFile::exists($path)) {
                 $formFile = $path;
             }
             // if custom layout, get the xml file from the template folder
             // template folder is first part of file name -- template:folder
             if (!$formFile && strpos($layout, ':') > 0) {
                 $temp = explode(':', $layout);
                 $templatePath = JPATH::clean(JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $option . '/' . $view . '/' . $temp[1] . '.xml');
                 if (JFile::exists($templatePath)) {
                     $formFile = $templatePath;
                 }
             }
         }
         //Now check for a view manifest file
         if (!$formFile) {
             $path = JPath::clean($base . '/views/metadata.xml');
             if (JFile::exists($path)) {
                 $formFile = $path;
             } else {
                 //Now check for a component manifest file
                 $path = JPath::clean($base . '/metadata.xml');
                 if (JFile::exists($path)) {
                     $formFile = $path;
                 }
             }
         }
     }
     if ($formFile) {
         // If an XML file was found in the component, load it first.
         // We need to qualify the full path to avoid collisions with component file names.
         if ($form->loadFile($formFile, true, '/metadata') == false) {
             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'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/metadata/layout/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $helpLoc = trim((string) $help[0]['local']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
             $this->helpLocal = $helpLoc == 'true' || $helpLoc == '1' || $helpLoc == 'local' ? true : false;
         }
     }
     // Now load the component params.
     // TODO: Work out why 'fixing' this breaks JForm
     if ($isNew = false) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $option . '/config.xml');
     } else {
         $path = 'null';
     }
     if (JFile::exists($path)) {
         // Add the component params last of all to the existing form.
         if (!$form->load($path, true, '/config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the specific type file
     if (!$form->loadFile('item_' . $type, false, false)) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data);
 }
Пример #7
0
 /**
  * Method to allow derived classes to preprocess the form.
  *
  * @param   JForm   $form   A JForm 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   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $clientId = $this->getState('item.client_id');
     $template = $this->getState('item.template');
     $lang = JFactory::getLanguage();
     $client = JApplicationHelper::getClientInfo($clientId);
     if (!$form->loadFile('style_' . $client->name, true)) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     jimport('joomla.filesystem.path');
     $formFile = JPath::clean($client->path . '/templates/' . $template . '/templateDetails.xml');
     // Load the core and/or local language file(s).
     $lang->load('tpl_' . $template, $client->path, null, false, true) || $lang->load('tpl_' . $template, $client->path . '/templates/' . $template, null, false, true);
     if (file_exists($formFile)) {
         // Get the template form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Disable home field if it is default style
     if (is_array($data) && array_key_exists('home', $data) && $data['home'] == '1' || is_object($data) && isset($data->home) && $data->home == '1') {
         $form->setFieldAttribute('home', 'readonly', 'true');
     }
     // Attempt to load the xml file.
     if (!($xml = simplexml_load_file($formFile))) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Get the help data from the XML file if present.
     $help = $xml->xpath('/extension/help');
     if (!empty($help)) {
         $helpKey = trim((string) $help[0]['key']);
         $helpURL = trim((string) $help[0]['url']);
         $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
         $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #8
0
 protected function preprocessForm(JForm $form, $data, $group = 'plugin')
 {
     // Figure out the provider/channel selected.. either from the request or from the saved table data
     if (empty($data)) {
         $jform = JFactory::getApplication()->input->post->get('jform', array(), 'array');
         $provider = isset($jform['provider']) ? $jform['provider'] : null;
         $type = isset($jform['type']) ? $jform['type'] : null;
     } else {
         $provider = isset($data->provider) ? $data->provider : null;
         $type = isset($data->type) ? $data->type : null;
     }
     if ($provider && $type) {
         JForm::addFieldPath(JPATH_SITE . '/components/com_jfbconnect/libraries/provider/' . $provider . '/channel/fields');
         $formFile = JPATH_SITE . '/components/com_jfbconnect/libraries/provider/' . $provider . '/channel/' . $type . '_outbound.xml';
         if (file_exists($formFile)) {
             if (!$form->loadFile($formFile, false)) {
                 throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
             }
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #9
0
 /**
  * @param	object	$form	A form object.
  * @param	mixed	$data	The data expected for the form.
  *
  * @return	void
  * @since	1.6
  * @throws	Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Initialise variables.
     $link = $this->getState('item.link');
     $type = $this->getState('item.type');
     $formFile = false;
     // Initialise form with component view params if available.
     if ($type == 'component') {
         $link = htmlspecialchars_decode($link);
         // Parse the link arguments.
         $args = array();
         parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args);
         // Confirm that the option is defined.
         $option = '';
         $base = '';
         if (isset($args['option'])) {
             // The option determines the base path to work with.
             $option = $args['option'];
             $base = JPATH_SITE . '/components/' . $option;
         }
         // Confirm a view is defined.
         $formFile = false;
         if (isset($args['view'])) {
             $view = $args['view'];
             // Determine the layout to search for.
             if (isset($args['layout'])) {
                 $layout = $args['layout'];
             } else {
                 $layout = 'default';
             }
             $formFile = false;
             // Check for the layout XML file. Use standard xml file if it exists.
             $path = JPath::clean($base . '/views/' . $view . '/tmpl/' . $layout . '.xml');
             if (JFile::exists($path)) {
                 $formFile = $path;
             }
             // if custom layout, get the xml file from the template folder
             // template folder is first part of file name -- template:folder
             if (!$formFile && strpos($layout, ':') > 0) {
                 $temp = explode(':', $layout);
                 $templatePath = JPATH::clean(JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $option . '/' . $view . '/' . $temp[1] . '.xml');
                 if (JFile::exists($templatePath)) {
                     $formFile = $templatePath;
                 }
             }
         }
         //Now check for a view manifest file
         if (!$formFile) {
             if (isset($view) && JFile::exists($path = JPath::clean($base . '/views/' . $view . '/metadata.xml'))) {
                 $formFile = $path;
             } else {
                 //Now check for a component manifest file
                 $path = JPath::clean($base . '/metadata.xml');
                 if (JFile::exists($path)) {
                     $formFile = $path;
                 }
             }
         }
     }
     if ($formFile) {
         // If an XML file was found in the component, load it first.
         // We need to qualify the full path to avoid collisions with component file names.
         if ($form->loadFile($formFile, true, '/metadata') == false) {
             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'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/metadata/layout/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $helpLoc = trim((string) $help[0]['local']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
             $this->helpLocal = $helpLoc == 'true' || $helpLoc == '1' || $helpLoc == 'local' ? true : false;
         }
     }
     // Now load the component params.
     // TODO: Work out why 'fixing' this breaks JForm
     if ($isNew = false) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $option . '/config.xml');
     } else {
         $path = 'null';
     }
     if (JFile::exists($path)) {
         // Add the component params last of all to the existing form.
         if (!$form->load($path, true, '/config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the specific type file
     if (!$form->loadFile('item_' . $type, false, false)) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Association menu items
     if (JFactory::getApplication()->get('menu_associations', 0)) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new JXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_MENUS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if ($tag != $data['language']) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'menuitem');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $option = $field->addChild('option', 'COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE');
                 $option->addAttribute('value', '');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data);
 }
 /**
  * @param    object $form A form object.
  * @param    mixed  $data The data expected for the form.
  *
  * @return    void
  * @since       1.1.0
  * @throws    Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $contentTypeID = $this->getState($this->getName() . '.content_type_id', 0);
     if ($contentTypeID) {
         $isNew = !(bool) $this->getState($this->getName() . '.id', 0);
         $fieldsForm = new KextensionsForm($form->getName());
         $fieldsData = FieldsandfiltersFieldsHelper::getFieldsByTypeIDColumnFieldType($contentTypeID);
         $fieldsForm->setPath('filters');
         $fieldsetXML = new SimpleXMLElement('<fieldset />');
         $fieldsetXML->addAttribute('name', 'fieldsandfilters');
         JPluginHelper::importPlugin('fieldsandfilterstypes');
         // Trigger the onFieldsandfiltersPrepareFormField event.
         JFactory::getApplication()->triggerEvent('onFieldsandfiltersPrepareFormField', array($fieldsForm, $fieldsData, $isNew));
         if ($fieldsFormXML = $fieldsForm->getFormFields()) {
             // Load the XML Helper
             KextensionsXML::setFields($fieldsetXML, $fieldsFormXML);
             $form->setField($fieldsetXML, 'fields');
             if ($default = $fieldsForm->getData()) {
                 $form->bind($default);
             }
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #11
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   1.6
  * @throws  Exception if there is an error loading the form.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Initialise variables.
     $lang = Lang::getRoot();
     $clientId = $this->getState('item.client_id');
     $module = $this->getState('item.module');
     $client = \Hubzero\Base\ClientManager::client($clientId);
     //$formFile = JPath::clean($client->path.'/modules/'.$module.'/'.$module.'.xml');
     $formFile = null;
     $patha = JPath::clean(PATH_APP . '/modules/' . $module . '/' . $module . '.xml');
     $pathc = JPath::clean(PATH_CORE . '/modules/' . $module . '/' . $module . '.xml');
     if (file_exists($patha)) {
         $formFile = $patha;
     } elseif (file_exists($pathc)) {
         $formFile = $pathc;
     }
     // Load the core and/or local language file(s).
     $lang->load($module, PATH_APP . '/bootstrap/' . $client->name, null, false, true) || $lang->load($module, PATH_APP . '/modules/' . $module, null, false, true) || $lang->load($module, PATH_CORE . '/modules/' . $module, null, false, true);
     if ($formFile) {
         // Get the module form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
         }
         // Attempt to load the xml file.
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/extension/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #12
0
 protected function preprocessForm(\JForm $form, $data, $group = 'content')
 {
     // if no data, grab the posted form data.
     if (!$data instanceof JObject) {
         $data = JFactory::getApplication()->input->get('jform', $data, 'array');
         $data = JArrayHelper::toObject($data);
     }
     $params = new JRegistry();
     $params->loadArray($data->params);
     if ($params->get('discovery.url')) {
         $plugin = $params->get('discovery.type');
         $language = JFactory::getLanguage();
         $language->load('plg_harvest_' . $plugin);
         $path = JPATH_ROOT . '/plugins/harvest/' . $plugin . '/forms/harvest.xml';
         $form->loadFile($path, false);
         foreach (JPluginHelper::getPlugin('ingest') as $plugin) {
             $language->load('plg_ingest_' . $plugin->name);
             $path = JPATH_ROOT . '/plugins/ingest/' . $plugin->name . '/forms/ingest.xml';
             $form->loadFile($path, false);
         }
         $form->removeField('originating_url');
         $form->removeField('harvester');
         // hide the run_once value (users cannot set it after discovery)
         $form->setFieldAttribute("run_once", 'type', 'hidden');
         $form->setFieldAttribute("run_once", 'class', '');
     } else {
         $form->removeField('state');
         $form->removeField('harvested');
         $form->removeField('url', 'params.discovery');
         $form->removeField('type', 'params.discovery');
     }
     parent::preprocessForm($form, $data, $group);
 }
Пример #13
0
 /**
  * Method to allow derived classes to preprocess the form.
  *
  * @access	protected
  * @param	JForm	$form	A JForm 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	12.2
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $baseFolder = JPATH_COMPONENT . DS . 'fork' . DS . 'models' . DS . 'forms';
     $formFile = $baseFolder . DS . $this->view_item . '.xml';
     if (file_exists($formFile)) {
         $xml = simplexml_load_file($formFile);
         $form->load($xml, true);
     }
     parent::preprocessForm($form, $data, $group);
 }
Пример #14
0
 /**
  * Override JModelAdmin::preprocessForm to ensure the correct plugin group is loaded.
  *
  * @param   JForm   $form   A JForm 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   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $plugin_type = '_none_');
     // by default content plugins are imported, skip them
 }
Пример #15
0
 protected function preprocessForm(JForm $form, $data, $group = 'djclassifiedsshipping')
 {
     return parent::preprocessForm($form, $data, $group);
 }
Пример #16
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param \JForm $form
  * @param mixed  $data
  * @param string $group
  *
  * @since    1.3.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'sichtweiten')
 {
     parent::preprocessForm($form, $data, $group);
 }
Пример #17
0
 /**
  * @param	object	A form object.
  * @param	mixed	The data expected for the form.
  * @return	mixed	True if successful.
  * @throws	Exception if there is an error in the form event.
  * @since	1.6
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // Initialise variables.
     $folder = $this->getState('item.folder');
     $element = $this->getState('item.element');
     $lang = JFactory::getLanguage();
     $client = JApplicationHelper::getClientInfo(0);
     // Load the core and/or local language sys file(s) for the ordering field.
     $db = JFactory::getDbo();
     $query = 'SELECT element' . ' FROM #__extensions' . ' WHERE (type =' . $db->Quote('plugin') . 'AND folder=' . $db->Quote($folder) . ')';
     $db->setQuery($query);
     $elements = $db->loadColumn();
     foreach ($elements as $elementa) {
         $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_PLUGINS . '/' . $folder . '/' . $elementa, null, false, true);
     }
     if (empty($folder) || empty($element)) {
         $app = JFactory::getApplication();
         $app->redirect(JRoute::_('index.php?option=com_plugins&view=plugins', false));
     }
     // Try 1.6 format: /plugins/folder/element/element.xml
     $formFile = JPath::clean(JPATH_PLUGINS . '/' . $folder . '/' . $element . '/' . $element . '.xml');
     if (!file_exists($formFile)) {
         // Try 1.5 format: /plugins/folder/element/element.xml
         $formFile = JPath::clean(JPATH_PLUGINS . '/' . $folder . '/' . $element . '.xml');
         if (!file_exists($formFile)) {
             throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $element . '.xml'));
             return false;
         }
     }
     // Load the core and/or local language file(s).
     $lang->load('plg_' . $folder . '_' . $element, JPATH_ADMINISTRATOR, null, false, true) || $lang->load('plg_' . $folder . '_' . $element, JPATH_PLUGINS . '/' . $folder . '/' . $element, null, false, true);
     if (file_exists($formFile)) {
         // Get the plugin 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'));
     }
     // Get the help data from the XML file if present.
     $help = $xml->xpath('/extension/help');
     if (!empty($help)) {
         $helpKey = trim((string) $help[0]['key']);
         $helpURL = trim((string) $help[0]['url']);
         $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
         $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #18
0
 /**
  * Method to preprocess the form.
  *
  * @param   JForm   $form   A JForm object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import.
  *
  * @return  void
  *
  * @see     JFormField
  * @since   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'playjoom')
 {
     jimport('joomla.filesystem.path');
     // Set the access control rules field component value.
     $form->setFieldAttribute('rules', 'component', 'com_playjoom');
     $form->setFieldAttribute('rules', 'section', 'audiotrack');
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #19
0
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $wgtype = $this->getState('item.wgtype');
     $lang = JFactory::getLanguage();
     $client = JApplicationHelper::getClientInfo($this->getState('filter.client_id', 0));
     $formFile = JPath::clean($client->path . '/administrator/components/com_bt_socialconnect/widgets/' . $wgtype . '/' . $wgtype . '.xml');
     $language_tag = 'en-GB';
     $lang->load($wgtype, $client->path, null, false, false) || $lang->load($wgtype, $client->path . '/administrator/components/com_bt_socialconnect/widgets/' . $wgtype, $language_tag, true) || $lang->load($wgtype, $client->path, $lang->getDefault(), false, false) || $lang->load($wgtype, $client->path . '/administrator/components/com_bt_socialconnect/widgets/' . $wgtype, $lang->getDefault(), false, false);
     if (file_exists($formFile)) {
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         $help = $xml->xpath('/extension/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
Пример #20
0
 /**
  * A protected method to get a set of ordering conditions.
  *
  * @param   JForm   $form   The form object.
  * @param   array   $data   The data to be injected into the form
  * @param   string  $group  The plugin group to process
  *
  * @return  array  An array of conditions to add to add to ordering queries.
  *
  * @since   1.6
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     if ($this->canCreateCategory()) {
         $form->setFieldAttribute('catid', 'allowAdd', 'true');
     }
     // Association newsfeeds items
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_NEWSFEEDS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_newsfeed');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('select', 'true');
                 $field->addAttribute('new', 'true');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
 /**
  * @param    object $form A form object.
  * @param    mixed  $data The data expected for the form.
  *
  * @return    void
  * @since       1.1.0
  * @throws    Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $data = $data instanceof JRegistry ? $data : new JRegistry($data);
     $fieldType = $data->get('type', $this->getState($this->getName() . '.type'));
     $typeMode = $data->get('type_mode', FieldsandfiltersModes::getModeName($data->get('mode', $this->getState($this->getName() . '.mode')), FieldsandfiltersModes::MODE_NAME_TYPE));
     try {
         if ($fieldType && $typeMode && ($type = FieldsandfiltersFactory::getTypes()->getTypes(true)->get($fieldType))) {
             $path = $type->forms->get($typeMode, new JObject())->get('path');
             $form::addFormPath($path);
             if (!$form->loadFile($typeMode, true, '/metadata/form/*')) {
                 throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
             }
             if ($layoutType = $data->get('params.type.' . $typeMode . '_layout', $this->getState($this->getName() . '.layoutType'))) {
                 $paths = array(JPath::clean(JPATH_PLUGINS . '/' . $type->type . '/' . $type->name . '/tmpl/' . $typeMode));
                 if (strpos($layoutType, ':') > 0 && strpos($layoutType, '_:') !== 0) {
                     list($template, $layoutType) = explode(':', $layoutType);
                     $paths[] = JPATH::clean(JPATH_SITE . '/templates/' . $template . '/html/plg_' . $type->type . '_' . $type->name . '/' . $typeMode);
                 }
                 $path = JPath::find($paths, $layoutType . '.xml');
                 if (is_file($path)) {
                     if (!$form->loadFile($path, true, '/form/*')) {
                         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
                     }
                 }
             }
             // load plugin language
             KextensionsLanguage::load('plg_' . $type->type . '_' . $type->name, JPATH_ADMINISTRATOR);
         }
         $contentTypeId = $data->get('content_type_id', $this->getState($this->getName() . '.content_type_id'));
         $extensionForm = $data->get('extension_form', 'extension');
         // get extension type objet by type id or plugin type
         if ($contentTypeId && ($extension = FieldsandfiltersFactory::getExtensions()->getExtensionsByTypeID($contentTypeId, true, true)->get($contentTypeId))) {
             $path = $extension->forms->get($extensionForm, new JObject())->get('path');
             $form::addFormPath($path);
             if (!$form->loadFile($extensionForm, true, '/metadata/form/*')) {
                 throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
             }
             // load plugin language
             KextensionsLanguage::load('plg_' . $extension->type . '_' . $extension->name, JPATH_ADMINISTRATOR);
         }
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return;
     }
     // overwrite the mode default of the plugin type mode
     $form->setFieldAttribute('mode', 'default', FieldsandfiltersModes::getMode($form->getFieldAttribute('mode', 'value', 'field.text', 'properties')));
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #22
0
 /**
  * Allows preprocessing of the JForm object.
  *
  * @param   JForm   $form   The form object
  * @param   array   $data   The data to be merged into the form object
  * @param   string  $group  The plugin group to be executed
  *
  * @return  void
  *
  * @since    3.6.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     if ($this->canCreateCategory()) {
         $form->setFieldAttribute('catid', 'allowAdd', 'true');
     }
     parent::preprocessForm($form, $data, $group);
 }
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Association content items
     $app = JFactory::getApplication();
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         // force to array (perhaps move to $this->loadFormData())
         $data = (array) $data;
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_CONTACT_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data['language']) || $tag != $data['language']) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_contact');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
Пример #24
0
 /**
  * @param	object	A form object.
  * @param	mixed	The data expected for the form.
  * @return	mixed	True if successful.
  * @throws	Exception if there is an error in the form event.
  * @since	1.6
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // Initialise variables.
     $field_type = $this->getState('field.field_type');
     $client = JApplicationHelper::getClientInfo(0);
     // Try 1.6 format: /plugins/folder/element/element.xml
     $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . $field_type . DS . $field_type . '.xml';
     if (!JFile::exists($pluginpath)) {
         $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . 'core' . DS . 'core.xml';
     }
     if (!file_exists($pluginpath)) {
         throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $field_type . '.xml'));
         return false;
     }
     // Load the core and/or local language file(s).
     /*	$lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, null, false, false)
     		||	$lang->load('plg_'.$folder.'_'.$element, $client->path.'/plugins/'.$folder.'/'.$element, null, false, false)
     		||	$lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
     		||	$lang->load('plg_'.$folder.'_'.$element, $client->path.'/plugins/'.$folder.'/'.$element, $lang->getDefault(), false, false);
     		*/
     if (file_exists($pluginpath)) {
         // Get the plugin form.
         if (!$form->loadFile($pluginpath, false, '//config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Attempt to load the xml file.
     if (!($xml = simplexml_load_file($pluginpath))) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Get the help data from the XML file if present.
     $help = $xml->xpath('/extension/help');
     if (!empty($help)) {
         $helpKey = trim((string) $help[0]['key']);
         $helpURL = trim((string) $help[0]['url']);
         $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
         $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data);
 }
Пример #25
0
 /**
  * Override preprocessForm to load the user plugin group instead of content.
  *
  * @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   1.6
  * @throws  Exception if there is an error loading the form.
  */
 protected function preprocessForm(JForm $form, $data, $group = '')
 {
     $obj = is_array($data) ? JArrayHelper::toObject($data, 'JObject') : $data;
     if (isset($obj->parent_id) && $obj->parent_id == 0 && $obj->id > 0) {
         $form->setFieldAttribute('parent_id', 'type', 'hidden');
         $form->setFieldAttribute('parent_id', 'hidden', 'true');
     }
     parent::preprocessForm($form, $data, 'user');
 }
Пример #26
0
 /**
  * Preprocess the form.
  *
  * @param   JForm   $form   Form object.
  * @param   object  $data   Data object.
  * @param   string  $group  Group name.
  *
  * @return  void
  *
  * @since   3.0.3
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Determine correct permissions to check.
     if ($this->getState('contact.id')) {
         // Existing record. Can only edit in selected categories.
         $form->setFieldAttribute('catid', 'action', 'core.edit');
     } else {
         // New record. Can only create in selected categories.
         $form->setFieldAttribute('catid', 'action', 'core.create');
     }
     if ($this->canCreateCategory()) {
         $form->setFieldAttribute('catid', 'allowAdd', 'true');
     }
     // Association content items
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_CONTACT_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_contact');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
Пример #27
0
 /**
  * Method to preprocess the form.
  *
  * @param   JForm   $form   A JForm object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import.
  *
  * @return  void
  *
  * @see     JFormField
  * @since   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.path');
     $lang = JFactory::getLanguage();
     $component = $this->getState('category.component');
     $section = $this->getState('category.section');
     $extension = JFactory::getApplication()->input->get('extension', null);
     // Get the component form if it exists
     $name = 'category' . ($section ? '.' . $section : '');
     // Looking first in the component models/forms folder
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/models/forms/{$name}.xml");
     // Old way: looking in the component folder
     if (!file_exists($path)) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/{$name}.xml");
     }
     if (file_exists($path)) {
         $lang->load($component, JPATH_BASE, null, false, true);
         $lang->load($component, JPATH_BASE . '/components/' . $component, null, false, true);
         if (!$form->loadFile($path, false)) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Try to find the component helper.
     $eName = str_replace('com_', '', $component);
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/helpers/category.php");
     if (file_exists($path)) {
         require_once $path;
         $cName = ucfirst($eName) . ucfirst($section) . 'HelperCategory';
         if (class_exists($cName) && is_callable(array($cName, 'onPrepareForm'))) {
             $lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, $lang->getDefault(), false, false);
             call_user_func_array(array($cName, 'onPrepareForm'), array(&$form));
             // Check for an error.
             if ($form instanceof Exception) {
                 $this->setError($form->getMessage());
                 return false;
             }
         }
     }
     // Set the access control rules field component value.
     $form->setFieldAttribute('rules', 'component', $component);
     $form->setFieldAttribute('rules', 'section', $name);
     // Association category items
     $assoc = $this->getAssoc();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_CATEGORIES_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_category');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('extension', $extension);
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #28
0
 /**
  * @param	object	A form object.
  * @param	mixed	The data expected for the form.
  * @throws	Exception if there is an error in the form event.
  * @since	1.6
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Initialise variables.
     $clientId = $this->getState('item.client_id');
     $template = $this->getState('item.template');
     $lang = Lang::getRoot();
     $client = \Hubzero\Base\ClientManager::client($clientId);
     if (!$form->loadFile('style_' . $client->name, true)) {
         throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
     }
     $base = PATH_CORE;
     if (is_dir(PATH_APP . '/templates/' . $template)) {
         $base = PATH_APP;
     }
     $formFile = Filesystem::cleanPath($base . '/templates/' . $template . '/templateDetails.xml');
     // Load the core and/or local language file(s).
     $lang->load('tpl_' . $template, $base . '/bootstrap/' . $client->name, null, false, true) || $lang->load('tpl_' . $template, $base . '/templates/' . $template, null, false, true);
     if (file_exists($formFile)) {
         // Get the template form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
         }
     }
     // Disable home field if it is default style
     if (is_array($data) && array_key_exists('home', $data) && $data['home'] == '1' || is_object($data) && isset($data->home) && $data->home == '1') {
         $form->setFieldAttribute('home', 'readonly', 'true');
     }
     // Attempt to load the xml file.
     if (!($xml = simplexml_load_file($formFile))) {
         throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
     }
     // Get the help data from the XML file if present.
     $help = $xml->xpath('/extension/help');
     if (!empty($help)) {
         $helpKey = trim((string) $help[0]['key']);
         $helpURL = trim((string) $help[0]['url']);
         $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
         $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Пример #29
0
 /**
  * Override preprocessForm to load the user plugin group instead of content.
  *
  * @param	object	A form object.
  * @param	mixed	The data expected for the form.
  * @throws	Exception if there is an error in the form event.
  * @since	1.6
  */
 protected function preprocessForm(JForm $form, $data, $group = 'user')
 {
     parent::preprocessForm($form, $data, $group);
 }
Пример #30
0
 /**
  * Method to preprocess the form.
  *
  * @param   JForm   $form   A JForm object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import.
  *
  * @return  void
  *
  * @see     JFormField
  * @since   3.1
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }