API16:JInstallerFile/populateFilesAndFolderList
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
function used to populate files and folder list
Description:JInstallerFile/populateFilesAndFolderList
Syntax
populateFilesAndFolderList()
Returns
boolean none
Defined in
libraries/joomla/installer/adapters/file.php
Importing
jimport( 'joomla.installer.adapters.file' );
Source Body
private function populateFilesAndFolderList() { // Initialise variable $this->folderList = array(); $this->fileList = array(); // Get fileset $eFileset = $this->manifest->fileset->files; // Set root folder names $packagePath = $this->parent->getPath('source'); $jRootPath = JPath::clean(JPATH_ROOT); // loop through all elements and get list of files and folders foreach ($this->manifest->fileset->files as $eFiles) { // Check if the element is files element $folder = (string)$eFiles->attributes()->folder; $target = (string)$eFiles->attributes()->target; //Split folder names into array to get folder names. This will // help in creating folders $arrList = split("/|\\/", $target); $folderName = $jRootPath; foreach ($arrList as $dir) { if(empty($dir)) continue ; $folderName .= DS.$dir; // Check if folder exists, if not then add to the array for folder creation if (!JFolder::exists($folderName)) { array_push($this->folderList, $folderName); } } //Create folder path $sourceFolder = empty($folder)?$packagePath:$packagePath.DS.$folder; $targetFolder = empty($target)?$jRootPath:$jRootPath.DS.$target; //Check if source folder exists if (! JFolder::exists($sourceFolder)) { JError::raiseWarning(1, JText::_('Files').' '.JText::_('Install').': '.JText::_('Failed to find source directory').': "'.$sourceFolder.'"'); // if installation fails, rollback $this->parent->abort(); return false; } // Check if all children exists if (count($eFiles->children())) { // loop through all filenames elements foreach ($eFiles->children() as $eFileName) { $path['src'] = $sourceFolder.DS.$eFileName; $path['dest'] = $targetFolder.DS.$eFileName; $path['type'] = 'file'; if ($eFileName->getName() == 'folder') { $folderName = $targetFolder.DS.$eFileName; array_push($this->folderList, $folderName); $path['type'] = 'folder'; } array_push($this->fileList, $path); } } else { $files = JFolder::files($sourceFolder); foreach ($files as $file) { $path['src'] = $sourceFolder.DS.$file; $path['dest'] = $targetFolder.DS.$file; array_push($this->fileList, $path); } } } }
[Edit See Also] SeeAlso:JInstallerFile/populateFilesAndFolderList
Examples
<CodeExamplesForm />
