Пример #1
1
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
     $this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
     $this->assoc = $this->get('Assoc');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check for tag type
     $this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
     JFactory::getApplication()->input->set('hidemainmenu', true);
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
             // Only allow to select tags with All language or with the forced language.
             $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
Пример #2
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);
 }
Пример #3
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
             // Only allow to select tags with All language or with the forced language.
             $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
Пример #4
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->modules = $this->get('Modules');
     $this->levels = $this->get('ViewLevels');
     $this->state = $this->get('State');
     $this->canDo = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));
     // Check if we're allowed to edit this item
     // No need to check for create, because then the moduletype select is empty
     if (!empty($this->item->id) && !$this->canDo->get('core.edit')) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     parent::display($tpl);
     $this->addToolbar();
 }
Пример #5
0
 /**
  * adds additional fields to the user editing form
  *
  * @param   JForm  $form  The form to be altered.
  * @param   mixed  $data  The associated data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareForm($form, $data)
 {
     $version = new JVersion();
     if (!$version->isCompatible('3.4')) {
         return true;
     }
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     // get form name.
     $name = $form->getName();
     $valid = array('com_content.article', 'com_categories.categorycom_content', 'com_templates.style', 'com_tags.tag', 'com_banners.banner', 'com_contact.contact', 'com_newsfeeds.newsfeed');
     // only allow some forms :(
     if (!in_array($name, $valid)) {
         return true;
     }
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     if ($user->getParam('editor', $config->get('editor')) !== "jce") {
         return true;
     }
     if (!JPluginHelper::getPlugin('editors', 'jce')) {
         return true;
     }
     $link = $this->getLink();
     $hasMedia = false;
     if ($link) {
         $fields = $form->getFieldset();
         foreach ($fields as $field) {
             $type = $field->getAttribute('type');
             if (strtolower($type) === "media") {
                 $name = $field->getAttribute('name');
                 $group = (string) $field->group;
                 $form->setFieldAttribute($name, 'link', $link, $group);
                 $form->setFieldAttribute($name, 'class', 'input-large wf-media-input', $group);
                 $hasMedia = true;
             }
         }
         if ($hasMedia) {
             // Include jQuery
             JHtml::_('jquery.framework');
             $document = JFactory::getDocument();
             $document->addScriptDeclaration('jQuery(document).ready(function($){$(".wf-media-input").removeAttr("readonly");});');
         }
     }
     return true;
 }
Пример #6
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);
 }
Пример #7
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() == 'modal') {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
         $this->form->setFieldAttribute('catid', 'readonly', 'true');
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Пример #8
0
 /**
  * @param	int $userId		The user id
  * @param	JForm $form
  *
  * @return	boolean
  */
 function onPrepareUserProfileForm($userId, &$form)
 {
     // Add the profile fields to the form.
     JForm::addFormPath(dirname(__FILE__) . DS . 'profiles');
     $form->load('profile', true, false);
     // Toggle whether the address1 field is required.
     if ($this->params->get('profile-require_address1', 1) > 0) {
         $form->setFieldAttribute('address1', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('address1', 'profile');
     }
     // Toggle whether the address2 field is required.
     if ($this->params->get('profile-require_address2', 1) > 0) {
         $form->setFieldAttribute('address2', 'required', $this->params->get('profile-require_address2') == 2, 'profile');
     } else {
         $form->removeField('address2', 'profile');
     }
     // Toggle whether the city field is required.
     if ($this->params->get('profile-require_city', 1) > 0) {
         $form->setFieldAttribute('city', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('city', 'profile');
     }
     // Toggle whether the region field is required.
     if ($this->params->get('profile-require_region', 1) > 0) {
         $form->setFieldAttribute('region', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('region', 'profile');
     }
     // Toggle whether the country field is required.
     if ($this->params->get('profile-require_country', 1) > 0) {
         $form->setFieldAttribute('country', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('country', 'profile');
     }
     // Toggle whether the postal code field is required.
     if ($this->params->get('profile-require_postal_code', 1) > 0) {
         $form->setFieldAttribute('postal_code', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('postal_code', 'profile');
     }
     // Toggle whether the phone field is required.
     if ($this->params->get('profile-require_phone', 1) > 0) {
         $form->setFieldAttribute('phone', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('phone', 'profile');
     }
     // Toggle whether the website field is required.
     if ($this->params->get('profile-require_website', 1) > 0) {
         $form->setFieldAttribute('website', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
     } else {
         $form->removeField('website', 'profile');
     }
     return true;
 }
Пример #9
0
 protected function preprocessForm(JForm $form, $data, $group = 'contact')
 {
     $userParams = JComponentHelper::getParams('com_contact');
     // Deal with captcha
     $captcha = $userParams->get('captcha', '0');
     if ($captcha === '0') {
         $form->removeField('captcha');
     } else {
         $form->setFieldAttribute('captcha', 'plugin', $captcha);
     }
     parent::preprocessForm($form, $data, 'user');
 }
Пример #10
0
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_djcatalog2');
     $user = JFactory::getUser();
     $switchable_fields = array('contact_phone', 'contact_street', 'contact_city', 'contact_zip', 'contact_country', 'contact_company_name', 'contact_email_copy');
     foreach ($switchable_fields as $field_name) {
         if ($params->get($field_name . '_field', '0') == '0') {
             $form->removeField($field_name);
         } else {
             if ($params->get($field_name . '_field', '0') == '2') {
                 $form->setFieldAttribute($field_name, 'required', 'required');
                 $form->setFieldAttribute($field_name, 'class', $form->getFieldAttribute($field_name, 'class') . ' required');
             }
         }
     }
     $plugin = JFactory::getApplication()->getParams()->get('contact_captcha', JFactory::getConfig()->get('captcha'));
     if ($user->id > 0 || ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null)) {
         $form->removeField('captcha');
     } else {
         $form->setFieldAttribute('captcha', 'plugin', $plugin, 'captcha');
     }
 }
Пример #11
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
     $this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
     $this->assoc = $this->get('Assoc');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check for tag type
     $this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
     JFactory::getApplication()->input->set('hidemainmenu', true);
     if ($this->getLayout() == 'modal') {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
         $this->form->setFieldAttribute('parent_id', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
Пример #12
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() == 'pagebreak') {
         // TODO: This is really dogy - should change this one day.
         $eName = JFactory::getApplication()->input->getCmd('e_name');
         $eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName);
         $this->document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
         $this->eName =& $eName;
         return parent::display($tpl);
     }
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = JHelperContent::getActions('com_content', 'article', $this->item->id);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
             // Only allow to select tags with All language or with the forced language.
             $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
Пример #13
0
 /**
  * This function displays the newsletter form on the user profile
  *
  * @param   JForm  $form  - the user form
  * @param   array  $data  - the user data
  *
  * @return bool
  */
 public function edit($form, $data)
 {
     $appl = JFactory::getApplication();
     $subscriptionData = CmcHelperUsers::getSubscription($data->email, $this->params->get('listid'));
     $renderer = CmcHelperXmlbuilder::getInstance($this->params);
     // Render Content
     $html = $renderer->build();
     if ($appl->isSite()) {
         CompojoomHtmlBehavior::jquery();
         JHtml::script('media/plg_user_cmc/js/cmc.js');
     }
     // Inject fields into the form
     $form->load($html, false);
     if ($subscriptionData) {
         $form->setFieldAttribute('newsletter', 'checked', 'checked', 'cmc');
         $form->bind(CmcHelperSubscription::convertMergesToFormData($subscriptionData->merges));
     }
 }
 function onContentPrepareForm(JForm $form, $data)
 {
     $name = $form->getName();
     if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
         return true;
     }
     // Add the extra fields
     JForm::addFormPath(dirname(__FILE__) . '/profiles');
     $form->loadFile('profile', false);
     // If we're admin we can do some extra things
     if ($name != "com_users.user") {
         $form->setFieldAttribute("programmename", "readonly", true, "swg_extras");
         // 			$form->setFieldAttrib("leaderid", "readonly", )
         $form->removeField("leaderid", "swg_extras");
         $form->removeField("leadersetup", "swg_extras");
     }
     return true;
 }
Пример #15
0
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $template = $this->getState('template.template');
     $lang = JFactory::getLanguage();
     $template_path = COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template;
     jimport('joomla.filesystem.path');
     $formFile = JPath::clean($template_path . DIRECTORY_SEPARATOR . 'template.xml');
     // Load the core and/or local language file(s).
     $lang->load('tpl_' . $template, $template_path, null, false, true) || $lang->load('tpl_' . $template, $template_path . '/templates/' . $template, null, false, true);
     $default_directory = 'components' . DIRECTORY_SEPARATOR . 'com_tz_portfolio_plus' . DIRECTORY_SEPARATOR . 'templates';
     $directory = $default_directory . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'html';
     if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . $directory)) {
         $form->setFieldAttribute('layout', 'directory', $directory, 'params');
     } elseif (is_array($data) && array_key_exists('protected', $data) && $data['protected'] == 1 || is_object($data) && isset($data->protected) && $data->protected == 1) {
         $form->removeField('layout', 'params');
     } else {
         $form->removeField('layout', 'params');
     }
     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);
 }
Пример #16
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         ContactHelper::addSubmenu('contacts');
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Preprocess the list of items to find ordering divisions.
     // TODO: Complete the ordering stuff with nested sets
     foreach ($this->items as &$item) {
         $item->order_up = true;
         $item->order_dn = true;
     }
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
     } else {
         // In article associations modal we need to remove language filter if forcing a language.
         // We also need to change the category filter to show show categories with All or the forced language.
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD')) {
             // If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
             $languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
             $this->filterForm->setField($languageXml, 'filter', true);
             // Also, unset the active language filter so the search tools is not open by default with this filter.
             unset($this->activeFilters['language']);
             // One last changes needed is to change the category filter to just show categories with All language or with the forced language.
             $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
         }
     }
     return parent::display($tpl);
 }
Пример #17
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         ContentHelper::addSubmenu('articles');
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->authors = $this->get('Authors');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     $this->vote = JPluginHelper::isEnabled('content', 'vote');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Levels filter - Used in Hathor.
     $this->f_levels = array(JHtml::_('select.option', '1', JText::_('J1')), JHtml::_('select.option', '2', JText::_('J2')), JHtml::_('select.option', '3', JText::_('J3')), JHtml::_('select.option', '4', JText::_('J4')), JHtml::_('select.option', '5', JText::_('J5')), JHtml::_('select.option', '6', JText::_('J6')), JHtml::_('select.option', '7', JText::_('J7')), JHtml::_('select.option', '8', JText::_('J8')), JHtml::_('select.option', '9', JText::_('J9')), JHtml::_('select.option', '10', JText::_('J10')));
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
     } else {
         // In article associations modal we need to remove language filter if forcing a language.
         // We also need to change the category filter to show show categories with All or the forced language.
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD')) {
             // If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
             $languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
             $this->filterForm->setField($languageXml, 'filter', true);
             // Also, unset the active language filter so the search tools is not open by default with this filter.
             unset($this->activeFilters['language']);
             // One last changes needed is to change the category filter to just show categories with All language or with the forced language.
             $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
         }
     }
     return parent::display($tpl);
 }
Пример #18
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');
 }
Пример #19
0
 /**
  * Method to validate the form data.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  * @since   12.2
  */
 public function validate($form, $data, $group = null)
 {
     // check if the not_required field is set
     if (DemoHelper::checkString($data['not_required'])) {
         $requiredFields = (array) explode(',', (string) $data['not_required']);
         $requiredFields = array_unique($requiredFields);
         // now change the required field attributes value
         foreach ($requiredFields as $requiredField) {
             // make sure there is a string value
             if (DemoHelper::checkString($requiredField)) {
                 // change to false
                 $form->setFieldAttribute($requiredField, 'required', 'false');
                 // also clear the data set
                 $data[$requiredField] = '';
             }
         }
     }
     return parent::validate($form, $data, $group);
 }
Пример #20
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);
 }
 /**
  * @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
 /**
  * @param	JForm	$form	The form to be altered.
  * @param	array	$data	The associated data for the form.
  *
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareForm($form, $data)
 {
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     if (!JHtml::isRegistered('users.url')) {
         JHtml::register('users.url', array(__CLASS__, 'url'));
     }
     if (!JHtml::isRegistered('users.calendar')) {
         JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
     }
     if (!JHtml::isRegistered('users.tos')) {
         JHtml::register('users.tos', array(__CLASS__, 'tos'));
     }
     // Check we are manipulating a valid form.
     $context = $form->getName();
     // The frontend and backend editor use the same form...
     if (!in_array($context, array('com_content.article'))) {
         return true;
     }
     // Note: The frontend form is generated by a custom view, we
     // have to alter it using template override to use our new fields
     // Load all needed field types (these are provided by the component)
     JForm::addFieldPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields');
     // Add the geotag fields to the form.
     JForm::addFormPath(dirname(__FILE__) . '/geotag');
     $form->loadFile('geotag', false);
     //throw new Exception(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields');
     // Set whether location is requried
     $form->setFieldAttribute('latitude', 'required', $this->params->get('require_location') == 2, 'metadata');
     $form->setFieldAttribute('longitude', 'required', $this->params->get('require_location') == 2, 'metadata');
     return true;
 }
Пример #23
0
 /**
  * @param	JForm	$form	The form to be altered.
  * @param	array	$data	The associated data for the form.
  *
  * @return	boolean
  * @since	1.6
  */
 public function onRoomTypePrepareForm($form, $data)
 {
     // Load solidres plugin language
     $lang = JFactory::getLanguage();
     $lang->load('plg_extension_solidres', JPATH_ADMINISTRATOR);
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     // Check we are manipulating a valid form.
     if (!in_array($form->getName(), array('com_solidres.roomtype'))) {
         return true;
     }
     // Add the registration fields to the form.
     JForm::addFormPath(__DIR__ . '/fields');
     $form->loadFile('roomtype', false);
     // Toggle whether the checkin time field is required.
     if ($this->params->get('param_roomtype_room_facilities', 1) > 0) {
         $form->setFieldAttribute('room_facilities', 'required', $this->params->get('param_roomtype_room_facilities') == 2, 'roomtype_custom_fields');
     } else {
         $form->removeField('room_facilities', 'roomtype_custom_fields');
     }
     // Toggle whether the checkout time field is required.
     if ($this->params->get('param_roomtype_room_size', 1) > 0) {
         $form->setFieldAttribute('room_size', 'required', $this->params->get('param_roomtype_room_size') == 2, 'roomtype_custom_fields');
     } else {
         $form->removeField('room_size', 'roomtype_custom_fields');
     }
     // Toggle whether the cancellation prepayment field is required.
     if ($this->params->get('param_roomtype_bed_size', 1) > 0) {
         $form->setFieldAttribute('bed_size', 'required', $this->params->get('param_roomtype_bed_size') == 2, 'roomtype_custom_fields');
     } else {
         $form->removeField('bed_size', 'roomtype_custom_fields');
     }
     return true;
 }
Пример #24
0
 /**
  * onCCKEngineAfterFormLoad
  *
  * @param \JForm            $form
  * @param array             $data
  * @param \JFormField       $formField
  * @param \SimpleXMLElement $element
  * @param boolean           $form_setted
  *
  * @return  void
  */
 public function onCCKEngineAfterFormLoad($form = null, $data = null, $formField = null, $element = null, $form_setted = false)
 {
     // Add Hide reg field
     $form->loadFile(dirname(__FILE__) . '/form/forms/fields.xml');
     // label do not required
     $form->setFieldAttribute('label', 'required', 'false');
 }
Пример #25
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);
 }
Пример #26
0
 /**
  * @param	JForm	$form	The form to be altered.
  * @param	array	$data	The associated data for the form.
  *
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareForm($form, $data)
 {
     // Load user_profile plugin language
     $lang = JFactory::getLanguage();
     $lang->load('plg_user_profile', JPATH_ADMINISTRATOR);
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     // Check we are manipulating a valid form.
     if (!in_array($form->getName(), array('com_admin.profile', 'com_users.user', 'com_users.registration', 'com_users.profile'))) {
         return true;
     }
     // Add the registration fields to the form.
     JForm::addFormPath(dirname(__FILE__) . '/profiles');
     $form->loadFile('profile', false);
     // Toggle whether the address1 field is required.
     if ($this->params->get('register-require_address1', 1) > 0) {
         $form->setFieldAttribute('address1', 'required', $this->params->get('register-require_address1') == 2, 'profile');
     } else {
         $form->removeField('address1', 'profile');
     }
     // Toggle whether the address2 field is required.
     if ($this->params->get('register-require_address2', 1) > 0) {
         $form->setFieldAttribute('address2', 'required', $this->params->get('register-require_address2') == 2, 'profile');
     } else {
         $form->removeField('address2', 'profile');
     }
     // Toggle whether the city field is required.
     if ($this->params->get('register-require_city', 1) > 0) {
         $form->setFieldAttribute('city', 'required', $this->params->get('register-require_city') == 2, 'profile');
     } else {
         $form->removeField('city', 'profile');
     }
     // Toggle whether the region field is required.
     if ($this->params->get('register-require_region', 1) > 0) {
         $form->setFieldAttribute('region', 'required', $this->params->get('register-require_region') == 2, 'profile');
     } else {
         $form->removeField('region', 'profile');
     }
     // Toggle whether the country field is required.
     if ($this->params->get('register-require_country', 1) > 0) {
         $form->setFieldAttribute('country', 'required', $this->params->get('register-require_country') == 2, 'profile');
     } else {
         $form->removeField('country', 'profile');
     }
     // Toggle whether the postal code field is required.
     if ($this->params->get('register-require_postal_code', 1) > 0) {
         $form->setFieldAttribute('postal_code', 'required', $this->params->get('register-require_postal_code') == 2, 'profile');
     } else {
         $form->removeField('postal_code', 'profile');
     }
     // Toggle whether the phone field is required.
     if ($this->params->get('register-require_phone', 1) > 0) {
         $form->setFieldAttribute('phone', 'required', $this->params->get('register-require_phone') == 2, 'profile');
     } else {
         $form->removeField('phone', 'profile');
     }
     // Toggle whether the website field is required.
     if ($this->params->get('register-require_website', 1) > 0) {
         $form->setFieldAttribute('website', 'required', $this->params->get('register-require_website') == 2, 'profile');
     } else {
         $form->removeField('website', 'profile');
     }
     // Toggle whether the favoritebook field is required.
     if ($this->params->get('register-require_favoritebook', 1) > 0) {
         $form->setFieldAttribute('favoritebook', 'required', $this->params->get('register-require_favoritebook') == 2, 'profile');
     } else {
         $form->removeField('favoritebook', 'profile');
     }
     // Toggle whether the aboutme field is required.
     if ($this->params->get('register-require_aboutme', 1) > 0) {
         $form->setFieldAttribute('aboutme', 'required', $this->params->get('register-require_aboutme') == 2, 'profile');
     } else {
         $form->removeField('aboutme', 'profile');
     }
     // Toggle whether the tos field is required.
     if ($this->params->get('register-require_tos', 1) > 0) {
         $form->setFieldAttribute('tos', 'required', $this->params->get('register-require_tos') == 2, 'profile');
     } else {
         $form->removeField('tos', 'profile');
     }
     // Toggle whether the dob field is required.
     if ($this->params->get('register-require_dob', 1) > 0) {
         $form->setFieldAttribute('dob', 'required', $this->params->get('register-require_dob') == 2, 'profile');
     } else {
         $form->removeField('dob', 'profile');
     }
     return true;
 }
Пример #27
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);
 }
Пример #28
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);
 }
Пример #29
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);
 }
Пример #30
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.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     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_CONTENT_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);
 }