english/libraries/joomla/installer/installer.php
/**
	 * Method to parse through a media element of the installation manifest and take appropriate
	 * action.
	 *
	 * @param	JXMLElement	$element	The xml node to process
	 * @param	int			$cid		Application ID of application to install to
	 *
	 * @return	boolean	True on success
	 * @since	11.1
	 */
Method to parse through a media element of the installation manifest and take appropriate
action.

@param       JXMLElement     $element        The xml node to process
@param       int                     $cid            Application ID of application to install to

@return      boolean True on success
@since       11.1
Method to parse through a media element of the installation manifest and take appropriate action . @param JXMLElement $element The xml node to process @param int $cid Application ID of application to install to @return boolean True on success @since 11 . 1
public function parseMedia($element, $cid=0)
	{
		if (!$element || !count($element->children())) {
			return 0;
		}
		$copyfiles = array ();
		jimport('joomla.application.helper');
		$client = JApplicationHelper::getClientInfo($cid);
		$folder = ((string)$element->attributes()->destination) ? '/' . $element->attributes()->destination : null;
		$destination = JPath::clean(JPATH_ROOT . '/media'.$folder);
		$folder = (string)$element->attributes()->folder;
		if ($folder && file_exists($this->getPath('source') . '/' . $folder)) {
			$source = $this->getPath('source') . '/' . $folder;
		}
		else {
			$source = $this->getPath('source');
		}
		foreach ($element->children() as $file)
		{
			$path['src']	= $source . '/' . $file;
			$path['dest']	= $destination . '/' . $file;
						$path['type']	= ($file->getName() == 'folder') ? 'folder' : 'file';
			if (basename($path['dest']) != $path['dest']) {
				$newdir = dirname($path['dest']);
				if (!JFolder::create($newdir)) {
					JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_CREATE_DIRECTORY', $newdir));
					return false;
				}
			}
			$copyfiles[] = $path;
		}
		return $this->copyFiles($copyfiles);
	}
public function parseMedia ( $ element , $ cid = 0 ) { if ( ! $ element || ! count ( $ element -> children ( ) ) ) { return 0 ; } $ copyfiles = array ( ) ; jimport ( 'joomla.application.helper' ) ; $ client = JApplicationHelper :: getClientInfo ( $ cid ) ; $ folder = ( ( string ) $ element -> attributes ( ) -> destination ) ? '/' . $ element -> attributes ( ) -> destination : null ; $ destination = JPath :: clean ( JPATH_ROOT . '/media' . $ folder ) ; $ folder = ( string ) $ element -> attributes ( ) -> folder ; if ( $ folder && file_exists ( $ this -> getPath ( 'source' ) . '/' . $ folder ) ) { $ source = $ this -> getPath ( 'source' ) . '/' . $ folder ; } else { $ source = $ this -> getPath ( 'source' ) ; } foreach ( $ element -> children ( ) as $ file ) { $ path [ 'src' ] = $ source . '/' . $ file ; $ path [ 'dest' ] = $ destination . '/' . $ file ; $ path [ 'type' ] = ( $ file -> getName ( ) == 'folder' ) ? 'folder' : 'file' ; if ( basename ( $ path [ 'dest' ] ) != $ path [ 'dest' ] ) { $ newdir = dirname ( $ path [ 'dest' ] ) ; if ( ! JFolder :: create ( $ newdir ) ) { JError :: raiseWarning ( 1 , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_CREATE_DIRECTORY' , $ newdir ) ) ; return false ; } } $ copyfiles [ ] = $ path ; } return $ this -> copyFiles ( $ copyfiles ) ; }
Method to parse through a media element of the installation manifest and take appropriate
 action.
Method to parse through a media element of the installation manifest and take appropriate action .
// Either the tag does not exist or has no children therefore we return zero files processed. // Initialise variables. // Get the client info // Here we set the folder we are going to copy the files to. //	Default 'media' Files are copied to the JPATH_BASE/media folder // Here we set the folder we are going to copy the files from. // Does the element have a folder attribute?
 // If so this indicates that the files are in a subdirectory of the source // folder and we should append the folder attribute to the source path when // copying files. // Process each file in the $files array (children of $tagName). // Is this path a file or folder?
 // Before we can add a file to the copyfiles array we need to ensure // that the folder we are copying our file to exits and if it doesn't, // we need to create it. // Add the file to the copyfiles array