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


PHP Filesystem::getView方法代码示例

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


在下文中一共展示了Filesystem::getView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extract

 /**
  * get metadata info for a media file
  *
  * @param $path
  * @return array
  */
 public function extract($path)
 {
     if (ini_get('allow_url_fopen')) {
         $file = \OC\Files\Filesystem::getView()->getAbsolutePath($path);
         $data = @$this->getID3->analyze('oc://' . $file);
     } else {
         // Fallback to the local FS
         $file = \OC\Files\Filesystem::getLocalFile($path);
     }
     \getid3_lib::CopyTagsToComments($data);
     return $data;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:18,代码来源:extractor.php

示例2: __construct

 public function __construct($imagePath, $user = null, $square = false)
 {
     if (!Filesystem::isValidPath($imagePath)) {
         return;
     }
     if (is_null($user)) {
         $this->view = Filesystem::getView();
         $this->user = \OCP\User::getUser();
     } else {
         $this->view = new View('/' . $user . '/files');
         $this->user = $user;
     }
     $this->useOriginal = (substr($imagePath, -4) === '.svg' or substr($imagePath, -5) === '.svgz');
     if ($this->useOriginal) {
         $this->path = $imagePath;
     } else {
         $galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
         if (strrpos($imagePath, '.')) {
             $extension = substr($imagePath, strrpos($imagePath, '.') + 1);
             $image = substr($imagePath, 0, strrpos($imagePath, '.'));
         } else {
             $extension = '';
             $image = $imagePath;
         }
         if ($square) {
             $extension = 'square.' . $extension;
         }
         $this->path = $galleryDir . $image . '.' . $extension;
         if (!file_exists($this->path)) {
             $this->create($imagePath, $square);
         }
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:33,代码来源:thumbnail.php

示例3: determineIcon

 public static function determineIcon($file)
 {
     if ($file['type'] === 'dir') {
         $dir = $file['directory'];
         $absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir . '/' . $file['name']);
         $mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
         if (!is_null($mount)) {
             $sid = $mount->getStorageId();
             if (!is_null($sid)) {
                 $sid = explode(':', $sid);
                 if ($sid[0] === 'shared') {
                     return \OC_Helper::mimetypeIcon('dir-shared');
                 }
                 if ($sid[0] !== 'local' and $sid[0] !== 'home') {
                     return \OC_Helper::mimetypeIcon('dir-external');
                 }
             }
         }
         return \OC_Helper::mimetypeIcon('dir');
     }
     if ($file['isPreviewAvailable']) {
         $pathForPreview = $file['directory'] . '/' . $file['name'];
         return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag'];
     }
     return \OC_Helper::mimetypeIcon($file['mimetype']);
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:26,代码来源:helper.php

示例4: unlink

 /**
  * Deletes the given file by moving it into the trashbin.
  *
  * @param string $path
  */
 public function unlink($path)
 {
     if (self::$disableTrash) {
         return $this->storage->unlink($path);
     }
     $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
     $result = true;
     if (!isset($this->deletedFiles[$normalized])) {
         $view = Filesystem::getView();
         $this->deletedFiles[$normalized] = $normalized;
         if ($filesPath = $view->getRelativePath($normalized)) {
             $filesPath = trim($filesPath, '/');
             $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
             // in cross-storage cases the file will be copied
             // but not deleted, so we delete it here
             if ($result) {
                 $this->storage->unlink($path);
             }
         } else {
             $result = $this->storage->unlink($path);
         }
         unset($this->deletedFiles[$normalized]);
     } else {
         if ($this->storage->file_exists($path)) {
             $result = $this->storage->unlink($path);
         }
     }
     return $result;
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:34,代码来源:storage.php

示例5: generateFileToken

 public function generateFileToken($fileId, $version)
 {
     // Get the FS view of the current user.
     $view = \OC\Files\Filesystem::getView();
     // Get the virtual path (if the file is shared).
     $path = $view->getPath($fileId);
     if (!$view->is_file($path) || !$view->isUpdatable($path)) {
         throw new \Exception('Invalid fileId.');
     }
     // Figure out the real owner, if not us.
     $owner = $view->getOwner($path);
     // Create a view into the owner's FS.
     $view = new \OC\Files\View('/' . $owner . '/files');
     // Find the real path.
     $path = $view->getPath($fileId);
     if (!$view->is_file($path)) {
         throw new \Exception('Invalid fileId.');
     }
     $editor = \OC::$server->getUserSession()->getUser()->getUID();
     $token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(32, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS);
     \OC::$server->getLogger()->debug('Issuing token for {editor} file {fileId}, version {version} owned by {owner}, path {path}: {token}', ['owner' => $owner, 'editor' => $editor, 'fileId' => $fileId, 'version' => $version, 'path' => $path, 'token' => $token]);
     $wopi = new \OCA\Richdocuments\Db\Wopi([$owner, $editor, $fileId, $version, $path, $token, time() + self::TOKEN_LIFETIME_SECONDS]);
     if (!$wopi->insert()) {
         throw new \Exception('Failed to add wopi token into database');
     }
     return $token;
 }
开发者ID:owncloud,项目名称:richdocuments,代码行数:27,代码来源:wopi.php

示例6: getFreeSpace

 /**
  * @param $parentUri
  * @return mixed
  */
 public function getFreeSpace($parentUri)
 {
     if (is_null($this->fileView)) {
         // initialize fileView
         $this->fileView = \OC\Files\Filesystem::getView();
     }
     $freeSpace = $this->fileView->free_space($parentUri);
     return $freeSpace;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:13,代码来源:quotaplugin.php

示例7: getMounts

 /**
  * get all storages for $dir
  *
  * @param string $dir
  * @return \OC\Files\Mount\MountPoint[]
  */
 protected function getMounts($dir)
 {
     //TODO: move to the node based fileapi once that's done
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($this->user);
     $absolutePath = Filesystem::getView()->getAbsolutePath($dir);
     $mountManager = Filesystem::getMountManager();
     $mounts = $mountManager->findIn($absolutePath);
     $mounts[] = $mountManager->find($absolutePath);
     $mounts = array_reverse($mounts);
     //start with the mount of $dir
     return $mounts;
 }
开发者ID:spielhoelle,项目名称:owncloud,代码行数:19,代码来源:scanner.php

示例8: impl

 /**
  * @return Directory
  */
 private function impl()
 {
     //
     // TODO: we need to mount filesystem of the give user
     //
     $user = \OC::$server->getUserSession()->getUser();
     if ($this->getName() !== $user->getUID()) {
         return new SimpleCollection($this->getName());
     }
     $view = \OC\Files\Filesystem::getView();
     $rootInfo = $view->getFileInfo('');
     $impl = new Directory($view, $rootInfo);
     return $impl;
 }
开发者ID:evanjt,项目名称:core,代码行数:17,代码来源:fileshome.php

示例9: unshareChildren

 public static function unshareChildren($params)
 {
     $path = Filesystem::getView()->getAbsolutePath($params['path']);
     $view = new \OC\Files\View('/');
     // find share mount points within $path and unmount them
     $mountManager = \OC\Files\Filesystem::getMountManager();
     $mountedShares = $mountManager->findIn($path);
     foreach ($mountedShares as $mount) {
         if ($mount->getStorage()->instanceOfStorage('OCA\\Files_Sharing\\ISharedStorage')) {
             $mountPoint = $mount->getMountPoint();
             $view->unlink($mountPoint);
         }
     }
 }
开发者ID:hyb148,项目名称:core,代码行数:14,代码来源:hooks.php

示例10: deleteHook

 public static function deleteHook($arguments)
 {
     // save delete file info
     $view = \OC\Files\Filesystem::getView();
     if (!is_null($view)) {
         $path = $arguments['path'];
         $info = $view->getFileInfo($path);
         if ($info) {
             self::$deleteFileInfo[$path] = $info;
         }
     }
     // save storage information
     self::$preStorageInfo = \OC_Helper::getStorageInfo('/');
 }
开发者ID:evaluation-alex,项目名称:web_hooks,代码行数:14,代码来源:hooks.php

示例11: rename

 public static function rename($args)
 {
     self::preDispatch();
     $fileId = intval(Helper::getArrayValueByKey($args, 'file_id', 0));
     $name = Helper::getArrayValueByKey($_POST, 'name');
     $view = \OC\Files\Filesystem::getView();
     $path = $view->getPath($fileId);
     if (isset($name) && $view->is_file($path) && $view->isUpdatable($path)) {
         $newPath = dirname($path) . '/' . $name;
         if ($view->rename($path, $newPath)) {
             \OCP\JSON::success();
             return;
         }
     }
     \OCP\JSON::error(array('message' => Config::getL10n()->t('You don\'t have permission to rename this document')));
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:16,代码来源:documentController.php

示例12: __construct

 public function __construct($imagePath, $user = null, $square = false)
 {
     if (!Filesystem::isValidPath($imagePath)) {
         return;
     }
     if (is_null($user)) {
         $this->view = Filesystem::getView();
         $this->user = \OCP\USER::getUser();
     } else {
         $this->view = new View('/' . $user . '/files');
         $this->user = $user;
     }
     $galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
     $this->path = $galleryDir . $imagePath . '.png';
     if (!file_exists($this->path)) {
         self::create($imagePath, $square);
     }
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:18,代码来源:albumthumbnail.php

示例13: __construct

 /**
  * @param array $barriers of given quota barriers which are to be used to fire a quota change
  */
 public function __construct($barriers = null, $view = null)
 {
     if (is_null($barriers)) {
         $barriers = \OC_Config::getValue('webhook_barriers', array());
     }
     if (!is_array($barriers)) {
         \OC_Log::write('webhooks', "Invalid barriers given: {$barriers}", \OC_Log::ERROR);
         $barriers = array();
     }
     sort($barriers);
     $this->barriers = $barriers;
     $this->notifications = new Notifications();
     $this->subscriptions = new Subscriptions();
     if (is_null($view)) {
         $view = \OC\Files\Filesystem::getView();
     }
     $this->view = $view;
 }
开发者ID:evaluation-alex,项目名称:web_hooks,代码行数:21,代码来源:publisher.php

示例14: av_scan

 public static function av_scan($path)
 {
     $path = $path[\OC\Files\Filesystem::signal_param_path];
     if ($path != '') {
         if (isset($_POST['dirToken'])) {
             //Public upload case
             $filesView = \OC\Files\Filesystem::getView();
         } else {
             $filesView = \OCP\Files::getStorage("files");
         }
         if (!is_object($filesView)) {
             \OCP\Util::writeLog('files_antivirus', 'Can\'t init filesystem view', \OCP\Util::WARN);
             return;
         }
         // check if path is a directory
         if ($filesView->is_dir($path)) {
             return;
         }
         // we should have a file to work with, and the file shouldn't
         // be empty
         $fileExists = $filesView->file_exists($path);
         if ($fileExists && $filesView->filesize($path) > 0) {
             $fileStatus = self::scanFile($filesView, $path);
             $result = $fileStatus->getNumericStatus();
             switch ($result) {
                 case Status::SCANRESULT_UNCHECKED:
                     //TODO: Show warning to the user: The file can not be checked
                     break;
                 case Status::SCANRESULT_INFECTED:
                     //remove file
                     $filesView->unlink($path);
                     Notification::sendMail($path);
                     $message = \OCP\Util::getL10N('files_antivirus')->t("Virus detected! Can't upload the file %s", array(basename($path)));
                     \OCP\JSON::error(array("data" => array("message" => $message)));
                     exit;
                     break;
                 case Status::SCANRESULT_CLEAN:
                     //do nothing
                     break;
             }
         }
     }
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:43,代码来源:scanner.php

示例15: joinAsUser

 /**
  * @NoAdminRequired
  */
 public function joinAsUser($fileId)
 {
     try {
         $view = \OC\Files\Filesystem::getView();
         $path = $view->getPath($fileId);
         if ($view->isUpdatable($path)) {
             $file = new File($fileId);
             $response = Db\Session::start($this->uid, $file);
         } else {
             $info = $view->getFileInfo($path);
             $response = array('permissions' => $info['permissions'], 'id' => $fileId);
         }
         $response = array_merge($response, array('status' => 'success'));
     } catch (\Exception $e) {
         $this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), array('app' => $this->appName));
         $response = array('status' => 'error');
     }
     return $response;
 }
开发者ID:Ebimedia,项目名称:owncloud,代码行数:22,代码来源:sessioncontroller.php


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