From ad2b8958011313463cf093b859a4dedcf679a40a Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 20 Jan 2008 18:20:08 +0000 Subject: [PATCH] * API: Added apfilterlanglinks parameter to list=allpages, replacing query.php?what=nolanglinks --- RELEASE-NOTES | 1 + includes/api/ApiQueryAllpages.php | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d57fd4adbd..351cc919ad 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -448,6 +448,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * action={login,block,delete,move,protect,rollback,unblock,undelete} now must be POSTed * prop=imageinfo interface changed: iihistory replaced by iilimit, iistart and iiend parameters * Added amlang parameter to meta=allmessages +* Added apfilterlanglinks parameter to list=allpages, replacing query.php?what=nolanglinks === Languages updated in 1.12 === diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 5ca0acc5c1..d21657f55f 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -95,10 +95,22 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { $this->dieUsage('prlevel may not be used without prtype', 'params'); } - $this->addTables('page'); + if($params['filterlanglinks'] == 'withoutlanglinks') { + $pageName = $this->getDB()->tableName('page'); + $llName = $this->getDB()->tableName('langlinks'); + $tables = "$pageName LEFT JOIN $llName ON page_id=ll_from"; + $this->addWhere('ll_from IS NULL'); + $this->addTables($tables); + $forceNameTitleIndex = false; + } else if($params['filterlanglinks'] == 'withlanglinks') { + $this->addTables(array('page', 'langlinks')); + $this->addWhere('page_id=ll_from'); + $forceNameTitleIndex = false; + } else { + $this->addTables('page'); + } if ($forceNameTitleIndex) $this->addOption('USE INDEX', 'name_title'); - if (is_null($resultPageSet)) { $this->addFields(array ( @@ -191,6 +203,14 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { 'ascending', 'descending' ) + ), + 'filterlanglinks' => array( + ApiBase :: PARAM_TYPE => array( + 'withlanglinks', + 'withoutlanglinks', + 'all' + ), + ApiBase :: PARAM_DFLT => 'all' ) ); } @@ -206,6 +226,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { 'maxsize' => 'Limit to pages with at most this many bytes', 'prtype' => 'Limit to protected pages only', 'prlevel' => 'The protection level (must be used with apprtype= parameter)', + 'filterlanglinks' => 'Filter based on whether a page has langlinks', 'limit' => 'How many total pages to return.' ); } -- 2.20.1