http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70038

Revision: 70038
Author:   nimishg
Date:     2010-07-27 20:38:38 +0000 (Tue, 27 Jul 2010)

Log Message:
-----------
Several bugfixes

Modified Paths:
--------------
    trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php
    trunk/extensions/SimpleSurvey/SimpleSurvey.php
    trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php

Modified: trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php
===================================================================
--- trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php      2010-07-27 
20:38:36 UTC (rev 70037)
+++ trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php      2010-07-27 
20:38:38 UTC (rev 70038)
@@ -1,16 +1,6 @@
 <?php 
 class SimpleSurvey extends PrefSwitchSurvey {
        // Correlation between names of field types and implementation classes
-       private static $fieldTypes = array(
-               'select' => 'PrefSwitchSurveyFieldSelect',
-               'radios' => 'PrefSwitchSurveyFieldRadios',
-               'checks' => 'PrefSwitchSurveyFieldChecks',
-               'boolean' => 'PrefSwitchSurveyFieldBoolean',
-               'dimensions' => 'PrefSwitchSurveyFieldDimensions',
-               'text' => 'PrefSwitchSurveyFieldText',
-               'smallinput' => 'PrefSwitchSurveyFieldSmallInput',
-       );
-       
        /* Static Functions */
        
        /* update schema*/
@@ -112,7 +102,7 @@
                                        'pss_name' => $name,
                                        'pss_question' => "logged_in",
                                        'pss_answer' => 
$wgUser->isLoggedIn()?"yes":"no",
-                                       'pss_answer_data' => 
isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null,
+                                       'pss_answer_data' => wfGetIP(),
                                ),
                                __METHOD__
                        );

Modified: trunk/extensions/SimpleSurvey/SimpleSurvey.php
===================================================================
--- trunk/extensions/SimpleSurvey/SimpleSurvey.php      2010-07-27 20:38:36 UTC 
(rev 70037)
+++ trunk/extensions/SimpleSurvey/SimpleSurvey.php      2010-07-27 20:38:38 UTC 
(rev 70038)
@@ -50,7 +50,7 @@
 
 
 // Always include the browser stuff...
-foreach ( $wgPrefSwitchSurveys as &$survey ) {
+foreach ( $wgPrefSwitchSurveys as $survey ) {
        $survey['questions']['browser'] = array(
                'visibility' => "hidden",
                'question' => 'prefswitch-survey-question-browser',

Modified: trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php
===================================================================
--- trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php       2010-07-27 
20:38:36 UTC (rev 70037)
+++ trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php       2010-07-27 
20:38:38 UTC (rev 70038)
@@ -51,8 +51,7 @@
                // $this->originTitle should never be Special:Userlogout
                if (
                        $this->originTitle &&
-                       $this->originTitle->getNamespace() == NS_SPECIAL &&
-                       SpecialPage::resolveAlias( 
$this->originTitle->getText() ) == 'Userlogout'
+                       $this->originTitle->isSpecial('Userlogout')
                ) {
                        $this->originTitle = null;
                }
@@ -74,8 +73,7 @@
                // Handle various modes
                
                $this->render( $wgRequest->getVal("survey") );
-               
-               
+       
                $wgOut->addHtml( '</div>' );
        }
        
@@ -85,39 +83,39 @@
                global $wgUser, $wgOut, $wgPrefSwitchSurveys, $wgValidSurveys;
                // Make sure links will retain the origin
                $query = array( 'from' => $this->origin, 'fromquery' => 
$this->originQuery );
-               if ( isset( $wgPrefSwitchSurveys[$mode] )  && in_array($mode, 
$wgValidSurveys) ){
-                       $wgOut->addWikiMsg( "simple-survey-intro-{$mode}" );
-                       
-                       // Setup a form
-                       $html = Xml::openElement(
-                               'form', array(
-                                       'method' => 'post',
-                                       'action' => 
$this->getTitle()->getLinkURL( $query ),
-                                       'class' => 'simple-survey',
-                                       'id' => "simple-survey-{$mode}"
-                               )
-                       );
-                       $html .= Xml::hidden( 'survey', $mode );
-                       // Render a survey
-                       $html .= SimpleSurvey::render(
-                               $wgPrefSwitchSurveys[$mode]['questions']
-                       );
-                       // Finish out the form
-                       $html .= Xml::openElement( 'dt', array( 'class' => 
'prefswitch-survey-submit' ) );
-                       $html .= Xml::submitButton(
-                               wfMsg( 
$wgPrefSwitchSurveys[$mode]['submit-msg'] ),
-                               array( 'id' => "simple-survey-submit-{$mode}", 
'class' => 'prefswitch-survey-submit' )
-                       );
-                       $html .= Xml::closeElement( 'dt' );
-                       $html .= Xml::closeElement( 'form' );
-                       $wgOut->addHtml( $html );
-               }
-               else{
+               
+               if ( !isset( $wgPrefSwitchSurveys[$mode] )  && !in_array($mode, 
$wgValidSurveys) ){
                        $wgOut->addWikiMsg( "simple-survey-invalid" );
                        if ( $this->originTitle ) {     
                                $wgOut->addHTML( wfMsg( "simple-survey-back", 
$this->originLink ) );
                        }
+                       return;
                }
                
+               $wgOut->addWikiMsg( "simple-survey-intro-{$mode}" );
+               
+               // Setup a form
+               $html = Xml::openElement(
+                       'form', array(
+                               'method' => 'post',
+                               'action' => $this->getTitle()->getLinkURL( 
$query ),
+                               'class' => 'simple-survey',
+                               'id' => "simple-survey-{$mode}"
+                       )
+               );
+               $html .= Xml::hidden( 'survey', $mode );
+               // Render a survey
+               $html .= SimpleSurvey::render(
+                       $wgPrefSwitchSurveys[$mode]['questions']
+               );
+               // Finish out the form
+               $html .= Xml::openElement( 'dt', array( 'class' => 
'prefswitch-survey-submit' ) );
+               $html .= Xml::submitButton(
+                       wfMsg( $wgPrefSwitchSurveys[$mode]['submit-msg'] ),
+                       array( 'id' => "simple-survey-submit-{$mode}", 'class' 
=> 'prefswitch-survey-submit' )
+               );
+               $html .= Xml::closeElement( 'dt' );
+               $html .= Xml::closeElement( 'form' );
+               $wgOut->addHtml( $html );       
        }
 }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to