function copy($sourcePath, $destinationPath) { Lms_Ufs::copy($sourcePath, $destinationPath); }
/** * Save file from remote machine to localhost * * @param string $strategy * @param array $params */ public static function localize($path, $strategy, $params = array()) { $oldPath = $path; $depth = 3; $imageDir = self::$imageDir; switch ($strategy) { case "cover": $imageDir .= 'covers/'; $depth = 2; break; case "photo": $imageDir .= 'photos/'; $depth = 3; break; case "screenshot": $imageDir .= 'screenshots/'; $depth = 3; break; case "poster": $imageDir .= 'posters/'; $depth = 2; break; case "cache": $imageDir .= 'cache/'; $depth = 2; break; } if (isset($params['extension'])) { $extension = $params['extension']; } else { $extension = strtolower(pathinfo($oldPath, PATHINFO_EXTENSION)); } $basename = isset($params['name']) && $params['name'] ? $params['name'] : basename($oldPath); $basename = Lms_LangHelpers::translit($basename); $basename = strtolower($basename); $basename = Lms_Ufu::nameToUrl($basename); $basename = ereg_replace('[^a-z0-9!@_\\.-]', '', $basename); if (strlen(trim($basename))) { do { $newPath = $imageDir . self::_generateRandomPrefixFolders($depth) . $basename . '.' . $extension; $depth++; } while (Lms_Ufs::file_exists($newPath)); Lms_FileSystem::createFolder(dirname($newPath), 0777, true); if (preg_match('{^https?://}i', $oldPath)) { self::downloadImage($oldPath, $newPath); } else { Lms_Ufs::copy($oldPath, $newPath); } return $newPath; } return $oldPath; }
function copy($newDesination) { Lms_Ufs::copy($this->getPath(), $newDesination); }