r80359 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80358‎ | r80359 | r80360 >
Date:00:00, 15 January 2011
Author:catrope
Status:ok
Tags:license-work 
Comment:
license-work: Initial stab at implementing Special:LicenseManager, still incomplete with lots of TODOs
Modified paths:
  • /branches/license-work/phase3/includes/specials/SpecialLicenseManager.php (modified) (history)
  • /branches/license-work/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: branches/license-work/phase3/includes/specials/SpecialLicenseManager.php
@@ -35,12 +35,60 @@
3636 }
3737
3838 function execute( $par ) {
 39+ // TODO: edit through Special:LicenseManager/123
 40+ // TODO: table instead of ul/li
 41+ // TODO: edit/delete restrictions
 42+ // TODO: keep Special:LicenseManager for write actions, move list to separate special page
 43+ // TODO: rm legal URL, add text of corresponding MW msgs
3944 global $wgRequest, $wgOut;
40 -
4145 $this->setHeaders();
42 -
 46+ $pager = new LicensePager( $this );
 47+ $wgOut->addHTML( $pager->getBody() );
4348 }
4449 }
4550
46 -class LicensePager extends IndexPager {
 51+class LicensePager extends AlphabeticPager {
 52+ protected $mSpecialPage;
 53+
 54+ public function __construct( $specialpage ) {
 55+ parent::__construct();
 56+ $this->mSpecialPage = $specialpage;
 57+ }
 58+ public function getQueryInfo() {
 59+ return array(
 60+ 'tables' => 'license',
 61+ 'fields' => array( 'lic_id', 'lic_name', 'lic_url', 'lic_count' ),
 62+ );
 63+ }
 64+
 65+ public function getIndexField() {
 66+ return 'lic_name';
 67+ }
 68+
 69+ public function getStartBody() {
 70+ return "<ul>";
 71+ }
 72+
 73+ public function getEndBody() {
 74+ return "</ul>";
 75+ }
 76+
 77+ public function formatRow( $row ) {
 78+ global $wgUser, $wgLang;
 79+ $sk = $wgUser->getSkin();
 80+ $editlink = $sk->link( $this->mSpecialPage->getTitle(),
 81+ wfMsg( 'licensemanager-edit-link' ),
 82+ array(),
 83+ array( 'edit' => $row->lic_id )
 84+ );
 85+ $deletelink = $sk->link( $this->mSpecialPage->getTitle(),
 86+ wfMsg( 'licensemanager-delete-link' ),
 87+ array(),
 88+ array( 'delete' => $row->lic_id )
 89+ );
 90+ $name = htmlspecialchars( $row->lic_name );
 91+ $urlLink = $sk->makeExternalLink( $row->lic_url, wfMsg( 'licensemanager-url-link' ) );
 92+ $count = wfMsg( 'licensemanager-filecount', $wgLang->formatNum( $row->lic_count ) );
 93+ return "<li>" . wfMsgHtml( 'licensemanager-row', $name, $urlLink, $count, $editlink, $deletelink ) . "</li>";
 94+ }
4795 }
\ No newline at end of file
Index: branches/license-work/phase3/languages/messages/MessagesEn.php
@@ -2456,7 +2456,13 @@
24572457 'fewestrevisions-summary' => '', # do not translate or duplicate this message to other languages
24582458
24592459 # LicenseManager
 2460+// TODO: qqq, messages.inc
24602461 'licensemanager' => 'License manager',
 2462+'licensemanager-row' => '$1 ($2) ($3) ($4) ($5)',
 2463+'licensemanager-url-link' => 'legal text',
 2464+'licensemanager-edit-link' => 'edit',
 2465+'licensemanager-delete-link' => 'delete',
 2466+'licensemanager-filecount' => 'used for $1 {{PLURAL:$1|file|files}}',
24612467
24622468 # Miscellaneous special pages
24632469 'nbytes' => '$1 {{PLURAL:$1|byte|bytes}}',

Status & tagging log