r31463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31462‎ | r31463 | r31464 >
Date:19:32, 2 March 2008
Author:btongminh
Status:old
Tags:
Comment:
Add some kind of interface to GlobalUsage.
Modified paths:
  • /trunk/extensions/GlobalUsage/GlobalUsage.i18n.php (modified) (history)
  • /trunk/extensions/GlobalUsage/GlobalUsage.php (modified) (history)
  • /trunk/extensions/GlobalUsage/GlobalUsage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalUsage/GlobalUsage_body.php
@@ -3,9 +3,9 @@
44 class GlobalUsage extends SpecialPage {
55 private static $database = array();
66
7 - function GlobalUsage() {
8 - SpecialPage::SpecialPage('GlobalUsage');
9 - //wfLoadExtensionMessages('GlobalUsage');
 7+ function __construct() {
 8+ parent::__construct('GlobalUsage');
 9+ wfLoadExtensionMessages( 'GlobalUsage' );
1010 }
1111
1212 static function getDatabase( $dbFlags = DB_MASTER ) {
@@ -173,20 +173,52 @@
174174 return true;
175175 }
176176
177 - function execute() {
178 - global $wgOut, $wgRequest;
 177+ public function execute( $par ) {
 178+ global $wgOut, $wgScript, $wgRequest;
179179
 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+
180204 $dbr = GlobalUsage::getDatabase( DB_SLAVE );
181205 $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 ),
186208 __METHOD__ );
187209
188210 // Quick dirty list output
189211 while ( $row = $dbr->fetchObject($res) )
190 - $wgOut->addWikiText("* [[:".$row->gil_wiki.":".$row->gil_pagename."]] \n");
 212+ $wgOut->addWikiText(GlobalUsage::formatItem( $row ) );
191213 $dbr->freeResult($res);
192214 }
 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+ }
193225 }
Index: trunk/extensions/GlobalUsage/GlobalUsage.i18n.php
@@ -11,7 +11,10 @@
1212 * @author Bryan Tong Minh
1313 */
1414 $messages['en'] = array(
 15+ 'globalusage' => 'Global file usage',
1516 'globalusage-desc' => '[[Special:GlobalUsage|Special page]] to view global file usage',
 17+ 'globalusage-ok' => 'Search',
 18+ 'globalusage-text' => 'Search global image usage.'
1619 );
1720
1821 /** Arabic (العربية)
Index: trunk/extensions/GlobalUsage/GlobalUsage.php
@@ -46,7 +46,7 @@
4747
4848 $wgExtensionMessagesFiles['GlobalUsage'] = $dir . 'GlobalUsage.i18n.php';
4949 $wgAutoloadClasses['GlobalUsage'] = $dir . 'GlobalUsage_body.php';
50 -//$wgExtensionMessageFiles['GlobalUsage'] = $dir . 'GlobalUsage.i18n.php';
 50+$wgExtensionMessageFiles['GlobalUsage'] = $dir . 'GlobalUsage.i18n.php';
5151 $wgSpecialPages['GlobalUsage'] = 'GlobalUsage';
5252
5353 $wgHooks['LinksUpdate'][] = 'GlobalUsage::updateLinks';

Status & tagging log