コード例 #1
0
 private function executeImage()
 {
     if (empty($this->mParams['tempName'])) {
         $this->dieUsageMsg('The tempName parameter must be set');
     }
     $tempFile = new FakeLocalFile(Title::newFromText($this->mParams['tempName'], 6), RepoGroup::singleton()->getLocalRepo());
     $duplicate = $this->getFileDuplicate($tempFile->getLocalRefPath());
     if ($duplicate) {
         return array('title' => $duplicate->getTitle()->getText());
     } else {
         $title = $this->getUniqueTitle(wfStripIllegalFilenameChars($this->mParams['title']));
         if (isset($this->mParams['license'])) {
             $pageText = SpecialUpload::getInitialPageText('', $this->mParams['license']);
         }
         $file = new LocalFile($title, RepoGroup::singleton()->getLocalRepo());
         $file->upload($tempFile->getPath(), '', $pageText ? $pageText : '');
         return array('title' => $file->getTitle()->getText());
     }
 }