Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -92,27 +92,27 @@ |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
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 ); |
107 | 107 | |
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 | + } |
117 | 117 | |
118 | 118 | $noticeName = $wgRequest->getVal( 'notice' ); |
119 | 119 | |
— | — | @@ -645,29 +645,33 @@ |
646 | 646 | } |
647 | 647 | |
648 | 648 | // 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; |
663 | 660 | } |
| 661 | + } else { |
| 662 | + $htmlOut .= $output_assigned; |
| 663 | + if( $this->editable ) { |
| 664 | + $htmlOut .= $output_templates; |
| 665 | + } |
664 | 666 | } |
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 | + } |
672 | 676 | $wgOut->addHTML( $htmlOut ); |
673 | 677 | } |
674 | 678 | |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -80,12 +80,12 @@ |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
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 | + } |
90 | 90 | |
91 | 91 | // Handle viewing a specific template |
92 | 92 | if ( $sub == 'view' && $wgRequest->getText( 'template' ) != '' ) { |
— | — | @@ -365,7 +365,7 @@ |
366 | 366 | $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9 ) ); |
367 | 367 | list( $lsLabel, $lsSelect ) = Xml::languageSelector( $wpUserLang ); |
368 | 368 | |
369 | | - $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); |
| 369 | + $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); |
370 | 370 | |
371 | 371 | $htmlOut .= Xml::tags( 'tr', null, |
372 | 372 | Xml::tags( 'td', null, $lsLabel ) . |
— | — | @@ -410,62 +410,63 @@ |
411 | 411 | $htmlOut .= Xml::closeElement( 'form' ); |
412 | 412 | } |
413 | 413 | |
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 | + ); |
424 | 424 | |
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 ); |
431 | 431 | |
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 | + } |
436 | 437 | |
437 | | - // Output HTML |
438 | | - $wgOut->addHTML( $htmlOut ); |
439 | | - } |
| 438 | + // Output HTML |
| 439 | + $wgOut->addHTML( $htmlOut ); |
| 440 | + } |
440 | 441 | |
441 | | - public function showViewAvailable( $template ) { |
442 | | - global $wgOut, $wgUser; |
| 442 | + public function showViewAvailable( $template ) { |
| 443 | + global $wgOut, $wgUser; |
443 | 444 | |
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' ); |
446 | 447 | |
447 | | - $sk = $wgUser->getSkin(); |
| 448 | + $sk = $wgUser->getSkin(); |
448 | 449 | |
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 = ''; |
452 | 453 | |
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 | + } |
470 | 471 | |
471 | 472 | private function updateMessage( $text, $translation, $lang, $token = false ) { |
472 | 473 | global $wgUser; |