english/administrator/components/com_templates/models/style.php
/**
	 * @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
	 */
@param       object  A form object.
@param       mixed   The data expected for the form.
@throws      Exception if there is an error in the form event.
@param object A form object . @param mixed The data expected for the form . @throws Exception if there is an error in the form event .
protected function preprocessForm(JForm $form, $data, $group = '')
	{
		$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.file');
		jimport('joomla.filesystem.folder');
		$formFile	= JPath::clean($client->path.'/templates/'.$template.'/templateDetails.xml');
			$lang->load('tpl_'.$template, $client->path, null, false, false)
		||	$lang->load('tpl_'.$template, $client->path.'/templates/'.$template, null, false, false)
		||	$lang->load('tpl_'.$template, $client->path, $lang->getDefault(), false, false)
		||	$lang->load('tpl_'.$template, $client->path.'/templates/'.$template, $lang->getDefault(), false, false);
		if (file_exists($formFile)) {
			if (!$form->loadFile($formFile, false, '//config')) {
				throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
			}
		}
		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');
		}
		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 = '' ) { $ 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.file' ) ; jimport ( 'joomla.filesystem.folder' ) ; $ formFile = JPath :: clean ( $ client -> path . '/templates/' . $ template . '/templateDetails.xml' ) ; $ lang -> load ( 'tpl_' . $ template , $ client -> path , null , false , false ) || $ lang -> load ( 'tpl_' . $ template , $ client -> path . '/templates/' . $ template , null , false , false ) || $ lang -> load ( 'tpl_' . $ template , $ client -> path , $ lang -> getDefault ( ) , false , false ) || $ lang -> load ( 'tpl_' . $ template , $ client -> path . '/templates/' . $ template , $ lang -> getDefault ( ) , false , false ) ; if ( file_exists ( $ formFile ) ) { if ( ! $ form -> loadFile ( $ formFile , false , '//config' ) ) { throw new Exception ( JText :: _ ( 'JERROR_LOADFILE_FAILED' ) ) ; } } 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' ) ; } 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 file(s). // Get the template form. // Disable home field if it is default style // Attempt to load the xml file. // Get the help data from the XML file if present. // Trigger the default form events.