r73068 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73067‎ | r73068 | r73069 >
Date:15:20, 15 September 2010
Author:catrope
Status:deferred
Tags:
Comment:
SimpleSurvey: Make the intro message optional and introduce a raw mode (triggered by ?raw=1) in which only the <form> and a <script> tag for PrefSwitch.js are output
Modified paths:
  • /trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php (modified) (history)
  • /trunk/extensions/SimpleSurvey/Surveys.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SimpleSurvey/Surveys.php
@@ -6,6 +6,7 @@
77
88 $wgPrefSwitchSurveys['vitals-07-2010'] = array(
99 'submit-msg' => 'vitals-07-2010-submit',
 10+ 'intro-msg' => 'simple-survey-intro-vitals-07-2010',
1011 'updatable' => false,
1112 'questions' => array(
1213 'use' => array(
Index: trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php
@@ -90,12 +90,23 @@
9191 UsabilityInitiativeHooks::initialize();
9292 UsabilityInitiativeHooks::addScript( 'PrefSwitch/PrefSwitch.js', $wgPrefSwitchStyleVersion );
9393 UsabilityInitiativeHooks::addStyle( 'PrefSwitch/PrefSwitch.css', $wgPrefSwitchStyleVersion );
94 - $wgOut->addHtml( '<div class="plainlinks">' );
 94+
9595 // Handle various modes
 96+ $renderedSurvey = $this->render( $wgRequest->getVal( "survey" ) );
9697
97 - $this->render( $wgRequest->getVal( "survey" ) );
98 -
 98+ $wgOut->addHtml( '<div class="plainlinks">' );
 99+ $wgOut->addHtml( $renderedSurvey );
99100 $wgOut->addHtml( '</div>' );
 101+
 102+ // Handle raw mode
 103+ // Only output the <form> and the <script>
 104+ if ( $wgRequest->getBool( 'raw' ) ) {
 105+ $wgOut->disable();
 106+ echo $renderedSurvey;
 107+
 108+ global $wgExtensionAssetsPath;
 109+ echo Html::linkedScript( "$wgExtensionAssetsPath/UsabilityInitiative/PrefSwitch/PrefSwitch.js?$wgPrefSwitchStyleVersion" );
 110+ }
100111 }
101112
102113 /* Private Functions */
@@ -113,7 +124,9 @@
114125 return;
115126 }
116127
117 - $wgOut->addWikiMsg( "simple-survey-intro-{$mode}" );
 128+ if ( isset( $wgPrefSwitchSurveys[$mode]['intro-msg'] ) ) {
 129+ $wgOut->addWikiMsg( $wgPrefSwitchSurveys[$mode]['intro-msg'] );
 130+ }
118131
119132 // Setup a form
120133 $html = Xml::openElement(
@@ -138,6 +151,6 @@
139152 );
140153 $html .= Xml::closeElement( 'dt' );
141154 $html .= Xml::closeElement( 'form' );
142 - $wgOut->addHtml( $html );
 155+ return $html;
143156 }
144157 }

Status & tagging log