Index: trunk/phase3/includes/api/ApiQueryIWBacklinks.php |
— | — | @@ -33,13 +33,21 @@ |
34 | 34 | * This gives links pointing to the given interwiki |
35 | 35 | * @ingroup API |
36 | 36 | */ |
37 | | -class ApiQueryIWBacklinks extends ApiQueryBase { |
| 37 | +class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { |
38 | 38 | |
39 | 39 | public function __construct( $query, $moduleName ) { |
40 | 40 | parent::__construct( $query, $moduleName, 'iwbl' ); |
41 | 41 | } |
| 42 | + |
| 43 | + public function execute() { |
| 44 | + $this->run(); |
| 45 | + } |
42 | 46 | |
43 | | - public function execute() { |
| 47 | + public function executeGenerator( $resultPageSet ) { |
| 48 | + $this->run( $resultPageSet ); |
| 49 | + } |
| 50 | + |
| 51 | + public function run( $resultPageSet = null ) { |
44 | 52 | $params = $this->extractRequestParams(); |
45 | 53 | |
46 | 54 | if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) { |
— | — | @@ -91,6 +99,8 @@ |
92 | 100 | |
93 | 101 | $db = $this->getDB(); |
94 | 102 | $res = $this->select( __METHOD__ ); |
| 103 | + |
| 104 | + $pages = array(); |
95 | 105 | |
96 | 106 | $count = 0; |
97 | 107 | $result = $this->getResult(); |
— | — | @@ -102,35 +112,40 @@ |
103 | 113 | break; |
104 | 114 | } |
105 | 115 | |
106 | | - $entry = array(); |
107 | | - |
108 | | - $entry['pageid'] = intval( $row->page_id ); |
109 | | - $entry['ns'] = $row->page_namespace; |
110 | | - $entry['title'] = $row->page_title; |
111 | | - |
112 | | - if ( $row->page_is_redirect ) { |
113 | | - $entry['redirect'] = ''; |
114 | | - } |
115 | | - |
116 | | - if ( $iwprefix ) { |
117 | | - $entry['iwprefix'] = $row->iwl_prefix; |
118 | | - } |
119 | | - |
120 | | - if ( $iwtitle ) { |
121 | | - $entry['iwtitle'] = $row->iwl_title; |
122 | | - } |
| 116 | + if ( !is_null( $resultPageSet ) ) { |
| 117 | + $pages[] = Title::makeTitle( $row->page_namespace, $row->page_title )->getPrefixedText(); |
| 118 | + } else { |
| 119 | + $entry = array(); |
| 120 | + |
| 121 | + $entry['pageid'] = intval( $row->page_id ); |
| 122 | + $entry['ns'] = $row->page_namespace; |
| 123 | + $entry['title'] = $row->page_title; |
| 124 | + |
| 125 | + if ( $row->page_is_redirect ) { |
| 126 | + $entry['redirect'] = ''; |
| 127 | + } |
| 128 | + |
| 129 | + if ( $iwprefix ) { |
| 130 | + $entry['iwprefix'] = $row->iwl_prefix; |
| 131 | + } |
| 132 | + |
| 133 | + if ( $iwtitle ) { |
| 134 | + $entry['iwtitle'] = $row->iwl_title; |
| 135 | + } |
123 | 136 | |
124 | | - $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); |
125 | | - if ( !$fit ) { |
126 | | - $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" ); |
127 | | - break; |
| 137 | + $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); |
| 138 | + if ( !$fit ) { |
| 139 | + $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" ); |
| 140 | + break; |
| 141 | + } |
128 | 142 | } |
129 | 143 | } |
130 | | - |
131 | | - $this->getResult()->setIndexedTagName_internal( |
132 | | - array( 'query', $this->getModuleName() ), |
133 | | - 'iw' |
134 | | - ); |
| 144 | + |
| 145 | + if ( is_null( $resultPageSet ) ) { |
| 146 | + $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'iw' ); |
| 147 | + } else { |
| 148 | + $resultPageSet->populateFromTitles( $pages ); |
| 149 | + } |
135 | 150 | } |
136 | 151 | |
137 | 152 | public function getAllowedParams() { |
— | — | @@ -188,7 +203,7 @@ |
189 | 204 | protected function getExamples() { |
190 | 205 | return array( |
191 | 206 | 'api.php?action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks', |
192 | | - //'api.php?action=query&generator=iwbacklinks&giwbltitle=Test&iwblprefix=wikibooks&prop=info' |
| 207 | + 'api.php?action=query&generator=iwbacklinks&giwbltitle=Test&iwblprefix=wikibooks&prop=info' |
193 | 208 | ); |
194 | 209 | } |
195 | 210 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -282,7 +282,8 @@ |
283 | 283 | * (bug 24296) Added converttitles parameter to convert titles to their |
284 | 284 | canonical language variant. |
285 | 285 | * Fixed "link" parameter in image links with "thumb" parameter. |
286 | | -* (bug 23936) - Add "displaytitle" to query/info API |
| 286 | +* (bug 23936) Add "displaytitle" to query/info API |
| 287 | +* (bug 24485) Make iwbacklinks a generator, display iwprefix and iwtitle optional |
287 | 288 | |
288 | 289 | === Languages updated in 1.17 === |
289 | 290 | |