Exemplo n.º 1
0
 public function getIcon()
 {
     if ($this->icon === null) {
         $mimeType = $this->getMimeType();
         if ($mimeType === 'directory') {
             $this->icon = 'fa-folder-open-o';
         } elseif (MimeType::isText($mimeType)) {
             $this->icon = 'fa-file-text-o';
         } elseif (MimeType::isImage($mimeType)) {
             $this->icon = 'fa-file-image-o';
         } elseif (MimeType::isAudio($mimeType)) {
             $this->icon = 'fa-file-audio-o';
         } elseif (MimeType::isVideo($mimeType)) {
             $this->icon = 'fa-file-video-o';
         } elseif (MimeType::isPdf($mimeType)) {
             $this->icon = 'fa-file-pdf-o';
         } elseif (MimeType::isArchive($mimeType)) {
             $this->icon = 'fa-file-archive-o';
         } else {
             $this->icon = 'fa-file-o';
         }
     }
     return $this->icon;
 }
 protected function playFile(Request $request, FileManager $fileManager)
 {
     if (!$request->query->has('path')) {
         return $this->abort(400);
     }
     $path = $fileManager->getAbsolutePath($request->query->get('path'));
     if (!is_file($path)) {
         return $this->abort(404);
     }
     $mimeType = FileUtils::getMimeType($path);
     if (!MimeType::isPlayable($mimeType)) {
         return $this->abort(500, 'error.notPlayable');
     }
     $relativePath = $fileManager->getRelativePath($path);
     $breadcrumb = self::getBreadcrumb($fileManager, $path, false);
     $name = pathinfo($relativePath, PATHINFO_BASENAME);
     if (MimeType::isAudio($mimeType)) {
         $mediaTag = "audio";
     } elseif (MimeType::isVideo($mimeType)) {
         $mediaTag = "video";
     }
     return $this->render(['name' => $name, 'breadcrumb' => $breadcrumb, 'mediaTag' => $mediaTag, 'type' => explode(";", $mimeType)[0], 'src' => $relativePath]);
 }