JFolder/move: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Moves a folder.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
{{Desc... |
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 86: | Line 86: | ||
<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 101: | Line 101: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API15]] | |||
Revision as of 17:20, 12 May 2013
Description
Moves a folder.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
move($src, $dest, $path= '')
| Parameter Name | Default Value | Description |
|---|---|---|
| $src | The path to the source folder. | |
| $dest | The path to the destination folder. | |
| $path | An optional base path to prefix to the file names. |
Returns
mixed Error message on false or boolean true on success.
Defined in
libraries/joomla/filesystem/folder.php
Importing
jimport( 'joomla.filesystem.folder' );
Source Body
function move($src, $dest, $path = '')
{
// Initialize variables
jimport('joomla.client.helper');
$ftpOptions = JClientHelper::getCredentials('ftp');
if ($path) {
$src = JPath::clean($path . DS . $src);
$dest = JPath::clean($path . DS . $dest);
}
if (!JFolder::exists($src) && !is_writable($src)) {
return JText::_('Cannot find source folder');
}
if (JFolder::exists($dest)) {
return JText::_('Folder already exists');
}
if ($ftpOptions['enabled'] == 1) {
// Connect the FTP client
jimport('joomla.client.ftp');
$ftp = &JFTP::getInstance(
$ftpOptions['host'], $ftpOptions['port'], null,
$ftpOptions['user'], $ftpOptions['pass']
);
//Translate path for the FTP account
$src = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $src), '/');
$dest = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dest), '/');
// Use FTP rename to simulate move
if (!$ftp->rename($src, $dest)) {
return JText::_('Rename failed');
}
$ret = true;
} else {
if (!@rename($src, $dest)) {
return JText::_('Rename failed');
}
$ret = true;
}
return $ret;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />