コード例 #1
0
 /**
  * @return string
  */
 public function title()
 {
     if ($this->isImage()) {
         return I18n::translatef('io/mimetype/image', strtoupper($this->type()));
     }
     return I18n::translatef('io/mimetype/file', strtoupper($this->type()));
 }
コード例 #2
0
 private function stashFile(Io_File $file_, $subPath_ = null)
 {
     $mimeType = $file_->getMimetype();
     if (null === $mimeType) {
         $this->addError(I18n::translatef('ui/panel/upload/file/error/unknown_mimetype', $file_->getName()));
         $file_->delete();
         return;
     }
     if (!$this->isValidMimetype($mimeType) || !$this->isValidFileExtension($file_->getExtension())) {
         $this->addError(I18n::translatef('ui/panel/upload/file/error/illegal_mimetype', $mimeType->title(), $file_->getName()));
         $file_->delete();
         return;
     }
     if ($this->extractArchives && $mimeType->isArchive()) {
         if (false === isset(self::$implArchives[$mimeType->name()])) {
             $this->addError(I18n::translatef('ui/panel/upload/file/error/unsupported_archive', $mimeType->name()));
             $file_->delete();
             return;
         }
         $archiveId = md5($file_->getPathAsString());
         $archiveImpl = self::$implArchives[$mimeType->name()];
         $archivePath = self::uploadPath($archiveId);
         // TODO Io_Archive_Zip
         $archive = new $archiveImpl();
         $archive->open($file_->getPathAsString());
         $archive->extractTo($archivePath);
         $this->scanTemporaryUploadPath(Io::path($archivePath), $subPath_);
         $archive->close();
         $file_->delete();
         return;
     }
     $file = $file_->move(self::uploadPath($subPath_)->getFile($file_->getName()));
     $this->m_files[$subPath_ . $file->getName()] = $file;
 }