english/libraries/joomla/installer/adapters/language.php
/**
	 * Install function that is designed to handle individual clients
	 */
Install function that is designed to handle individual clients
Install function that is designed to handle individual clients
protected function _install($cname, $basePath, $clientId, &$element)
	{
		$this->manifest = $this->parent->getManifest();
		$name = JFilterInput::getInstance()->clean((string)$this->manifest->name, 'cmd');
		$this->set('name', $name);
		$tag = (string)$this->manifest->tag;
		if ( ! $tag)
		{
			$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', JText::_('JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG')));
			return false;
		}
		$this->set('tag', $tag);
		$this->parent->setPath('extension_site', $basePath . '/language/' . $tag);
				if ($element && count($element->children()))
		{
			$files = $element->children();
			foreach ($files 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;
			}
		}
		$created = false;
		if (!file_exists($this->parent->getPath('extension_site')))
		{
			if (!$created = JFolder::create($this->parent->getPath('extension_site')))
			{
				$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_CREATE_FOLDER_FAILED', $this->parent->getPath('extension_site'))));
				return false;
			}
		}
		else
		{
			$updateElement = $this->manifest->update;
			if ($this->parent->getUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass,'update')) || is_a($updateElement, 'JXMLElement')) {
				return $this->update(); 
			}
			else if (!$this->parent->getOverwrite())
			{
				if (file_exists($this->parent->getPath('extension_site'))) {
					JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_site'))));
				}
				else {
					JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_administrator'))));
				}
				return false;
			}
		}
		if ($created) {
			$this->parent->pushStep(array ('type' => 'folder', 'path' => $this->parent->getPath('extension_site')));
		}
		if ($this->parent->parseFiles($element) === false)
		{
			$this->parent->abort();
			return false;
		}
		$this->parent->parseMedia($this->manifest->media);
		$this->parent->setPath('extension_site', $basePath . '/language/pdf_fonts');
		$overwrite = $this->parent->setOverwrite(true);
		if ($this->parent->parseFiles($this->manifest->fonts) === false)
		{
			$this->parent->abort();
			return false;
		}
		$this->parent->setOverwrite($overwrite);
		$description = (string)$this->manifest->description;
		if ($description) {
			$this->parent->set('message', JText::_($description));
		}
		else {
			$this->parent->set('message', '');
		}
		$row = JTable::getInstance('extension');
		$row->set('name', $this->get('name'));
		$row->set('type', 'language');
		$row->set('element', $this->get('tag'));
		$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('manifest_cache', $this->parent->generateManifestCache());
		if (!$row->store())
		{
			$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError()));
			return false;
		}
		$update = JTable::getInstance('update');
		$uid = $update->find(Array('element'=>$this->get('tag'),
								'type'=>'language',
								'client_id'=>'',
								'folder'=>''));
		if ($uid) {
			$update->delete($uid);
		}
		return $row->get('extension_id');
	}
protected function _install ( $ cname , $ basePath , $ clientId , & $ element ) { $ this -> manifest = $ this -> parent -> getManifest ( ) ; $ name = JFilterInput :: getInstance ( ) -> clean ( ( string ) $ this -> manifest -> name , 'cmd' ) ; $ this -> set ( 'name' , $ name ) ; $ tag = ( string ) $ this -> manifest -> tag ; if ( ! $ tag ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: _ ( 'JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG' ) ) ) ; return false ; } $ this -> set ( 'tag' , $ tag ) ; $ this -> parent -> setPath ( 'extension_site' , $ basePath . '/language/' . $ tag ) ; if ( $ element && count ( $ element -> children ( ) ) ) { $ files = $ element -> children ( ) ; foreach ( $ files 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 ; } } $ created = false ; if ( ! file_exists ( $ this -> parent -> getPath ( 'extension_site' ) ) ) { if ( ! $ created = JFolder :: create ( $ this -> parent -> getPath ( 'extension_site' ) ) ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_CREATE_FOLDER_FAILED' , $ this -> parent -> getPath ( 'extension_site' ) ) ) ) ; return false ; } } else { $ updateElement = $ this -> manifest -> update ; if ( $ this -> parent -> getUpgrade ( ) || ( $ this -> parent -> manifestClass && method_exists ( $ this -> parent -> manifestClass , 'update' ) ) || is_a ( $ updateElement , 'JXMLElement' ) ) { return $ this -> update ( ) ; } else if ( ! $ this -> parent -> getOverwrite ( ) ) { if ( file_exists ( $ this -> parent -> getPath ( 'extension_site' ) ) ) { JError :: raiseWarning ( 1 , JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_FOLDER_IN_USE' , $ this -> parent -> getPath ( 'extension_site' ) ) ) ) ; } else { JError :: raiseWarning ( 1 , JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_FOLDER_IN_USE' , $ this -> parent -> getPath ( 'extension_administrator' ) ) ) ) ; } return false ; } } if ( $ created ) { $ this -> parent -> pushStep ( array ( 'type' => 'folder' , 'path' => $ this -> parent -> getPath ( 'extension_site' ) ) ) ; } if ( $ this -> parent -> parseFiles ( $ element ) === false ) { $ this -> parent -> abort ( ) ; return false ; } $ this -> parent -> parseMedia ( $ this -> manifest -> media ) ; $ this -> parent -> setPath ( 'extension_site' , $ basePath . '/language/pdf_fonts' ) ; $ overwrite = $ this -> parent -> setOverwrite ( true ) ; if ( $ this -> parent -> parseFiles ( $ this -> manifest -> fonts ) === false ) { $ this -> parent -> abort ( ) ; return false ; } $ this -> parent -> setOverwrite ( $ overwrite ) ; $ description = ( string ) $ this -> manifest -> description ; if ( $ description ) { $ this -> parent -> set ( 'message' , JText :: _ ( $ description ) ) ; } else { $ this -> parent -> set ( 'message' , '' ) ; } $ row = JTable :: getInstance ( 'extension' ) ; $ row -> set ( 'name' , $ this -> get ( 'name' ) ) ; $ row -> set ( 'type' , 'language' ) ; $ row -> set ( 'element' , $ this -> get ( 'tag' ) ) ; $ 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 ( 'manifest_cache' , $ this -> parent -> generateManifestCache ( ) ) ; if ( ! $ row -> store ( ) ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT' , $ row -> getError ( ) ) ) ; return false ; } $ update = JTable :: getInstance ( 'update' ) ; $ uid = $ update -> find ( Array ( 'element' => $ this -> get ( 'tag' ) , 'type' => 'language' , 'client_id' => '' , 'folder' => '' ) ) ; if ( $ uid ) { $ update -> delete ( $ uid ) ; } return $ row -> get ( 'extension_id' ) ; }
Install function that is designed to handle individual clients
Install function that is designed to handle individual clients
// 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. // If the language directory does not exist, let's create it // Look for an update function or update tag // Upgrade manually set or // Update function available or // Update tag detected // transfer control to the update function // Overwrite is set // We didn't have overwrite set, find an update function or find an update tag so lets call it safe // If the site exists say so. // If the admin exists say so. /*
		 * If we created the language directory we will want to remove it if we
		 * have to roll back the installation, so let's add it to the installation
		 * step stack
		 */ // 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 // Add an entry to the extension table with a whole heap of defaults // There is no folder for languages // Install failed, roll back changes // Clobber any possible pending updates