class ApiPageSet extends ApiQueryBase {
private $mAllPages; // [ns][dbkey] => page_id or 0 when missing
- private $mTitles, $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles;
+ private $mTitles, $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles, $mInterwikiTitles;
private $mResolveRedirects, $mPendingRedirectIDs;
private $mGoodRevIDs, $mMissingRevIDs;
$this->mMissingPageIDs = array ();
$this->mRedirectTitles = array ();
$this->mNormalizedTitles = array ();
+ $this->mInterwikiTitles = array ();
$this->mGoodRevIDs = array();
$this->mMissingRevIDs = array();
return $this->mNormalizedTitles;
}
+ /**
+ * Get a list of interwiki titles - maps the title given
+ * with to the interwiki prefix.
+ * @return array raw_prefixed_title (string) => interwiki_prefix (string)
+ */
+ public function getInterwikiTitles() {
+ return $this->mInterwikiTitles;
+ }
+
/**
* Get the list of revision IDs (requested with revids= parameter)
* @return array revID (int) => pageID (int)
/**
* Given an array of title strings, convert them into Title objects.
+ * Alternativelly, an array of Title objects may be given.
* This method validates access rights for the title,
* and appends normalization values to the output.
*
foreach ($titles as $title) {
$titleObj = is_string($title) ? Title :: newFromText($title) : $title;
-
- // Validation
if (!$titleObj)
$this->dieUsage("bad title $titleString", 'invalidtitle');
- if ($titleObj->getNamespace() < 0)
- $this->dieUsage("No support for special page $titleString has been implemented", 'unsupportednamespace');
- if (!$titleObj->userCanRead())
- $this->dieUsage("No read permission for $titleString", 'titleaccessdenied');
- $linkBatch->addObj($titleObj);
+ $iw = $titleObj->getInterwiki();
+ if (!empty($iw)) {
+ // This title is an interwiki link.
+ $this->mInterwikiTitles[$titleObj->getPrefixedText()] = $iw;
+ } else {
+
+ // Validation
+ if ($titleObj->getNamespace() < 0)
+ $this->dieUsage("No support for special page $titleString has been implemented", 'unsupportednamespace');
+ if (!$titleObj->userCanRead())
+ $this->dieUsage("No read permission for $titleString", 'titleaccessdenied');
+ $linkBatch->addObj($titleObj);
+ }
+
// Make sure we remember the original title that was given to us
// This way the caller can correlate new titles with the originally requested,
// i.e. namespace is localized or capitalization is different
$result->setIndexedTagName($normValues, 'n');
$result->addValue('query', 'normalized', $normValues);
}
+
+ // Interwiki titles
+ $intrwValues = array ();
+ foreach ($pageSet->getInterwikiTitles() as $rawTitleStr => $interwikiStr) {
+ $intrwValues[] = array (
+ 'title' => $rawTitleStr,
+ 'iw' => $interwikiStr
+ );
+ }
+ if (!empty ($intrwValues)) {
+ $result->setIndexedTagName($intrwValues, 'i');
+ $result->addValue('query', 'interwiki', $intrwValues);
+ }
+
// Show redirect information
$redirValues = array ();
foreach ($pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo) {