r70910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70909‎ | r70910 | r70911 >
Date:18:58, 11 August 2010
Author:kaldari
Status:ok
Tags:
Comment:
rolling back premature commit of SpecialNoticeTemplate.php in r70908
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -72,48 +72,16 @@
7373 // Handle adding banner
7474 // FIXME: getText()? weak comparison
7575 if ( $wgRequest->getVal( 'wpMethod' ) == 'addTemplate' ) {
76 -
77 - // Handle "Display to anonymous users" checkbox
78 - $displayAnon = 0;
79 - if ( $wgRequest->getVal( 'displayAnon' ) ) {
80 - $displayAnon = $wgRequest->getVal( 'displayAnon' );
81 - }
82 -
83 - // Handle "Display to logged in users" checkbox
84 - $displayAccount = 0;
85 - if ( $wgRequest->getVal( 'displayAccount' ) ) {
86 - $displayAccount = $wgRequest->getVal( 'displayAccount' );
87 - }
88 -
8976 $this->addTemplate(
9077 $wgRequest->getVal( 'templateName' ),
91 - $wgRequest->getVal( 'templateBody' ),
92 - $displayAnon,
93 - $displayAccount
 78+ $wgRequest->getVal( 'templateBody' )
9479 );
9580 $sub = 'view';
9681 }
97 -
98 - // Handle editing banner
9982 if ( $wgRequest->getVal( 'wpMethod' ) == 'editTemplate' ) {
100 -
101 - // Handle "Display to anonymous users" checkbox
102 - $displayAnon = 0;
103 - if ( $wgRequest->getVal( 'displayAnon' ) ) {
104 - $displayAnon = $wgRequest->getVal( 'displayAnon' );
105 - }
106 -
107 - // Handle "Display to logged in users" checkbox
108 - $displayAccount = 0;
109 - if ( $wgRequest->getVal( 'displayAccount' ) ) {
110 - $displayAccount = $wgRequest->getVal( 'displayAccount' );
111 - }
112 -
11383 $this->editTemplate(
11484 $wgRequest->getVal( 'template' ),
115 - $wgRequest->getVal( 'templateBody' ),
116 - $displayAnon,
117 - $displayAccount
 85+ $wgRequest->getVal( 'templateBody' )
11886 );
11987 $sub = 'view';
12088 }
@@ -226,15 +194,6 @@
227195 $htmlOut .= Xml::tags( 'p', null,
228196 Xml::inputLabel( wfMsg( 'centralnotice-banner-name' ) . ":", 'templateName', 'templateName', 25 )
229197 );
230 -
231 - $htmlOut .= Xml::openElement( 'p', null );
232 - $htmlOut .= wfMsg( 'centralnotice-banner-display' );
233 - $htmlOut .= Xml::check( 'displayAnon', true, array( 'id' => 'displayAnon' ) );
234 - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' );
235 - $htmlOut .= Xml::check( 'displayAccount', true, array( 'id' => 'displayAccount' ) );
236 - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' );
237 - $htmlOut .= Xml::closeElement( 'p' );
238 -
239198 $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) );
240199 $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' );
241200 $buttons = array();
@@ -272,10 +231,8 @@
273232
274233 if ( $this->editable ) {
275234 $readonly = array();
276 - $disabled = array();
277235 } else {
278236 $readonly = array( 'readonly' => 'readonly' );
279 - $disabled = array( 'disabled' => 'disabled' );
280237 }
281238
282239 // Get user's language
@@ -284,17 +241,6 @@
285242 // Get current banner
286243 $currentTemplate = $wgRequest->getText( 'template' );
287244
288 - // Pull template settings from database
289 - $dbr = wfGetDB( DB_SLAVE );
290 - $row = $dbr->selectRow( 'cn_templates',
291 - array(
292 - 'tmp_display_anon',
293 - 'tmp_display_account'
294 - ),
295 - array( 'tmp_name' => $currentTemplate ),
296 - __METHOD__
297 - );
298 -
299245 // Begin building HTML
300246 $htmlOut = '';
301247
@@ -451,18 +397,6 @@
452398 $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) );
453399 $htmlOut .= Xml::hidden( 'wpMethod', 'editTemplate' );
454400 }
455 -
456 - // FIXME
457 - $htmlOut .= Xml::fieldset( 'Settings' );
458 - $htmlOut .= Xml::openElement( 'p', null );
459 - $htmlOut .= wfMsg( 'centralnotice-banner-display' );
460 - $htmlOut .= Xml::check( 'displayAnon', ( $row->tmp_display_anon == 1 ), wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) );
461 - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' );
462 - $htmlOut .= Xml::check( 'displayAccount', ( $row->tmp_display_account == 1 ), wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) );
463 - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' );
464 - $htmlOut .= Xml::closeElement( 'p' );
465 - $htmlOut .= Xml::closeElement( 'fieldset' );
466 -
467401 $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-edit-template' ) );
468402 $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' );
469403 $buttons = array();
@@ -620,7 +554,7 @@
621555 /**
622556 * Create a new banner
623557 */
624 - private function addTemplate( $name, $body, $displayAnon, $displayAccount ) {
 558+ private function addTemplate ( $name, $body ) {
625559 global $wgOut;
626560
627561 if ( $body == '' || $name == '' ) {
@@ -645,12 +579,9 @@
646580 } else {
647581 $dbw = wfGetDB( DB_MASTER );
648582 $dbw->begin();
649 - $res = $dbw->insert( 'cn_templates',
650 - array(
651 - 'tmp_name' => $name,
652 - 'tmp_display_anon' => $displayAnon,
653 - 'tmp_display_account' => $displayAccount
654 - ),
 583+ $res = $dbw->insert(
 584+ 'cn_templates',
 585+ array( 'tmp_name' => $name ),
655586 __METHOD__
656587 );
657588 $dbw->commit();
@@ -667,7 +598,7 @@
668599 /**
669600 * Update a banner
670601 */
671 - private function editTemplate( $name, $body, $displayAnon, $displayAccount ) {
 602+ private function editTemplate ( $name, $body ) {
672603 global $wgOut;
673604
674605 if ( $body == '' || $name == '' ) {
@@ -681,18 +612,7 @@
682613 __METHOD__
683614 );
684615
685 - if ( $dbr->numRows( $res ) == 1 ) {
686 - $dbw = wfGetDB( DB_MASTER );
687 - $dbw->begin();
688 - $res = $dbw->update( 'cn_templates',
689 - array(
690 - 'tmp_display_anon' => $displayAnon,
691 - 'tmp_display_account' => $displayAccount
692 - ),
693 - array( 'tmp_name' => $name )
694 - );
695 - $dbw->commit();
696 -
 616+ if ( $dbr->numRows( $res ) > 0 ) {
697617 // Perhaps these should move into the db as blob
698618 $article = new Article(
699619 Title::newFromText( "centralnotice-template-{$name}", NS_MEDIAWIKI )

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70908adding patch-notice_preferred.sql to update hook per comment at r68758kaldari18:54, 11 August 2010

Status & tagging log