本文整理汇总了PHP中ApiPageSet::populateFromPageIDs方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiPageSet::populateFromPageIDs方法的具体用法?PHP ApiPageSet::populateFromPageIDs怎么用?PHP ApiPageSet::populateFromPageIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiPageSet
的用法示例。
在下文中一共展示了ApiPageSet::populateFromPageIDs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
//.........这里部分代码省略.........
}
if ($params['user'] !== null) {
$id = User::idFromName($params['user']);
if ($id) {
$this->addWhereFld('rev_user', $id);
} else {
$this->addWhereFld('rev_user_text', $params['user']);
}
} elseif ($params['excludeuser'] !== null) {
$id = User::idFromName($params['excludeuser']);
if ($id) {
$this->addWhere('rev_user != ' . $id);
} else {
$this->addWhere('rev_user_text != ' . $db->addQuotes($params['excludeuser']));
}
}
if ($params['user'] !== null || $params['excludeuser'] !== null) {
// Paranoia: avoid brute force searches (bug 17342)
if (!$this->getUser()->isAllowed('deletedhistory')) {
$bitmask = Revision::DELETED_USER;
} elseif (!$this->getUser()->isAllowedAny('suppressrevision', 'viewsuppressed')) {
$bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
if ($bitmask) {
$this->addWhere($db->bitAnd('rev_deleted', $bitmask) . " != {$bitmask}");
}
}
$dir = $params['dir'];
if ($params['continue'] !== null) {
$op = $dir == 'newer' ? '>' : '<';
$cont = explode('|', $params['continue']);
$this->dieContinueUsageIf(count($cont) != 2);
$ts = $db->addQuotes($db->timestamp($cont[0]));
$rev_id = (int) $cont[1];
$this->dieContinueUsageIf(strval($rev_id) !== $cont[1]);
$this->addWhere("rev_timestamp {$op} {$ts} OR " . "(rev_timestamp = {$ts} AND " . "rev_id {$op}= {$rev_id})");
}
$this->addOption('LIMIT', $this->limit + 1);
$sort = $dir == 'newer' ? '' : ' DESC';
$orderby = array();
// Targeting index rev_timestamp, user_timestamp, or usertext_timestamp
// But 'user' is always constant for the latter two, so it doesn't matter here.
$orderby[] = "rev_timestamp {$sort}";
$orderby[] = "rev_id {$sort}";
$this->addOption('ORDER BY', $orderby);
$res = $this->select(__METHOD__);
$pageMap = array();
// Maps rev_page to array index
$count = 0;
$nextIndex = 0;
$generated = array();
foreach ($res as $row) {
if (++$count > $this->limit) {
// We've had enough
$this->setContinueEnumParameter('continue', "{$row->rev_timestamp}|{$row->rev_id}");
break;
}
// Miser mode namespace check
if ($miser_ns !== null && !in_array($row->page_namespace, $miser_ns)) {
continue;
}
if ($resultPageSet !== null) {
if ($params['generatetitles']) {
$generated[$row->rev_page] = $row->rev_page;
} else {
$generated[] = $row->rev_id;
}
} else {
$revision = Revision::newFromRow($row);
$rev = $this->extractRevisionInfo($revision, $row);
if (!isset($pageMap[$row->rev_page])) {
$index = $nextIndex++;
$pageMap[$row->rev_page] = $index;
$title = $revision->getTitle();
$a = array('pageid' => $title->getArticleID(), 'revisions' => array($rev));
ApiResult::setIndexedTagName($a['revisions'], 'rev');
ApiQueryBase::addTitleInfo($a, $title);
$fit = $result->addValue(array('query', $this->getModuleName()), $index, $a);
} else {
$index = $pageMap[$row->rev_page];
$fit = $result->addValue(array('query', $this->getModuleName(), $index, 'revisions'), null, $rev);
}
if (!$fit) {
$this->setContinueEnumParameter('continue', "{$row->rev_timestamp}|{$row->rev_id}");
break;
}
}
}
if ($resultPageSet !== null) {
if ($params['generatetitles']) {
$resultPageSet->populateFromPageIDs($generated);
} else {
$resultPageSet->populateFromRevisionIDs($generated);
}
} else {
$result->addIndexedTagName(array('query', $this->getModuleName()), 'page');
}
}