Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
— | — | @@ -2025,6 +2025,18 @@ |
2026 | 2026 | }, |
2027 | 2027 | |
2028 | 2028 | // }}} |
| 2029 | + // {{{ verify |
| 2030 | + |
| 2031 | + /** |
| 2032 | + * Verifies that this CTA can be displayed |
| 2033 | + * |
| 2034 | + * @return bool whether the CTA can be displayed |
| 2035 | + */ |
| 2036 | + verify: function () { |
| 2037 | + return $.articleFeedbackv5.ctas['3'].getSurveyUrl() !== false; |
| 2038 | + }, |
| 2039 | + |
| 2040 | + // }}} |
2029 | 2041 | // {{{ build |
2030 | 2042 | |
2031 | 2043 | /** |
— | — | @@ -2038,21 +2050,41 @@ |
2039 | 2051 | var $block = $( $.articleFeedbackv5.currentCTA().templates.block ); |
2040 | 2052 | |
2041 | 2053 | // Fill in the go-to-survey link |
2042 | | - var survey_track_id = $.articleFeedbackv5.bucketName() + '-' + |
2043 | | - $.articleFeedbackv5.ctaName() + '-button_click-' + |
2044 | | - ( $.articleFeedbackv5.inDialog ? 'overlay': 'bottom' ); |
2045 | | - $block.find( '.articleFeedbackv5-cta-button' ) |
2046 | | - .attr( 'href', $.articleFeedbackv5.trackingUrl( |
2047 | | - mw.config.get( 'wgArticleFeedbackv5SurveyUrl' ) + |
2048 | | - '?c=' + $.articleFeedbackv5.bucketId + |
2049 | | - '&f=' + $.articleFeedbackv5.feedbackId, |
2050 | | - survey_track_id |
2051 | | - ) ); |
| 2054 | + var survey_url = $.articleFeedbackv5.currentCTA().getSurveyUrl(); |
| 2055 | + if ( survey_url ) { |
| 2056 | + var survey_track_id = $.articleFeedbackv5.bucketName() + '-' + |
| 2057 | + $.articleFeedbackv5.ctaName() + '-button_click-' + |
| 2058 | + ( $.articleFeedbackv5.inDialog ? 'overlay': 'bottom' ); |
| 2059 | + $block.find( '.articleFeedbackv5-cta-button' ) |
| 2060 | + .attr( 'href', $.articleFeedbackv5.trackingUrl( |
| 2061 | + survey_url + '?c=' + $.articleFeedbackv5.feedbackId, |
| 2062 | + survey_track_id |
| 2063 | + ) ); |
| 2064 | + } |
2052 | 2065 | |
2053 | 2066 | return $block; |
2054 | 2067 | }, |
2055 | 2068 | |
2056 | 2069 | // }}} |
| 2070 | + // {{{ getSurveyUrl |
| 2071 | + |
| 2072 | + /** |
| 2073 | + * Gets the appropriate survey url, or returns false if none was |
| 2074 | + * found |
| 2075 | + * |
| 2076 | + * @return mixed the url, if one is availabe, or false if not |
| 2077 | + */ |
| 2078 | + getSurveyUrl: function () { |
| 2079 | + var base = mw.config.get( 'wgArticleFeedbackv5SurveyUrls' ); |
| 2080 | + aft5_debug( base ); |
| 2081 | + aft5_debug( $.articleFeedbackv5.bucketId ); |
| 2082 | + if ( typeof base != 'object' || !( $.articleFeedbackv5.bucketId in base ) ) { |
| 2083 | + return false; |
| 2084 | + } |
| 2085 | + return base[$.articleFeedbackv5.bucketId]; |
| 2086 | + }, |
| 2087 | + |
| 2088 | + // }}} |
2057 | 2089 | // {{{ bindEvents |
2058 | 2090 | |
2059 | 2091 | /** |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
— | — | @@ -10,9 +10,6 @@ |
11 | 11 | * @version 0.1.0 |
12 | 12 | */ |
13 | 13 | |
14 | | -/* XXX: Survey setup */ |
15 | | -require_once( dirname( dirname( __FILE__ ) ) . '/SimpleSurvey/SimpleSurvey.php' ); |
16 | | - |
17 | 14 | /* Configuration */ |
18 | 15 | |
19 | 16 | // How long text-based feedback is allowed to be before returning an error. |
— | — | @@ -190,42 +187,11 @@ |
191 | 188 | * |
192 | 189 | * @var string |
193 | 190 | */ |
194 | | -$wgArticleFeedbackv5SurveyUrl = "https://www.surveymonkey.com/s/aft5"; |
195 | | - |
196 | | -// Would ordinarily call this articlefeedback but survey names are 16 chars max |
197 | | -$wgPrefSwitchSurveys['articlerating'] = array( |
198 | | - 'updatable' => false, |
199 | | - 'submit-msg' => 'articlefeedbackv5-survey-submit', |
200 | | - 'questions' => array( |
201 | | - 'origin' => array( |
202 | | - 'visibility' => 'hidden', |
203 | | - 'question' => 'articlefeedbackv5-survey-question-origin', |
204 | | - 'type' => 'text', |
205 | | - ), |
206 | | - 'whyrated' => array( |
207 | | - 'question' => 'articlefeedbackv5-survey-question-whyrated', |
208 | | - 'type' => 'checks', |
209 | | - 'answers' => array( |
210 | | - 'contribute-rating' => 'articlefeedbackv5-survey-answer-whyrated-contribute-rating', |
211 | | - 'development' => 'articlefeedbackv5-survey-answer-whyrated-development', |
212 | | - 'contribute-wiki' => 'articlefeedbackv5-survey-answer-whyrated-contribute-wiki', |
213 | | - 'sharing-opinion' => 'articlefeedbackv5-survey-answer-whyrated-sharing-opinion', |
214 | | - 'didntrate' => 'articlefeedbackv5-survey-answer-whyrated-didntrate', |
215 | | - ), |
216 | | - 'other' => 'articlefeedbackv5-survey-answer-whyrated-other', |
217 | | - ), |
218 | | - 'useful' => array( |
219 | | - 'question' => 'articlefeedbackv5-survey-question-useful', |
220 | | - 'type' => 'boolean', |
221 | | - 'iffalse' => 'articlefeedbackv5-survey-question-useful-iffalse', |
222 | | - ), |
223 | | - 'comments' => array( |
224 | | - 'question' => 'articlefeedbackv5-survey-question-comments', |
225 | | - 'type' => 'text', |
226 | | - ), |
227 | | - ), |
| 191 | +$wgArticleFeedbackv5SurveyUrls = array( |
| 192 | + '1' => 'https://www.surveymonkey.com/s/aft5-1', |
| 193 | + '2' => 'https://www.surveymonkey.com/s/aft5-2', |
| 194 | + '3' => 'https://www.surveymonkey.com/s/aft5-3', |
228 | 195 | ); |
229 | | -$wgValidSurveys[] = 'articlerating'; |
230 | 196 | |
231 | 197 | // Replace default emailcapture message |
232 | 198 | $wgEmailCaptureAutoResponse['body-msg'] = 'articlefeedbackv5-emailcapture-response-body'; |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php |
— | — | @@ -269,7 +269,7 @@ |
270 | 270 | $wgArticleFeedbackv5LinkBuckets, |
271 | 271 | $wgArticleFeedbackv5Namespaces, |
272 | 272 | $wgArticleFeedbackv5LearnToEdit, |
273 | | - $wgArticleFeedbackv5SurveyUrl; |
| 273 | + $wgArticleFeedbackv5SurveyUrls; |
274 | 274 | $vars['wgArticleFeedbackv5SMaxage'] = $wgArticleFeedbackv5SMaxage; |
275 | 275 | $vars['wgArticleFeedbackv5Categories'] = $wgArticleFeedbackv5Categories; |
276 | 276 | $vars['wgArticleFeedbackv5BlacklistCategories'] = $wgArticleFeedbackv5BlacklistCategories; |
— | — | @@ -285,7 +285,7 @@ |
286 | 286 | $vars['wgArticleFeedbackv5LearnToEdit'] = $wgArticleFeedbackv5LearnToEdit; |
287 | 287 | $vars['wgArticleFeedbackv5WhatsThisPage'] = wfMsgForContent( 'articlefeedbackv5-bucket5-form-panel-explanation-link' ); |
288 | 288 | $vars['wgArticleFeedbackv5TermsPage'] = wfMsgForContent( 'articlefeedbackv5-transparency-terms-url' ); |
289 | | - $vars['wgArticleFeedbackv5SurveyUrl'] = $wgArticleFeedbackv5SurveyUrl; |
| 289 | + $vars['wgArticleFeedbackv5SurveyUrls'] = $wgArticleFeedbackv5SurveyUrls; |
290 | 290 | return true; |
291 | 291 | } |
292 | 292 | |