/** * Injects several fields into specific forms. * * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * * @since 2.0 */ public function onContentPrepareForm($form, $data) { // Check we are manipulating a valid form if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check if the password field needs injecting if ($this->params->get('use_ldap_password', false) && in_array($form->getName(), $this->passwordForms)) { // Check if this user should have a profile if (SHLdapHelper::isUserLdap(isset($data->id) ? $data->id : 0)) { if ($this->params->get('ldap_password_layout_edit', true)) { // Check if this is in the 'edit' layout or in the save state if (strtolower(JFactory::getApplication()->input->get('layout')) === 'edit' || strtolower(JFactory::getApplication()->input->get('task')) === 'save') { $form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false); } } else { $form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false); } } } // Check if the domain field needs injecting if ($this->params->get('use_ldap_domain', false) && in_array($form->getName(), $this->domainForms)) { $form->loadFile(realpath(__DIR__) . '/forms/ldap_domain.xml', false, false); } return true; }
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); }
/** * * Enter description here ... * @param JForm $form * @param unknown $data */ function onContentPrepareForm($form, $data) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $this->template = $this->getTemplateName(); if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) { jimport('joomla.filesystem.path'); //JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params'); $plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml'); $tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml'); if (!$plg_file) { return false; } if ($tpl_file) { $form->loadFile($plg_file, false, '//form'); $form->loadFile($tpl_file, false, '//config'); } else { $form->loadFile($plg_file, false, '//form'); } if ($app->isSite()) { $jmstorage_fields = $form->getFieldset('jmstorage'); foreach ($jmstorage_fields as $name => $field) { $form->removeField($name, 'params'); } $form->removeField('config', 'params'); } if ($app->isAdmin()) { $doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}'); } } }
protected function getInput() { $end = $this->element['end']; $styles = $this->element['styles']; $background = $this->element['background'] ? 'background-image: url(' . $this->getPathToImages() . '/images/' . $this->element['background'] . ');' : ''; $tag = $this->element['tag']; if ($end == '1') { // $html = '</li></'.$tag.'><li>'; $html = '</' . $tag . '><div><div>'; } else { // $html = '</li><'.$tag.' style="'.$background.$styles.'" ><li>'; $html = '</div></div><' . $tag . ' style="' . $background . $styles . '" >'; } // var_dump($html); $identifier = 'menustyles'; $form = new JForm($identifier); JForm::addFormPath(JPATH_SITE . '/modules/mod_slideshowck/elements/test'); if (!($formexists = $form->loadFile($identifier, false))) { echo '<p style="color:red">' . JText::_('Problem loading the file : ' . $identifier . '.xml') . '</p>'; return ''; } $fields = $form->getFieldset(); foreach ($fields as $key => $field) { // echo '<div class="ckpopup_row">'; $html .= $form->getLabel(str_replace($identifier . "_", "", $key), $identifier); $html .= $form->getInput(str_replace($identifier . "_", "", $key), $identifier); // echo '</div>'; } return $html; }
/** * Event method that runs on content preparation * * @param JForm $form The form object * @param integer $data The form data * * @return bool */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $name = $form->getName(); if (!in_array($name, array('com_content.article'))) { return true; } $include_categories = $this->params->get('include_categories'); if (empty($include_categories)) { return true; } if (empty($data)) { $input = JFactory::getApplication()->input; $data = (object) $input->post->get('jform', array(), 'array'); } if (is_array($data)) { jimport('joomla.utilities.arrayhelper'); $data = JArrayHelper::toObject($data); } if (empty($data->catid)) { return true; } if (!in_array($data->catid, $include_categories)) { return true; } JForm::addFormPath(__DIR__ . '/form'); $form->loadFile('form'); if (!empty($data->id)) { $data = $this->loadTest($data); } return true; }
/** * Method to preprocess the form * * @param JForm $form A form object. * @param mixed $data The data expected for the form. * @param string $group The name of the plugin group to import (defaults to "content"). * * @return void * * @since 3.2 * @throws Exception if there is an error loading the form. */ protected function preprocessForm(JForm $form, $data, $group = 'content') { jimport('joomla.filesystem.path'); $lang = JFactory::getLanguage(); $module = $this->getState()->get('module.name'); $basePath = JPATH_BASE; $formFile = JPath::clean($basePath . '/modules/' . $module . '/' . $module . '.xml'); // Load the core and/or local language file(s). $lang->load($module, $basePath, null, false, true) || $lang->load($module, $basePath . '/modules/' . $module, null, false, true); if (file_exists($formFile)) { // Get the module form. if (!$form->loadFile($formFile, false, '//config')) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Attempt to load the xml file. if (!($xml = simplexml_load_file($formFile))) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } } // Load the default advanced params JForm::addFormPath(JPATH_BASE . '/components/com_config/model/form'); $form->loadFile('modules_advanced', false); // Trigger the default form events. parent::preprocessForm($form, $data, $group); }
/** * Override preprocessForm to load the user plugin group instead of content. * * @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 = 'user') { $userParams = JComponentHelper::getParams('com_users'); //Add the choice for site language at registration time if ($userParams->get('site_language') == 1 && $userParams->get('frontend_userparams') == 1) { $form->loadFile('sitelang', false); } }
public static function getForm() { $myForm = new JForm('callback'); // Добавили путь где лежит форма здесь form.xml лежит в корне модуля $myForm->addFormPath(__DIR__); // Прочитали и вернули $myForm->loadFile('form', false); return $myForm; }
/** * Function that gets the config settings * * @return Object */ protected function getAssignments() { if (!isset($this->assignments)) { $xmlfile = JPATH_ADMINISTRATOR . '/components/com_advancedmodules/assignments.xml'; $assignments = new JForm('assignments', array('control' => 'advancedparams')); $assignments->loadFile($xmlfile, 1, '//config'); $assignments->bind($this->item->advancedparams); $this->assignments = $assignments; } return $this->assignments; }
/** * Event onContentPrepareForm * * @param JForm $form * @param array $data * * @return bool */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $context = $form->getName(); if (!in_array($context, $this->allowedContext)) { return true; } JForm::addFormPath(__DIR__ . '/form'); $form->loadFile('form', false); return true; }
/** * Display configurations for registration * * @return void */ public function displayTask() { $config = new \JForm('com_members.registration'); $config->loadFile(dirname(dirname(__DIR__)) . DS . 'config' . DS . 'config.xml', true, '/config'); $config->bind($this->config->toArray()); $this->config = $config; $this->view->params = $config->getFieldset('registration'); // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Output the HTML $this->view->display(); }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean */ public function onContentPrepareForm($form, $data) { 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__) . '/form'); $form->loadFile('socialmetatags', false); return true; }
/** * @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; } // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, array('com_users.registration'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(dirname(__FILE__) . '/forms'); $form->loadFile('hprecaptcha', false); return true; }
/** * Event method that runs on content preparation * * @param JForm $form The form object * @param integer $data The form data * * @return bool */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $name = $form->getName(); if (!in_array($name, array('com_content.article'))) { return true; } JForm::addFormPath(__DIR__ . '/form'); $form->loadFile('form'); if (!empty($data->id)) { $data = $this->loadTest($data); } return true; }
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; }
/** * Method to manipulate the MageBridge Product Relation backend-form * * @param JForm $form The form to be altered * @param JForm $data The associated data for the form * @return boolean */ public function onMageBridgeProductPrepareForm($form, $data) { // Check if this plugin can be used if ($this->isEnabled() == false) { return false; } // Add the plugin-form to main form $formFile = JPATH_SITE . '/plugins/magebridgeproduct/' . $this->_name . '/form/form.xml'; if (file_exists($formFile)) { $form->loadFile($formFile, false); } // Load the original values from the deprecated connector-architecture if (!empty($this->connector_field)) { $pluginName = $this->_name; if (!empty($data['connector']) && !empty($data['connector_value']) && $pluginName == $data['connector']) { $form->bind(array('actions' => array($this->connector_field => $data['connector_value']))); } } }
/** * Default view function * * @return void */ public function displayTask() { // Get scope $this->view->scope = Request::getWord('scope', 'Hub'); $this->view->scope_id = Request::getInt('scope_id', 0); // Get permissions $access = new \JForm('permissions'); $access->loadFile(dirname(dirname(__DIR__)) . DS . 'models' . DS . 'forms' . DS . 'permissions.xml'); // Bind existing rules if applicable $asset = new \JTableAsset($this->database); $name = 'com_time.' . strtolower($this->view->scope) . '.' . $this->view->scope_id; $asset->loadByName($name); if ($asset->get('id')) { $access->setValue('asset_id', null, $asset->get('id')); } $this->view->permissions = $access->getField(strtolower($this->view->scope)); // Display $this->view->display(); }
/** * @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) { // Exit if an admin form if ($this->app->isAdmin()) { return; } 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_contact.contact'))) { return true; } // Add the fields to the form. JForm::addFormPath(dirname(__FILE__) . '/forms'); $form->loadFile('customform', false); return true; }
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); }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ public function onContentPrepareForm($form, $data) { // Get application $application = JFactory::getApplication(); // Get settings $params = JComponentHelper::getParams('com_k2'); // Get form name $name = $form->getName(); // Valid forms $forms = array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'); // Rendering condition if ($application->isSite() && $params->get('K2UserProfile') == 'native' && in_array($name, $forms)) { // Add K2 profile fields to the form JForm::addFormPath(__DIR__ . '/forms'); $form->loadFile('profile', false); } // Return return true; }
protected function getInput() { $identifier = $this->element['identifier']; $form = new JForm($identifier); JForm::addFormPath(JPATH_SITE . '/plugins/system/maximenuckparams/elements/ckstylesmanager'); // $form->load('test.xml'); if (!($formexists = $form->loadFile($identifier, false))) { echo '<p style="color:red">' . JText::_('Problem loading the file : ' . $identifier . '.xml') . '</p>'; return ''; } // $test = $form->getInput('maximenu_colbgcolor333', 'testt'); // fonctionne $this->createFields($form, $identifier, $this->name); $document = JFactory::getDocument(); $document->addScriptDeclaration("JURI='" . JURI::root() . "'"); $path = 'plugins/system/maximenuckparams/elements/ckstylesmanager/'; JHTML::_('behavior.modal'); JHTML::_('script', $path . 'ckstylesmanager.js'); JHTML::_('stylesheet', $path . 'ckstylesmanager.css'); $html = '<input name="' . $this->name . '" id="' . $this->name . '" type="hidden" value="' . $this->value . '" />' . '<input name="' . $this->name . '_button" id="' . $this->name . '_button" class="ckstylesmanager_button" type="button" value="' . JText::_('MOD_MAXIMENUCK_CKSTYLESEDIT_' . strtoupper($identifier)) . '" onclick="javascript:loadStylesCK($(\'ckpopup_' . $identifier . '\'),$(\'' . $this->name . '\'));"/>'; return $html; }
/** * @param JForm $form Joomla XML form * @param array|object $data Form data (j2.5 is array, j3.0 is object, converted to array for easy usage between both) */ public function onContentPrepareForm($form, $data) { if ($form instanceof JForm && $form->getName() == 'com_menus.item') { $data = (array) $data; if (isset($data['request']['option']) && $data['request']['option'] == 'com_comprofiler' && isset($data['request']['view']) && $data['request']['view'] == 'pluginclass') { $element = isset($data['request']['plugin']) ? $data['request']['plugin'] : 'cb.core'; if ($element) { $db = JFactory::getDBO(); $query = 'SELECT ' . $db->quoteName('type') . ', ' . $db->quoteName('folder') . "\n FROM " . $db->quoteName('#__comprofiler_plugin') . "\n WHERE " . $db->quoteName('element') . " = " . $db->quote($element); $db->setQuery($query); $plugin = $db->loadAssoc(); if ($plugin) { $path = JPATH_ROOT . '/components/com_comprofiler/plugin/' . $plugin['type'] . '/' . $plugin['folder'] . '/xml'; if (file_exists($path)) { JForm::addFormPath($path); $form->loadFile('metadata', false); } } } } } }
/** * Add additional field to the user editing form * * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * * @since 1.0.0 */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { throw new RuntimeException(JText::_('JERROR_NOT_A_FORM')); return false; } // Only run in front-end. if (!JFactory::getApplication()->isSite()) { return true; } // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) { return true; } $folder = $this->params->get('folder', ''); $avatarFolder = JPATH_ROOT . '/' . $folder; // If the avatar folder doesn't exist, we don't display the fields. if (!JFolder::exists($avatarFolder)) { return true; } $layout = JFactory::getApplication()->input->get('layout', 'default'); if ($layout != 'default' || $layout == 'default' && $this->params->get('display_avatar_in_profile', 0) == 1) { JForm::addFormPath(__DIR__ . '/profiles'); $form->loadFile('profile', false); } return true; }
/** * 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); }
/** * 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); }
/** * 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); }
/** * @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); }
/** * Add JA Extended menu parameter - used for Joomla 1.6 * * @param JForm $form The form to be altered. * @param array $data The associated data for the form * * @return null */ function onContentPrepareForm($form, $data) { if ($form->getName() == 'com_menus.item') { JForm::addFormPath(JPATH_SITE . DS . T3_CORE . DS . 'params'); $form->loadFile('params', false); } if (T3Common::detect() && !JFactory::getApplication()->isAdmin() && $form->getName() == 'com_config.templates') { JForm::addFormPath(JPATH_SITE . DS . T3_CORE . DS . 'admin'); $form->loadFile('frontedit', false); } }
/** * 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') { if (JComponentHelper::getParams('com_users')->get('frontend_userparams')) { $form->loadFile('frontend', false); if (JFactory::getUser()->authorise('core.login.admin')) { $form->loadFile('frontend_admin', false); } } parent::preprocessForm($form, $data, $group); }
/** * 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); }