JInstallerFile/populateFilesAndFolderList: Difference between revisions
From Joomla! Documentation
New page: ===Description===
function used to populate files and folder list
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JInstallerFile/populateFilesAndFold... |
m removing red link to edit, no existant pages |
||
| Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 104: | Line 104: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Examples=== | ===Examples=== | ||
| Line 119: | Line 119: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API16]] | |||
Revision as of 03:01, 14 May 2013
Description
function used to populate files and folder list
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
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);
}
}
}
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />