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


PHP RepoGroup类代码示例

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


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

示例1: uploadImageFromUrl

 /**
  * @desc Uploads an image on a wki
  *
  * @static
  * @param string $imageUrl url address to original file
  * @param Object $oImageData an object with obligatory field "name" and optional fields: "comment", "description"
  * @param User | null $user optional User's class instance (the file will be "uploaded" by this user)
  *
  * @return array
  */
 public static function uploadImageFromUrl($imageUrl, $oImageData, $user = null)
 {
     // disable recentchange hooks
     global $wgHooks;
     $wgHooks['RecentChange_save'] = array();
     $wgHooks['RecentChange_beforeSave'] = array();
     /* prepare temporary file */
     $data = array('wpUpload' => 1, 'wpSourceType' => 'web', 'wpUploadFileURL' => $imageUrl);
     //validate of optional image data
     foreach (array(self::FILE_DATA_COMMENT_OPION_NAME, self::FILE_DATA_DESC_OPION_NAME) as $option) {
         if (!isset($oImageData->{$option})) {
             $oImageData->{$option} = $oImageData->name;
         }
     }
     $upload = F::build('UploadFromUrl');
     /* @var $upload UploadFromUrl */
     $upload->initializeFromRequest(F::build('FauxRequest', array($data, true)));
     $upload->fetchFile();
     $upload->verifyUpload();
     // create destination file
     $title = Title::newFromText($oImageData->name, NS_FILE);
     $file = F::build('WikiaLocalFile', array($title, RepoGroup::singleton()->getLocalRepo()));
     /* @var $file WikiaLocalFile */
     /* real upload */
     $result = $file->upload($upload->getTempPath(), $oImageData->comment, $oImageData->description, File::DELETE_SOURCE, false, false, $user);
     return array('status' => $result->ok, 'page_id' => $title->getArticleID(), 'errors' => $result->errors);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:37,代码来源:ImagesService.class.php

示例2: getRepo

 /**
  * @return FileRepo
  */
 function getRepo()
 {
     if (!isset($this->repo)) {
         $this->repo = RepoGroup::singleton()->getLocalRepo();
     }
     return $this->repo;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:10,代码来源:rebuildImages.php

示例3: execute

 public function execute()
 {
     $repo = RepoGroup::singleton()->getLocalRepo();
     $dbr = $repo->getSlaveDb();
     // how far back should this look for files to delete?
     global $wgUploadStashMaxAge;
     $this->output("Getting list of files to clean up...\n");
     $res = $dbr->select('uploadstash', 'us_key', 'us_timestamp < ' . $dbr->addQuotes($dbr->timestamp(time() - $wgUploadStashMaxAge)), __METHOD__);
     if (!is_object($res) || $res->numRows() == 0) {
         $this->output("No files to cleanup!\n");
         // nothing to do.
         return;
     }
     // finish the read before starting writes.
     $keys = array();
     foreach ($res as $row) {
         array_push($keys, $row->us_key);
     }
     $this->output('Removing ' . count($keys) . " file(s)...\n");
     // this could be done some other, more direct/efficient way, but using
     // UploadStash's own methods means it's less likely to fall accidentally
     // out-of-date someday
     $stash = new UploadStash($repo);
     foreach ($keys as $key) {
         try {
             $stash->getFile($key, true);
             $stash->removeFileNoAuth($key);
         } catch (UploadStashBadPathException $ex) {
             $this->output("Failed removing stashed upload with key: {$key}\n");
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:cleanupUploadStash.php

示例4: parserFunction

 public static function parserFunction($parser, $vid = null, $img = null)
 {
     global $wgTitle, $wgContLang;
     wfLoadExtensionMessages('WHVid');
     if ($vid === null || $img === null) {
         return '<div class="errorbox">' . wfMsg('missing-params') . '</div>';
     }
     $vid = htmlspecialchars($vid);
     $divId = "whvid-" . md5($vid . mt_rand(1, 1000));
     $vidUrl = self::getVidUrl($vid);
     $imgTitle = Title::newFromURL($img, NS_IMAGE);
     $imgUrl = null;
     if ($imgTitle) {
         $imgFile = RepoGroup::singleton()->findFile($imgTitle);
         $smallImgUrl = '';
         $largeImgUrl = '';
         if ($imgFile) {
             $width = 550;
             $height = 309;
             $thumb = $imgFile->getThumbnail($width, $height);
             $largeImgUrl = wfGetPad($thumb->getUrl());
             $width = 240;
             //$height = 135;
             $thumb = $imgFile->getThumbnail($width);
             $smallImgUrl = wfGetPad($thumb->getUrl());
         }
     }
     return $parser->insertStripItem(wfMsgForContent('embed-html', $divId, $vidUrl, $largeImgUrl, $smallImgUrl));
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:29,代码来源:WHVid.body.php

示例5: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $modulePrefix = $this->getModulePrefix();
     $prop = array_flip($params['prop']);
     $scale = $this->getScale($params);
     $result = $this->getResult();
     if (!$params['filekey'] && !$params['sessionkey']) {
         $this->dieUsage("One of filekey or sessionkey must be supplied", 'nofilekey');
     }
     // Alias sessionkey to filekey, but give an existing filekey precedence.
     if (!$params['filekey'] && $params['sessionkey']) {
         $params['filekey'] = $params['sessionkey'];
     }
     try {
         $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash($this->getUser());
         foreach ($params['filekey'] as $filekey) {
             $file = $stash->getFile($filekey);
             $finalThumbParam = $this->mergeThumbParams($file, $scale, $params['urlparam']);
             $imageInfo = ApiQueryImageInfo::getInfo($file, $prop, $result, $finalThumbParam);
             $result->addValue(array('query', $this->getModuleName()), null, $imageInfo);
             $result->addIndexedTagName(array('query', $this->getModuleName()), $modulePrefix);
         }
         // @todo Update exception handling here to understand current getFile exceptions
     } catch (UploadStashFileNotFoundException $e) {
         $this->dieUsage("File not found: " . $e->getMessage(), "invalidsessiondata");
     } catch (UploadStashBadPathException $e) {
         $this->dieUsage("Bad path: " . $e->getMessage(), "invalidsessiondata");
     }
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:30,代码来源:ApiQueryStashImageInfo.php

示例6: getLocalFile

 public function getLocalFile()
 {
     if (is_null($this->mLocalFile)) {
         $this->mLocalFile = new FakeLocalFile(Title::newFromText('Temp_file_' . time() . '.jpg', NS_FILE), RepoGroup::singleton()->getLocalRepo());
     }
     return $this->mLocalFile;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:7,代码来源:UploadVisualizationImageFromFile.class.php

示例7: execute

 public function execute()
 {
     global $wgCityId;
     $db = wfGetDB(DB_MASTER);
     (new WikiaSQL())->SELECT('*')->FROM('page')->WHERE('page_is_redirect')->EQUAL_TO(1)->runLoop($db, function ($a, $row) use($db) {
         $title = Title::newFromID($row->page_id);
         if (!$title->isDeleted()) {
             $rev = Revision::newFromTitle($title);
             $text = $rev->getText();
             $rt = Title::newFromRedirectRecurse($text);
             if (!$rt) {
                 // page is marked as redirect but $text is not valid redirect
                 $this->output('Fixed ID: ' . $title->getArticleID() . ' Title: ' . $title->getText() . "\n");
                 // Fix page table
                 (new WikiaSQL())->UPDATE('page')->SET('page_is_redirect', 0)->WHERE('page_id')->EQUAL_TO($row->page_id)->RUN($db);
                 // remove redirect from redirect table
                 (new WikiaSQL())->DELETE('redirect')->WHERE('rd_from')->EQUAL_TO($row->page_id)->RUN($db);
                 // clear cache
                 LinkCache::singleton()->addGoodLinkObj($row->page_id, $title, strlen($text), 0, $rev->getId());
                 if ($title->getNamespace() == NS_FILE) {
                     RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($title);
                 }
             }
         }
     });
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:fixFalseRedirects.php

示例8: execute

 public function execute()
 {
     $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
     // Make sure we have files in the title set:
     if (!empty($pageIds[NS_FILE])) {
         $titles = array_keys($pageIds[NS_FILE]);
         asort($titles);
         // Ensure the order is always the same
         $result = $this->getResult();
         $images = RepoGroup::singleton()->findFiles($titles);
         foreach ($images as $img) {
             // if its a "transcode" add the transcode status table output
             if (TimedMediaHandlerHooks::isTranscodableTitle($img->getTitle())) {
                 $transcodeStatus = WebVideoTranscode::getTranscodeState($img->getTitle()->getDBKey());
                 // remove useless properties
                 foreach ($transcodeStatus as $key => &$val) {
                     unset($val['id']);
                     unset($val['image_name']);
                     unset($val['key']);
                 }
                 $result->addValue(array('query', 'pages', $img->getTitle()->getArticleID()), 'transcodestatus', $transcodeStatus);
             }
         }
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:25,代码来源:ApiTranscodeStatus.php

示例9: execute

 public function execute()
 {
     $repo = RepoGroup::singleton()->getLocalRepo();
     $dbr = $repo->getSlaveDb();
     $this->output("Getting list of files to clean up...\n");
     $res = $dbr->select('uploadstash', 'us_key', 'us_timestamp < ' . $dbr->timestamp(time() - UploadStash::REPO_AGE * 3600), __METHOD__);
     if (!is_object($res) || $res->numRows() == 0) {
         // nothing to do.
         return false;
     }
     // finish the read before starting writes.
     $keys = array();
     foreach ($res as $row) {
         array_push($keys, $row->us_key);
     }
     $this->output('Removing ' . count($keys) . " file(s)...\n");
     // this could be done some other, more direct/efficient way, but using
     // UploadStash's own methods means it's less likely to fall accidentally
     // out-of-date someday
     $stash = new UploadStash($repo);
     foreach ($keys as $key) {
         $stash->getFile($key, true);
         $stash->removeFileNoAuth($key);
     }
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:25,代码来源:cleanupUploadStash.php

示例10: execute

 function execute()
 {
     $subdir = $this->getOption('subdir', '');
     $verbose = $this->hasOption('verbose');
     $repo = RepoGroup::singleton()->getLocalRepo();
     if ($repo->hasSha1Storage()) {
         $this->error("Local repo uses SHA-1 file storage names; aborting.", 1);
     }
     $directory = $repo->getZonePath('public');
     if ($subdir != '') {
         $directory .= "/{$subdir}/";
     }
     if ($verbose) {
         $this->output("Scanning files under {$directory}:\n");
     }
     $list = $repo->getBackend()->getFileList(['dir' => $directory]);
     if ($list === null) {
         $this->error("Could not get file listing.", 1);
     }
     $pathBatch = [];
     foreach ($list as $path) {
         if (preg_match('#^(thumb|deleted)/#', $path)) {
             continue;
             // handle ugly nested containers on stock installs
         }
         $pathBatch[] = $path;
         if (count($pathBatch) >= $this->mBatchSize) {
             $this->checkFiles($repo, $pathBatch, $verbose);
             $pathBatch = [];
         }
     }
     $this->checkFiles($repo, $pathBatch, $verbose);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:findOrphanedFiles.php

示例11: setUpForeignRepo

 private function setUpForeignRepo()
 {
     global $wgUploadDirectory;
     $this->setMwGlobals('wgForeignFileRepos', [['class' => 'ForeignAPIRepo', 'name' => 'wikimediacommons', 'backend' => 'wikimediacommons-backend', 'apibase' => 'https://commons.wikimedia.org/w/api.php', 'hashLevels' => 2, 'fetchDescription' => true, 'descriptionCacheExpiry' => 43200, 'apiThumbCacheExpiry' => 86400, 'directory' => $wgUploadDirectory]]);
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:RepoGroupTest.php

示例12: filePath

 function filePath($name)
 {
     if (!isset($this->repo)) {
         $this->repo = RepoGroup::singleton()->getLocalRepo();
     }
     return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath($name) . $name;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:7,代码来源:cleanupImages.php

示例13: execute

 function execute()
 {
     $lastName = $this->getOption('start', '');
     $repo = RepoGroup::singleton()->getLocalRepo();
     $dbr = $repo->getSlaveDB();
     $be = $repo->getBackend();
     $mtime1 = $dbr->timestampOrNull($this->getOption('mtimeafter', null));
     $mtime2 = $dbr->timestampOrNull($this->getOption('mtimebefore', null));
     $joinTables = array('image');
     $joinConds = array('image' => array('INNER JOIN', 'img_name = page_title'));
     if ($mtime1 || $mtime2) {
         $joinTables[] = 'logging';
         $on = array('log_page = page_id', 'log_type' => array('upload', 'move', 'delete'));
         if ($mtime1) {
             $on[] = "log_timestamp > {$dbr->addQuotes($mtime1)}";
         }
         if ($mtime2) {
             $on[] = "log_timestamp < {$dbr->addQuotes($mtime2)}";
         }
         $joinConds['logging'] = array('INNER JOIN', $on);
     }
     do {
         $res = $dbr->select(array_merge(array('page'), $joinTables), array('img_name' => 'DISTINCT(page_title)'), array('page_namespace' => NS_FILE, "page_title >= " . $dbr->addQuotes($lastName)), __METHOD__, array('ORDER BY' => 'page_title', 'LIMIT' => $this->mBatchSize), $joinConds);
         // Check if any of these files are missing...
         $pathsByName = array();
         foreach ($res as $row) {
             $file = $repo->newFile($row->img_name);
             $pathsByName[$row->img_name] = $file->getPath();
             $lastName = $row->img_name;
         }
         $be->preloadFileStat(array('srcs' => $pathsByName));
         foreach ($pathsByName as $path) {
             if ($be->fileExists(array('src' => $path)) === false) {
                 $this->output("{$path}\n");
             }
         }
         // Find all missing old versions of any of the files in this batch...
         if (count($pathsByName)) {
             $ores = $dbr->select('oldimage', array('oi_name', 'oi_archive_name'), array('oi_name' => array_keys($pathsByName)), __METHOD__);
             $checkPaths = array();
             foreach ($ores as $row) {
                 if (!strlen($row->oi_archive_name)) {
                     continue;
                     // broken row
                 }
                 $file = $repo->newFromArchiveName($row->oi_name, $row->oi_archive_name);
                 $checkPaths[] = $file->getPath();
             }
             foreach (array_chunk($checkPaths, $this->mBatchSize) as $paths) {
                 $be->preloadFileStat(array('srcs' => $paths));
                 foreach ($paths as $path) {
                     if ($be->fileExists(array('src' => $path)) === false) {
                         $this->output("{$path}\n");
                     }
                 }
             }
         }
     } while ($res->numRows() >= $this->mBatchSize);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:59,代码来源:findMissingFiles.php

示例14: getLocalFile

 public function getLocalFile()
 {
     if (is_null($this->mLocalFile)) {
         //TODO: find out what namespace constant 6 is
         $this->mLocalFile = new FakeLocalFile(Title::newFromText('Temp_file_' . time(), 6), RepoGroup::singleton()->getLocalRepo());
     }
     return $this->mLocalFile;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:UploadWordmarkFromFile.class.php

示例15: getFileDuplicate

 protected function getFileDuplicate($filepath)
 {
     $duplicates = RepoGroup::singleton()->findBySha1(FSFile::getSha1Base36FromPath($filepath));
     if (count($duplicates) > 0) {
         return $duplicates[0];
     }
     return null;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:ApiAddMedia.php


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