r46009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46008‎ | r46009 | r46010 >
Date:10:16, 22 January 2009
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Also show templates used by notices in Central:Notice for users without centralnotice-admin right
* Removed "Submit" button for users without centralnotice-admin right in Special:CentralNotice
* Fixed XHTML errors
* Whitespaces fixes
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -92,27 +92,27 @@
9393 }
9494 }
9595
96 - // Handle setting preferred
97 - $preferredNotices = $wgRequest->getArray( 'preferred' );
98 - if ( isset( $preferredNotices ) ) {
99 - // Set since this is a single display
100 - if ( $method == 'listNoticeDetail' ) {
101 - $notice = $wgRequest->getVal ( 'notice' );
102 - CentralNoticeDB::updatePreferred( $notice, '1' );
103 - }
104 - else {
105 - // Build list of notices to unset
106 - $unsetNotices = array_diff( $this->getNoticesName(), $preferredNotices );
 96+ // Handle setting preferred
 97+ $preferredNotices = $wgRequest->getArray( 'preferred' );
 98+ if ( isset( $preferredNotices ) ) {
 99+ // Set since this is a single display
 100+ if ( $method == 'listNoticeDetail' ) {
 101+ $notice = $wgRequest->getVal ( 'notice' );
 102+ CentralNoticeDB::updatePreferred( $notice, '1' );
 103+ }
 104+ else {
 105+ // Build list of notices to unset
 106+ $unsetNotices = array_diff( $this->getNoticesName(), $preferredNotices );
107107
108 - // Set flag accordingly
109 - foreach( $preferredNotices as $notice ) {
110 - CentralNoticeDB::updatePreferred( $notice, '1' );
111 - }
112 - foreach( $unsetNotices as $notice ) {
113 - CentralNoticeDB::updatePreferred( $notice, '0' );
114 - }
115 - }
116 - }
 108+ // Set flag accordingly
 109+ foreach( $preferredNotices as $notice ) {
 110+ CentralNoticeDB::updatePreferred( $notice, '1' );
 111+ }
 112+ foreach( $unsetNotices as $notice ) {
 113+ CentralNoticeDB::updatePreferred( $notice, '0' );
 114+ }
 115+ }
 116+ }
117117
118118 $noticeName = $wgRequest->getVal( 'notice' );
119119
@@ -645,29 +645,33 @@
646646 }
647647
648648 // Catch for no templates so that we dont' double message
649 - if( $this->editable ) {
650 - if ( $output_assigned == '' && $output_templates == '' ) {
651 - $htmlOut .= wfMsg( 'centralnotice-no-templates' );
652 - $htmlOut .= Xml::element( 'p' );
653 - $newPage = SpecialPage::getTitleFor( 'NoticeTemplate/add' );
654 - $sk = $wgUser->getSkin();
655 - $htmlOut .= $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-add-template' ) );
656 - $htmlOut .= Xml::element( 'p' );
657 - } elseif ( $output_assigned == '' ) {
658 - $htmlOut .= wfMsg( 'centralnotice-no-templates-assigned' );
659 - $htmlOut .= $output_templates;
660 - } else {
661 - $htmlOut .= $output_assigned;
662 - $htmlOut .= $output_templates;
 649+ if ( $output_assigned == '' && $output_templates == '' ) {
 650+ $htmlOut .= wfMsg( 'centralnotice-no-templates' );
 651+ $htmlOut .= Xml::element( 'p' );
 652+ $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'add' );
 653+ $sk = $wgUser->getSkin();
 654+ $htmlOut .= $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-add-template' ) );
 655+ $htmlOut .= Xml::element( 'p' );
 656+ } elseif ( $output_assigned == '' ) {
 657+ $htmlOut .= wfMsg( 'centralnotice-no-templates-assigned' );
 658+ if( $this->editable ) {
 659+ $htmlOut .= $output_templates;
663660 }
 661+ } else {
 662+ $htmlOut .= $output_assigned;
 663+ if( $this->editable ) {
 664+ $htmlOut .= $output_templates;
 665+ }
664666 }
665 - $htmlOut .= Xml::tags( 'tr', null,
666 - Xml::tags( 'td', array( 'collspan' => 2 ),
667 - Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
668 - )
669 - );
670 -
671 - $htmlOut .= Xml::closeElement( 'form' );
 667+
 668+ if( $this->editable ) {
 669+ $htmlOut .= Xml::tags( 'tr', null,
 670+ Xml::tags( 'td', array( 'collspan' => 2 ),
 671+ Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
 672+ )
 673+ );
 674+ $htmlOut .= Xml::closeElement( 'form' );
 675+ }
672676 $wgOut->addHTML( $htmlOut );
673677 }
674678
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -80,12 +80,12 @@
8181 }
8282 }
8383
84 - // Handle viewiing of a template in all languages
85 - if ( $sub == 'view' && $wgRequest->getVal( 'wpUserLanguage' ) == 'all' ) {
86 - $template = $wgRequest->getVal( 'template' );
87 - $this->showViewAvailable( $template );
88 - return;
89 - }
 84+ // Handle viewiing of a template in all languages
 85+ if ( $sub == 'view' && $wgRequest->getVal( 'wpUserLanguage' ) == 'all' ) {
 86+ $template = $wgRequest->getVal( 'template' );
 87+ $this->showViewAvailable( $template );
 88+ return;
 89+ }
9090
9191 // Handle viewing a specific template
9292 if ( $sub == 'view' && $wgRequest->getText( 'template' ) != '' ) {
@@ -365,7 +365,7 @@
366366 $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9 ) );
367367 list( $lsLabel, $lsSelect ) = Xml::languageSelector( $wpUserLang );
368368
369 - $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
 369+ $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
370370
371371 $htmlOut .= Xml::tags( 'tr', null,
372372 Xml::tags( 'td', null, $lsLabel ) .
@@ -410,62 +410,63 @@
411411 $htmlOut .= Xml::closeElement( 'form' );
412412 }
413413
414 - /*
415 - * Show Clone form
416 - */
417 - if ( $this->editable ) {
418 - $htmlOut .= Xml::openElement ( 'form',
419 - array(
420 - 'method' => 'post',
421 - 'action' => SpecialPage::getTitleFor( 'NoticeTemplate', 'clone' )->getLocalUrl()
422 - )
423 - );
 414+ /*
 415+ * Show Clone form
 416+ */
 417+ if ( $this->editable ) {
 418+ $htmlOut .= Xml::openElement ( 'form',
 419+ array(
 420+ 'method' => 'post',
 421+ 'action' => SpecialPage::getTitleFor( 'NoticeTemplate', 'clone' )->getLocalUrl()
 422+ )
 423+ );
424424
425 - $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-clone-notice' ) );
426 - $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) );
427 - $htmlOut .= Xml::openElement( 'tr' );
428 - $htmlOut .= Xml::inputLabel( 'Name:', 'newTemplate', 'newTemplate, 25');
429 - $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-clone' ), array ( 'id' => 'clone' ) );
430 - $htmlOut .= Xml::hidden( 'oldTemplate', $currentTemplate );
 425+ $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-clone-notice' ) );
 426+ $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) );
 427+ $htmlOut .= Xml::openElement( 'tr' );
 428+ $htmlOut .= Xml::inputLabel( 'Name:', 'newTemplate', 'newTemplate, 25');
 429+ $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-clone' ), array ( 'id' => 'clone' ) );
 430+ $htmlOut .= Xml::hidden( 'oldTemplate', $currentTemplate );
431431
432 - $htmlOut .= Xml::closeElement( 'tr' );
433 - $htmlOut .= Xml::closeElement( 'table' );
434 - $htmlOut .= Xml::closeElement( 'form' );
435 - }
 432+ $htmlOut .= Xml::closeElement( 'tr' );
 433+ $htmlOut .= Xml::closeElement( 'table' );
 434+ $htmlOut .= Xml::closeElement( 'fieldset' );
 435+ $htmlOut .= Xml::closeElement( 'form' );
 436+ }
436437
437 - // Output HTML
438 - $wgOut->addHTML( $htmlOut );
439 - }
 438+ // Output HTML
 439+ $wgOut->addHTML( $htmlOut );
 440+ }
440441
441 - public function showViewAvailable( $template ) {
442 - global $wgOut, $wgUser;
 442+ public function showViewAvailable( $template ) {
 443+ global $wgOut, $wgUser;
443444
444 - // Testing to see if bumping up the memory limit lets meta preview
445 - ini_set( 'memory_limit', '120M' );
 445+ // Testing to see if bumping up the memory limit lets meta preview
 446+ ini_set( 'memory_limit', '120M' );
446447
447 - $sk = $wgUser->getSkin();
 448+ $sk = $wgUser->getSkin();
448449
449 - // Pull all available text for a template
450 - $langs = array_keys( $this->getTranslations( $template ) );
451 - $htmlOut = '';
 450+ // Pull all available text for a template
 451+ $langs = array_keys( $this->getTranslations( $template ) );
 452+ $htmlOut = '';
452453
453 - foreach( $langs as $lang ) {
454 - // Link and Preview all available translations
455 - $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
456 - $render = new SpecialNoticeText();
457 - $render->project = 'wikipedia';
458 - $render->language = $lang;
459 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
460 - $sk->makeLinkObj( $viewPage,
461 - $lang,
462 - 'template=' . urlencode( $template ) . "&wpUserLanguage=$lang") .
463 - Xml::fieldset( wfMsg( 'centralnotice-preview' ),
464 - $render->getHtmlNotice( $template )
465 - )
466 - );
467 - }
468 - return $wgOut->addHtml( $htmlOut );
469 - }
 454+ foreach( $langs as $lang ) {
 455+ // Link and Preview all available translations
 456+ $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
 457+ $render = new SpecialNoticeText();
 458+ $render->project = 'wikipedia';
 459+ $render->language = $lang;
 460+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
 461+ $sk->makeLinkObj( $viewPage,
 462+ $lang,
 463+ 'template=' . urlencode( $template ) . "&wpUserLanguage=$lang") .
 464+ Xml::fieldset( wfMsg( 'centralnotice-preview' ),
 465+ $render->getHtmlNotice( $template )
 466+ )
 467+ );
 468+ }
 469+ return $wgOut->addHtml( $htmlOut );
 470+ }
470471
471472 private function updateMessage( $text, $translation, $lang, $token = false ) {
472473 global $wgUser;

Comments

#Comment by Brion VIBBER (talk | contribs)   02:16, 23 January 2009

This fixed bug 16749

Status & tagging log