当前位置: 首页>>代码示例>>PHP>>正文


PHP MOXMAN::getFileSystemManager方法代码示例

本文整理汇总了PHP中MOXMAN::getFileSystemManager方法的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN::getFileSystemManager方法的具体用法?PHP MOXMAN::getFileSystemManager怎么用?PHP MOXMAN::getFileSystemManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MOXMAN的用法示例。


在下文中一共展示了MOXMAN::getFileSystemManager方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
 {
     $rootPaths = array();
     foreach (MOXMAN::getFileSystemManager()->getFileSystems() as $filesystem) {
         $rootFile = $filesystem->getRootFile();
         if (!$rootFile->isHidden()) {
             // Get root file meta data
             $meta = $rootFile->getMetaData();
             $meta = $meta->getAll("ui");
             // Add show/hide login to meta
             $meta["standalone"] = MOXMAN::getAuthManager()->hasStandalone();
             // Return name, path and optional meta data
             $rootPaths[] = (object) array("name" => $filesystem->getRootName(), "path" => $rootFile->getPublicPath(), "meta" => $meta, "config" => $this->getPublicConfig($rootFile));
         }
     }
     return $rootPaths;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:23,代码来源:ListRootsCommand.php

示例2: __construct

 /**
  * Constructs a new memory file stream.
  *
  * @param MOXMAN_Vfs_IFile $file File instance for memory stream.
  * @param string Stream mode READ or WRITE.
  */
 public function __construct(MOXMAN_Vfs_IFile $file, $mode)
 {
     $this->mode = $mode;
     $this->file = $file;
     // Get local temp file path
     $fileSystemManager = MOXMAN::getFileSystemManager();
     $this->localTempFilePath = $fileSystemManager->getLocalTempPath($file);
     // Export to local temp file
     if ($mode === MOXMAN_Vfs_IFileStream::READ || $mode === MOXMAN_Vfs_IFileStream::APPEND) {
         $file->exportTo($this->localTempFilePath);
     }
     // Open local temp file for r,w or a
     $this->fp = fopen($this->localTempFilePath, $mode);
     if (!$this->fp) {
         throw new MOXMAN_Exception("Could not open file stream for file: " . $file->getPath());
     }
 }
开发者ID:tremor-od,项目名称:pizza.loc,代码行数:23,代码来源:MemoryFileStream.php

示例3: 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)
 {
     $rootPaths = array();
     foreach (MOXMAN::getFileSystemManager()->getFileSystems() as $filesystem) {
         $rootFile = $filesystem->getRootFile();
         if (!$rootFile->isHidden()) {
             // Get root file meta data
             $meta = $rootFile->getMetaData();
             $meta = $meta->getAll("ui");
             // Add initial path if it's specified in config
             $initalPath = $filesystem->getConfig()->get("filesystem.inital_path", "");
             if ($initalPath) {
                 $meta["initial_path"] = $initalPath;
             }
             // Return name, path and optional meta data
             $rootPaths[] = (object) array("name" => $filesystem->getRootName(), "path" => $rootFile->getPublicPath(), "meta" => $meta, "config" => $this->getPublicConfig($rootFile));
         }
     }
     return $rootPaths;
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:26,代码来源:ListRootsCommand.php

示例4: 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)
 {
     $fromFile = MOXMAN::getFile($params->from);
     $toFile = MOXMAN::getFile($params->to);
     $config = $toFile->getConfig();
     if ($config->get('general.demo')) {
         throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
     }
     if (!$fromFile->exists()) {
         throw new MOXMAN_Exception("From file doesn't exist: " . $fromFile->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
     }
     if (!$toFile->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $toFile->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     $paths = array();
     $fileSystemManager = MOXMAN::getFileSystemManager();
     $zipArchive = new ZipArchive();
     $localTempFilePath = null;
     $result = array();
     if ($fromFile instanceof MOXMAN_Vfs_Local_File) {
         $res = $zipArchive->open($fromFile->getPath());
     } else {
         $localTempFilePath = $fileSystemManager->getLocalTempPath($fromFile);
         $fromFile->exportTo($localTempFilePath);
         $res = $zipArchive->open($localTempFilePath);
     }
     if ($res) {
         for ($i = 0; $i < $zipArchive->numFiles; $i++) {
             $stat = $zipArchive->statIndex($i);
             $paths[] = $stat["name"];
         }
         $filter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($config);
         $fileSystem = $toFile->getFileSystem();
         foreach ($paths as $path) {
             $isFile = !preg_match('/\\/$/', $path);
             $toPath = MOXMAN_Util_PathUtils::combine($toFile->getPath(), iconv('cp437', 'UTF-8', $path));
             $targetFile = MOXMAN::getFile($toPath);
             if ($filter->accept($targetFile, $isFile) === MOXMAN_Vfs_IFileFilter::ACCEPTED) {
                 if ($isFile) {
                     $content = $zipArchive->getFromName($path);
                     // Fire before file action add event
                     $args = new MOXMAN_Core_FileActionEventArgs("add", $targetFile);
                     $args->getData()->fileSize = strlen($content);
                     MOXMAN::getPluginManager()->get("core")->fire("BeforeFileAction", $args);
                     $targetFile = $args->getFile();
                     $targetFile = $this->mkdirs($targetFile, true);
                     $stream = $targetFile->open(MOXMAN_Vfs_IFileStream::WRITE);
                     $stream->write($content);
                     $stream->close();
                     //echo "Create file: ". $targetFile->getPublicPath() ."\n";
                     $this->fireFileAction(MOXMAN_Core_FileActionEventArgs::ADD, $targetFile);
                 } else {
                     $targetFile = $this->mkdirs($targetFile);
                 }
                 $result[] = $this->fileToJson($targetFile);
             }
         }
         $zipArchive->close();
         if ($localTempFilePath) {
             $fileSystemManager->removeLocalTempFile($fromFile);
         }
     }
     return $result;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:70,代码来源:UnZipCommand.php

示例5: init

 public function init()
 {
     MOXMAN::getFileSystemManager()->registerFileSystem("s3", "MOXMAN_AmazonS3_FileSystem");
 }
开发者ID:newton27,项目名称:dolphin.pro,代码行数:4,代码来源:Plugin.php

示例6: removeFormat

 /**
  * Removes formats from an image.
  *
  * @param MOXMAN_Vfs_IFile $file File to generate images for.
  */
 public function removeFormat(MOXMAN_Vfs_IFile $file)
 {
     if (!$file->exists()) {
         return;
     }
     $config = $file->getConfig();
     $format = $config->get("autoformat.rules", "");
     if ($config->get("autoformat.delete_format_images", true) === false) {
         return;
     }
     // @codeCoverageIgnoreStart
     if (!$format) {
         return;
     }
     // @codeCoverageIgnoreEnd
     $chunks = preg_split('/,/', $format, 0, PREG_SPLIT_NO_EMPTY);
     $imageInfo = MOXMAN_Media_MediaInfo::getInfo($file);
     $width = $imageInfo["width"];
     $height = $imageInfo["height"];
     foreach ($chunks as $chunk) {
         $parts = explode('=', $chunk);
         $fileName = preg_replace('/\\..+$/', '', $file->getName());
         $extension = preg_replace('/^.+\\./', '', $file->getName());
         $targetWidth = $newWidth = $width;
         $targetHeight = $newHeight = $height;
         $items = explode('|', $parts[0]);
         foreach ($items as $item) {
             switch ($item) {
                 case "gif":
                 case "jpg":
                 case "jpeg":
                 case "png":
                     $extension = $item;
                     break;
                 default:
                     $matches = array();
                     if (preg_match('/\\s?([0-9|\\*]+)\\s?x([0-9|\\*]+)\\s?/', $item, $matches)) {
                         $targetWidth = $matches[1];
                         $targetHeight = $matches[2];
                         if ($targetWidth == '*') {
                             // Width is omitted
                             $targetWidth = floor($width / ($height / $targetHeight));
                         }
                         if ($targetHeight == '*') {
                             // Height is omitted
                             $targetHeight = floor($height / ($width / $targetWidth));
                         }
                     }
             }
         }
         // Scale it
         if ($targetWidth != $width || $targetHeight != $height) {
             $scale = min($targetWidth / $width, $targetHeight / $height);
             $newWidth = $scale > 1 ? $width : floor($width * $scale);
             $newHeight = $scale > 1 ? $height : floor($height * $scale);
         }
         // Build output path
         $outPath = $parts[1];
         $outPath = str_replace("%f", $fileName, $outPath);
         $outPath = str_replace("%e", $extension, $outPath);
         $outPath = str_replace("%ow", "" . $width, $outPath);
         $outPath = str_replace("%oh", "" . $height, $outPath);
         $outPath = str_replace("%tw", "" . $targetWidth, $outPath);
         $outPath = str_replace("%th", "" . $targetHeight, $outPath);
         $outPath = str_replace("%w", "" . $newWidth, $outPath);
         $outPath = str_replace("%h", "" . $newHeight, $outPath);
         $outFile = MOXMAN::getFileSystemManager()->getFile($file->getParent(), $outPath);
         if ($outFile->exists()) {
             $outFile->delete();
         }
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:77,代码来源:Plugin.php

示例7: 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);
 }
开发者ID:vidalweb,项目名称:MoxieManager,代码行数:29,代码来源:AlterImageCommand.php

示例8: init

 public function init()
 {
     MOXMAN::getFileSystemManager()->registerFileSystem("favorite", "MOXMAN_Favorites_FileSystem");
     MOXMAN::getFileSystemManager()->addRoot("Favorites=favorite:///");
     MOXMAN::getPluginManager()->get("core")->bind("FileAction", "onFileAction", $this);
 }
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:6,代码来源:Plugin.php

示例9: sendFile

 /**
  * Sends the specified file to the client by streaming it.
  *
  * @param MOXMAN_Vfs_IFile $file File to stream to client.
  * @param Boolean $download State if the file should be downloaded or not by the client.
  */
 public function sendFile(MOXMAN_Vfs_IFile $file, $download = false)
 {
     // Check if the file is a local file is so use the faster method
     if ($file instanceof MOXMAN_Vfs_Local_File) {
         $this->sendLocalFile($file->getInternalPath(), $download);
         return;
     }
     // Check if the remote file system has a local temp path
     $localTempPath = MOXMAN::getFileSystemManager()->getLocalTempPath($file);
     if (file_exists($localTempPath)) {
         $this->sendLocalFile($localTempPath, $download);
         return;
     }
     if ($download) {
         $this->disableCache();
         $this->setHeader("Content-type", "application/octet-stream");
         $this->setHeader("Content-Disposition", "attachment; filename=\"" . $file->getName() . "\"");
     } else {
         $this->setHeader("Content-type", MOXMAN_Util_Mime::get($file->getName()));
     }
     // Non local file system then read and stream
     $stream = $file->open(MOXMAN_Vfs_IFileStream::READ);
     if ($stream) {
         // Read chunk by chunk and stream it
         while (($buff = $stream->read()) !== "") {
             $this->sendContent($buff);
         }
         $stream->close();
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:36,代码来源:Response.php


注:本文中的MOXMAN::getFileSystemManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。