protected function paste($args)
{
$dst = $args['dst'];
$targets = is_array($args['targets']) ? $args['targets'] : array();
$cut = !empty($args['cut']);
$error = $cut ? self::ERROR_MOVE : self::ERROR_COPY;
$result = array('changed' => array(), 'added' => array(), 'removed' => array());
if (($dstVolume = $this->volume($dst)) == false) {
return array('error' => $this->error($error, '#' . $targets[0], self::ERROR_TRGDIR_NOT_FOUND, '#' . $dst));
}
$hashes = $renames = array();
$suffix = '~';
if (!empty($args['renames'])) {
$renames = array_flip($args['renames']);
if (is_string($args['suffix']) && !preg_match('/[\\/\\?*:|"<>]/', $args['suffix'])) {
$suffix = $args['suffix'];
}
}
if (!empty($args['hashes'])) {
$hashes = array_flip($args['hashes']);
}
foreach ($targets as $target) {
elFinder::extendTimeLimit();
if (($srcVolume = $this->volume($target)) == false) {
$result['warning'] = $this->error($error, '#' . $target, self::ERROR_FILE_NOT_FOUND);
break;
}
$rnres = array();
if ($renames) {
$file = $srcVolume->file($target);
if (isset($renames[$file['name']])) {
$dir = $dstVolume->realpath($dst);
if (isset($hashes[$file['name']])) {
$hash = $hashes[$file['name']];
} else {
$hash = $dstVolume->getHash($dir, $file['name']);
}
$rnres = $this->rename(array('target' => $hash, 'name' => $dstVolume->uniqueName($dir, $file['name'], $suffix, true, 0)));
if (!empty($rnres['error'])) {
$result['warning'] = $rnres['error'];
break;
}
}
}
if (($file = $dstVolume->paste($srcVolume, $target, $dst, $cut, $hashes)) == false) {
$result['warning'] = $this->error($dstVolume->error());
break;
}
$dirChange = !empty($file['dirChange']);
unset($file['dirChange']);
if ($dirChange) {
$result['changed'][] = $file;
} else {
$result['added'][] = $file;
}
if ($rnres) {
$result = array_merge_recursive($result, $rnres);
}
}
return $result;
}