Index: trunk/extensions/Survey/test/SurveyQuestionTest.php |
— | — | @@ -2,26 +2,26 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * SurveyQuestion test case. |
6 | | - * |
| 6 | + * |
7 | 7 | * @ingroup Survey |
8 | 8 | * @since 0.1 |
9 | | - * |
| 9 | + * |
10 | 10 | * @licence GNU GPL v3 |
11 | 11 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
12 | 12 | */ |
13 | 13 | class SurveyQuestionTest extends MediaWikiTestCase { |
14 | | - |
| 14 | + |
15 | 15 | /** |
16 | 16 | * Tests SurveyQuestion::newFromUrlData and SurveyQuestion::toUrlData |
17 | 17 | */ |
18 | 18 | public function testQuestionUrlSerialization() { |
19 | 19 | $question = new SurveyQuestion( 9001, 42, 'ohai there!', 0, true ); |
20 | | - |
21 | | - $this->assertEquals( |
22 | | - $question, |
23 | | - SurveyQuestion::newFromUrlData( $question->toUrlData() ), |
24 | | - "Serializaion test failed at " . __METHOD__ |
25 | | - ); |
| 20 | + |
| 21 | + $this->assertEquals( |
| 22 | + $question, |
| 23 | + SurveyQuestion::newFromUrlData( $question->toUrlData() ), |
| 24 | + "Serializaion test failed at " . __METHOD__ |
| 25 | + ); |
26 | 26 | } |
27 | 27 | |
28 | 28 | } |
Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -36,13 +36,11 @@ |
37 | 37 | |
38 | 38 | if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
39 | 39 | $this->handleSubmission(); |
40 | | - } |
41 | | - else { |
| 40 | + } else { |
42 | 41 | if ( is_null( $subPage ) ) { |
43 | 42 | $survey = new Survey( null, true ); |
44 | 43 | $survey->loadDefaults(); |
45 | | - } |
46 | | - else { |
| 44 | + } else { |
47 | 45 | $survey = Survey::newFromName( $subPage, null, true ); |
48 | 46 | } |
49 | 47 | |
— | — | @@ -70,8 +68,7 @@ |
71 | 69 | |
72 | 70 | if ( $wgRequest->getInt( 'survey-id' ) == 0 ) { |
73 | 71 | $survey = new Survey( null ); |
74 | | - } |
75 | | - else { |
| 72 | + } else { |
76 | 73 | $survey = Survey::newFromId( $wgRequest->getInt( 'survey-id' ), null, false ); |
77 | 74 | } |
78 | 75 | |
— | — | @@ -102,8 +99,7 @@ |
103 | 100 | |
104 | 101 | if ( preg_match( '/survey-question-text-(\d)+/', $name, $matches ) ) { |
105 | 102 | $questions[] = $this->getSubmittedQuestion( $matches[1] ); |
106 | | - } |
107 | | - else if ( preg_match( '/survey-question-text-new-(\d)+/', $name, $matches ) ) { |
| 103 | + } elseif ( preg_match( '/survey-question-text-new-(\d)+/', $name, $matches ) ) { |
108 | 104 | $questions[] = $this->getSubmittedQuestion( $matches[1], true ); |
109 | 105 | } |
110 | 106 | } |
— | — | @@ -126,8 +122,7 @@ |
127 | 123 | if ( $isNewQuestion ) { |
128 | 124 | $questionDbId = null; |
129 | 125 | $questionId = "new-$questionId"; |
130 | | - } |
131 | | - else { |
| 126 | + } else { |
132 | 127 | $questionDbId = $questionId; |
133 | 128 | } |
134 | 129 | |
— | — | @@ -241,8 +236,7 @@ |
242 | 237 | // the second argument for the HTMLForm constructor. |
243 | 238 | if ( is_callable( array( $this, 'getContext' ) ) ) { |
244 | 239 | $form = new HTMLForm( $fields, $this->getContext() ); |
245 | | - } |
246 | | - else { |
| 240 | + } else { |
247 | 241 | $form = new HTMLForm( $fields ); |
248 | 242 | } |
249 | 243 | |
— | — | @@ -270,8 +264,7 @@ |
271 | 265 | foreach ( $this->mParams['options'] as $name => $value ) { |
272 | 266 | if ( is_bool( $value ) ) { |
273 | 267 | $value = $value ? '1' : '0'; |
274 | | - } |
275 | | - elseif( is_object( $value ) || is_array( $value ) ) { |
| 268 | + } elseif( is_object( $value ) || is_array( $value ) ) { |
276 | 269 | $value = FormatJson::encode( $value ); |
277 | 270 | } |
278 | 271 | |
Index: trunk/extensions/Survey/specials/SpecialSurveys.php |
— | — | @@ -38,8 +38,7 @@ |
39 | 39 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) |
40 | 40 | && $wgRequest->getCheck( 'newsurvey' ) ) { |
41 | 41 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Survey', $wgRequest->getVal( 'newsurvey' ) )->getLocalURL() ); |
42 | | - } |
43 | | - else { |
| 42 | + } else { |
44 | 43 | $this->displaySurveys(); |
45 | 44 | } |
46 | 45 | } |
Index: trunk/extensions/Survey/includes/SurveyDBClass.php |
— | — | @@ -195,7 +195,7 @@ |
196 | 196 | $fields = array_keys( static::getFieldTypes() ); |
197 | 197 | } |
198 | 198 | |
199 | | - $dbr = wfgetDB( DB_SLAVE ); |
| 199 | + $dbr = wfGetDB( DB_SLAVE ); |
200 | 200 | |
201 | 201 | return $dbr->select( |
202 | 202 | static::getDBTable(), |
— | — | @@ -227,8 +227,7 @@ |
228 | 228 | public function writeToDB() { |
229 | 229 | if ( $this->hasIdField() ) { |
230 | 230 | return $this->updateInDB(); |
231 | | - } |
232 | | - else { |
| 231 | + } else { |
233 | 232 | return $this->insertIntoDB(); |
234 | 233 | } |
235 | 234 | } |
— | — | @@ -348,8 +347,7 @@ |
349 | 348 | case 'bool': |
350 | 349 | if ( is_string( $value ) ) { |
351 | 350 | $value = $value !== '0'; |
352 | | - } |
353 | | - else if ( is_int( $value ) ) { |
| 351 | + } elseif ( is_int( $value ) ) { |
354 | 352 | $value = $value !== 0; |
355 | 353 | } |
356 | 354 | break; |
— | — | @@ -366,8 +364,7 @@ |
367 | 365 | } |
368 | 366 | |
369 | 367 | $this->fields[$name] = $value; |
370 | | - } |
371 | | - else { |
| 368 | + } else { |
372 | 369 | throw new MWException( 'Attempted to set unknonw field ' . $name ); |
373 | 370 | } |
374 | 371 | } |
— | — | @@ -385,8 +382,7 @@ |
386 | 383 | public function getField( $name ) { |
387 | 384 | if ( $this->hasField( $name ) ) { |
388 | 385 | return $this->fields[$name]; |
389 | | - } |
390 | | - else { |
| 386 | + } else { |
391 | 387 | throw new MWException( 'Attempted to get not-set field ' . $name ); |
392 | 388 | } |
393 | 389 | } |
— | — | @@ -561,8 +557,7 @@ |
562 | 558 | |
563 | 559 | if ( !is_array( $fields ) ) { |
564 | 560 | $setFields = $this->getSetFieldNames(); |
565 | | - } |
566 | | - else { |
| 561 | + } else { |
567 | 562 | foreach ( $fields as $field ) { |
568 | 563 | if ( $this->hasField( $field ) ) { |
569 | 564 | $setFields[] = $field; |
Index: trunk/extensions/Survey/includes/SurveyTag.php |
— | — | @@ -48,8 +48,7 @@ |
49 | 49 | |
50 | 50 | $this->parameters['class'] = 'surveytag'; |
51 | 51 | $this->parameters['survey-data-token'] = $GLOBALS['wgUser']->editToken(); |
52 | | - } |
53 | | - else { |
| 52 | + } else { |
54 | 53 | throw new MWException( 'Invalid parameters for survey tag.' ); |
55 | 54 | } |
56 | 55 | } |
Index: trunk/extensions/Survey/includes/Survey.class.php |
— | — | @@ -269,7 +269,7 @@ |
270 | 270 | array( 'submission_survey_id' => $this->getId() ) |
271 | 271 | ); |
272 | 272 | |
273 | | - $dbw = wfgetDB( DB_MASTER ); |
| 273 | + $dbw = wfGetDB( DB_MASTER ); |
274 | 274 | |
275 | 275 | $dbw->begin(); |
276 | 276 | |
Index: trunk/extensions/Survey/api/ApiSubmitSurvey.php |
— | — | @@ -37,8 +37,7 @@ |
38 | 38 | if ( $survey === false ) { |
39 | 39 | $this->dieUsage( wfMsgExt( 'survey-err-survey-name-unknown', 'parsemag', $params['name'] ), 'survey-name-unknown' ); |
40 | 40 | } |
41 | | - } |
42 | | - else { |
| 41 | + } else { |
43 | 42 | $survey = Survey::newFromId( $params['id'], null, false ); |
44 | 43 | |
45 | 44 | if ( $survey === false ) { |
Index: trunk/extensions/Survey/api/ApiAddSurvey.php |
— | — | @@ -38,8 +38,7 @@ |
39 | 39 | catch ( DBQueryError $ex ) { |
40 | 40 | if ( $ex->errno == 1062 ) { |
41 | 41 | $this->dieUsage( wfMsgExt( 'survey-err-duplicate-name', 'parsemag', $params['name'] ), 'duplicate-survey-name' ); |
42 | | - } |
43 | | - else { |
| 42 | + } else { |
44 | 43 | throw $ex; |
45 | 44 | } |
46 | 45 | } |
Index: trunk/extensions/Survey/api/ApiQuerySurveys.php |
— | — | @@ -15,11 +15,11 @@ |
16 | 16 | class ApiQuerySurveys extends ApiQueryBase { |
17 | 17 | |
18 | 18 | public function __construct( $main, $action ) { |
19 | | - parent :: __construct( $main, $action, 'su' ); |
| 19 | + parent::__construct( $main, $action, 'su' ); |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | | - * Retrieve the specil words from the database. |
| 23 | + * Retrieve the special words from the database. |
24 | 24 | */ |
25 | 25 | public function execute() { |
26 | 26 | global $wgUser; |
— | — | @@ -52,8 +52,7 @@ |
53 | 53 | |
54 | 54 | if ( isset( $params['ids'] ) ) { |
55 | 55 | $this->addWhere( array( 'survey_id' => $params['ids'] ) ); |
56 | | - } |
57 | | - else { |
| 56 | + } else { |
58 | 57 | $this->addWhere( array( 'survey_name' => $params['names'] ) ); |
59 | 58 | } |
60 | 59 | |
— | — | @@ -144,11 +143,11 @@ |
145 | 144 | ApiBase::PARAM_TYPE => 'integer', |
146 | 145 | ), |
147 | 146 | 'limit' => array( |
148 | | - ApiBase :: PARAM_DFLT => 20, |
149 | | - ApiBase :: PARAM_TYPE => 'limit', |
150 | | - ApiBase :: PARAM_MIN => 1, |
151 | | - ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
152 | | - ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
| 147 | + ApiBase::PARAM_DFLT => 20, |
| 148 | + ApiBase::PARAM_TYPE => 'limit', |
| 149 | + ApiBase::PARAM_MIN => 1, |
| 150 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 151 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
153 | 152 | ), |
154 | 153 | 'continue' => null, |
155 | 154 | 'token' => null, |
— | — | @@ -168,7 +167,7 @@ |
169 | 168 | 'enabled' => 'Enabled state to filter on', |
170 | 169 | 'props' => 'Survey data to query', |
171 | 170 | 'continue' => 'Offset number from where to continue the query', |
172 | | - 'limit' => 'Max amount of words to return', |
| 171 | + 'limit' => 'Max amount of words to return', |
173 | 172 | 'token' => 'Edit token. You can get one of these through prop=info.', |
174 | 173 | ); |
175 | 174 | } |
Index: trunk/extensions/Survey/resources/ext.survey.special.surveys.js |
— | — | @@ -20,8 +20,7 @@ |
21 | 21 | function( data ) { |
22 | 22 | if ( data.success ) { |
23 | 23 | successCallback(); |
24 | | - } |
25 | | - else { |
| 24 | + } else { |
26 | 25 | failCallback( survey.msg( 'surveys-special-delete-failed' ) ); |
27 | 26 | } |
28 | 27 | } |
Index: trunk/extensions/Survey/resources/jquery.survey.js |
— | — | @@ -32,12 +32,10 @@ |
33 | 33 | function( data ) { |
34 | 34 | if ( data.surveys ) { |
35 | 35 | callback( data.surveys ); |
36 | | - } |
37 | | - else if ( data.error ) { |
| 36 | + } else if ( data.error ) { |
38 | 37 | debugger; |
39 | 38 | // TODO |
40 | | - } |
41 | | - else { |
| 39 | + } else { |
42 | 40 | debugger; |
43 | 41 | // TODO |
44 | 42 | } |
— | — | @@ -187,14 +185,12 @@ |
188 | 186 | function() { |
189 | 187 | if ( surveyData.thanks == '' ) { |
190 | 188 | _this.doCompletion(); |
191 | | - } |
192 | | - else { |
| 189 | + } else { |
193 | 190 | _this.showCompletion( surveyData ); |
194 | 191 | } |
195 | 192 | } |
196 | 193 | ); |
197 | | - } |
198 | | - else { |
| 194 | + } else { |
199 | 195 | // TODO |
200 | 196 | |
201 | 197 | $this.button( 'enable' ); |
— | — | @@ -239,8 +235,7 @@ |
240 | 236 | if ( $this.attr( 'survey-data-id' ) ) { |
241 | 237 | this.identifier = $this.attr( 'survey-data-id' ); |
242 | 238 | this.identifierType = 'id'; |
243 | | - } |
244 | | - else if ( $this.attr( 'survey-data-name' ) ) { |
| 239 | + } else if ( $this.attr( 'survey-data-name' ) ) { |
245 | 240 | this.identifier = $this.attr( 'survey-data-name' ); |
246 | 241 | this.identifierType = 'name'; |
247 | 242 | } |
Index: trunk/extensions/Survey/resources/ext.survey.js |
— | — | @@ -14,8 +14,7 @@ |
15 | 15 | if ( typeof console !== 'undefined' ) { |
16 | 16 | console.log( 'Survey: ' + message ); |
17 | 17 | } |
18 | | - } |
19 | | - else { |
| 18 | + } else { |
20 | 19 | return mediaWiki.log.call( mediaWiki.log, 'Survey: ' + message ); |
21 | 20 | } |
22 | 21 | } |
— | — | @@ -30,8 +29,7 @@ |
31 | 30 | } |
32 | 31 | |
33 | 32 | return message; |
34 | | - } |
35 | | - else { |
| 33 | + } else { |
36 | 34 | return mediaWiki.msg.apply( mediaWiki.msg, arguments ); |
37 | 35 | } |
38 | 36 | }; |