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


PHP LocalFile类代码示例

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


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

示例1: purgeFromArchiveTable

 protected function purgeFromArchiveTable(LocalFile $file)
 {
     $db = $file->getRepo()->getSlaveDB();
     $res = $db->select('filearchive', array('fa_archive_name'), array('fa_name' => $file->getName()), __METHOD__);
     foreach ($res as $row) {
         $file->purgeOldThumbnails($row->fa_archive_name);
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:8,代码来源:purgeDeletedFiles.php

示例2: uploadImage

 /**
  * Handle image upload
  *
  * Returns array with uploaded files details or error details
  */
 public function uploadImage($uploadFieldName = self::DEFAULT_FILE_FIELD_NAME, $destFileName = null, $forceOverwrite = false)
 {
     global $IP, $wgRequest, $wgUser;
     wfProfileIn(__METHOD__);
     $ret = false;
     // check whether upload is enabled (RT #53714)
     if (!WikiaPhotoGalleryHelper::isUploadAllowed()) {
         $ret = array('error' => true, 'message' => wfMsg('uploaddisabled'));
         wfProfileOut(__METHOD__);
         return $ret;
     }
     $imageName = stripslashes(!empty($destFileName) ? $destFileName : $wgRequest->getFileName($uploadFieldName));
     // validate name and content of uploaded photo
     $nameValidation = $this->checkImageName($imageName, $uploadFieldName);
     if ($nameValidation == UploadBase::SUCCESS) {
         // get path to uploaded image
         $imagePath = $wgRequest->getFileTempName($uploadFieldName);
         // check if image with this name is already uploaded
         if ($this->imageExists($imageName) && !$forceOverwrite) {
             // upload as temporary file
             $this->log(__METHOD__, "image '{$imageName}' already exists!");
             $tempName = $this->tempFileName($wgUser);
             $title = Title::makeTitle(NS_FILE, $tempName);
             $localRepo = RepoGroup::singleton()->getLocalRepo();
             $file = new FakeLocalFile($title, $localRepo);
             $file->upload($wgRequest->getFileTempName($uploadFieldName), '', '');
             // store uploaded image in GarbageCollector (image will be removed if not used)
             $tempId = $this->tempFileStoreInfo($tempName);
             // generate thumbnail (to fit 200x200 box) of temporary file
             $width = min(WikiaPhotoGalleryHelper::thumbnailMaxWidth, $file->width);
             $height = min(WikiaPhotoGalleryHelper::thumbnailMaxHeight, $file->height);
             $thumbnail = $file->transform(array('height' => $height, 'width' => $width));
             // split uploaded file name into name + extension (foo-bar.png => foo-bar + png)
             list($fileName, $extensionsName) = UploadBase::splitExtensions($imageName);
             $extensionName = !empty($extensionsName) ? end($extensionsName) : '';
             $this->log(__METHOD__, 'upload successful');
             $ret = array('conflict' => true, 'name' => $imageName, 'nameParts' => array($fileName, $extensionName), 'tempId' => $tempId, 'size' => array('height' => $file->height, 'width' => $file->width), 'thumbnail' => array('height' => $thumbnail->height, 'url' => $thumbnail->url, 'width' => $thumbnail->width));
         } else {
             // use regular MW upload
             $this->log(__METHOD__, "image '{$imageName}' is new one - uploading as MW file");
             $this->log(__METHOD__, "uploading '{$imagePath}' as File:{$imageName}");
             // create title and file objects for MW image to create
             $imageTitle = Title::newFromText($imageName, NS_FILE);
             $imageFile = new LocalFile($imageTitle, RepoGroup::singleton()->getLocalRepo());
             // perform upload
             $result = $imageFile->upload($imagePath, '', '');
             $this->log(__METHOD__, !empty($result->ok) ? 'upload successful' : 'upload failed');
             $ret = array('success' => !empty($result->ok), 'name' => $imageName, 'size' => array('height' => !empty($result->ok) ? $imageFile->getHeight() : 0, 'width' => !empty($result->ok) ? $imageFile->getWidth() : 0));
         }
     } else {
         $reason = $nameValidation;
         $this->log(__METHOD__, "upload failed - file name is not valid (error #{$reason})");
         $ret = array('error' => true, 'reason' => $reason, 'message' => $this->translateError($reason));
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:62,代码来源:WikiaPhotoGalleryUpload.class.php

示例3: purgeVideoInfoCache

 /**
  * Clear cache of video info specific to given file
  * @param LocalFile $file
  * @return bool
  */
 public static function purgeVideoInfoCache(\LocalFile $file)
 {
     $mediaService = new MediaQueryService();
     $mediaService->clearCacheTotalVideos();
     if (!$file->isLocal()) {
         $mediaService->clearCacheTotalPremiumVideos();
     }
     if (!empty(F::app()->wg->UseVideoVerticalFilters)) {
         VideoInfoHooksHelper::clearCategories($file->getTitle());
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:VideoInfoHooksHelper.class.php

示例4: processUpload

 /**
  * Do the upload.
  * Checks are made in SpecialUpload::execute()
  */
 protected function processUpload()
 {
     // Fetch the file if required
     $status = $this->mUpload->fetchFile();
     if (!$status->isOK()) {
         $this->showUploadError($this->getOutput()->parse($status->getWikiText()));
         return;
     }
     if (!Hooks::run('UploadForm:BeforeProcessing', array(&$this))) {
         wfDebug("Hook 'UploadForm:BeforeProcessing' broke processing the file.\n");
         // This code path is deprecated. If you want to break upload processing
         // do so by hooking into the appropriate hooks in UploadBase::verifyUpload
         // and UploadBase::verifyFile.
         // If you use this hook to break uploading, the user will be returned
         // an empty form with no error message whatsoever.
         return;
     }
     // Upload verification
     $details = $this->mUpload->verifyUpload();
     if ($details['status'] != UploadBase::OK) {
         $this->processVerificationError($details);
         return;
     }
     // Verify permissions for this title
     $permErrors = $this->mUpload->verifyTitlePermissions($this->getUser());
     if ($permErrors !== true) {
         $code = array_shift($permErrors[0]);
         $this->showRecoverableUploadError($this->msg($code, $permErrors[0])->parse());
         return;
     }
     $this->mLocalFile = $this->mUpload->getLocalFile();
     // Check warnings if necessary
     if (!$this->mIgnoreWarning) {
         $warnings = $this->mUpload->checkWarnings();
         if ($this->showUploadWarning($warnings)) {
             return;
         }
     }
     // This is as late as we can throttle, after expected issues have been handled
     if (UploadBase::isThrottled($this->getUser())) {
         $this->showRecoverableUploadError($this->msg('actionthrottledtext')->escaped());
         return;
     }
     // Get the page text if this is not a reupload
     if (!$this->mForReUpload) {
         $pageText = self::getInitialPageText($this->mComment, $this->mLicense, $this->mCopyrightStatus, $this->mCopyrightSource, $this->getConfig());
     } else {
         $pageText = false;
     }
     $status = $this->mUpload->performUpload($this->mComment, $pageText, $this->mWatchthis, $this->getUser());
     if (!$status->isGood()) {
         $this->showUploadError($this->getOutput()->parse($status->getWikiText()));
         return;
     }
     // Success, redirect to description page
     $this->mUploadSuccessful = true;
     Hooks::run('SpecialUploadComplete', array(&$this));
     $this->getOutput()->redirect($this->mLocalFile->getTitle()->getFullURL());
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:63,代码来源:SpecialUpload.php

示例5: newFileFromRow

 function newFileFromRow($row)
 {
     if (isset($row->img_name)) {
         return LocalFile::newFromRow($row, $this);
     } elseif (isset($row->oi_name)) {
         return OldLocalFile::newFromRow($row, $this);
     } else {
         throw new MWException(__METHOD__ . ': invalid row');
     }
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:10,代码来源:LocalRepo.php

示例6: executeImage

 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());
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:ApiAddMediaPermanent.php

示例7: uploadFromUrl

 /**
  * @param LocalFile $file
  * @param string $url
  * @param string $comment
  * @return FileRepoStatus
  */
 private function uploadFromUrl($file, $url, $comment)
 {
     $tmpFile = tempnam(wfTempDir(), 'upload');
     // fetch an asset
     $res = Http::get($url, 'default', ['noProxy' => true]);
     $this->assertTrue($res !== false, 'File from <' . $url . '> should be uploaded');
     file_put_contents($tmpFile, $res);
     $this->assertTrue(is_readable($tmpFile), 'Temp file for HTTP upload should be created and readable');
     Wikia::log(__METHOD__, false, sprintf('uploading %s (%.2f kB) as %s', $tmpFile, filesize($tmpFile) / 1024, $file->getName()), true);
     $res = $file->upload($tmpFile, $comment, '');
     #unlink( $tmpFile );
     return $res;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:ImagesServiceUploadTest.php

示例8: tempFileStoreInfo

 /**
  * Store info in the db to enable the script to pick it up later during the day (via an automated cleaning routine)
  */
 public function tempFileStoreInfo($filename)
 {
     global $wgExternalSharedDB, $wgCityId;
     wfProfileIn(__METHOD__);
     $title = Title::makeTitle(NS_FILE, $filename);
     $localRepo = RepoGroup::singleton()->getLocalRepo();
     $path = LocalFile::newFromTitle($title, $localRepo)->getPath();
     $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
     $dbw->insert('garbage_collector', array('gc_filename' => $path, 'gc_timestamp' => $dbw->timestamp(), 'gc_wiki_id' => $wgCityId), __METHOD__);
     $id = $dbw->insertId();
     $this->log(__METHOD__, "image stored as #{$id}");
     $dbw->commit();
     wfProfileOut(__METHOD__);
     return $id;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:WikiaTempFilesUpload.class.php

示例9: findFiles

 function findFiles($titles)
 {
     // FIXME: Only accepts a $titles array where the keys are the sanitized
     // file names.
     if (count($titles) == 0) {
         return array();
     }
     $dbr = $this->getSlaveDB();
     $res = $dbr->select('image', LocalFile::selectFields(), array('img_name' => array_keys($titles)));
     $result = array();
     while ($row = $res->fetchObject()) {
         $result[$row->img_name] = $this->newFileFromRow($row);
     }
     $res->free();
     return $result;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:16,代码来源:LocalRepo.php

示例10: saveSettings

 public function saveSettings($settings, $cityId = null)
 {
     global $wgCityId, $wgUser;
     $cityId = empty($cityId) ? $wgCityId : $cityId;
     // Verify wordmark length ( CONN-116 )
     if (!empty($settings['wordmark-text'])) {
         $settings['wordmark-text'] = trim($settings['wordmark-text']);
     }
     if (empty($settings['wordmark-text'])) {
         // Do not save wordmark if its empty.
         unset($settings['wordmark-text']);
     } else {
         if (mb_strlen($settings['wordmark-text']) > 50) {
             $settings['wordmark-text'] = mb_substr($settings['wordmark-text'], 0, 50);
         }
     }
     if (isset($settings['favicon-image-name']) && strpos($settings['favicon-image-name'], 'Temp_file_') === 0) {
         $temp_file = new LocalFile(Title::newFromText($settings['favicon-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
         $file = new LocalFile(Title::newFromText(self::FaviconImageName, 6), RepoGroup::singleton()->getLocalRepo());
         $file->upload($temp_file->getPath(), '', '');
         $temp_file->delete('');
         Wikia::invalidateFavicon();
         $settings['favicon-image-url'] = $file->getURL();
         $settings['favicon-image-name'] = $file->getName();
         $file->repo->forceMaster();
         $history = $file->getHistory(1);
         if (count($history) == 1) {
             $oldFaviconFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
         }
     }
     if (isset($settings['wordmark-image-name']) && strpos($settings['wordmark-image-name'], 'Temp_file_') === 0) {
         $temp_file = new LocalFile(Title::newFromText($settings['wordmark-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
         $file = new LocalFile(Title::newFromText(self::WordmarkImageName, 6), RepoGroup::singleton()->getLocalRepo());
         $file->upload($temp_file->getPath(), '', '');
         $temp_file->delete('');
         $settings['wordmark-image-url'] = $file->getURL();
         $settings['wordmark-image-name'] = $file->getName();
         $file->repo->forceMaster();
         $history = $file->getHistory(1);
         if (count($history) == 1) {
             $oldFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
         }
     }
     if (isset($settings['background-image-name']) && strpos($settings['background-image-name'], 'Temp_file_') === 0) {
         $temp_file = new LocalFile(Title::newFromText($settings['background-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
         $file = new LocalFile(Title::newFromText(self::BackgroundImageName, 6), RepoGroup::singleton()->getLocalRepo());
         $file->upload($temp_file->getPath(), '', '');
         $temp_file->delete('');
         $settings['background-image'] = $file->getURL();
         $settings['background-image-name'] = $file->getName();
         $settings['background-image-width'] = $file->getWidth();
         $settings['background-image-height'] = $file->getHeight();
         $imageServing = new ImageServing(null, 120, array("w" => "120", "h" => "65"));
         $settings['user-background-image'] = $file->getURL();
         $settings['user-background-image-thumb'] = wfReplaceImageServer($file->getThumbUrl($imageServing->getCut($file->getWidth(), $file->getHeight(), "origin") . "-" . $file->getName()));
         $file->repo->forceMaster();
         $history = $file->getHistory(1);
         if (count($history) == 1) {
             $oldBackgroundFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
         }
     }
     $reason = wfMsg('themedesigner-reason', $wgUser->getName());
     // update history
     if (!empty($GLOBALS[self::WikiFactoryHistory])) {
         $history = $GLOBALS[self::WikiFactoryHistory];
         $lastItem = end($history);
         $revisionId = intval($lastItem['revision']) + 1;
     } else {
         $history = array();
         $revisionId = 1;
     }
     // #140758 - Jakub
     // validation
     // default color values
     foreach (ThemeDesignerHelper::getColorVars() as $sColorVar => $sDefaultValue) {
         if (!isset($settings[$sColorVar]) || !ThemeDesignerHelper::isValidColor($settings[$sColorVar])) {
             $settings[$sColorVar] = $sDefaultValue;
         }
     }
     // update WF variable with current theme settings
     WikiFactory::setVarByName(self::WikiFactorySettings, $cityId, $settings, $reason);
     // add entry
     $history[] = array('settings' => $settings, 'author' => $wgUser->getName(), 'timestamp' => wfTimestampNow(), 'revision' => $revisionId);
     // limit history size to last 10 changes
     $history = array_slice($history, -self::HistoryItemsLimit);
     if (count($history) > 1) {
         for ($i = 0; $i < count($history) - 1; $i++) {
             if (isset($oldFaviconFile) && isset($history[$i]['settings']['favicon-image-name'])) {
                 if ($history[$i]['settings']['favicon-image-name'] == self::FaviconImageName) {
                     $history[$i]['settings']['favicon-image-name'] = $oldFaviconFile['name'];
                     $history[$i]['settings']['favicon-image-url'] = $oldFaviconFile['url'];
                 }
             }
             if (isset($oldFile) && isset($history[$i]['settings']['wordmark-image-name'])) {
                 if ($history[$i]['settings']['wordmark-image-name'] == self::WordmarkImageName) {
                     $history[$i]['settings']['wordmark-image-name'] = $oldFile['name'];
                     $history[$i]['settings']['wordmark-image-url'] = $oldFile['url'];
                 }
             }
             if (isset($oldBackgroundFile) && isset($history[$i]['settings']['background-image-name'])) {
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:ThemeSettings.class.php

示例11: getDeletedPath

 protected function getDeletedPath(LocalRepo $repo, LocalFile $file)
 {
     $hash = $repo->getFileSha1($file->getPath());
     $key = "{$hash}.{$file->getExtension()}";
     return $repo->getDeletedHashPath($key) . $key;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:6,代码来源:purgeChangedFiles.php

示例12: findBySha1s

 /**
  * Get an array of arrays or iterators of file objects for files that
  * have the given SHA-1 content hashes.
  *
  * Overrides generic implementation in FileRepo for performance reason
  *
  * @param $hashes array An array of hashes
  * @return array An Array of arrays or iterators of file objects and the hash as key
  */
 function findBySha1s(array $hashes)
 {
     if (!count($hashes)) {
         return array();
         //empty parameter
     }
     $dbr = $this->getSlaveDB();
     $res = $dbr->select('image', LocalFile::selectFields(), array('img_sha1' => $hashes), __METHOD__, array('ORDER BY' => 'img_name'));
     $result = array();
     foreach ($res as $row) {
         $file = $this->newFileFromRow($row);
         $result[$file->getSha1()][] = $file;
     }
     $res->free();
     return $result;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:25,代码来源:LocalRepo.php

示例13: findFilesByPrefix

 /**
  * Return an array of files where the name starts with $prefix.
  *
  * @param string $prefix The prefix to search for
  * @param int $limit The maximum amount of files to return
  * @return array
  */
 public function findFilesByPrefix($prefix, $limit)
 {
     $selectOptions = array('ORDER BY' => 'img_name', 'LIMIT' => intval($limit));
     // Query database
     $dbr = $this->getSlaveDB();
     $res = $dbr->select('image', LocalFile::selectFields(), 'img_name ' . $dbr->buildLike($prefix, $dbr->anyString()), __METHOD__, $selectOptions);
     // Build file objects
     $files = array();
     foreach ($res as $row) {
         $files[] = $this->newFileFromRow($row);
     }
     return $files;
 }
开发者ID:rugby110,项目名称:mediawiki,代码行数:20,代码来源:LocalRepo.php

示例14: testMoveTo

 public function testMoveTo()
 {
     //existing file
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext'));
     $this->assertFalse(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext'));
     $originalContent = file_get_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext');
     $this->assertTrue($this->fixture_file->moveTo($this->fixture_dir));
     $this->assertFalse(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext'));
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext'));
     $this->assertEquals($originalContent, file_get_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext'));
     unlink(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext');
     //non-existing file
     $this->assertFalse(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext'));
     try {
         $this->fixture_file->moveTo($this->fixture_dir);
         $fail->fail();
     } catch (EyeFileNotFoundException $e) {
         // normal situation
     }
     //existing directory containing files
     mkdir(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1');
     $dir = new LocalFile(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1');
     $originalContent = '## test - content ##';
     file_put_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1/mySubFile.ext', $originalContent);
     $this->assertTrue(is_dir(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1'));
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1/mySubFile.ext'));
     $this->assertTrue($dir->moveTo($this->fixture_dir));
     $this->assertFalse(is_dir(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1'));
     $this->assertTrue(is_dir(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1'));
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1/mySubFile.ext'));
     $this->assertEquals($originalContent, file_get_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1/mySubFile.ext'));
     unlink(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1/mySubFile.ext');
     rmdir(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1');
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:34,代码来源:LocalFileTest.php

示例15: run

 /**
  * @param $resultPageSet ApiPageSet
  * @return void
  */
 private function run($resultPageSet = null)
 {
     $repo = $this->mRepo;
     if (!$repo instanceof LocalRepo) {
         $this->dieUsage('Local file repository does not support querying all images', 'unsupportedrepo');
     }
     $db = $this->getDB();
     $params = $this->extractRequestParams();
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         if (count($cont) != 1) {
             $this->dieUsage("Invalid continue param. You should pass the " . "original value returned by the previous query", "_badcontinue");
         }
         $op = $params['dir'] == 'descending' ? '<' : '>';
         $cont_from = $db->addQuotes($cont[0]);
         $this->addWhere("img_name {$op}= {$cont_from}");
     }
     // Image filters
     $dir = $params['dir'] == 'descending' ? 'older' : 'newer';
     $from = is_null($params['from']) ? null : $this->titlePartToKey($params['from']);
     $to = is_null($params['to']) ? null : $this->titlePartToKey($params['to']);
     $this->addWhereRange('img_name', $dir, $from, $to);
     if (isset($params['prefix'])) {
         $this->addWhere('img_name' . $db->buildLike($this->titlePartToKey($params['prefix']), $db->anyString()));
     }
     if (isset($params['minsize'])) {
         $this->addWhere('img_size>=' . intval($params['minsize']));
     }
     if (isset($params['maxsize'])) {
         $this->addWhere('img_size<=' . intval($params['maxsize']));
     }
     $sha1 = false;
     if (isset($params['sha1'])) {
         if (!$this->validateSha1Hash($params['sha1'])) {
             $this->dieUsage('The SHA1 hash provided is not valid', 'invalidsha1hash');
         }
         $sha1 = wfBaseConvert($params['sha1'], 16, 36, 31);
     } elseif (isset($params['sha1base36'])) {
         $sha1 = $params['sha1base36'];
         if (!$this->validateSha1Base36Hash($sha1)) {
             $this->dieUsage('The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash');
         }
     }
     if ($sha1) {
         $this->addWhereFld('img_sha1', $sha1);
     }
     if (!is_null($params['mime'])) {
         global $wgMiserMode;
         if ($wgMiserMode) {
             $this->dieUsage('MIME search disabled in Miser Mode', 'mimesearchdisabled');
         }
         list($major, $minor) = File::splitMime($params['mime']);
         $this->addWhereFld('img_major_mime', $major);
         $this->addWhereFld('img_minor_mime', $minor);
     }
     $this->addTables('image');
     $prop = array_flip($params['prop']);
     $this->addFields(LocalFile::selectFields());
     $limit = $params['limit'];
     $this->addOption('LIMIT', $limit + 1);
     $sort = $params['dir'] == 'descending' ? ' DESC' : '';
     $this->addOption('ORDER BY', 'img_name' . $sort);
     $res = $this->select(__METHOD__);
     $titles = array();
     $count = 0;
     $result = $this->getResult();
     foreach ($res as $row) {
         if (++$count > $limit) {
             // We've reached the one extra which shows that there are additional pages to be had. Stop here...
             $this->setContinueEnumParameter('continue', $row->img_name);
             break;
         }
         if (is_null($resultPageSet)) {
             $file = $repo->newFileFromRow($row);
             $info = array_merge(array('name' => $row->img_name), ApiQueryImageInfo::getInfo($file, $prop, $result));
             self::addTitleInfo($info, $file->getTitle());
             $fit = $result->addValue(array('query', $this->getModuleName()), null, $info);
             if (!$fit) {
                 $this->setContinueEnumParameter('continue', $row->img_name);
                 break;
             }
         } else {
             $titles[] = Title::makeTitle(NS_FILE, $row->img_name);
         }
     }
     if (is_null($resultPageSet)) {
         $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'img');
     } else {
         $resultPageSet->populateFromTitles($titles);
     }
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:95,代码来源:ApiQueryAllImages.php


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