Exemplo n.º 1
0
 /**
  * Get the local directory corresponding to one of the basic zones
  * @param string $zone
  * @return bool|null|string
  */
 function getZonePath($zone)
 {
     $supported = ['public', 'thumb'];
     if (in_array($zone, $supported)) {
         return parent::getZonePath($zone);
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Get the path of the transcoded directory, or a particular file if $suffix is specified
  *
  * @param bool|string $suffix if not false, the name of a media file
  *
  * @return string
  */
 function getTranscodedPath($suffix = false)
 {
     $this->assertRepoDefined();
     return $this->repo->getZonePath('transcoded') . '/' . $this->getThumbRel($suffix);
 }
Exemplo n.º 3
0
 /**
  * A LocalFile wrapper around a file that has been temporarily stashed,
  * so we can do things like create thumbnails for it. Arguably
  * UnregisteredLocalFile should be handling its own file repo but that
  * class is a bit retarded currently.
  *
  * @param FileRepo $repo Repository where we should find the path
  * @param string $path Path to file
  * @param string $key Key to store the path and any stashed data under
  * @throws UploadStashBadPathException
  * @throws UploadStashFileNotFoundException
  */
 public function __construct($repo, $path, $key)
 {
     $this->fileKey = $key;
     // resolve mwrepo:// urls
     if ($repo->isVirtualUrl($path)) {
         $path = $repo->resolveVirtualUrl($path);
     } else {
         // check if path appears to be sane, no parent traversals,
         // and is in this repo's temp zone.
         $repoTempPath = $repo->getZonePath('temp');
         if (!$repo->validateFilename($path) || strpos($path, $repoTempPath) !== 0) {
             wfDebug("UploadStash: tried to construct an UploadStashFile " . "from a file that should already exist at '{$path}', but path is not valid\n");
             throw new UploadStashBadPathException('path is not valid');
         }
         // check if path exists! and is a plain file.
         if (!$repo->fileExists($path)) {
             wfDebug("UploadStash: tried to construct an UploadStashFile from " . "a file that should already exist at '{$path}', but path is not found\n");
             throw new UploadStashFileNotFoundException('cannot find path, or not a plain file');
         }
     }
     parent::__construct(false, $repo, $path, false);
     $this->name = basename($this->path);
 }