当前位置: 首页>>代码示例>>PHP>>正文


PHP LocalFile::exists方法代码示例

本文整理汇总了PHP中LocalFile::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP LocalFile::exists方法的具体用法?PHP LocalFile::exists怎么用?PHP LocalFile::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LocalFile的用法示例。


在下文中一共展示了LocalFile::exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateParameters

 /**
  * Validate the user parameters and set $this->archiveName and $this->file.
  * Throws an error if validation fails
  */
 protected function validateParameters()
 {
     // Validate the input title
     $title = Title::makeTitleSafe(NS_FILE, $this->params['filename']);
     if (is_null($title)) {
         $this->dieUsageMsg(array('invalidtitle', $this->params['filename']));
     }
     $localRepo = RepoGroup::singleton()->getLocalRepo();
     // Check if the file really exists
     $this->file = $localRepo->newFile($title);
     if (!$this->file->exists()) {
         $this->dieUsageMsg('notanarticle');
     }
     // Check if the archivename is valid for this file
     $this->archiveName = $this->params['archivename'];
     $oldFile = $localRepo->newFromArchiveName($title, $this->archiveName);
     if (!$oldFile->exists()) {
         $this->dieUsageMsg('filerevert-badversion');
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:24,代码来源:ApiFileRevert.php

示例2: purgeFromArchiveTable

 protected function purgeFromArchiveTable(LocalRepo $repo, LocalFile $file)
 {
     $dbr = $repo->getSlaveDB();
     $res = $dbr->select('filearchive', array('fa_archive_name'), array('fa_name' => $file->getName()), __METHOD__);
     foreach ($res as $row) {
         if ($row->fa_archive_name === null) {
             // Was not an old version (current version names checked already)
             continue;
         }
         $ofile = $repo->newFromArchiveName($file->getTitle(), $row->fa_archive_name);
         // If there is an orphaned storage file still there...delete it
         if (!$file->exists() && $repo->fileExists($ofile->getPath())) {
             $dpath = $this->getDeletedPath($repo, $ofile);
             if ($repo->fileExists($dpath)) {
                 // Sanity check to avoid data loss
                 $repo->getBackend()->delete(array('src' => $ofile->getPath()));
                 $this->output("Deleted orphan file: {$ofile->getPath()}.\n");
             } else {
                 $this->error("File was not deleted: {$ofile->getPath()}.\n");
             }
         }
         $file->purgeOldThumbnails($row->fa_archive_name);
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:24,代码来源:purgeChangedFiles.php

示例3: exists

 /**
  * If archive name is an empty string, then file does not "exist"
  *
  * This is the case for a couple files on Wikimedia servers where
  * the old version is "lost".
  */
 public function exists()
 {
     $archiveName = $this->getArchiveName();
     if ($archiveName === '' || !is_string($archiveName)) {
         return false;
     }
     return parent::exists();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:14,代码来源:OldLocalFile.php

示例4: insertImage

 protected function insertImage($name, $mwname, $result)
 {
     global $wgRequest, $wgImageMagickConvertCommand, $wgServer;
     if (!$result) {
         $result = array();
     } elseif ($result['error']) {
         return $result;
     }
     $fromPage = $wgRequest->getVal('viapage');
     if (!empty($mwname) && !empty($name)) {
         $name = trim(urldecode($name));
         $dateTime = new DateTime();
         $mwDate = wfTimestamp(TS_MW);
         // Mediawiki timestamp: 'YmdHis'
         list($first, $ext) = self::splitFilenameExt($name);
         $ext = strtolower($ext);
         $validExts = array('GIF', 'JPG', 'JPEG', 'PNG');
         if (!in_array(strtoupper($ext), $validExts)) {
             $result['error'] = 'Error: Invalid file extension ' . strtoupper($ext) . '. Valid extensions are:';
             foreach ($validExts as $validExt) {
                 $result['error'] .= ' ' . strtoupper($validExt);
             }
             $result['error'] .= '.';
             return $result;
         }
         $saveName = false;
         $titleExists = false;
         $suffixNum = 1;
         while (!$saveName || $titleExists) {
             $saveName = 'User Completed Image ' . $fromPage . ' ' . $dateTime->format('Y.m.d H.i.s') . ' ' . $suffixNum . '.' . $ext;
             $title = Title::makeTitleSafe(NS_IMAGE, $saveName);
             $newFile = true;
             $titleExists = $title->exists();
             $suffixNum++;
         }
         $temp_file = new TempLocalImageFile(Title::newFromText($mwname, NS_IMAGE), RepoGroup::singleton()->getLocalRepo());
         if (!$temp_file || !$temp_file->exists()) {
             $result['error'] = 'Error: A server error has occurred. Please try again.';
             return $result;
         }
         // Image orientation is a bit wonky on some mobile devices; use ImageMagick's auto-orient to try fixing it.
         $tempFilePath = $temp_file->getPath();
         $cmd = $wgImageMagickConvertCommand . ' ' . $tempFilePath . ' -auto-orient ' . $tempFilePath;
         exec($cmd);
         // Use a CC license
         $comment = '{{Self}}';
         $file = new LocalFile($title, RepoGroup::singleton()->getLocalRepo());
         $file->upload($tempFilePath, $comment, $comment);
         if (!$file || !$file->exists()) {
             $result['error'] = 'Error: A server error has occurred. Please try again.';
             return $result;
         }
         $temp_file->delete('');
         $fileTitle = $file->getTitle();
         $fileURL = $file->url;
         $thumbURL = '';
         $thumb = $file->getThumbnail(200, -1, true, true);
         if (!$thumb) {
             $result['error'] = 'Error: A server error has occurred. Please try again.';
             $file->delete('');
             return $result;
         }
         $thumbURL = $thumb->url;
         $result['titleText'] = $fileTitle->getText();
         $result['titleDBkey'] = substr($fileTitle->getDBkey(), 21);
         // Only keep important info
         $result['titlePreText'] = '/' . $fileTitle->getPrefixedText();
         $result['titleArtID'] = $fileTitle->getArticleID();
         $result['timestamp'] = $mwDate;
         $result['fromPage'] = $wgRequest->getVal('viapage');
         $result['thumbURL'] = $thumbURL;
         $result['fileURL'] = $wgServer . $fileURL;
     }
     return $result;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:75,代码来源:ImageUploadHandler.class.php

示例5: deleteImageHelper

 protected function deleteImageHelper($imageName)
 {
     $title = Title::newFromText($imageName, NS_FILE);
     $file = new LocalFile($title, RepoGroup::singleton()->getLocalRepo());
     $visualization = new CityVisualization();
     $visualization->removeImageFromReview($this->wg->cityId, $title->getArticleId(), $this->wg->contLang->getCode());
     if ($file->exists()) {
         $file->delete('no longer needed');
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:PromoImage.class.php


注:本文中的LocalFile::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。