Index: branches/license-work/phase3/includes/specials/SpecialLicenseManager.php |
— | — | @@ -35,12 +35,60 @@ |
36 | 36 | } |
37 | 37 | |
38 | 38 | 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 |
39 | 44 | global $wgRequest, $wgOut; |
40 | | - |
41 | 45 | $this->setHeaders(); |
42 | | - |
| 46 | + $pager = new LicensePager( $this ); |
| 47 | + $wgOut->addHTML( $pager->getBody() ); |
43 | 48 | } |
44 | 49 | } |
45 | 50 | |
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 | + } |
47 | 95 | } |
\ No newline at end of file |
Index: branches/license-work/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2456,7 +2456,13 @@ |
2457 | 2457 | 'fewestrevisions-summary' => '', # do not translate or duplicate this message to other languages |
2458 | 2458 | |
2459 | 2459 | # LicenseManager |
| 2460 | +// TODO: qqq, messages.inc |
2460 | 2461 | '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}}', |
2461 | 2467 | |
2462 | 2468 | # Miscellaneous special pages |
2463 | 2469 | 'nbytes' => '$1 {{PLURAL:$1|byte|bytes}}', |