Index: trunk/extensions/Survey/Survey.php |
— | — | @@ -157,7 +157,8 @@ |
158 | 158 | 'jquery.survey.js' |
159 | 159 | ), |
160 | 160 | 'styles' => array( |
161 | | - 'fancybox/jquery.fancybox-1.3.4.css', |
| 161 | + // This file makes the RL go mad for some reason, so for now load it the old fashioned way. |
| 162 | + //'fancybox/jquery.fancybox-1.3.4.css', |
162 | 163 | ), |
163 | 164 | 'dependencies' => array( 'ext.survey' ), |
164 | 165 | 'messages' => array( |
Index: trunk/extensions/Survey/includes/SurveyTag.php |
— | — | @@ -67,6 +67,12 @@ |
68 | 68 | |
69 | 69 | if ( !$loadedJs ) { |
70 | 70 | $parser->getOutput()->addModules( 'ext.survey.jquery' ); |
| 71 | + |
| 72 | + global $wgExtensionAssetsPath, $wgScriptPath; |
| 73 | + $parser->getOutput()->addHeadItem( Html::linkedStyle( |
| 74 | + ( $wgExtensionAssetsPath === false ? $wgScriptPath . '/extensions' : $wgExtensionAssetsPath ) |
| 75 | + . '/Survey/resources/fancybox/jquery.fancybox-1.3.4.css' |
| 76 | + ) ); |
71 | 77 | } |
72 | 78 | |
73 | 79 | return Html::element( |
Index: trunk/extensions/Survey/api/ApiSubmitSurvey.php |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getTokenSalt() { |
53 | | - return ''; |
| 53 | + return 'submitsurvey'; |
54 | 54 | } |
55 | 55 | |
56 | 56 | public function getAllowedParams() { |
Index: trunk/extensions/Survey/api/ApiEditSurvey.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | } |
68 | 68 | |
69 | 69 | public function getTokenSalt() { |
70 | | - return ''; |
| 70 | + return 'editsurvey'; |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function getAllowedParams() { |
Index: trunk/extensions/Survey/api/ApiAddSurvey.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | } |
76 | 76 | |
77 | 77 | public function getTokenSalt() { |
78 | | - return ''; |
| 78 | + return 'addsurvey'; |
79 | 79 | } |
80 | 80 | |
81 | 81 | public function getAllowedParams() { |
Index: trunk/extensions/Survey/api/ApiQuerySurveys.php |
— | — | @@ -37,6 +37,8 @@ |
38 | 38 | |
39 | 39 | $surveys = array(); |
40 | 40 | |
| 41 | + // TODO |
| 42 | + |
41 | 43 | if ( isset( $params['ids'] ) ) { |
42 | 44 | foreach ( $params['ids'] as $surveyId ) { |
43 | 45 | $survey = Survey::newFromId( $surveyId, $params['incquestions'] == 1 ); |
— | — | @@ -96,6 +98,9 @@ |
97 | 99 | ApiBase::PARAM_TYPE => 'integer', |
98 | 100 | ApiBase::PARAM_DFLT => '0', |
99 | 101 | ), |
| 102 | + 'enabled' => array( |
| 103 | + ApiBase::PARAM_TYPE => 'integer', |
| 104 | + ), |
100 | 105 | 'limit' => array( |
101 | 106 | ApiBase :: PARAM_DFLT => 20, |
102 | 107 | ApiBase :: PARAM_TYPE => 'limit', |
— | — | @@ -118,6 +123,7 @@ |
119 | 124 | 'ids' => 'The IDs of the surveys to return', |
120 | 125 | 'names' => 'The names of the surveys to return', |
121 | 126 | 'incquestions' => 'Include the questions of the surveys or not', |
| 127 | + 'enabled' => 'Enabled state to filter on', |
122 | 128 | 'continue' => 'Offset number from where to continue the query', |
123 | 129 | 'limit' => 'Max amount of words to return', |
124 | 130 | 'token' => 'Edit token. You can get one of these through prop=info.', |
Index: trunk/extensions/Survey/resources/ext.survey.special.survey.js |
— | — | @@ -9,8 +9,6 @@ |
10 | 10 | |
11 | 11 | var _this = this; |
12 | 12 | |
13 | | - var questionTypes = {}; |
14 | | - |
15 | 13 | var $table = null; |
16 | 14 | var newQuestionNr = 0; |
17 | 15 | var questionNr = 0; |
— | — | @@ -95,7 +93,7 @@ |
96 | 94 | 'for': 'survey-question-type-' + question.id |
97 | 95 | } ).text( mw.msg( 'survey-special-label-type' ) ) ); |
98 | 96 | |
99 | | - $input.append( survey.htmlSelect( questionTypes, question.type, { |
| 97 | + $input.append( survey.question.getTypeSelector( question.type, { |
100 | 98 | 'id': 'survey-question-type-' + question.id, |
101 | 99 | 'name': 'survey-question-type-' + question.id |
102 | 100 | } ) ); |
— | — | @@ -133,16 +131,7 @@ |
134 | 132 | $( '#survey-question-text-new' ).focus().select(); |
135 | 133 | }; |
136 | 134 | |
137 | | - function initTypes() { |
138 | | - var types = [ 'text', 'number', 'select', 'radio' ]; |
139 | | - for ( type in types ) { |
140 | | - questionTypes[survey.msg( 'survey-question-type-' + types[type] )] = type; |
141 | | - } |
142 | | - }; |
143 | | - |
144 | 135 | function setup() { |
145 | | - initTypes(); |
146 | | - |
147 | 136 | $table = $( '#survey-name' ).closest( 'tbody' ); |
148 | 137 | |
149 | 138 | $table.append( '<tr><td colspan="2"><hr /></td></tr>' ); |
Index: trunk/extensions/Survey/resources/jquery.survey.js |
— | — | @@ -17,7 +17,9 @@ |
18 | 18 | 'action': 'query', |
19 | 19 | 'list': 'surveys', |
20 | 20 | 'format': 'json', |
21 | | - 'sunames': options.names.join( '|' ) |
| 21 | + 'sunames': options.names.join( '|' ), |
| 22 | + 'suincquestions': 1, |
| 23 | + 'suenabled': 1 |
22 | 24 | }, |
23 | 25 | function( data ) { |
24 | 26 | if ( data.surveys ) { |
— | — | @@ -39,8 +41,32 @@ |
40 | 42 | // TODO |
41 | 43 | }; |
42 | 44 | |
| 45 | + this.getQuestionInput = function( question ) { |
| 46 | + var type = survey.question.type; |
| 47 | + |
| 48 | + var $input; |
| 49 | + |
| 50 | + switch ( question.type ) { |
| 51 | + case type.TEXT: default: |
| 52 | + $input = $( '<input />' ).attr( { |
| 53 | + 'id': 'survey-question-' + question.id, |
| 54 | + 'class': 'survey-question' |
| 55 | + } ); |
| 56 | + break; |
| 57 | + } |
| 58 | + |
| 59 | + return $input; |
| 60 | + }; |
| 61 | + |
43 | 62 | this.getSurveyQuestion = function( question ) { |
44 | | - return ''; // TODO |
| 63 | + $q = $( '<div />' ); |
| 64 | + |
| 65 | + $q.append( '<hr />' ); |
| 66 | + $q.append( $( '<p />' ).text( question.text ) ); |
| 67 | + |
| 68 | + $q.append( this.getQuestionInput( question ) ) |
| 69 | + |
| 70 | + return $q; |
45 | 71 | }; |
46 | 72 | |
47 | 73 | this.getSurveyQuestions = function( questions ) { |
— | — | @@ -56,10 +82,10 @@ |
57 | 83 | this.getSurveyBody = function( surveyData ) { |
58 | 84 | $survey = $( '<div />' ); |
59 | 85 | |
| 86 | + $survey.append( $( '<h1 />' ).text( surveyData.name ) ); |
| 87 | + |
60 | 88 | $survey.append( this.getSurveyQuestions( surveyData.questions ) ); |
61 | 89 | |
62 | | - $survey.append( JSON.stringify( surveyData ) ); |
63 | | - |
64 | 90 | return $survey; |
65 | 91 | }; |
66 | 92 | |
Index: trunk/extensions/Survey/resources/ext.survey.js |
— | — | @@ -52,6 +52,34 @@ |
53 | 53 | return $select; |
54 | 54 | }; |
55 | 55 | |
| 56 | + this.question = new( function() { |
| 57 | + |
| 58 | + this.type = new( function() { |
| 59 | + this.TEXT = 0; |
| 60 | + this.NUMBER = 1; |
| 61 | + this.SELECT = 2; |
| 62 | + this.RADIO = 3; |
| 63 | + } ); |
| 64 | + |
| 65 | + this.getTypeSelector = function( value, attributes ) { |
| 66 | + var options = []; |
| 67 | + |
| 68 | + var types = { |
| 69 | + 'text': survey.question.type.TEXT, |
| 70 | + 'number': survey.question.type.NUMBER, |
| 71 | + 'select': survey.question.type.SELECT, |
| 72 | + 'radio': survey.question.type.RADIO |
| 73 | + }; |
| 74 | + |
| 75 | + for ( msg in types ) { |
| 76 | + options[survey.msg( 'survey-question-type-' + msg )] = types[msg]; |
| 77 | + } |
| 78 | + |
| 79 | + return survey.htmlSelect( options, value, attributes ); |
| 80 | + }; |
| 81 | + |
| 82 | + } ); |
| 83 | + |
56 | 84 | } )(); |
57 | 85 | |
58 | 86 | |