english/administrator/components/com_categories/models/category.php
/**
	 * @param	object	A form object.
	 * @param	mixed	The data expected for the form.
	 * @throws	Exception if there is an error loading the form.
	 * @since	1.6
	 */
@param       object  A form object.
@param       mixed   The data expected for the form.
@throws      Exception if there is an error loading the form.
@param object A form object . @param mixed The data expected for the form . @throws Exception if there is an error loading the form .
protected function preprocessForm(JForm $form, $data, $groups = '')
	{
		jimport('joomla.filesystem.path');
		$lang		= JFactory::getLanguage();
		$extension	= $this->getState('category.extension');
		$component	= $this->getState('category.component');
		$section	= $this->getState('category.section');
		jimport('joomla.filesystem.path');
		$name = 'category'.($section ? ('.'.$section):'');
		$path = JPath::clean(JPATH_ADMINISTRATOR."/components/$component/models/forms/$name.xml");
		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'));
			}
		}
		$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));
				if (JError::isError($form)) {
					$this->setError($form->getMessage());
					return false;
				}
			}
		}
		$form->setFieldAttribute('rules', 'component',	$component);
		$form->setFieldAttribute('rules', 'section',	$name);
		parent::preprocessForm($form, $data);
	}
protected function preprocessForm ( JForm $ form , $ data , $ groups = '' ) { jimport ( 'joomla.filesystem.path' ) ; $ lang = JFactory :: getLanguage ( ) ; $ extension = $ this -> getState ( 'category.extension' ) ; $ component = $ this -> getState ( 'category.component' ) ; $ section = $ this -> getState ( 'category.section' ) ; jimport ( 'joomla.filesystem.path' ) ; $ name = 'category' . ( $ section ? ( '.' . $ section ) : '' ) ; $ path = JPath :: clean ( JPATH_ADMINISTRATOR . " /components/ $ component /models/forms/ $ name .xml " ) ; 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' ) ) ; } } $ 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 ) ) ; if ( JError :: isError ( $ form ) ) { $ this -> setError ( $ form -> getMessage ( ) ) ; return false ; } } } $ form -> setFieldAttribute ( 'rules' , 'component' , $ component ) ; $ form -> setFieldAttribute ( 'rules' , 'section' , $ name ) ; parent :: preprocessForm ( $ form , $ data ) ; }
@param       object  A form object.
@param object A form object .
// Initialise variables. // Get the component form if it exists // Looking first in the component models/forms folder // Old way: looking in the component folder // Try to find the component helper. // Check for an error. // Set the access control rules field component value. // Trigger the default form events.