english/libraries/joomla/installer/adapters/language.php
/**
	 * Custom update method
	 *
	 * @return  boolean  True on success, false on failure
	 * @since   11.1
	 */
Custom update method
@return  boolean  True on success, false on failure
@since   11.1
Custom update method @return boolean True on success false on failure @since 11 . 1
public function update()
	{
		$xml = $this->parent->getManifest();
		$this->manifest	= $xml;
		$cname		= $xml->attributes()->client;
		jimport('joomla.application.helper');
		$client = JApplicationHelper::getClientInfo($cname, true);
		if ($client === null || (empty($cname) && $cname !== 0))
		{
			$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_UNKNOWN_CLIENT_TYPE', $cname)));
			return false;
		}
		$basePath = $client->path;
		$clientId = $client->id;
		$name = (string)$this->manifest->name;
		$name = JFilterInput::getInstance()->clean($name, 'cmd');
		$this->set('name', $name);
		$tag = (string)$xml->tag;
		if (!$tag)
		{
			$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', JText::_('JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG')));
			return false;
		}
		$this->set('tag', $tag);
		$folder = $tag;
		$this->parent->setPath('extension_site', $basePath . '/language/' . $this->get('tag'));
				if (count($xml->files->children()))
		{
			foreach ($xml->files->children() as $file)
			{
				if ((string)$file->attributes()->file == 'meta')
				{
					$this->_core = true;
					break;
				}
			}
		}
		if (!$this->_core)
		{
			if (!JFile::exists($this->parent->getPath('extension_site') . '/' . $this->get('tag').'.xml'))
			{
				$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_NO_CORE_LANGUAGE', $this->get('tag'))));
				return false;
			}
		}
		if ($this->parent->parseFiles($xml->files) === false)
		{
			$this->parent->abort();
			return false;
		}
		$this->parent->parseMedia($xml->media);
		$this->parent->setPath('extension_site', $basePath . '/language/pdf_fonts');
		$overwrite = $this->parent->setOverwrite(true);
		if ($this->parent->parseFiles($xml->fonts) === false)
		{
			$this->parent->abort();
			return false;
		}
		$this->parent->setOverwrite($overwrite);
		$this->parent->set('message', (string)$xml->description);
		$update = JTable::getInstance('update');
		$uid = $update->find(Array('element'=>$this->get('tag'),
								'type'=>'language',
								'client_id'=>$clientId));
		if ($uid)
		{
			$update->delete($uid);
		}
		$row = JTable::getInstance('extension');
		$eid = $row->find(Array('element'=>strtolower($this->get('tag')),
						'type'=>'language', 'client_id'=>$clientId));
		if ($eid) {
			$row->load($eid);
		}
		else
		{
			$row->set('folder', ''); 
			$row->set('enabled', 1);
			$row->set('protected', 0);
			$row->set('access', 0);
			$row->set('client_id', $clientId);
			$row->set('params', $this->parent->getParams());
		}
		$row->set('name', $this->get('name'));
		$row->set('type', 'language');
		$row->set('element', $this->get('tag'));
		$row->set('manifest_cache', $this->parent->generateManifestCache());
		if (!$row->store())
		{
			$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError()));
			return false;
		}
		ob_start();
		ob_implicit_flush(false);
		if ($this->parent->manifestClass && method_exists($this->parent->manifestClass,'postflight'))
		{
			$this->parent->manifestClass->postflight('update', $this);
		}
		$msg .= ob_get_contents(); 
		ob_end_clean();
		if ($msg != '') {
			$this->parent->set('extension_message', $msg);
		}
		return $row->get('extension_id');
	}
public function update ( ) { $ xml = $ this -> parent -> getManifest ( ) ; $ this -> manifest = $ xml ; $ cname = $ xml -> attributes ( ) -> client ; jimport ( 'joomla.application.helper' ) ; $ client = JApplicationHelper :: getClientInfo ( $ cname , true ) ; if ( $ client === null || ( empty ( $ cname ) && $ cname !== 0 ) ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_UNKNOWN_CLIENT_TYPE' , $ cname ) ) ) ; return false ; } $ basePath = $ client -> path ; $ clientId = $ client -> id ; $ name = ( string ) $ this -> manifest -> name ; $ name = JFilterInput :: getInstance ( ) -> clean ( $ name , 'cmd' ) ; $ this -> set ( 'name' , $ name ) ; $ tag = ( string ) $ xml -> tag ; if ( ! $ tag ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: _ ( 'JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG' ) ) ) ; return false ; } $ this -> set ( 'tag' , $ tag ) ; $ folder = $ tag ; $ this -> parent -> setPath ( 'extension_site' , $ basePath . '/language/' . $ this -> get ( 'tag' ) ) ; if ( count ( $ xml -> files -> children ( ) ) ) { foreach ( $ xml -> files -> children ( ) as $ file ) { if ( ( string ) $ file -> attributes ( ) -> file == 'meta' ) { $ this -> _core = true ; break ; } } } if ( ! $ this -> _core ) { if ( ! JFile :: exists ( $ this -> parent -> getPath ( 'extension_site' ) . '/' . $ this -> get ( 'tag' ) . '.xml' ) ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_NO_CORE_LANGUAGE' , $ this -> get ( 'tag' ) ) ) ) ; return false ; } } if ( $ this -> parent -> parseFiles ( $ xml -> files ) === false ) { $ this -> parent -> abort ( ) ; return false ; } $ this -> parent -> parseMedia ( $ xml -> media ) ; $ this -> parent -> setPath ( 'extension_site' , $ basePath . '/language/pdf_fonts' ) ; $ overwrite = $ this -> parent -> setOverwrite ( true ) ; if ( $ this -> parent -> parseFiles ( $ xml -> fonts ) === false ) { $ this -> parent -> abort ( ) ; return false ; } $ this -> parent -> setOverwrite ( $ overwrite ) ; $ this -> parent -> set ( 'message' , ( string ) $ xml -> description ) ; $ update = JTable :: getInstance ( 'update' ) ; $ uid = $ update -> find ( Array ( 'element' => $ this -> get ( 'tag' ) , 'type' => 'language' , 'client_id' => $ clientId ) ) ; if ( $ uid ) { $ update -> delete ( $ uid ) ; } $ row = JTable :: getInstance ( 'extension' ) ; $ eid = $ row -> find ( Array ( 'element' => strtolower ( $ this -> get ( 'tag' ) ) , 'type' => 'language' , 'client_id' => $ clientId ) ) ; if ( $ eid ) { $ row -> load ( $ eid ) ; } else { $ row -> set ( 'folder' , '' ) ; $ row -> set ( 'enabled' , 1 ) ; $ row -> set ( 'protected' , 0 ) ; $ row -> set ( 'access' , 0 ) ; $ row -> set ( 'client_id' , $ clientId ) ; $ row -> set ( 'params' , $ this -> parent -> getParams ( ) ) ; } $ row -> set ( 'name' , $ this -> get ( 'name' ) ) ; $ row -> set ( 'type' , 'language' ) ; $ row -> set ( 'element' , $ this -> get ( 'tag' ) ) ; $ row -> set ( 'manifest_cache' , $ this -> parent -> generateManifestCache ( ) ) ; if ( ! $ row -> store ( ) ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , $ row -> getError ( ) ) ) ; return false ; } ob_start ( ) ; ob_implicit_flush ( false ) ; if ( $ this -> parent -> manifestClass && method_exists ( $ this -> parent -> manifestClass , 'postflight' ) ) { $ this -> parent -> manifestClass -> postflight ( 'update' , $ this ) ; } $ msg .= ob_get_contents ( ) ; ob_end_clean ( ) ; if ( $ msg != '' ) { $ this -> parent -> set ( 'extension_message' , $ msg ) ; } return $ row -> get ( 'extension_id' ) ; }
Custom update method
 @return  boolean  True on success, false on failure
 @since   11.1
Custom update method @return boolean True on success false on failure @since 11 . 1
// Attempt to map the client to a base path // Get the language name // Set the extensions name // Get the Language tag [ISO tag, eg. en-GB] // Check if we found the tag - if we didn't, we may be trying to install from an older language package // Set the language installation path // Do we have a meta file in the file list?  In other words... is this a core language pack?
 // Either we are installing a core pack or a core pack must exist for the language we are installing. // Copy all the necessary files // Install failed, rollback changes // Parse optional tags // Copy all the necessary font files to the common pdf_fonts directory // Install failed, rollback changes // Get the language description and set it as message // Finalization and Cleanup Section // Clobber any possible pending updates // Update an entry to the extension table // set the defaults // There is no folder for language // Install failed, roll back changes // And now we run the postflight // append messages