Index: trunk/extensions/GlobalUsage/GlobalUsage_body.php |
— | — | @@ -3,9 +3,9 @@ |
4 | 4 | class GlobalUsage extends SpecialPage { |
5 | 5 | private static $database = array(); |
6 | 6 | |
7 | | - function GlobalUsage() { |
8 | | - SpecialPage::SpecialPage('GlobalUsage'); |
9 | | - //wfLoadExtensionMessages('GlobalUsage'); |
| 7 | + function __construct() { |
| 8 | + parent::__construct('GlobalUsage'); |
| 9 | + wfLoadExtensionMessages( 'GlobalUsage' ); |
10 | 10 | } |
11 | 11 | |
12 | 12 | static function getDatabase( $dbFlags = DB_MASTER ) { |
— | — | @@ -173,20 +173,52 @@ |
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | |
177 | | - function execute() { |
178 | | - global $wgOut, $wgRequest; |
| 177 | + public function execute( $par ) { |
| 178 | + global $wgOut, $wgScript, $wgRequest; |
179 | 179 | |
| 180 | + $this->setHeaders(); |
| 181 | + |
| 182 | + $self = Title::makeTitle( NS_SPECIAL, 'GlobalUsage' ); |
| 183 | + $target= Title::makeTitleSafe( NS_IMAGE, $wgRequest->getText( 'target', $par ) ); |
| 184 | + |
| 185 | + $wgOut->addWikiText( wfMsg( 'globalusage-text' ) ); |
| 186 | + |
| 187 | + $form = Xml::openElement( 'form', array( |
| 188 | + 'id' => 'mw-globalusage-form', |
| 189 | + 'method' => 'get', |
| 190 | + 'action' => $wgScript )); |
| 191 | + $form .= Xml::hidden( 'title', $self->getPrefixedDbKey() ); |
| 192 | + $form .= Xml::openElement( 'fieldset' ); |
| 193 | + $form .= Xml::element( 'legend', array(), wfMsg( 'globalusage' )); |
| 194 | + $form .= Xml::inputLabel( wfMsg( 'filename' ), 'target', |
| 195 | + 'target', 50, $target->getDBkey() ); |
| 196 | + $form .= Xml::submitButton( wfMsg( 'globalusage-ok' ) ); |
| 197 | + $form .= Xml::closeElement( 'fieldset' ); |
| 198 | + $form .= Xml::closeElement( 'form' ); |
| 199 | + |
| 200 | + $wgOut->addHtml( $form ); |
| 201 | + |
| 202 | + if ( !$target->getDBkey() ) return; |
| 203 | + |
180 | 204 | $dbr = GlobalUsage::getDatabase( DB_SLAVE ); |
181 | 205 | $res = $dbr->select( 'globalimagelinks', |
182 | | - array( 'gil_wiki', 'gil_pagename' ), |
183 | | - // Needs normalizing |
184 | | - array( 'gil_to' => $wgRequest->getText('image'), |
185 | | - 'gil_is_local' => 0), |
| 206 | + array( 'gil_wiki', 'gil_page_namespace', 'gil_page_title' ), |
| 207 | + array( 'gil_to' => $target->getDBkey(), 'gil_is_local' => 0 ), |
186 | 208 | __METHOD__ ); |
187 | 209 | |
188 | 210 | // Quick dirty list output |
189 | 211 | while ( $row = $dbr->fetchObject($res) ) |
190 | | - $wgOut->addWikiText("* [[:".$row->gil_wiki.":".$row->gil_pagename."]] \n"); |
| 212 | + $wgOut->addWikiText(GlobalUsage::formatItem( $row ) ); |
191 | 213 | $dbr->freeResult($res); |
192 | 214 | } |
| 215 | + |
| 216 | + public static function formatItem( $row ) { |
| 217 | + $out = '* [['; |
| 218 | + if ( GlobalUsage::getLocalInterwiki() != $row->gil_wiki ) |
| 219 | + $out .= ':'.$row->gil_wiki; |
| 220 | + if ( $row->gil_page_namespace ) |
| 221 | + $out .= ':'.str_replace('_', ' ', $row->gil_page_namespace); |
| 222 | + $out .= ':'.str_replace('_', ' ', $row->gil_page_title)."]]\n"; |
| 223 | + return $out; |
| 224 | + } |
193 | 225 | } |
Index: trunk/extensions/GlobalUsage/GlobalUsage.i18n.php |
— | — | @@ -11,7 +11,10 @@ |
12 | 12 | * @author Bryan Tong Minh |
13 | 13 | */ |
14 | 14 | $messages['en'] = array( |
| 15 | + 'globalusage' => 'Global file usage', |
15 | 16 | 'globalusage-desc' => '[[Special:GlobalUsage|Special page]] to view global file usage', |
| 17 | + 'globalusage-ok' => 'Search', |
| 18 | + 'globalusage-text' => 'Search global image usage.' |
16 | 19 | ); |
17 | 20 | |
18 | 21 | /** Arabic (العربية) |
Index: trunk/extensions/GlobalUsage/GlobalUsage.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | |
48 | 48 | $wgExtensionMessagesFiles['GlobalUsage'] = $dir . 'GlobalUsage.i18n.php'; |
49 | 49 | $wgAutoloadClasses['GlobalUsage'] = $dir . 'GlobalUsage_body.php'; |
50 | | -//$wgExtensionMessageFiles['GlobalUsage'] = $dir . 'GlobalUsage.i18n.php'; |
| 50 | +$wgExtensionMessageFiles['GlobalUsage'] = $dir . 'GlobalUsage.i18n.php'; |
51 | 51 | $wgSpecialPages['GlobalUsage'] = 'GlobalUsage'; |
52 | 52 | |
53 | 53 | $wgHooks['LinksUpdate'][] = 'GlobalUsage::updateLinks'; |