/** * Return the name of this file * * @return string */ public function getName() { if (!isset($this->name)) { $this->assertRepoDefined(); $this->name = $this->repo->getNameFromTitle($this->title); } return $this->name; }
/** * Create an UnregisteredLocalFile based on a path or a (title,repo) pair. * A FileRepo object is not required here, unlike most other File classes. * * @throws MWException * @param Title|bool $title * @param FileRepo|bool $repo * @param string|bool $path * @param string|bool $mime */ function __construct($title = false, $repo = false, $path = false, $mime = false) { if (!($title && $repo) && !$path) { throw new MWException(__METHOD__ . ': not enough parameters, must specify title and repo, or a full path'); } if ($title instanceof Title) { $this->title = File::normalizeTitle($title, 'exception'); $this->name = $repo->getNameFromTitle($title); } else { $this->name = basename($path); $this->title = File::normalizeTitle($this->name, 'exception'); } $this->repo = $repo; if ($path) { $this->path = $path; } else { $this->assertRepoDefined(); $this->path = $repo->getRootDirectory() . '/' . $repo->getHashPath($this->name) . $this->name; } if ($mime) { $this->mime = $mime; } $this->dims = array(); }