/** * Method to get a form object. * * @return mixed A JForm object on success, false on failure. * @since 1.6 */ public function getForm() { // Get the form. $form = parent::getForm('application', 'com_config.application', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } return $form; }
/** * Method to get the record form. * * @return mixed JForm object on success, false on failure. */ public function getForm() { // Initialise variables. $app = JFactory::getApplication(); // Get the form. $form = parent::getForm('config', 'com_messages.config', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } return $form; }
/** * Method to get the record form. * * @return mixed JForm object on success, false on failure. * @since 1.6 */ public function getForm() { // Get the form. $form = parent::getForm('download', 'com_banners.download', array('array' => 'jform')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } $form->setValue('basename', $this->getState('basename')); $form->setValue('compressed', $this->getState('compressed')); return $form; }
/** * Method to get the row form. * * @return mixed JForm object on success, false on failure. */ public function getForm() { // Initialise variables. $app = JFactory::getApplication(); // Get the form. $form = parent::getForm('mail', 'com_users.mail', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } // Check the session for previously entered form data. $data = $app->getUserState('com_users.display.mail.data', array()); // Bind the form data if present. if (!empty($data)) { $form->bind($data); } return $form; }
/** * Method to get a form object. * * @return mixed A JForm object on success, false on failure. * @since 1.6 */ public function getForm() { $option = $this->getState('component.option'); $path = $this->getState('component.path', ''); jimport('joomla.form.form'); if ($path) { // Add the search path for the admin component config.xml file. JForm::addFormPath($path); } else { // Add the search path for the admin component config.xml file. JForm::addFormPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . $option); } // Get the form. $form = parent::getForm('config', 'com_config.component', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } return $form; }
/** * Method to get the registration form. * * The base form is loaded from XML and then an event is fired * for users plugins to extend the form with extra fields. * * @access public * @return mixed JForm object on success, false on failure. * @since 1.0 */ function getForm() { // Get the form. $form = parent::getForm('registration', 'com_users.registration', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } // Get the dispatcher and load the users plugins. $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('users'); // Trigger the form preparation event. $results = $dispatcher->trigger('onPrepareUserRegistrationForm', array(&$form)); // Check for errors encountered while preparing the form. if (count($results) && in_array(false, $results, true)) { $this->setError($dispatcher->getError()); return false; } return $form; }
/** * Method to get a form object. * * @access public * @param string $xml The form data. Can be XML string if file flag is set to false. * @param array $options Optional array of parameters. * @param boolean $clear Optional argument to force load a new form. * @return mixed JForm object on success, False on error. */ public function &getForm($xml = 'weblink', $name = 'com_weblinks.weblink', $options = array(), $clear = false) { $options += array('array' => 'jform', 'event' => 'onPrepareForm'); $form = parent::getForm($xml, $name, $options); return $form; }
/** * Method to get a form object for the template params. * * @param string An optional plugin folder. * @param string An options plugin element. * * @return mixed A JForm object on success, false on failure. */ public function getParamsForm($folder = null, $element = null) { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); // Initialise variables. $lang = JFactory::getLanguage(); $form = null; $formName = 'com_plugins.plugin.params'; $formOptions = array('array' => 'jformparams', 'event' => 'onPrepareForm'); if (empty($folder) && empty($element)) { $item = $this->getItem(); $folder = $item->folder; $element = $item->element; } $client = JApplicationHelper::getClientInfo(0); // Try 1.6 format: /plugins/folder/element/element.xml $formFile = JPath::clean($client->path . '/plugins/' . $folder . '/' . $element . '/' . $element . '.xml'); if (!file_exists($formFile)) { // Try 1.5 format: /plugins/folder/element/element.xml $formFile = JPath::clean($client->path . '/plugins/' . $folder . '/' . $element . '.xml'); if (!file_exists($formFile)) { $this->setError(JText::sprintf('JError_File_not_found', $element . '.xml')); return false; } } // Load the core and/or local language file(s). $lang->load('plg_' . $folder . '_' . $element, $client->path . '/plugins/' . $folder . '/' . $element); $lang->load('plg_' . $folder . '_' . $element, JPATH_SITE); $lang->load('plg_' . $folder . '_' . $element, JPATH_ADMINISTRATOR); // 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. $form = parent::getForm($formFile, $formName, $formOptions, true); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } return $form; }
/** * Method to get a form object for the menu item params. * * This is one of the most complicated aspects of the menu item. * If it's an alias, a separator or URL, we just need a simple form for the extra params. * If it's a component, we need to look first for layout, view and component form data. * Then we need to add the component configuration if it's available. Note that hidden fieldset groups * with not display in the menu edit form. * * @param string An optional type (component, url, alias or separator). * @param string An optional link * * @return mixed A JForm object on success, false on failure. * @since 1.6 */ public function getParamsForm($type = null, $link = null) { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); // Initialise variables. $form = null; $formFile = null; $formName = 'com_menus.item.params'; $formOptions = array('array' => 'jformparams', 'event' => 'onPrepareForm'); // Determine the link type. if (empty($type)) { $type = $this->getState('item.type'); } if (empty($link)) { // If the link not supplied, try to load it. if ($item =& $this->getItem()) { $link = htmlspecialchars_decode($item->link); } } // Initialise form with component view params if available. if ($type == 'component') { // Parse the link arguments. $args = array(); parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args); // Confirm that the option is defined. $option = ''; if (isset($args['option'])) { // The option determines the base path to work with. $option = $args['option']; $base = JPATH_SITE . DS . 'components' . DS . $option; } // Confirm a view is defined. 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 . DS . 'views' . DS . $view . DS . 'tmpl' . DS . $layout . '.xml'); if (JFile::exists($path)) { $formFile = $path; } // if custom layout, get the xml file from the template folder // TODO: only look in the template folder for the menu item's template if (!$formFile) { $folders = JFolder::folders(JPATH_SITE . DS . 'templates', '', false, true); foreach ($folders as $folder) { if (JFile::exists($folder . DS . 'html' . DS . $option . DS . $view . DS . $layout . '.xml')) { $formFile = $folder . DS . 'html' . DS . $option . DS . $view . DS . $layout . '.xml'; break; } } } // } // TODO: Now check for a view manifest file // TODO: Now check for a component manifest file } 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. $form = parent::getForm($formFile, $formName, $formOptions, true); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } } // Now load the component params. if ($isNew = false) { $path = JPath::clean(JPATH_ADMINISTRATOR . DS . 'components' . DS . $option . DS . 'config.xml'); } else { $path = 'null'; } if (JFile::exists($path)) { if (empty($form)) { // It's possible the form hasn't been defined yet. $form = parent::getForm($path, $formName, $formOptions, true); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } } else { // Add the component params last of all to the existing form. $form->load($path, true, false); } } } // If no component file found, or not a component, create the form. if (empty($form)) { $form = parent::getForm('item_' . $type, $formName, $formOptions, true); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } } else { $form->load('item_' . $type, true, false); } return $form; }
/** * Method to get the record form. * * @return mixed JForm object on success, false on failure. */ public function getForm() { // Initialise variables. $app = JFactory::getApplication(); // Get the form. $form = parent::getForm('newsfeed', 'com_newsfeeds.newsfeed', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } // Determine correct permissions to check. if ($this->getState('newsfeed.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'); } // Check the session for previously entered form data. $data = $app->getUserState('com_newsfeeds.edit.newsfeed.data', array()); // Bind the form data if present. if (!empty($data)) { $form->bind($data); } return $form; }
/** * Method to get a form object for the module params. * * @param string An optional module folder. * @param int An client id. * * @return mixed A JForm object on success, false on failure. */ public function getParamsForm($module = null, $clientId = null) { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); // Initialise variables. $lang = JFactory::getLanguage(); $form = null; $formName = 'com_modules.module.params'; $formOptions = array('array' => 'jformparams', 'event' => 'onPrepareForm'); if (empty($module) && is_null($clientId)) { $item = $this->getItem(); $clientId = $item->client_id; $module = $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 . '/modules/' . $module); $lang->load($module, $client->path); if (file_exists($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. $form = parent::getForm($formFile, $formName, $formOptions, true); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } } return $form; }
/** * Method to get the record form. * * @return mixed JForm object on success, false on failure. */ public function getForm() { // Initialise variables. $app = JFactory::getApplication(); // Get the form. $form = parent::getForm('user', 'com_users.user', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } // Get the dispatcher and load the users plugins. $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('user'); // Trigger the form preparation event. $results = $dispatcher->trigger('onPrepareUserProfileForm', array($this->getState('user.id'), &$form)); // Check for errors encountered while preparing the form. if (count($results) && in_array(false, $results, true)) { $this->setError($dispatcher->getError()); return false; } // Check the session for previously entered form data. $data = $app->getUserState('com_users.edit.user.data', array()); // Bind the form data if present. if (!empty($data)) { $form->bind($data); } return $form; }
/** * Method to get the row form. * * @return mixed JForm object on success, false on failure. * @since 1.6 */ public function getForm() { // Initialise variables. $app =& JFactory::getApplication(); JImport('joomla.form.form'); JForm::addFieldPath('JPATH_ADMINISTRATOR/components/com_users/models/fields'); // Get the form. $form = parent::getForm('contact', 'com_contact.contact', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } // Check the session for previously entered form data. $data = $app->getUserState('com_contact.edit.contact.data', array()); // Bind the form data if present. if (!empty($data)) { $form->bind($data); } return $form; }
/** * Method to get the row form. * * @return mixed JForm object on success, false on failure. * @since 1.6 */ public function getForm() { // Initialise variables. $app =& JFactory::getApplication(); // Get the form. $form = parent::getForm('category', 'com_categories.category', array('array' => 'jform', 'event' => 'onPrepareForm')); // Check for an error. if (JError::isError($form)) { $this->setError($form->getMessage()); return false; } // Set the access control rules field compoennt value. $form->setFieldAttribute('rules', 'component', $this->getState('category.extension')); // Check the session for previously entered form data. $data = $app->getUserState('com_categories.edit.category.data', array()); // Bind the form data if present. if (!empty($data)) { $form->bind($data); } return $form; }