Difference between revisions of "JFolder/move"
From Joomla! Documentation
< API16:JFolder
(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 98: | Line 98: | ||
<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 113: | Line 113: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Revision as of 21:52, 13 May 2013
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Moves a folder.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
move($src, $dest, $path= '', $use_streams=false)
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. | |
$use_streams | false |
Returns[edit]
mixed Error message on false or boolean true on success.
Defined in[edit]
libraries/joomla/filesystem/folder.php
Importing[edit]
jimport( 'joomla.filesystem.folder' );
Source Body[edit]
function move($src, $dest, $path = '', $use_streams=false)
{
// Initialise 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)) {
return JText::_('Cannot find source folder');
}
if (JFolder::exists($dest)) {
return JText::_('Folder already exists');
}
if($use_streams) {
$stream =& JFactory::getStream();
if(!$stream->move($src, $dest)) {
return JText::_('Rename failed').': '. $stream->getError();
//return JError::raiseError(-1, JText::_('Rename failed').': '. $stream->getError()));
}
$ret = true;
} else {
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[edit]
<CodeExamplesForm />