r70038 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70037‎ | r70038 | r70039 >
Date:20:38, 27 July 2010
Author:nimishg
Status:deferred (Comments)
Tags:
Comment:
Several bugfixes
Modified paths:
  • /trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php (modified) (history)
  • /trunk/extensions/SimpleSurvey/SimpleSurvey.php (modified) (history)
  • /trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php
@@ -1,16 +1,6 @@
22 <?php
33 class SimpleSurvey extends PrefSwitchSurvey {
44 // Correlation between names of field types and implementation classes
5 - private static $fieldTypes = array(
6 - 'select' => 'PrefSwitchSurveyFieldSelect',
7 - 'radios' => 'PrefSwitchSurveyFieldRadios',
8 - 'checks' => 'PrefSwitchSurveyFieldChecks',
9 - 'boolean' => 'PrefSwitchSurveyFieldBoolean',
10 - 'dimensions' => 'PrefSwitchSurveyFieldDimensions',
11 - 'text' => 'PrefSwitchSurveyFieldText',
12 - 'smallinput' => 'PrefSwitchSurveyFieldSmallInput',
13 - );
14 -
155 /* Static Functions */
166
177 /* update schema*/
@@ -112,7 +102,7 @@
113103 'pss_name' => $name,
114104 'pss_question' => "logged_in",
115105 'pss_answer' => $wgUser->isLoggedIn()?"yes":"no",
116 - 'pss_answer_data' => isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null,
 106+ 'pss_answer_data' => wfGetIP(),
117107 ),
118108 __METHOD__
119109 );
Index: trunk/extensions/SimpleSurvey/SimpleSurvey.php
@@ -50,7 +50,7 @@
5151
5252
5353 // Always include the browser stuff...
54 -foreach ( $wgPrefSwitchSurveys as &$survey ) {
 54+foreach ( $wgPrefSwitchSurveys as $survey ) {
5555 $survey['questions']['browser'] = array(
5656 'visibility' => "hidden",
5757 'question' => 'prefswitch-survey-question-browser',
Index: trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php
@@ -51,8 +51,7 @@
5252 // $this->originTitle should never be Special:Userlogout
5353 if (
5454 $this->originTitle &&
55 - $this->originTitle->getNamespace() == NS_SPECIAL &&
56 - SpecialPage::resolveAlias( $this->originTitle->getText() ) == 'Userlogout'
 55+ $this->originTitle->isSpecial('Userlogout')
5756 ) {
5857 $this->originTitle = null;
5958 }
@@ -74,8 +73,7 @@
7574 // Handle various modes
7675
7776 $this->render( $wgRequest->getVal("survey") );
78 -
79 -
 77+
8078 $wgOut->addHtml( '</div>' );
8179 }
8280
@@ -85,39 +83,39 @@
8684 global $wgUser, $wgOut, $wgPrefSwitchSurveys, $wgValidSurveys;
8785 // Make sure links will retain the origin
8886 $query = array( 'from' => $this->origin, 'fromquery' => $this->originQuery );
89 - if ( isset( $wgPrefSwitchSurveys[$mode] ) && in_array($mode, $wgValidSurveys) ){
90 - $wgOut->addWikiMsg( "simple-survey-intro-{$mode}" );
91 -
92 - // Setup a form
93 - $html = Xml::openElement(
94 - 'form', array(
95 - 'method' => 'post',
96 - 'action' => $this->getTitle()->getLinkURL( $query ),
97 - 'class' => 'simple-survey',
98 - 'id' => "simple-survey-{$mode}"
99 - )
100 - );
101 - $html .= Xml::hidden( 'survey', $mode );
102 - // Render a survey
103 - $html .= SimpleSurvey::render(
104 - $wgPrefSwitchSurveys[$mode]['questions']
105 - );
106 - // Finish out the form
107 - $html .= Xml::openElement( 'dt', array( 'class' => 'prefswitch-survey-submit' ) );
108 - $html .= Xml::submitButton(
109 - wfMsg( $wgPrefSwitchSurveys[$mode]['submit-msg'] ),
110 - array( 'id' => "simple-survey-submit-{$mode}", 'class' => 'prefswitch-survey-submit' )
111 - );
112 - $html .= Xml::closeElement( 'dt' );
113 - $html .= Xml::closeElement( 'form' );
114 - $wgOut->addHtml( $html );
115 - }
116 - else{
 87+
 88+ if ( !isset( $wgPrefSwitchSurveys[$mode] ) && !in_array($mode, $wgValidSurveys) ){
11789 $wgOut->addWikiMsg( "simple-survey-invalid" );
11890 if ( $this->originTitle ) {
11991 $wgOut->addHTML( wfMsg( "simple-survey-back", $this->originLink ) );
12092 }
 93+ return;
12194 }
12295
 96+ $wgOut->addWikiMsg( "simple-survey-intro-{$mode}" );
 97+
 98+ // Setup a form
 99+ $html = Xml::openElement(
 100+ 'form', array(
 101+ 'method' => 'post',
 102+ 'action' => $this->getTitle()->getLinkURL( $query ),
 103+ 'class' => 'simple-survey',
 104+ 'id' => "simple-survey-{$mode}"
 105+ )
 106+ );
 107+ $html .= Xml::hidden( 'survey', $mode );
 108+ // Render a survey
 109+ $html .= SimpleSurvey::render(
 110+ $wgPrefSwitchSurveys[$mode]['questions']
 111+ );
 112+ // Finish out the form
 113+ $html .= Xml::openElement( 'dt', array( 'class' => 'prefswitch-survey-submit' ) );
 114+ $html .= Xml::submitButton(
 115+ wfMsg( $wgPrefSwitchSurveys[$mode]['submit-msg'] ),
 116+ array( 'id' => "simple-survey-submit-{$mode}", 'class' => 'prefswitch-survey-submit' )
 117+ );
 118+ $html .= Xml::closeElement( 'dt' );
 119+ $html .= Xml::closeElement( 'form' );
 120+ $wgOut->addHtml( $html );
123121 }
124122 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r72241Fix fixme from r70038...reedy23:32, 2 September 2010

Comments

#Comment by Catrope (talk | contribs)   16:37, 3 August 2010
-foreach ( $wgPrefSwitchSurveys as &$survey ) {
+foreach ( $wgPrefSwitchSurveys as $survey ) {

I'm pretty sure that's the exact opposite of what you want.

Status & tagging log