r96814 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96813‎ | r96814 | r96815 >
Date:21:50, 11 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added control to set survey ratio
Modified paths:
  • /trunk/extensions/Survey/Survey.i18n.php (modified) (history)
  • /trunk/extensions/Survey/Survey.sql (modified) (history)
  • /trunk/extensions/Survey/specials/SpecialSurvey.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Survey/Survey.sql
@@ -14,7 +14,7 @@
1515 survey_user_type TINYINT NOT NULL default '0', -- Type of users that can participate in the survey
1616 survey_namespaces BLOB NOT NULL, -- Namespaces on which the survey can be displayed
1717 survey_ratio TINYINT unsigned NOT NULL, -- Percentage of users to show the survey to
18 - survey_expiry INT unsigned NOT NULL -- Coockie expiry time for the survey
 18+ survey_expiry INT unsigned NOT NULL, -- Coockie expiry time for the survey
1919 ) /*$wgDBTableOptions*/;
2020
2121 -- Questions
Index: trunk/extensions/Survey/Survey.i18n.php
@@ -102,6 +102,7 @@
103103 'survey-special-label-name' => 'Survey ID',
104104 'survey-special-label-title' => 'Survey title',
105105 'survey-special-label-enabled' => 'Survey enabled',
 106+ 'survey-special-label-ratio' => 'Percentage of people to show the survey to',
106107 'survey-special-label-add-first' => 'Add question',
107108 'survey-special-label-add-another' => 'Add another question',
108109 'survey-special-label-addquestion' => 'New question',
Index: trunk/extensions/Survey/specials/SpecialSurvey.php
@@ -79,7 +79,7 @@
8080
8181 $survey->setField( 'enabled', $wgRequest->getCheck( 'survey-enabled' ) );
8282
83 - foreach ( array( 'user_type' ) as $field ) {
 83+ foreach ( array( 'user_type', 'ratio' ) as $field ) {
8484 $survey->setField( $field, $wgRequest->getInt( 'survey-' . $field ) );
8585 }
8686
@@ -224,7 +224,21 @@
225225 ),
226226 );
227227
 228+ $nrs = array_merge( array( 0.01, 0.1 ), range( 1, 100 ) );
 229+
228230 $fields[] = array(
 231+ 'type' => 'select',
 232+ 'default' => $survey->getField( 'ratio' ),
 233+ 'label-message' => 'survey-special-label-ratio',
 234+ 'id' => 'survey-ratio',
 235+ 'name' => 'survey-ratio',
 236+ 'options' => array_flip( array_map(
 237+ function( $n ) { return $GLOBALS['wgLang']->formatNum( $n ); },
 238+ array_combine( $nrs, $nrs )
 239+ ) ),
 240+ );
 241+
 242+ $fields[] = array(
229243 'type' => 'text',
230244 'default' => $survey->getField( 'header' ),
231245 'label-message' => 'survey-special-label-header',

Status & tagging log