protected function elFinderVolumeDrupal::_move in elFinder file manager 8.2
Same name and namespace in other branches
- 6.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::_move()
- 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::_move()
- 7.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::_move()
Move file into another parent dir
@author Alexey Sukhotin
Parameters
string $source source file path:
string $target target dir path:
string $name file name:
Return value
bool
File
- src/
Controller/ elFinderVolumeDrupal.php, line 159 - elFinder driver for Drupal filesystem.
Class
- elFinderVolumeDrupal
- @file
Code
protected function _move($source, $targetDir, $name) {
$target = $targetDir . DIRECTORY_SEPARATOR . (!empty($name) ? $name : basename($source));
if (!is_dir($target) && !$this
->CheckExtension($this
->_drupalfileobject($target))) {
return FALSE;
}
if (is_dir($source)) {
$srcuri = $this
->drupalpathtouri($source);
$dsturi = $this
->drupalpathtouri($target);
$children = db_select('file_managed', 'f')
->condition('uri', $srcuri . '/%', 'LIKE')
->fields('f', array(
'fid',
'uri',
))
->execute()
->fetchAll();
foreach ($children as $child) {
$newuri = str_replace("{$srcuri}/", "{$dsturi}/", $child->uri);
db_update('file_managed')
->fields(array(
'uri' => $newuri,
))
->condition('fid', $child->fid)
->execute();
}
return @rename($source, $target);
}
elseif (@file_move($this
->_drupalfileobject($source), $this
->drupalpathtouri($target))) {
return TRUE;
}
return FALSE;
}