當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OldLocalFile::newFromArchiveName方法代碼示例

本文整理匯總了PHP中OldLocalFile::newFromArchiveName方法的典型用法代碼示例。如果您正苦於以下問題:PHP OldLocalFile::newFromArchiveName方法的具體用法?PHP OldLocalFile::newFromArchiveName怎麽用?PHP OldLocalFile::newFromArchiveName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OldLocalFile的用法示例。


在下文中一共展示了OldLocalFile::newFromArchiveName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getFreshURL

 public function getFreshURL($name, $definedName)
 {
     $title = Title::newFromText($definedName, NS_FILE);
     if ($definedName != $name) {
         $file = OldLocalFile::newFromArchiveName($title, RepoGroup::singleton()->getLocalRepo(), $name);
         return wfReplaceImageServer($file->getUrl());
     } else {
         $file = new LocalFile($title, RepoGroup::singleton()->getLocalRepo());
         return wfReplaceImageServer($file->getUrl());
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:11,代碼來源:ThemeSettings.class.php

示例2: newFromArchiveName

 function newFromArchiveName($title, $archiveName)
 {
     return OldLocalFile::newFromArchiveName($title, $this, $archiveName);
 }
開發者ID:rocLv,項目名稱:conference,代碼行數:4,代碼來源:LocalRepo.php

示例3: importUpload

 /**
  * @return bool
  */
 function importUpload()
 {
     # Construct a file
     $archiveName = $this->getArchiveName();
     if ($archiveName) {
         wfDebug(__METHOD__ . "Importing archived file as {$archiveName}\n");
         $file = OldLocalFile::newFromArchiveName($this->getTitle(), RepoGroup::singleton()->getLocalRepo(), $archiveName);
     } else {
         $file = wfLocalFile($this->getTitle());
         $file->load(File::READ_LATEST);
         wfDebug(__METHOD__ . 'Importing new file as ' . $file->getName() . "\n");
         if ($file->exists() && $file->getTimestamp() > $this->getTimestamp()) {
             $archiveName = $file->getTimestamp() . '!' . $file->getName();
             $file = OldLocalFile::newFromArchiveName($this->getTitle(), RepoGroup::singleton()->getLocalRepo(), $archiveName);
             wfDebug(__METHOD__ . "File already exists; importing as {$archiveName}\n");
         }
     }
     if (!$file) {
         wfDebug(__METHOD__ . ': Bad file for ' . $this->getTitle() . "\n");
         return false;
     }
     # Get the file source or download if necessary
     $source = $this->getFileSrc();
     $flags = $this->isTempSrc() ? File::DELETE_SOURCE : 0;
     if (!$source) {
         $source = $this->downloadSource();
         $flags |= File::DELETE_SOURCE;
     }
     if (!$source) {
         wfDebug(__METHOD__ . ": Could not fetch remote file.\n");
         return false;
     }
     $sha1 = $this->getSha1();
     if ($sha1 && $sha1 !== sha1_file($source)) {
         if ($flags & File::DELETE_SOURCE) {
             # Broken file; delete it if it is a temporary file
             unlink($source);
         }
         wfDebug(__METHOD__ . ": Corrupt file {$source}.\n");
         return false;
     }
     $user = User::newFromName($this->user_text);
     # Do the actual upload
     if ($archiveName) {
         $status = $file->uploadOld($source, $archiveName, $this->getTimestamp(), $this->getComment(), $user, $flags);
     } else {
         $status = $file->upload($source, $this->getComment(), $this->getComment(), $flags, false, $this->getTimestamp(), $user);
     }
     if ($status->isGood()) {
         wfDebug(__METHOD__ . ": Successful\n");
         return true;
     } else {
         wfDebug(__METHOD__ . ': failed: ' . $status->getHTML() . "\n");
         return false;
     }
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:59,代碼來源:Import.php

示例4: importUpload

 /**
  * @return bool
  */
 function importUpload()
 {
     # Construct a file
     $archiveName = $this->getArchiveName();
     if ($archiveName) {
         wfDebug(__METHOD__ . "Importing archived file as {$archiveName}\n");
         $file = OldLocalFile::newFromArchiveName($this->getTitle(), RepoGroup::singleton()->getLocalRepo(), $archiveName);
     } else {
         $file = wfLocalFile($this->getTitle());
         $file->load(File::READ_LATEST);
         wfDebug(__METHOD__ . 'Importing new file as ' . $file->getName() . "\n");
         if ($file->exists() && $file->getTimestamp() > $this->getTimestamp()) {
             $archiveName = $file->getTimestamp() . '!' . $file->getName();
             $file = OldLocalFile::newFromArchiveName($this->getTitle(), RepoGroup::singleton()->getLocalRepo(), $archiveName);
             wfDebug(__METHOD__ . "File already exists; importing as {$archiveName}\n");
         }
     }
     if (!$file) {
         wfDebug(__METHOD__ . ': Bad file for ' . $this->getTitle() . "\n");
         return false;
     }
     # Get the file source or download if necessary
     $source = $this->getFileSrc();
     $autoDeleteSource = $this->isTempSrc();
     if (!strlen($source)) {
         $source = $this->downloadSource();
         $autoDeleteSource = true;
     }
     if (!strlen($source)) {
         wfDebug(__METHOD__ . ": Could not fetch remote file.\n");
         return false;
     }
     $tmpFile = new TempFSFile($source);
     if ($autoDeleteSource) {
         $tmpFile->autocollect();
     }
     $sha1File = ltrim(sha1_file($source), '0');
     $sha1 = $this->getSha1();
     if ($sha1 && $sha1 !== $sha1File) {
         wfDebug(__METHOD__ . ": Corrupt file {$source}.\n");
         return false;
     }
     $user = $this->getUserObj() ?: User::newFromName($this->getUser());
     # Do the actual upload
     if ($archiveName) {
         $status = $file->uploadOld($source, $archiveName, $this->getTimestamp(), $this->getComment(), $user);
     } else {
         $flags = 0;
         $status = $file->upload($source, $this->getComment(), $this->getComment(), $flags, false, $this->getTimestamp(), $user);
     }
     if ($status->isGood()) {
         wfDebug(__METHOD__ . ": Successful\n");
         return true;
     } else {
         wfDebug(__METHOD__ . ': failed: ' . $status->getHTML() . "\n");
         return false;
     }
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:61,代碼來源:WikiRevision.php

示例5: onSubmit

 public function onSubmit($data)
 {
     $this->useTransactionalTimeLimit();
     $old = $this->getRequest()->getText('oldimage');
     $localFile = $this->page->getFile();
     $oldFile = OldLocalFile::newFromArchiveName($this->getTitle(), $localFile->getRepo(), $old);
     $source = $localFile->getArchiveVirtualUrl($old);
     $comment = $data['comment'];
     if ($localFile->getSha1() === $oldFile->getSha1()) {
         return Status::newFatal('filerevert-identical');
     }
     // TODO: Preserve file properties from database instead of reloading from file
     return $localFile->upload($source, $comment, $comment, 0, false, false, $this->getUser());
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:14,代碼來源:RevertAction.php


注:本文中的OldLocalFile::newFromArchiveName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。