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


PHP LocalFile::newFromRow方法代碼示例

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


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

示例1: 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

示例2: purgeImagesSQL

 public function purgeImagesSQL($whereSQL)
 {
     # Purge files of any images
     # lance.gatlin@gmail.com: tested good 16Jul11
     $images_rows = $this->dbw->select('image', array('*'), array($whereSQL));
     if ($images_rows->numRows() == 0) {
         return;
     }
     $imageNames = array();
     foreach ($images_rows as $row) {
         $file = LocalFile::newFromRow($row, $this->repo);
         # Purge thumbnails and purge cache for pages using this image
         $file->purgeEverything();
         # Purge thumbnail directories
         // TODO: Mediawiki does not purge the directories used to store thumbnails
         $path = $file->getPath();
         if ($path !== false && file_exists($path)) {
             unlink($path);
         }
         $imageNames[] = "'" . $row->img_name . "'";
     }
     # Purge images
     # lance.gatlin@gmail.com: tested good 9Jul11
     $this->dbw->delete('image', array($whereSQL));
     # Purge old versions of these images
     $imageNames_list = implode(',', $imageNames);
     $this->purgeOldImagesSQL("oi_name IN ({$imageNames_list})");
     $this->purgePagesSQL("page_title IN ({$imageNames_list}) AND page_namespace={$this->nsFile}");
 }
開發者ID:seinlin,項目名稱:UserAdmin,代碼行數:29,代碼來源:MWPurge_1_16.class.php

示例3: execute

 public function execute()
 {
     global $wgUser;
     $wgUser = User::newFromName(self::USER);
     $this->isDryRun = $this->hasOption('dry-run');
     $this->otherLocation = $this->getOption('other-location');
     $this->repo = RepoGroup::singleton()->getLocalRepo();
     $this->dbr = $this->getDB(DB_SLAVE);
     $images = 0;
     $imagesMissing = 0;
     $imagesFixed = 0;
     $res = $this->dbr->select('image', LocalFile::selectFields(), '', __METHOD__);
     $count = $res->numRows();
     $this->output(sprintf("Checking all images (%d images)%s...\n\n", $count, $this->isDryRun ? ' in dry run mode' : ''));
     while ($row = $res->fetchObject()) {
         $file = LocalFile::newFromRow($row, $this->repo);
         // 1. check file size (img_size = 0 in image table)
         $this->checkFileSize($file);
         // 2. check for missing files on FS / Swift storage
         $result = $this->processMissingFile($file);
         switch ($result) {
             case self::RESULT_RESTORED:
                 $imagesFixed++;
                 $imagesMissing++;
                 break;
             case self::RESULT_NOT_RESTORED:
                 $imagesMissing++;
                 break;
         }
         // progress
         if (++$images % 100) {
             $this->output(sprintf("%d%%\r", $images / $count * 100));
         }
     }
     // summary
     if (!empty($this->otherLocation)) {
         $this->output(sprintf("Restored %d images from second location \n", count($this->foundMissing)));
         $this->output("List of restored files: \n");
         $this->output(sprintf("%s\n\n", implode("\t\n", $this->foundMissing)));
     }
     $this->output(sprintf("Detected %d missing images (%.2f%% of %d images) and fixed %d images\n\n", $imagesMissing, $imagesMissing / $count * 100, $count, $imagesFixed));
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:42,代碼來源:fixBrokenImages.php


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