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


PHP ApiPageSet::getGoodTitles方法代码示例

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


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

示例1: runOnPageSet

 protected function runOnPageSet(ApiPageSet $pageSet)
 {
     $articles = array_map(function (Title $item) {
         return Article::newFromTitle($item, RequestContext::getMain());
     }, $pageSet->getGoodTitles());
     /**
      * @var Article $article
      */
     foreach ($articles as $id => $article) {
         $d = $article->getParserOutput()->getProperty(PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME);
         if (is_array($d)) {
             $inf = [];
             foreach (array_keys($d) as $k => $v) {
                 $inf[$k] = [];
             }
             $pageSet->getResult()->setIndexedTagName($inf, 'infobox');
             $pageSet->getResult()->addValue(['query', 'pages', $id], 'infoboxes', $inf);
             foreach ($d as $count => $infobox) {
                 $s = isset($infobox['sources']) ? $infobox['sources'] : [];
                 $pageSet->getResult()->addValue(['query', 'pages', $id, 'infoboxes', $count], 'id', $count);
                 $pageSet->getResult()->setIndexedTagName($s, "source");
                 $pageSet->getResult()->addValue(['query', 'pages', $id, 'infoboxes', $count], 'sources', $s);
             }
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:ApiQueryPortableInfobox.class.php

示例2: execute

 public function execute()
 {
     $user = $this->getUser();
     if ($user->isAnon()) {
         $this->dieUsage('Anonymous users cannot use watchlist change notifications', 'notloggedin');
     }
     $params = $this->extractRequestParams();
     $this->requireMaxOneParameter($params, 'timestamp', 'torevid', 'newerthanrevid');
     $pageSet = new ApiPageSet($this);
     $args = array_merge(array($params, 'entirewatchlist'), array_keys($pageSet->getAllowedParams()));
     call_user_func_array(array($this, 'requireOnlyOneParameter'), $args);
     $dbw = $this->getDB(DB_MASTER);
     $timestamp = null;
     if (isset($params['timestamp'])) {
         $timestamp = $dbw->timestamp($params['timestamp']);
     }
     if (!$params['entirewatchlist']) {
         $pageSet->execute();
     }
     if (isset($params['torevid'])) {
         if ($params['entirewatchlist'] || $pageSet->getGoodTitleCount() > 1) {
             $this->dieUsage('torevid may only be used with a single page', 'multpages');
         }
         $title = reset($pageSet->getGoodTitles());
         $timestamp = Revision::getTimestampFromId($title, $params['torevid']);
         if ($timestamp) {
             $timestamp = $dbw->timestamp($timestamp);
         } else {
             $timestamp = null;
         }
     } elseif (isset($params['newerthanrevid'])) {
         if ($params['entirewatchlist'] || $pageSet->getGoodTitleCount() > 1) {
             $this->dieUsage('newerthanrevid may only be used with a single page', 'multpages');
         }
         $title = reset($pageSet->getGoodTitles());
         $revid = $title->getNextRevisionID($params['newerthanrevid']);
         if ($revid) {
             $timestamp = $dbw->timestamp(Revision::getTimestampFromId($title, $revid));
         } else {
             $timestamp = null;
         }
     }
     $apiResult = $this->getResult();
     $result = array();
     if ($params['entirewatchlist']) {
         // Entire watchlist mode: Just update the thing and return a success indicator
         $dbw->update('watchlist', array('wl_notificationtimestamp' => $timestamp), array('wl_user' => $user->getID()), __METHOD__);
         $result['notificationtimestamp'] = is_null($timestamp) ? '' : wfTimestamp(TS_ISO_8601, $timestamp);
     } else {
         // First, log the invalid titles
         foreach ($pageSet->getInvalidTitles() as $title) {
             $r = array();
             $r['title'] = $title;
             $r['invalid'] = '';
             $result[] = $r;
         }
         foreach ($pageSet->getMissingPageIDs() as $p) {
             $page = array();
             $page['pageid'] = $p;
             $page['missing'] = '';
             $page['notwatched'] = '';
             $result[] = $page;
         }
         foreach ($pageSet->getMissingRevisionIDs() as $r) {
             $rev = array();
             $rev['revid'] = $r;
             $rev['missing'] = '';
             $rev['notwatched'] = '';
             $result[] = $rev;
         }
         // Now process the valid titles
         $lb = new LinkBatch($pageSet->getTitles());
         $dbw->update('watchlist', array('wl_notificationtimestamp' => $timestamp), array('wl_user' => $user->getID(), $lb->constructSet('wl', $dbw)), __METHOD__);
         // Query the results of our update
         $timestamps = array();
         $res = $dbw->select('watchlist', array('wl_namespace', 'wl_title', 'wl_notificationtimestamp'), array('wl_user' => $user->getID(), $lb->constructSet('wl', $dbw)), __METHOD__);
         foreach ($res as $row) {
             $timestamps[$row->wl_namespace][$row->wl_title] = $row->wl_notificationtimestamp;
         }
         // Now, put the valid titles into the result
         foreach ($pageSet->getTitles() as $title) {
             $ns = $title->getNamespace();
             $dbkey = $title->getDBkey();
             $r = array('ns' => intval($ns), 'title' => $title->getPrefixedText());
             if (!$title->exists()) {
                 $r['missing'] = '';
             }
             if (isset($timestamps[$ns]) && array_key_exists($dbkey, $timestamps[$ns])) {
                 $r['notificationtimestamp'] = '';
                 if ($timestamps[$ns][$dbkey] !== null) {
                     $r['notificationtimestamp'] = wfTimestamp(TS_ISO_8601, $timestamps[$ns][$dbkey]);
                 }
             } else {
                 $r['notwatched'] = '';
             }
             $result[] = $r;
         }
         $apiResult->setIndexedTagName($result, 'page');
     }
     $apiResult->addValue(null, $this->getModuleName(), $result);
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:ApiSetNotificationTimestamp.php

示例3: doExport

 /**
  * @param ApiPageSet $pageSet Pages to be exported
  * @param ApiResult $result Result to output to
  */
 private function doExport($pageSet, $result)
 {
     $exportTitles = array();
     $titles = $pageSet->getGoodTitles();
     if (count($titles)) {
         $user = $this->getUser();
         /** @var $title Title */
         foreach ($titles as $title) {
             if ($title->userCan('read', $user)) {
                 $exportTitles[] = $title;
             }
         }
     }
     $exporter = new WikiExporter($this->getDB());
     // WikiExporter writes to stdout, so catch its
     // output with an ob
     ob_start();
     $exporter->openStream();
     foreach ($exportTitles as $title) {
         $exporter->pageByTitle($title);
     }
     $exporter->closeStream();
     $exportxml = ob_get_contents();
     ob_end_clean();
     // Don't check the size of exported stuff
     // It's not continuable, so it would cause more
     // problems than it'd solve
     if ($this->mParams['exportnowrap']) {
         $result->reset();
         // Raw formatter will handle this
         $result->addValue(null, 'text', $exportxml, ApiResult::NO_SIZE_CHECK);
         $result->addValue(null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK);
     } else {
         $r = array();
         ApiResult::setContent($r, $exportxml);
         $result->addValue('query', 'export', $r, ApiResult::NO_SIZE_CHECK);
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:42,代码来源:ApiQuery.php

示例4: doExport

 /**
  * @param ApiPageSet $pageSet Pages to be exported
  * @param ApiResult $result Result to output to
  */
 private function doExport($pageSet, $result)
 {
     $exportTitles = [];
     $titles = $pageSet->getGoodTitles();
     if (count($titles)) {
         $user = $this->getUser();
         /** @var $title Title */
         foreach ($titles as $title) {
             if ($title->userCan('read', $user)) {
                 $exportTitles[] = $title;
             }
         }
     }
     $exporter = new WikiExporter($this->getDB());
     $sink = new DumpStringOutput();
     $exporter->setOutputSink($sink);
     $exporter->openStream();
     foreach ($exportTitles as $title) {
         $exporter->pageByTitle($title);
     }
     $exporter->closeStream();
     // Don't check the size of exported stuff
     // It's not continuable, so it would cause more
     // problems than it'd solve
     if ($this->mParams['exportnowrap']) {
         $result->reset();
         // Raw formatter will handle this
         $result->addValue(null, 'text', $sink, ApiResult::NO_SIZE_CHECK);
         $result->addValue(null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK);
     } else {
         $result->addValue('query', 'export', $sink, ApiResult::NO_SIZE_CHECK);
         $result->addValue('query', ApiResult::META_BC_SUBELEMENTS, ['export']);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:38,代码来源:ApiQuery.php


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