english/administrator/components/com_plugins/models/plugin.php
/**
	 * @param	object	A form object.
	 * @param	mixed	The data expected for the form.
	 * @return	mixed	True if successful.
	 * @throws	Exception if there is an error in the form event.
	 * @since	1.6
	 */
@param       object  A form object.
@param       mixed   The data expected for the form.
@return      mixed   True if successful.
@throws      Exception if there is an error in the form event.
@param object A form object . @param mixed The data expected for the form . @return mixed True if successful . @throws Exception if there is an error in the form event .
protected function preprocessForm(JForm $form, $data, $group = '')
	{
		jimport('joomla.filesystem.file');
		jimport('joomla.filesystem.folder');
		$folder		= $this->getState('item.folder');
		$element	= $this->getState('item.element');
		$lang		= JFactory::getLanguage();
		$client		= JApplicationHelper::getClientInfo(0);
		$db = JFactory::getDbo();
		$query = 'SELECT element' .
				' FROM #__extensions' .
				' WHERE (type =' .$db->Quote('plugin'). 'AND folder='. $db->Quote($folder) . ')';
		$db->setQuery($query);
		$elements = $db->loadResultArray();
		foreach ($elements as $elementa)
		{
				$lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_ADMINISTRATOR, null, false, false)
			||	$lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_PLUGINS.'/'.$folder.'/'.$elementa, null, false, false)
			||	$lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
			||	$lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_PLUGINS.'/'.$folder.'/'.$elementa, $lang->getDefault(), false, false);
		}
		if (empty($folder) || empty($element)) {
			$app = JFactory::getApplication();
			$app->redirect(JRoute::_('index.php?option=com_plugins&view=plugins',false));
		}
		$formFile = JPath::clean(JPATH_PLUGINS.'/'.$folder.'/'.$element.'/'.$element.'.xml');
		if (!file_exists($formFile)) {
			$formFile = JPath::clean(JPATH_PLUGINS.'/'.$folder.'/'.$element.'.xml');
			if (!file_exists($formFile)) {
				throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $element.'.xml'));
				return false;
			}
		}
			$lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, null, false, false)
		||	$lang->load('plg_'.$folder.'_'.$element, JPATH_PLUGINS.'/'.$folder.'/'.$element, null, false, false)
		||	$lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
		||	$lang->load('plg_'.$folder.'_'.$element, JPATH_PLUGINS.'/'.$folder.'/'.$element, $lang->getDefault(), false, false);
		if (file_exists($formFile)) {
			if (!$form->loadFile($formFile, false, '//config')) {
				throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
			}
		}
		if (!$xml = simplexml_load_file($formFile)) {
			throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
		}
		$help = $xml->xpath('/extension/help');
		if (!empty($help)) {
			$helpKey = trim((string) $help[0]['key']);
			$helpURL = trim((string) $help[0]['url']);
			$this->helpKey = $helpKey ? $helpKey : $this->helpKey;
			$this->helpURL = $helpURL ? $helpURL : $this->helpURL;
		}
		parent::preprocessForm($form, $data, $group);
	}
protected function preprocessForm ( JForm $ form , $ data , $ group = '' ) { jimport ( 'joomla.filesystem.file' ) ; jimport ( 'joomla.filesystem.folder' ) ; $ folder = $ this -> getState ( 'item.folder' ) ; $ element = $ this -> getState ( 'item.element' ) ; $ lang = JFactory :: getLanguage ( ) ; $ client = JApplicationHelper :: getClientInfo ( 0 ) ; $ db = JFactory :: getDbo ( ) ; $ query = 'SELECT element' . ' FROM #__extensions' . ' WHERE (type =' . $ db -> Quote ( 'plugin' ) . 'AND folder=' . $ db -> Quote ( $ folder ) . ')' ; $ db -> setQuery ( $ query ) ; $ elements = $ db -> loadResultArray ( ) ; foreach ( $ elements as $ elementa ) { $ lang -> load ( 'plg_' . $ folder . '_' . $ elementa . '.sys' , JPATH_ADMINISTRATOR , null , false , false ) || $ lang -> load ( 'plg_' . $ folder . '_' . $ elementa . '.sys' , JPATH_PLUGINS . '/' . $ folder . '/' . $ elementa , null , false , false ) || $ lang -> load ( 'plg_' . $ folder . '_' . $ elementa . '.sys' , JPATH_ADMINISTRATOR , $ lang -> getDefault ( ) , false , false ) || $ lang -> load ( 'plg_' . $ folder . '_' . $ elementa . '.sys' , JPATH_PLUGINS . '/' . $ folder . '/' . $ elementa , $ lang -> getDefault ( ) , false , false ) ; } if ( empty ( $ folder ) || empty ( $ element ) ) { $ app = JFactory :: getApplication ( ) ; $ app -> redirect ( JRoute :: _ ( 'index.php?option=com_plugins&view=plugins' , false ) ) ; } $ formFile = JPath :: clean ( JPATH_PLUGINS . '/' . $ folder . '/' . $ element . '/' . $ element . '.xml' ) ; if ( ! file_exists ( $ formFile ) ) { $ formFile = JPath :: clean ( JPATH_PLUGINS . '/' . $ folder . '/' . $ element . '.xml' ) ; if ( ! file_exists ( $ formFile ) ) { throw new Exception ( JText :: sprintf ( 'COM_PLUGINS_ERROR_FILE_NOT_FOUND' , $ element . '.xml' ) ) ; return false ; } } $ lang -> load ( 'plg_' . $ folder . '_' . $ element , JPATH_ADMINISTRATOR , null , false , false ) || $ lang -> load ( 'plg_' . $ folder . '_' . $ element , JPATH_PLUGINS . '/' . $ folder . '/' . $ element , null , false , false ) || $ lang -> load ( 'plg_' . $ folder . '_' . $ element , JPATH_ADMINISTRATOR , $ lang -> getDefault ( ) , false , false ) || $ lang -> load ( 'plg_' . $ folder . '_' . $ element , JPATH_PLUGINS . '/' . $ folder . '/' . $ element , $ lang -> getDefault ( ) , false , false ) ; if ( file_exists ( $ formFile ) ) { if ( ! $ form -> loadFile ( $ formFile , false , '//config' ) ) { throw new Exception ( JText :: _ ( 'JERROR_LOADFILE_FAILED' ) ) ; } } if ( ! $ xml = simplexml_load_file ( $ formFile ) ) { throw new Exception ( JText :: _ ( 'JERROR_LOADFILE_FAILED' ) ) ; } $ help = $ xml -> xpath ( '/extension/help' ) ; if ( ! empty ( $ help ) ) { $ helpKey = trim ( ( string ) $ help [ 0 ] [ 'key' ] ) ; $ helpURL = trim ( ( string ) $ help [ 0 ] [ 'url' ] ) ; $ this -> helpKey = $ helpKey ? $ helpKey : $ this -> helpKey ; $ this -> helpURL = $ helpURL ? $ helpURL : $ this -> helpURL ; } parent :: preprocessForm ( $ form , $ data , $ group ) ; }
@param       object  A form object.
@param object A form object .
// Initialise variables. // Load the core and/or local language sys file(s) for the ordering field. // Try 1.6 format: /plugins/folder/element/element.xml // Try 1.5 format: /plugins/folder/element/element.xml // Load the core and/or local language file(s). // Get the plugin form. // Attempt to load the xml file. // Get the help data from the XML file if present. // Trigger the default form events.