Index: trunk/extensions/GlobalUsage/GlobalUsageQuery.php |
— | — | @@ -169,6 +169,7 @@ |
170 | 170 | 'gil_to', |
171 | 171 | 'gil_wiki', |
172 | 172 | 'gil_page', |
| 173 | + 'gil_page_namespace_id', |
173 | 174 | 'gil_page_namespace', |
174 | 175 | 'gil_page_title' |
175 | 176 | ), |
— | — | @@ -211,6 +212,7 @@ |
212 | 213 | $this->result[$row->gil_to][$row->gil_wiki][] = array( |
213 | 214 | 'image' => $row->gil_to, |
214 | 215 | 'id' => $row->gil_page, |
| 216 | + 'namespace_id' => $row->gil_page_namespace_id, |
215 | 217 | 'namespace' => $row->gil_page_namespace, |
216 | 218 | 'title' => $row->gil_page_title, |
217 | 219 | 'wiki' => $row->gil_wiki, |
Index: trunk/extensions/GlobalUsage/ApiQueryGlobalUsage.php |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | |
31 | 31 | public function execute() { |
32 | 32 | $params = $this->extractRequestParams(); |
| 33 | + $prop = array_flip( $params['prop'] ); |
33 | 34 | |
34 | 35 | $pageIds = $this->getPageSet()->getAllTitlesByNamespace(); |
35 | 36 | if ( !empty( $pageIds[NS_FILE] ) ) { |
— | — | @@ -51,18 +52,29 @@ |
52 | 53 | $pageId = intval( $pageIds[$image] ); |
53 | 54 | foreach ( $wikis as $wiki => $result ) { |
54 | 55 | foreach ( $result as $item ) { |
55 | | - if ( $item['namespace'] ) |
| 56 | + if ( $item['namespace'] ) { |
56 | 57 | $title = "{$item['namespace']}:{$item['title']}"; |
57 | | - else |
| 58 | + } else { |
58 | 59 | $title = $item['title']; |
59 | | - $url = WikiMap::getForeignUrl( $item['wiki'], $title ); |
| 60 | + } |
| 61 | + $result = array( |
| 62 | + 'title' => $title, |
| 63 | + 'wiki' => WikiMap::getWikiName( $wiki ) |
| 64 | + ); |
| 65 | + if ( isset( $prop['url'] ) ) { |
| 66 | + $result['url'] = wfExpandUrl( |
| 67 | + WikiMap::getForeignUrl( $item['wiki'], $title ) ); |
| 68 | + } |
| 69 | + if ( isset( $prop['pageid'] ) ) { |
| 70 | + $result['pageid'] = $item['id']; |
| 71 | + } |
| 72 | + if ( isset( $prop['namespace'] ) ) { |
| 73 | + $result['ns'] = $item['namespace_id']; |
| 74 | + } |
| 75 | + |
60 | 76 | $fit = $apiResult->addValue( array( |
61 | 77 | 'query', 'pages', $pageId, 'globalusage' |
62 | | - ), null, array( |
63 | | - 'title' => $title, |
64 | | - 'url' => $url, |
65 | | - 'wiki' => WikiMap::getWikiName( $wiki ) |
66 | | - ) ); |
| 78 | + ), null, $result ); |
67 | 79 | |
68 | 80 | if ( !$fit ) { |
69 | 81 | $continue = "{$item['image']}|{$item['wiki']}|{$item['id']}"; |
— | — | @@ -94,6 +106,15 @@ |
95 | 107 | |
96 | 108 | public function getAllowedParams() { |
97 | 109 | return array( |
| 110 | + 'prop' => array( |
| 111 | + ApiBase::PARAM_DFLT => 'url', |
| 112 | + ApiBase::PARAM_TYPE => array( |
| 113 | + 'url', |
| 114 | + 'pageid', |
| 115 | + 'namespace', |
| 116 | + ), |
| 117 | + ApiBase::PARAM_ISMULTI => true, |
| 118 | + ), |
98 | 119 | 'limit' => array( |
99 | 120 | ApiBase :: PARAM_DFLT => 10, |
100 | 121 | ApiBase :: PARAM_TYPE => 'limit', |
— | — | @@ -108,6 +129,12 @@ |
109 | 130 | |
110 | 131 | public function getParamDescription () { |
111 | 132 | return array( |
| 133 | + 'prop' => array( |
| 134 | + 'What properties to return', |
| 135 | + ' url - Adds url ', |
| 136 | + ' pageid - Adds page id', |
| 137 | + ' namespace - Adds namespace id', |
| 138 | + ), |
112 | 139 | 'limit' => 'How many links to return', |
113 | 140 | 'continue' => 'When more results are available, use this to continue', |
114 | 141 | 'filterlocal' => 'Filter local usage of the file', |