english/libraries/joomla/installer/installer.php
/**
	 * Method to parse through a files element of the installation manifest and remove
	 * the files that were installed
	 *
	 * @param	object	$element	The xml node to process
	 * @param	int		$cid		Application ID of application to remove from
	 *
	 * @return	boolean	True on success
	 * @since	11.1
	 */
Method to parse through a files element of the installation manifest and remove
the files that were installed

@param       object  $element        The xml node to process
@param       int             $cid            Application ID of application to remove from

@return      boolean True on success
@since       11.1
Method to parse through a files element of the installation manifest and remove the files that were installed @param object $element The xml node to process @param int $cid Application ID of application to remove from @return boolean True on success @since 11 . 1
public function removeFiles($element, $cid=0)
	{
		if (!$element || !count($element->children())) {
			return true;
		}
		$removefiles = array ();
		$retval = true;
		$debug = false;
		if (isset($GLOBALS['installerdebug']) && $GLOBALS['installerdebug']) {
			$debug = true;
		}
		jimport('joomla.application.helper');
		if ($cid > -1) {
			$client = JApplicationHelper::getClientInfo($cid);
		}
		else {
			$client = null;
		}
		$files = $element->children();
		if (count($files) == 0) {
			return true;
		}
		$folder = '';
		switch ($element->getName())
		{
			case 'media':
				if ((string)$element->attributes()->destination) {
					$folder = (string)$element->attributes()->destination;
				}
				else {
					$folder = '';
				}
				$source = $client->path . '/media/' . $folder;
				break;
			case 'languages':
				$lang_client = (string)$element->attributes()->client;
				if ($lang_client) {
					$client = JApplicationHelper::getClientInfo($lang_client, true);
					$source = $client->path . '/language';
				}
				else {
					if ($client) {
						$source = $client->path . '/language';
					}
					else {
						$source = '';
					}
				}
				break;
			default:
				if ($client) {
					$pathname = 'extension_'.$client->name;
					$source = $this->getPath($pathname);
				}
				else {
					$pathname = 'extension_root';
					$source = $this->getPath($pathname);
				}
				break;
		}
		foreach ($files as $file)
		{
			if ($file->getName() == 'language' && (string)$file->attributes()->tag != '') {
				if ($source) {
					$path = $source . '/' . $file->attributes()->tag . '/' . basename((string)$file);
				}
				else {
					$target_client = JApplicationHelper::getClientInfo((string)$file->attributes()->client, true);
					$path = $target_client->path . '/language/' . $file->attributes()->tag . '/' . basename((string)$file);
				}
				if (!JFolder::exists(dirname($path)))
				{
					continue;
				}
			}
			else {
				$path = $source . '/' . $file;
			}
			if (is_dir($path)) {
				$val = JFolder::delete($path);
			}
			else {
				$val = JFile::delete($path);
			}
			if ($val === false) {
				JError::raiseWarning(43, 'Failed to delete '. $path);
				$retval = false;
			}
		}
		if (!empty($folder)) {
			$val = JFolder::delete($source);
		}
		return $retval;
	}
public function removeFiles ( $ element , $ cid = 0 ) { if ( ! $ element || ! count ( $ element -> children ( ) ) ) { return true ; } $ removefiles = array ( ) ; $ retval = true ; $ debug = false ; if ( isset ( $ GLOBALS [ 'installerdebug' ] ) && $ GLOBALS [ 'installerdebug' ] ) { $ debug = true ; } jimport ( 'joomla.application.helper' ) ; if ( $ cid > - 1 ) { $ client = JApplicationHelper :: getClientInfo ( $ cid ) ; } else { $ client = null ; } $ files = $ element -> children ( ) ; if ( count ( $ files ) == 0 ) { return true ; } $ folder = '' ; switch ( $ element -> getName ( ) ) { case 'media' : if ( ( string ) $ element -> attributes ( ) -> destination ) { $ folder = ( string ) $ element -> attributes ( ) -> destination ; } else { $ folder = '' ; } $ source = $ client -> path . '/media/' . $ folder ; break ; case 'languages' : $ lang_client = ( string ) $ element -> attributes ( ) -> client ; if ( $ lang_client ) { $ client = JApplicationHelper :: getClientInfo ( $ lang_client , true ) ; $ source = $ client -> path . '/language' ; } else { if ( $ client ) { $ source = $ client -> path . '/language' ; } else { $ source = '' ; } } break ; default : if ( $ client ) { $ pathname = 'extension_' . $ client -> name ; $ source = $ this -> getPath ( $ pathname ) ; } else { $ pathname = 'extension_root' ; $ source = $ this -> getPath ( $ pathname ) ; } break ; } foreach ( $ files as $ file ) { if ( $ file -> getName ( ) == 'language' && ( string ) $ file -> attributes ( ) -> tag != '' ) { if ( $ source ) { $ path = $ source . '/' . $ file -> attributes ( ) -> tag . '/' . basename ( ( string ) $ file ) ; } else { $ target_client = JApplicationHelper :: getClientInfo ( ( string ) $ file -> attributes ( ) -> client , true ) ; $ path = $ target_client -> path . '/language/' . $ file -> attributes ( ) -> tag . '/' . basename ( ( string ) $ file ) ; } if ( ! JFolder :: exists ( dirname ( $ path ) ) ) { continue ; } } else { $ path = $ source . '/' . $ file ; } if ( is_dir ( $ path ) ) { $ val = JFolder :: delete ( $ path ) ; } else { $ val = JFile :: delete ( $ path ) ; } if ( $ val === false ) { JError :: raiseWarning ( 43 , 'Failed to delete ' . $ path ) ; $ retval = false ; } } if ( ! empty ( $ folder ) ) { $ val = JFolder :: delete ( $ source ) ; } return $ retval ; }
Method to parse through a files element of the installation manifest and remove
 the files that were installed
Method to parse through a files element of the installation manifest and remove the files that were installed
// Either the tag does not exist or has no children therefore we return zero files processed. // Initialise variables. // Get the client info if we're using a specific client // Get the array of file nodes to process // No files to process /*
		 * Here we set the folder we are going to remove the files from.  There are a few
		 * special cases that need to be considered for certain reserved tags.
		 */ // Process each file in the $files array (children of $tagName). // If the file is a language, we must handle it differently.  Language files // go in a subdirectory based on the language code, ie. //		<language tag="en_US">en_US.mycomponent.ini</language> // would go in the en_US subdirectory of the languages directory. // If the language folder is not present, then the core pack hasn't been installed... ignore // Actually delete the files/folders