本文整理汇总了PHP中MOXMAN_Util_PathUtils::combine方法的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN_Util_PathUtils::combine方法的具体用法?PHP MOXMAN_Util_PathUtils::combine怎么用?PHP MOXMAN_Util_PathUtils::combine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOXMAN_Util_PathUtils
的用法示例。
在下文中一共展示了MOXMAN_Util_PathUtils::combine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$toPath = $params->to;
$ext = MOXMAN_Util_PathUtils::getExtension($toPath);
if ($ext !== 'zip') {
$toPath .= '.zip';
}
$toFile = MOXMAN::getFile($toPath);
$config = $toFile->getConfig();
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$toFile->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $toFile->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$zipWriter = new MOXMAN_Zip_ZipWriter(array("compressionLevel" => 5));
$filter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($config);
$path = $params->path;
foreach ($params->names as $name) {
$fromFile = MOXMAN::getFile(MOXMAN_Util_PathUtils::combine($path, $name));
$this->addZipFiles($fromFile, $fromFile->getParent(), $filter, $zipWriter);
}
$stream = $toFile->open(MOXMAN_Vfs_IFileStream::WRITE);
if ($stream) {
$stream->write($zipWriter->toString());
$stream->close();
}
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::ADD, $toFile);
return $this->fileToJson($toFile);
}
示例2: processRequest
/**
* Process a request using the specified context.
*
* @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
*/
public function processRequest(MOXMAN_Http_Context $httpContext)
{
$request = $httpContext->getRequest();
$response = $httpContext->getResponse();
$path = $request->get("path");
$names = explode('/', $request->get("names", ""));
$zipName = $request->get("zipname", "files.zip");
if (count($names) === 1) {
$file = MOXMAN::getFile(MOXMAN_Util_PathUtils::combine($path, $names[0]));
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig(MOXMAN::getFile($path)->getConfig(), "download");
if (!$filter->accept($file)) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
if ($file->isFile()) {
$response->sendFile($file, true);
return;
}
}
// Download multiple files as zip
$zipWriter = new MOXMAN_Zip_ZipWriter(array("compressionLevel" => 0));
// Setup download headers
$response->disableCache();
$response->setHeader("Content-type", "application/octet-stream");
$response->setHeader("Content-Disposition", 'attachment; filename="' . $zipName . '"');
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig(MOXMAN::getFile($path)->getConfig(), "download");
// Combine files to zip
foreach ($names as $name) {
$fromFile = MOXMAN::getFile(MOXMAN_Util_PathUtils::combine($path, $name));
$this->addZipFiles($fromFile, $fromFile->getParent(), $filter, $zipWriter);
}
$response->sendContent($zipWriter->toString());
}
示例3: initialize
/**
* Initializes the storage instance.
*
* @param MOXMAN_Util_Config $config Config instance.
* @param int $type Storage type to use, can be any of the type constants.
* @param string $name Name of the user/group if those types are used or an empty string.
*/
public function initialize($config, $type, $name)
{
$this->config = $config;
$this->type = $type;
$this->name = $name;
$this->storagePath = MOXMAN_Util_PathUtils::combine($config->get("storage.path"), ($name ? $type . "." . $name : $type) . ".json");
}
示例4: processRequest
/**
* Sends the specified file with the correct mime type back to the browser.
* This method gets called from the client side using the stream file.
*
* @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
*/
public function processRequest(MOXMAN_Http_Context $httpContext)
{
$request = $httpContext->getRequest();
$response = $httpContext->getResponse();
try {
$file = MOXMAN::getFile($request->get("path"));
} catch (Exception $e) {
$response->setStatus("500", "Could not resolve path: " . $request->get("path"));
if (MOXMAN::getLogger()) {
MOXMAN::getLogger()->debug("Could not resolve path: " . $request->get("path"));
}
return;
}
// Create thumbnail
if ($request->get("thumb")) {
try {
$file = $this->plugin->createThumbnail($file);
} catch (Exception $e) {
$response->setStatus("500", "Could not generate thumbnail.");
$response->sendContent("Could not generate thumbnail.");
return;
}
}
// Fire before stream event
$args = new MOXMAN_Vfs_StreamEventArgs($httpContext, $file);
$this->plugin->fire("BeforeStream", $args);
$file = $args->getFile();
// Stream temp file if it exists
if ($tempName = $request->get("tempname")) {
$ext = MOXMAN_Util_PathUtils::getExtension($file->getName());
$tempName = "mcic_" . md5(session_id() . $file->getName()) . "." . $ext;
$tempFilePath = MOXMAN_Util_PathUtils::combine(MOXMAN_Util_PathUtils::getTempDir(), $tempName);
if (file_exists($tempFilePath)) {
$response->sendLocalFile($tempFilePath);
return;
}
}
$url = $file->getUrl();
if ($url && !$request->get("stream", false)) {
$response->redirect($url);
} else {
// Force 48h cache time
$offset = 48 * 60 * 60;
$response->setHeader("Cache-Control", "max-age=" . $offset);
$response->setHeader("Date", gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
$response->setHeader("Expires", gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
$response->setHeader("Pragma", "public");
$response->sendFile($file);
}
}
示例5: getFile
/**
* Returns a file object out of the specified URL.
*
* @param string Absolute URL for the specified file.
* @return MOXMAN_Vfs_IFile File that got resolved or null if it wasn't found.
*/
public function getFile($url)
{
$file = null;
$prefix = $this->fileSystem->getBucketOption("urlprefix");
$prefix = preg_replace('/^https?:\\/\\//', '//', $prefix);
$url = preg_replace('/^https?:\\/\\//', '//', $url);
if (strpos($url, $prefix) === 0) {
$bucketKey = $this->fileSystem->getBucketOption("key");
$path = urldecode(substr($url, strlen($prefix)));
$filePath = MOXMAN_Util_PathUtils::combine("s3://" . $bucketKey, $path);
if (MOXMAN_Util_PathUtils::isChildOf($filePath, $this->fileSystem->getRootPath())) {
return $this->fileSystem->getFile($filePath);
}
}
return $file;
}
示例6: getFile
/**
* Returns a file object out of the specified URL.
*
* @param string Absolute URL for the specified file.
* @return MOXMAN_Vfs_IFile File that got resolved or null if it wasn't found.
*/
public function getFile($url)
{
$config = $this->fileSystem->getConfig();
$file = null;
// Get config items
$wwwroot = $config->get("filesystem.local.wwwroot");
$prefix = $config->get("filesystem.local.urlprefix");
$paths = MOXMAN_Util_PathUtils::getSitePaths();
// No wwwroot specified try to figure out a wwwroot
if (!$wwwroot) {
$wwwroot = $paths["wwwroot"];
} else {
// Force the www root to an absolute file system path
$wwwroot = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $wwwroot);
}
// Add prefix to URL
if ($prefix == "") {
$prefix = MOXMAN_Util_PathUtils::combine("{proto}://{host}", $paths["prefix"]);
}
// Replace protocol
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
$prefix = str_replace("{proto}", "https", $prefix);
} else {
$prefix = str_replace("{proto}", "http", $prefix);
}
// Replace host/port
$prefix = str_replace("{host}", $_SERVER['HTTP_HOST'], $prefix);
$prefix = str_replace("{port}", $_SERVER['SERVER_PORT'], $prefix);
// Remove prefix from url
if ($prefix && strpos($url, $prefix) === 0) {
$url = substr($url, strlen($prefix));
}
// Parse url and check if path part of the URL is within the root of the file system
$url = parse_url($url);
if (isset($url["path"])) {
$path = MOXMAN_Util_PathUtils::combine($wwwroot, $url["path"]);
if (MOXMAN_Util_PathUtils::isChildOf($path, $this->fileSystem->getRootPath())) {
// Crop away root path part and glue it back on again since the case might be different
// For example: c:/inetpub/wwwroot and C:/InetPub/WWWRoot this will force it into the
// valid fileSystem root path prefix
$path = substr($path, strlen($this->fileSystem->getRootPath()));
$path = MOXMAN_Util_PathUtils::combine($this->fileSystem->getRootPath(), $path);
$file = $this->fileSystem->getFile($path);
}
}
return $file;
}
示例7: locate
public static function locate($optionName, $pathLocations)
{
$rootPath = MOXMAN_ROOT;
$fullPath = MOXMAN::getConfig()->get($optionName);
if ($fullPath) {
return $fullPath;
}
while ($rootPath) {
foreach ($pathLocations as $path) {
$fullPath = MOXMAN_Util_PathUtils::combine($rootPath, $path);
if (file_exists($fullPath)) {
return $fullPath;
}
}
if (dirname($rootPath) === $rootPath) {
break;
}
$rootPath = dirname($rootPath);
}
throw new MOXMAN_Exception("Error could not locate library/framework. Please configure: " . $optionName);
}
示例8: getUrl
/**
* Returns an URL for the specified file object.
*
* @param MOXMAN_Vfs_IFile $file File to get the absolute URL for.
* @return String Absolute URL for the specified file.
*/
public function getUrl(MOXMAN_Vfs_IFile $file)
{
$config = $file->getConfig();
// Get config items
$wwwroot = $config->get("filesystem.local.wwwroot");
$prefix = $config->get("filesystem.local.urlprefix");
$suffix = $config->get("filesystem.local.urlsuffix");
$paths = MOXMAN_Util_PathUtils::getSitePaths();
// No wwwroot specified try to figure out a wwwroot
if (!$wwwroot) {
$wwwroot = $paths["wwwroot"];
} else {
// Force the www root to an absolute file system path
$wwwroot = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $wwwroot);
}
// Add prefix to URL
if ($prefix == "") {
$prefix = MOXMAN_Util_PathUtils::combine("{proto}://{host}", $paths["prefix"]);
}
// Replace protocol
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
$prefix = str_replace("{proto}", "https", $prefix);
} else {
$prefix = str_replace("{proto}", "http", $prefix);
}
// Replace host/port
$prefix = str_replace("{host}", $_SERVER['HTTP_HOST'], $prefix);
$prefix = str_replace("{port}", $_SERVER['SERVER_PORT'], $prefix);
// Insert path into URL
$url = substr($file->getPath(), strlen($wwwroot));
$url = MOXMAN_Util_PathUtils::combine($prefix, $url);
// Add suffix to URL
if ($suffix) {
$url .= $suffix;
}
return $url;
}
示例9: copyDir
/** @ignore */
private function copyDir($from, $to)
{
$fromPathRoot = $from->getPath();
$files = $this->getFiles($fromPathRoot);
foreach ($files as $fromPath) {
$toPath = MOXMAN_Util_PathUtils::combine($to->getPath(), substr($fromPath, strlen($fromPathRoot)));
if (is_file($fromPath)) {
if ($to instanceof MOXMAN_Vfs_Local_File) {
copy($fromPath, $toPath);
} else {
$to->getFileSystem()->getFile($toPath)->importFrom($fromPath);
}
} else {
if ($to instanceof MOXMAN_Vfs_Local_File) {
MOXMAN_Util_PathUtils::verifyPath($toPath, true, "dir");
mkdir($toPath);
} else {
$to->getFileSystem()->getFile($toPath)->mkdir();
}
}
}
}
示例10: save
/**
* Executes the save command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
private function save($params)
{
$file = MOXMAN::getFile($params->path);
$config = $file->getConfig();
if ($config->get("general.demo")) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$file->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "edit");
if ($filter->accept($file) !== MOXMAN_Vfs_CombinedFileFilter::ACCEPTED) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
// Import temp file as target file
if (isset($params->tempname)) {
$tempFilePath = MOXMAN_Util_PathUtils::combine(MOXMAN_Util_PathUtils::getTempDir(), $params->tempname);
$file->importFrom($tempFilePath);
}
MOXMAN::getFileSystemManager()->removeLocalTempFile($file);
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::ADD, $file);
return parent::fileToJson($file, true);
}
示例11: getFileList
/**
* Lists files in the specified path and returns an array with stat info details.
*
* @param String $path Path to list files in.
* @return Array Array with stat info name/value arrays.
*/
private function getFileList($path)
{
$files = array();
$prefix = $path === "/" ? "" : substr($path, 1) . "/";
$xml = $this->sendXmlRequest(array("query" => array("comp" => "list", "restype" => "container", "prefix" => $prefix, "delimiter" => "/", "maxresults" => 99999)));
// List dirs
if (isset($xml->Blobs->BlobPrefix)) {
foreach ($xml->Blobs->BlobPrefix as $blobPrefix) {
if ($prefix != $blobPrefix->Name) {
$stat = array("name" => basename($blobPrefix->Name), "isdir" => true, "size" => 0, "mdate" => 0);
$path = MOXMAN_Util_PathUtils::combine($path, $stat["name"]);
$files[] = $stat;
}
}
}
// List files
if (isset($xml->Blobs->Blob)) {
foreach ($xml->Blobs->Blob as $blob) {
if ($prefix != $blob->Name) {
$stat = array("name" => basename($blob->Name), "isdir" => false, "size" => intval($blob->Properties->{"Content-Length"}), "mdate" => strtotime($blob->Properties->{"Last-Modified"}));
$path = MOXMAN_Util_PathUtils::combine($path, $stat["name"]);
$files[] = $stat;
}
}
}
return $files;
}
示例12: getUrl
/**
* Returns the URL of the memory file.
*
* @return String Memory file URL.
*/
public function getUrl()
{
return MOXMAN_Util_PathUtils::combine("http://memory", $this->getPath());
}
示例13: getPublicPath
/**
* Returns the public path for a file. A public path is a path that is safe
* to pass to the client side since it doesn't show the systems full path.
*
* @return String Public path for the file to be passed out to the client.
*/
public function getPublicPath()
{
if (!$this->publicPath) {
// Use absolute path if debug mode is enabled or user_friendly_paths is off
/*if (!$this->fileSystem->getConfig()->get("general.user_friendly_paths")) {
return $this->getPath();
}*/
$rootName = $this->fileSystem->getRootName();
$this->publicPath = MOXMAN_Util_PathUtils::combine($rootName !== "/" ? "/" . $rootName : $rootName, substr($this->path, strlen($this->fileSystem->getRootPath())));
}
return $this->publicPath;
}
示例14: fileToJson
/**
* Converts a file instance to a JSON serializable object.
*
* @param MOXMAN_Vfs_IFile $file File to convert into JSON format.
* @param Boolean $meta State if the meta data should be returned or not.
* @return stdClass JSON serializable object.
*/
public static function fileToJson($file, $meta = false)
{
$config = $file->getConfig();
$renameFilter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "rename");
$editFilter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "edit");
$viewFilter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "view");
$result = (object) array("path" => $file->getPublicPath(), "size" => $file->getSize(), "lastModified" => $file->getLastModified(), "isFile" => $file->isFile(), "canRead" => $file->canRead(), "canWrite" => $file->canWrite(), "canEdit" => $file->isFile() && $editFilter->accept($file) === MOXMAN_Vfs_IFileFilter::ACCEPTED, "canRename" => $renameFilter->accept($file) === MOXMAN_Vfs_IFileFilter::ACCEPTED, "canView" => $file->isFile() && $viewFilter->accept($file) === MOXMAN_Vfs_IFileFilter::ACCEPTED, "canPreview" => $file->isFile() && MOXMAN_Media_ImageAlter::canEdit($file), "exists" => $file->exists());
if ($meta) {
$metaData = $file->getMetaData();
//$args = $this->fireCustomInfo(MOXMAN_Core_CustomInfoEventArgs::INSERT_TYPE, $file);
$metaData = (object) $metaData->getAll();
if ($file instanceof MOXMAN_Vfs_Local_File && MOXMAN_Media_ImageAlter::canEdit($file)) {
$thumbnailFolderPath = MOXMAN_Util_PathUtils::combine($file->getParent(), $config->get('thumbnail.folder'));
$thumbnailFile = MOXMAN::getFile($thumbnailFolderPath, $config->get('thumbnail.prefix') . $file->getName());
// TODO: Implement stat info cache layer here
$info = MOXMAN_Media_MediaInfo::getInfo($file);
$metaData->width = $info["width"];
$metaData->height = $info["height"];
if ($thumbnailFile->exists()) {
$metaData->thumb_url = $thumbnailFile->getUrl();
$info = MOXMAN_Media_MediaInfo::getInfo($thumbnailFile);
$metaData->thumb_width = $info["width"];
$metaData->thumb_height = $info["height"];
}
}
$metaData->url = $file->getUrl();
$result->meta = $metaData;
}
return $result;
}
示例15: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$url = isset($params->url) ? $params->url : "";
$path = isset($params->path) ? $params->path : "{default}";
$lastPath = isset($params->lastPath) ? $params->lastPath : "";
$offset = isset($params->offset) ? $params->offset : 0;
$length = isset($params->length) ? $params->length : null;
$orderBy = isset($params->orderBy) ? $params->orderBy : "name";
$desc = isset($params->desc) ? $params->desc : false;
// Result URL to closest file
$file = null;
if ($url) {
try {
$file = MOXMAN::getFile($url);
} catch (MOXMAN_Exception $e) {
// Might throw exception ignore it
$file = null;
}
if ($file) {
if ($file->exists()) {
$urlFile = $file;
}
while (!$file->exists() || !$file->isDirectory()) {
$file = $file->getParentFile();
}
}
}
// Resolve lastPath input
if ($lastPath && !$file) {
try {
$file = MOXMAN::getFile($lastPath);
} catch (MOXMAN_Exception $e) {
// Might throw exception ignore it
$file = null;
}
if ($file) {
while (!$file->exists() || !$file->isDirectory()) {
$file = $file->getParentFile();
}
}
}
$file = $file ? $file : MOXMAN::getFile($path);
// Force update on cached file info
if (isset($params->force) && $params->force) {
MOXMAN_Vfs_Cache_FileInfoStorage::getInstance()->updateFileList($file);
}
if (!$file->isDirectory()) {
throw new MOXMAN_Exception("Path isn't a directory: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_TYPE);
}
$config = $file->getConfig();
// Setup input file filter
$paramsFileFilter = new MOXMAN_Vfs_BasicFileFilter();
if (isset($params->include_directory_pattern) && $params->include_directory_pattern) {
$paramsFileFilter->setIncludeDirectoryPattern($params->include_directory_pattern);
}
if (isset($params->exclude_directory_pattern) && $params->exclude_directory_pattern) {
$paramsFileFilter->setExcludeDirectoryPattern($params->exclude_directory_pattern);
}
if (isset($params->include_file_pattern) && $params->include_file_pattern) {
$paramsFileFilter->setIncludeFilePattern($params->include_file_pattern);
}
if (isset($params->exclude_file_pattern) && $params->exclude_file_pattern) {
$paramsFileFilter->setExcludeFilePattern($params->exclude_file_pattern);
}
if (isset($params->extensions) && $params->extensions) {
$paramsFileFilter->setIncludeExtensions($params->extensions);
}
if (isset($params->filter) && $params->filter != null) {
$paramsFileFilter->setIncludeWildcardPattern($params->filter);
}
if (isset($params->only_dirs) && $params->only_dirs === true) {
$paramsFileFilter->setOnlyDirs(true);
}
if (isset($params->only_files) && $params->only_files === true) {
$paramsFileFilter->setOnlyFiles(true);
}
// Setup file filter
$configuredFilter = new MOXMAN_Vfs_BasicFileFilter();
$configuredFilter->setIncludeDirectoryPattern($config->get('filesystem.include_directory_pattern'));
$configuredFilter->setExcludeDirectoryPattern($config->get('filesystem.exclude_directory_pattern'));
$configuredFilter->setIncludeFilePattern($config->get('filesystem.include_file_pattern'));
$configuredFilter->setExcludeFilePattern($config->get('filesystem.exclude_file_pattern'));
$configuredFilter->setIncludeExtensions($config->get('filesystem.extensions'));
// Setup combined filter
$combinedFilter = new MOXMAN_Vfs_CombinedFileFilter();
$combinedFilter->addFilter($paramsFileFilter);
$combinedFilter->addFilter($configuredFilter);
$files = $file->listFilesFiltered($combinedFilter)->limit($offset, $length)->orderBy($orderBy, $desc);
$args = $this->fireFilesAction(MOXMAN_Vfs_FileActionEventArgs::LIST_FILES, $file, $files);
$files = $args->getFileList();
$renameFilter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($file->getConfig(), "rename");
$editFilter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($file->getConfig(), "edit");
$viewFilter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($file->getConfig(), "view");
// List thumbnails and make lookup table
//.........这里部分代码省略.........