Example #1
0
 /**
  * Determine icon for a given file
  *
  * @param \OC\Files\FileInfo $file file info
  * @return string icon URL
  */
 public static function determineIcon($file)
 {
     if ($file['type'] === 'dir') {
         $icon = \OC_Helper::mimetypeIcon('dir');
         // TODO: move this part to the client side, using mountType
         if ($file->isShared()) {
             $icon = \OC_Helper::mimetypeIcon('dir-shared');
         } elseif ($file->isMounted()) {
             $icon = \OC_Helper::mimetypeIcon('dir-external');
         }
     } else {
         $icon = \OC_Helper::mimetypeIcon($file->getMimetype());
     }
     return substr($icon, 0, -3) . 'svg';
 }
Example #2
0
 /**
  * Check if a preview can be generated for a file
  *
  * @param \OC\Files\FileInfo $file
  * @return bool
  */
 public static function isAvailable($file)
 {
     if (!\OC_Config::getValue('enable_previews', true)) {
         return false;
     }
     //check if there are preview backends
     if (empty(self::$providers)) {
         self::initProviders();
     }
     //remove last element because it has the mimetype *
     $providers = array_slice(self::$providers, 0, -1);
     foreach ($providers as $supportedMimeType => $provider) {
         /**
          * @var \OC\Preview\Provider $provider
          */
         if (preg_match($supportedMimeType, $file->getMimetype())) {
             return $provider->isAvailable($file);
         }
     }
     return false;
 }
Example #3
0
 /**
  * get the filesystem info
  *
  * @param string $path
  * @param boolean|string $includeMountPoints true to add mountpoint sizes,
  * 'ext' to add only ext storage mount point sizes. Defaults to true.
  * defaults to true
  * @return \OC\Files\FileInfo|false False if file does not exist
  */
 public function getFileInfo($path, $includeMountPoints = true)
 {
     $this->assertPathLength($path);
     if (!Filesystem::isValidPath($path)) {
         return false;
     }
     if (Cache\Scanner::isPartialFile($path)) {
         return $this->getPartFileInfo($path);
     }
     $relativePath = $path;
     $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
     $mount = Filesystem::getMountManager()->find($path);
     $storage = $mount->getStorage();
     $internalPath = $mount->getInternalPath($path);
     if ($storage) {
         $data = $this->getCacheEntry($storage, $internalPath, $relativePath);
         if (!$data instanceof ICacheEntry) {
             return false;
         }
         if ($mount instanceof MoveableMount && $internalPath === '') {
             $data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
         }
         $owner = $this->getUserObjectForOwner($storage->getOwner($internalPath));
         $info = new FileInfo($path, $storage, $internalPath, $data, $mount, $owner);
         if ($data and isset($data['fileid'])) {
             if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
                 //add the sizes of other mount points to the folder
                 $extOnly = $includeMountPoints === 'ext';
                 $mounts = Filesystem::getMountManager()->findIn($path);
                 foreach ($mounts as $mount) {
                     $subStorage = $mount->getStorage();
                     if ($subStorage) {
                         // exclude shared storage ?
                         if ($extOnly && $subStorage instanceof \OC\Files\Storage\Shared) {
                             continue;
                         }
                         $subCache = $subStorage->getCache('');
                         $rootEntry = $subCache->get('');
                         $info->addSubEntry($rootEntry, $mount->getMountPoint());
                     }
                 }
             }
         }
         return $info;
     }
     return false;
 }
Example #4
0
 /**
  * Check if a preview can be generated for a file
  *
  * @param \OC\Files\FileInfo $file
  * @return bool
  */
 public static function isAvailable(\OC\Files\FileInfo $file)
 {
     if (!\OC_Config::getValue('enable_previews', true)) {
         return false;
     }
     $mount = $file->getMountPoint();
     if ($mount and !$mount->getOption('previews', true)) {
         return false;
     }
     //check if there are preview backends
     if (empty(self::$providers)) {
         self::initProviders();
     }
     foreach (self::$providers as $supportedMimeType => $provider) {
         /**
          * @var \OC\Preview\Provider $provider
          */
         if (preg_match($supportedMimeType, $file->getMimetype())) {
             return $provider->isAvailable($file);
         }
     }
     return false;
 }
Example #5
0
File: txt.php Project: Romua1d/core
 /**
  * Check if a preview can be generated for $path
  *
  * @param \OC\Files\FileInfo $file
  * @return bool
  */
 public function isAvailable($file)
 {
     return $file->getSize() > 5;
 }