Index: trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php |
— | — | @@ -1,16 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | class SimpleSurvey extends PrefSwitchSurvey { |
4 | 4 | // 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 | | - |
15 | 5 | /* Static Functions */ |
16 | 6 | |
17 | 7 | /* update schema*/ |
— | — | @@ -112,7 +102,7 @@ |
113 | 103 | 'pss_name' => $name, |
114 | 104 | 'pss_question' => "logged_in", |
115 | 105 | 'pss_answer' => $wgUser->isLoggedIn()?"yes":"no", |
116 | | - 'pss_answer_data' => isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null, |
| 106 | + 'pss_answer_data' => wfGetIP(), |
117 | 107 | ), |
118 | 108 | __METHOD__ |
119 | 109 | ); |
Index: trunk/extensions/SimpleSurvey/SimpleSurvey.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | |
52 | 52 | |
53 | 53 | // Always include the browser stuff... |
54 | | -foreach ( $wgPrefSwitchSurveys as &$survey ) { |
| 54 | +foreach ( $wgPrefSwitchSurveys as $survey ) { |
55 | 55 | $survey['questions']['browser'] = array( |
56 | 56 | 'visibility' => "hidden", |
57 | 57 | 'question' => 'prefswitch-survey-question-browser', |
Index: trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php |
— | — | @@ -51,8 +51,7 @@ |
52 | 52 | // $this->originTitle should never be Special:Userlogout |
53 | 53 | if ( |
54 | 54 | $this->originTitle && |
55 | | - $this->originTitle->getNamespace() == NS_SPECIAL && |
56 | | - SpecialPage::resolveAlias( $this->originTitle->getText() ) == 'Userlogout' |
| 55 | + $this->originTitle->isSpecial('Userlogout') |
57 | 56 | ) { |
58 | 57 | $this->originTitle = null; |
59 | 58 | } |
— | — | @@ -74,8 +73,7 @@ |
75 | 74 | // Handle various modes |
76 | 75 | |
77 | 76 | $this->render( $wgRequest->getVal("survey") ); |
78 | | - |
79 | | - |
| 77 | + |
80 | 78 | $wgOut->addHtml( '</div>' ); |
81 | 79 | } |
82 | 80 | |
— | — | @@ -85,39 +83,39 @@ |
86 | 84 | global $wgUser, $wgOut, $wgPrefSwitchSurveys, $wgValidSurveys; |
87 | 85 | // Make sure links will retain the origin |
88 | 86 | $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) ){ |
117 | 89 | $wgOut->addWikiMsg( "simple-survey-invalid" ); |
118 | 90 | if ( $this->originTitle ) { |
119 | 91 | $wgOut->addHTML( wfMsg( "simple-survey-back", $this->originLink ) ); |
120 | 92 | } |
| 93 | + return; |
121 | 94 | } |
122 | 95 | |
| 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 ); |
123 | 121 | } |
124 | 122 | } |