Index: trunk/phase3/includes/api/ApiQueryQuerypage.php |
— | — | @@ -1,154 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on Jul 12, 2009 |
6 | | - * |
7 | | - * API for MediaWiki 1.8+ |
8 | | - * |
9 | | - * Copyright (C) 2009 Bryan Tong Minh <Bryan.TongMinh@Gmail.com> |
10 | | - * |
11 | | - * This program is free software; you can redistribute it and/or modify |
12 | | - * it under the terms of the GNU General Public License as published by |
13 | | - * the Free Software Foundation; either version 2 of the License, or |
14 | | - * (at your option) any later version. |
15 | | - * |
16 | | - * This program is distributed in the hope that it will be useful, |
17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | | - * GNU General Public License for more details. |
20 | | - * |
21 | | - * You should have received a copy of the GNU General Public License along |
22 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
23 | | - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24 | | - * http://www.gnu.org/copyleft/gpl.html |
25 | | - */ |
26 | | - |
27 | | -if (!defined('MEDIAWIKI')) { |
28 | | - // Eclipse helper - will be ignored in production |
29 | | - require_once ('ApiQueryBase.php'); |
30 | | -} |
31 | | - |
32 | | -/** |
33 | | - * Query module to access querypages |
34 | | - * |
35 | | - * @ingroup API |
36 | | - */ |
37 | | -class ApiQueryQuerypage extends ApiQueryBase { |
38 | | - static $queryPages = array( |
39 | | - 'ancientpages' => 'AncientPagesPage', |
40 | | - 'brokenredirects' => 'BrokenRedirectsPage', |
41 | | - 'deadendpages' => 'DeadendPagesPage', |
42 | | - 'disambiguations' => 'DisambiguationsPage', |
43 | | - ); |
44 | | - |
45 | | - public function __construct($query, $moduleName) { |
46 | | - parent :: __construct($query, $moduleName, 'qp'); |
47 | | - } |
48 | | - |
49 | | - public function execute() { |
50 | | - $this->run(); |
51 | | - } |
52 | | - |
53 | | - public function executeGenerator($resultPageSet) { |
54 | | - $this->run( $resultPageSet ); |
55 | | - } |
56 | | - |
57 | | - private function run($resultPageSet = null) { |
58 | | - $params = $this->extractRequestParams(); |
59 | | - $offset = $params['offset']; |
60 | | - $limit = $params['limit']; |
61 | | - |
62 | | - // Try to find an entry in $wgQueryPages |
63 | | - $name = $params['querypage']; |
64 | | - if ( is_null( $name ) ) |
65 | | - $this->dieUsageMsg( array( 'missingparam', 'querypage' ) ); |
66 | | - if ( !isset( self::$queryPages[$name] ) ) |
67 | | - $this->dieUsage( 'Querypage unrecognized', 'unknownquerypage' ); |
68 | | - |
69 | | - // Get the result from the query page |
70 | | - $class = self::$queryPages[$name]; |
71 | | - $queryPage = new $class; |
72 | | - $result = $queryPage->reallyDoQuery( $offset, $limit + 1 ); |
73 | | - |
74 | | - // Output the result |
75 | | - $apiResult = $this->getResult(); |
76 | | - $resultPath = array( 'query', $this->getModuleName() ); |
77 | | - $count = 0; |
78 | | - while ( $row = $result['dbr']->fetchObject( $result['result'] ) ) { |
79 | | - if ( ++ $count > $limit ) { |
80 | | - // We've reached the one extra which shows that there are additional pages to be had. Stop here... |
81 | | - $this->setContinueEnumParameter( 'offset', $offset + $count - 1 ); |
82 | | - break; |
83 | | - } |
84 | | - |
85 | | - if ( is_null( $resultPageSet ) ) { |
86 | | - // Normal mode; let the query page make a sensible result out of it |
87 | | - $vals = $queryPage->formatApiResult( $row ); |
88 | | - $fit = $apiResult->addValue( $resultPath, null, $vals ); |
89 | | - if( !$fit ) |
90 | | - { |
91 | | - $this->setContinueEnumParameter( 'offset', $offset + $count ); |
92 | | - break; |
93 | | - } |
94 | | - } else { |
95 | | - // Generator mode; not yet supported |
96 | | - $resultPageSet->processDbRow( $row ); |
97 | | - } |
98 | | - } |
99 | | - // Set XML element to 'p' |
100 | | - if ( is_null( $resultPageSet ) ) { |
101 | | - $apiResult->setIndexedTagName_internal( array( 'query', $this->getModuleName()), 'p' ); |
102 | | - } |
103 | | - |
104 | | - // Set meta information |
105 | | - if ( $result['cached'] ) { |
106 | | - // Set cached date if available, else simply true |
107 | | - $apiResult->addValue( $resultPath, 'cached', |
108 | | - $result === true ? true : wfTimestamp( TS_ISO_8601, $result['cached'] ) ); |
109 | | - } |
110 | | - if ( $result['disabled'] ) |
111 | | - // No further updates will be performed |
112 | | - $apiResult->addValue( $resultPath, 'disabled', true ); |
113 | | - |
114 | | - |
115 | | - } |
116 | | - |
117 | | - public function getAllowedParams() { |
118 | | - return array ( |
119 | | - 'offset' => 0, |
120 | | - 'limit' => array ( |
121 | | - ApiBase :: PARAM_DFLT => 10, |
122 | | - ApiBase :: PARAM_TYPE => 'limit', |
123 | | - ApiBase :: PARAM_MIN => 1, |
124 | | - ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
125 | | - ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
126 | | - ), |
127 | | - 'querypage' => array( |
128 | | - ApiBase :: PARAM_TYPE => array_keys( self::$queryPages ) |
129 | | - ), |
130 | | - ); |
131 | | - } |
132 | | - |
133 | | - public function getParamDescription() { |
134 | | - return array ( |
135 | | - 'offset' => 'The offset to start enumerating from.', |
136 | | - 'limit' => 'How many total pages to return.', |
137 | | - 'querypage' => 'Which querypage to use', |
138 | | - ); |
139 | | - } |
140 | | - |
141 | | - public function getDescription() { |
142 | | - return 'Query one of the builtin query pages.'; |
143 | | - } |
144 | | - |
145 | | - protected function getExamples() { |
146 | | - return array ( |
147 | | - ' Query a list of broken redirects', |
148 | | - ' api.php?action=query&list=querypage&qpquerypage=brokenredirects', |
149 | | - ); |
150 | | - } |
151 | | - |
152 | | - public function getVersion() { |
153 | | - return __CLASS__ . ': $Id:$'; |
154 | | - } |
155 | | -} |
\ No newline at end of file |
Index: trunk/phase3/includes/api/ApiQuery.php |
— | — | @@ -81,7 +81,6 @@ |
82 | 82 | 'users' => 'ApiQueryUsers', |
83 | 83 | 'random' => 'ApiQueryRandom', |
84 | 84 | 'protectedtitles' => 'ApiQueryProtectedTitles', |
85 | | - 'querypage' => 'ApiQueryQuerypage', |
86 | 85 | ); |
87 | 86 | |
88 | 87 | private $mQueryMetaModules = array ( |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -302,7 +302,6 @@ |
303 | 303 | 'ApiQueryLangLinks' => 'includes/api/ApiQueryLangLinks.php', |
304 | 304 | 'ApiQueryLinks' => 'includes/api/ApiQueryLinks.php', |
305 | 305 | 'ApiQueryLogEvents' => 'includes/api/ApiQueryLogEvents.php', |
306 | | - 'ApiQueryQuerypage' => 'includes/api/ApiQueryQuerypage.php', |
307 | 306 | 'ApiQueryProtectedTitles' => 'includes/api/ApiQueryProtectedTitles.php', |
308 | 307 | 'ApiQueryRandom' => 'includes/api/ApiQueryRandom.php', |
309 | 308 | 'ApiQueryRecentChanges'=> 'includes/api/ApiQueryRecentChanges.php', |
Index: trunk/phase3/includes/specials/SpecialDisambiguations.php |
— | — | @@ -94,12 +94,6 @@ |
95 | 95 | |
96 | 96 | return "$from $edit $arr $to"; |
97 | 97 | } |
98 | | - function formatApiResult( $row ) { |
99 | | - $linkTo = Title::makeTitle( NS_MAIN, $row->value ); |
100 | | - $result = parent::formatApiResult( $row ); |
101 | | - $result['to'] = $linkTo->getPrefixedText(); |
102 | | - return $result; |
103 | | - } |
104 | 98 | } |
105 | 99 | |
106 | 100 | /** |
Index: trunk/phase3/includes/specials/SpecialAncientpages.php |
— | — | @@ -62,10 +62,6 @@ |
63 | 63 | ); |
64 | 64 | return wfSpecialList($link, htmlspecialchars($d) ); |
65 | 65 | } |
66 | | - function formatApiResult( $row ) { |
67 | | - $result = parent::formatApiResult( $row ); |
68 | | - $result['timestamp'] = wfTimestamp( TS_ISO_8601, $row->value ); |
69 | | - } |
70 | 66 | } |
71 | 67 | |
72 | 68 | function wfSpecialAncientpages() { |
Index: trunk/phase3/includes/QueryPage.php |
— | — | @@ -176,11 +176,12 @@ |
177 | 177 | * Formats the result as something that can be understood by the API. |
178 | 178 | * Defaults to setting id, ns and title |
179 | 179 | */ |
180 | | - function formatApiResult( $row ) { |
| 180 | + function formatApiResult( $result ) { |
181 | 181 | $title = Title::makeTitle( $row->namespace, $row->title ); |
182 | 182 | return array( |
183 | | - 'ns' => intval( $title->getNamespace() ), |
184 | | - 'title' => $title->getPrefixedText(), |
| 183 | + 'pageid' => intval( $row->id ), |
| 184 | + 'ns' => intval( $title->getNamespace() ), |
| 185 | + 'title' => $title->getPrefixedText(), |
185 | 186 | ); |
186 | 187 | } |
187 | 188 | |
— | — | @@ -360,7 +361,7 @@ |
361 | 362 | * 'count' => number of results, |
362 | 363 | * 'dbr' => the database used for fetching the data |
363 | 364 | */ |
364 | | - public function reallyDoQuery( $offset, $limit ) { |
| 365 | + protected function reallyDoQuery( $offset, $limit ) { |
365 | 366 | $result = array( 'disabled' => false ); |
366 | 367 | |
367 | 368 | $this->offset = $offset; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -292,7 +292,6 @@ |
293 | 293 | * Added snippet field to list=search output |
294 | 294 | * (bug 17809) Add number of users in user groups to meta=siteinfo |
295 | 295 | * (bug 18533) Add readonly reason to readonly exception |
296 | | -* (bug 14869) Allow access to QueryPage-based special pages via API |
297 | 296 | |
298 | 297 | === Languages updated in 1.16 === |
299 | 298 | |