Index: trunk/extensions/Survey/Survey.sql |
— | — | @@ -1,47 +0,0 @@ |
2 | | - |
3 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/surveys ( |
4 | | - survey_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
5 | | - survey_name VARCHAR(255) NOT NULL, -- String indentifier for the survey |
6 | | - survey_title VARCHAR(255) NOT NULL, -- Title of the survey |
7 | | - survey_enabled TINYINT NOT NULL default '0', -- If the survey can be taken by users |
8 | | - survey_header TEXT NOT NULL, -- Text to display above the survey |
9 | | - survey_footer TEXT NOT NULL, -- Text to display below the survey |
10 | | - survey_thanks TEXT NOT NULL, -- Text to display after survey submission |
11 | | - survey_user_type TINYINT unsigned NOT NULL default '0', -- Type of users that can participate in the survey |
12 | | - survey_namespaces BLOB NOT NULL, -- Namespaces on which the survey can be displayed |
13 | | - survey_ratio TINYINT unsigned NOT NULL, -- Percentage of users to show the survey to |
14 | | - survey_expiry INT unsigned NOT NULL, -- Coockie expiry time for the survey |
15 | | - survey_min_pages TINYINT unsigned NOT NULL -- Min amount of pages the user needs to view before getting the survey |
16 | | -) /*$wgDBTableOptions*/; |
17 | | - |
18 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/survey_questions ( |
19 | | - question_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY, |
20 | | - question_survey_id SMALLINT unsigned NOT NULL, -- Foreign key: surveys.survey_id |
21 | | - question_text TEXT NOT NULL, |
22 | | - question_type INT(2) unsigned NOT NULL, |
23 | | - question_required TINYINT NOT NULL, |
24 | | - question_answers BLOB NOT NULL, |
25 | | - question_removed TINYINT NOT NULL default '0' |
26 | | -) /*$wgDBTableOptions*/; |
27 | | - |
28 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/survey_submissions ( |
29 | | - submission_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY, |
30 | | - submission_survey_id SMALLINT unsigned NOT NULL, -- Foreign key: surveys.survey_id |
31 | | - submission_user_name VARCHAR(255) NOT NULL, -- The person that made the submission (account name or ip) |
32 | | - submission_page_id INT(10) unsigned NULL, -- The id of the page the submission was made on |
33 | | - submission_time CHAR(14) binary NOT NULL default '' -- The time the submission was made |
34 | | -) /*$wgDBTableOptions*/; |
35 | | - |
36 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/survey_answers ( |
37 | | - answer_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
38 | | - answer_submission_id INT(10) unsigned NOT NULL, -- Foreign key: survey_submissions.submission_id |
39 | | - answer_question_id INT(10) unsigned NOT NULL, -- Foreign key: survey_questions.question_id |
40 | | - answer_text BLOB NOT NULL |
41 | | -) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Index: trunk/extensions/Survey/sql/Survey_indexSurveyName.sql |
— | — | @@ -1 +0,0 @@ |
2 | | -CREATE UNIQUE INDEX /*i*/surveys_survey_name ON /*_*/surveys (survey_name); |
\ No newline at end of file |
Index: trunk/extensions/Survey/sql/Survey_indexQuestionId.sql |
— | — | @@ -1 +0,0 @@ |
2 | | -CREATE INDEX /*i*/surveys_question_id ON /*_*/survey_answers (answer_question_id); |
\ No newline at end of file |
Index: trunk/extensions/Survey/sql/Survey_indexSubmissionId.sql |
— | — | @@ -1 +0,0 @@ |
2 | | -CREATE INDEX /*i*/surveys_submission_id ON /*_*/survey_answers (answer_submission_id); |
\ No newline at end of file |
Index: trunk/extensions/Survey/sql/Survey.sql |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +-- MySQL version of the database schema for the Survey extension. |
| 3 | +-- Licence: GNU GPL v3+ |
| 4 | +-- Author: Jeroen De Dauw < jeroendedauw@gmail.com > |
| 5 | + |
| 6 | +-- Surveys |
| 7 | +CREATE TABLE IF NOT EXISTS /*_*/surveys ( |
| 8 | + survey_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
| 9 | + survey_name VARCHAR(255) NOT NULL, -- String indentifier for the survey |
| 10 | + survey_title VARCHAR(255) NOT NULL, -- Title of the survey |
| 11 | + survey_enabled TINYINT NOT NULL default '0', -- If the survey can be taken by users |
| 12 | + survey_header TEXT NOT NULL, -- Text to display above the survey |
| 13 | + survey_footer TEXT NOT NULL, -- Text to display below the survey |
| 14 | + survey_thanks TEXT NOT NULL, -- Text to display after survey submission |
| 15 | + survey_user_type TINYINT unsigned NOT NULL default '0', -- Type of users that can participate in the survey |
| 16 | + survey_namespaces BLOB NOT NULL, -- Namespaces on which the survey can be displayed |
| 17 | + 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 |
| 19 | + survey_min_pages TINYINT unsigned NOT NULL -- Min amount of pages the user needs to view before getting the survey |
| 20 | +) /*$wgDBTableOptions*/; |
| 21 | + |
| 22 | +CREATE UNIQUE INDEX /*i*/surveys_survey_name ON /*_*/surveys (survey_name); |
| 23 | + |
| 24 | +-- Questions |
| 25 | +CREATE TABLE IF NOT EXISTS /*_*/survey_questions ( |
| 26 | + question_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY, |
| 27 | + question_survey_id SMALLINT unsigned NOT NULL, -- Foreign key: surveys.survey_id |
| 28 | + question_text TEXT NOT NULL, |
| 29 | + question_type INT(2) unsigned NOT NULL, |
| 30 | + question_required TINYINT NOT NULL, |
| 31 | + question_answers BLOB NOT NULL, |
| 32 | + question_removed TINYINT NOT NULL default '0' |
| 33 | +) /*$wgDBTableOptions*/; |
| 34 | + |
| 35 | +-- Submissions |
| 36 | +CREATE TABLE IF NOT EXISTS /*_*/survey_submissions ( |
| 37 | + submission_id INT(10) unsigned NOT NULL auto_increment PRIMARY KEY, |
| 38 | + submission_survey_id SMALLINT unsigned NOT NULL, -- Foreign key: surveys.survey_id |
| 39 | + submission_user_name VARCHAR(255) NOT NULL, -- The person that made the submission (account name or ip) |
| 40 | + submission_page_id INT(10) unsigned NULL, -- The id of the page the submission was made on |
| 41 | + submission_time CHAR(14) binary NOT NULL default '' -- The time the submission was made |
| 42 | +) /*$wgDBTableOptions*/; |
| 43 | + |
| 44 | +-- Answers |
| 45 | +CREATE TABLE IF NOT EXISTS /*_*/survey_answers ( |
| 46 | + answer_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
| 47 | + answer_submission_id INT(10) unsigned NOT NULL, -- Foreign key: survey_submissions.submission_id |
| 48 | + answer_question_id INT(10) unsigned NOT NULL, -- Foreign key: survey_questions.question_id |
| 49 | + answer_text BLOB NOT NULL |
| 50 | +) /*$wgDBTableOptions*/; |
| 51 | + |
| 52 | +CREATE INDEX /*i*/surveys_submission_id ON /*_*/survey_answers (answer_submission_id); |
| 53 | +CREATE INDEX /*i*/surveys_question_id ON /*_*/survey_answers (answer_question_id); |
Property changes on: trunk/extensions/Survey/sql/Survey.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 54 | + native |
Index: trunk/extensions/Survey/Survey.php |
— | — | @@ -24,11 +24,11 @@ |
25 | 25 | die( 'Not an entry point.' ); |
26 | 26 | } |
27 | 27 | |
28 | | -if ( version_compare( $wgVersion, '1.17', '<' ) ) { |
29 | | - die( '<b>Error:</b> Survey requires MediaWiki 1.17 or above.' ); |
| 28 | +if ( version_compare( $wgVersion, '1.18c', '<' ) ) { |
| 29 | + die( '<b>Error:</b> This version of Survey requires MediaWiki 1.18 or above. For MediaWiki 1.17.x, you can use Survey 0.1.2.' ); |
30 | 30 | } |
31 | 31 | |
32 | | -define( 'Survey_VERSION', '0.1.2' ); |
| 32 | +define( 'Survey_VERSION', '0.2 alpha' ); |
33 | 33 | |
34 | 34 | $wgExtensionCredits['other'][] = array( |
35 | 35 | 'path' => __FILE__, |
Index: trunk/extensions/Survey/specials/SpecialSurveyPage.php |
— | — | @@ -58,32 +58,6 @@ |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | | - * Get the OutputPage being used for this instance. |
63 | | - * This overrides the getOutput method of Specialpage added in MediaWiki 1.18, |
64 | | - * and returns $wgOut for older versions. |
65 | | - * |
66 | | - * @since 0.1 |
67 | | - * |
68 | | - * @return OutputPage |
69 | | - */ |
70 | | - public function getOutput() { |
71 | | - return version_compare( $GLOBALS['wgVersion'], '1.18', '>=' ) ? parent::getOutput() : $GLOBALS['wgOut']; |
72 | | - } |
73 | | - |
74 | | - /** |
75 | | - * Shortcut to get user's language. |
76 | | - * This overrides the getLang method of Specialpage added in MediaWiki 1.18, |
77 | | - * and returns $wgLang for older versions. |
78 | | - * |
79 | | - * @since 0.1 |
80 | | - * |
81 | | - * @return Language |
82 | | - */ |
83 | | - public function getLang() { |
84 | | - return version_compare( $GLOBALS['wgVersion'], '1.18', '>=' ) ? parent::getLang() : $GLOBALS['wgLang']; |
85 | | - } |
86 | | - |
87 | | - /** |
88 | 62 | * Add resource loader modules or use fallback code for |
89 | 63 | * earlier versions of MediaWiki. |
90 | 64 | * |
— | — | @@ -129,7 +103,7 @@ |
130 | 104 | * @param array $links |
131 | 105 | */ |
132 | 106 | protected function displayNavigation( array $links ) { |
133 | | - $this->getOutput()->addHTML( Html::rawElement( 'p', array(), $this->getLang()->pipeList( $links ) ) ); |
| 107 | + $this->getOutput()->addHTML( Html::rawElement( 'p', array(), $this->getLanguage()->pipeList( $links ) ) ); |
134 | 108 | } |
135 | 109 | |
136 | 110 | } |
Index: trunk/extensions/Survey/specials/SpecialSurveyStats.php |
— | — | @@ -252,7 +252,7 @@ |
253 | 253 | 'surveys-surveystats-question-answer', |
254 | 254 | 'parsemag', |
255 | 255 | $answer, |
256 | | - $this->getLang()->formatNum( $answerCount ) |
| 256 | + $this->getLanguage()->formatNum( $answerCount ) |
257 | 257 | ) |
258 | 258 | ); |
259 | 259 | } |
Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -34,9 +34,7 @@ |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | | - global $wgRequest, $wgUser; |
39 | | - |
40 | | - if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 38 | + if ( $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) ) { |
41 | 39 | $this->handleSubmission(); |
42 | 40 | } else { |
43 | 41 | if ( is_null( $subPage ) || trim( $subPage ) === '' ) { |
— | — | @@ -72,24 +70,24 @@ |
73 | 71 | * @since 0.1 |
74 | 72 | */ |
75 | 73 | protected function handleSubmission() { |
76 | | - global $wgRequest; |
| 74 | + $req = $this->getRequest(); |
77 | 75 | |
78 | | - $values = $wgRequest->getValues(); |
| 76 | + $values = $req->getValues(); |
79 | 77 | |
80 | | - if ( $wgRequest->getInt( 'survey-id' ) == 0 ) { |
| 78 | + if ( $req->getInt( 'survey-id' ) == 0 ) { |
81 | 79 | $survey = new Survey( null ); |
82 | 80 | } else { |
83 | | - $survey = Survey::newFromId( $wgRequest->getInt( 'survey-id' ), null, false ); |
| 81 | + $survey = Survey::newFromId( $req->getInt( 'survey-id' ), null, false ); |
84 | 82 | } |
85 | 83 | |
86 | 84 | foreach ( array( 'name', 'title', 'header', 'footer', 'thanks' ) as $field ) { |
87 | | - $survey->setField( $field, $wgRequest->getText( 'survey-' . $field ) ); |
| 85 | + $survey->setField( $field, $req->getText( 'survey-' . $field ) ); |
88 | 86 | } |
89 | 87 | |
90 | | - $survey->setField( 'enabled', $wgRequest->getCheck( 'survey-enabled' ) ); |
| 88 | + $survey->setField( 'enabled', $req->getCheck( 'survey-enabled' ) ); |
91 | 89 | |
92 | 90 | foreach ( array( 'user_type', 'ratio', 'min_pages', 'expiry' ) as $field ) { |
93 | | - $survey->setField( $field, $wgRequest->getInt( 'survey-' . $field ) ); |
| 91 | + $survey->setField( $field, $req->getInt( 'survey-' . $field ) ); |
94 | 92 | } |
95 | 93 | |
96 | 94 | $survey->setField( 'namespaces', array() ); |
— | — | @@ -132,7 +130,7 @@ |
133 | 131 | * @return SurveyQuestion |
134 | 132 | */ |
135 | 133 | protected function getSubmittedQuestion( $questionId, $isNewQuestion = false ) { |
136 | | - global $wgRequest; |
| 134 | + $req = $this->getRequest(); |
137 | 135 | |
138 | 136 | if ( $isNewQuestion ) { |
139 | 137 | $questionDbId = null; |
— | — | @@ -142,7 +140,7 @@ |
143 | 141 | } |
144 | 142 | |
145 | 143 | $answers = array_filter( |
146 | | - explode( "\n", $wgRequest->getText( "survey-question-answers-$questionId" ) ), |
| 144 | + explode( "\n", $req->getText( "survey-question-answers-$questionId" ) ), |
147 | 145 | function( $line ) { |
148 | 146 | return trim( $line ) != ''; |
149 | 147 | } |
— | — | @@ -151,8 +149,8 @@ |
152 | 150 | $question = new SurveyQuestion( array( |
153 | 151 | 'id' => $questionDbId, |
154 | 152 | 'removed' => 0, |
155 | | - 'text' => $wgRequest->getText( "survey-question-text-$questionId" ), |
156 | | - 'type' => $wgRequest->getInt( "survey-question-type-$questionId" ), |
| 153 | + 'text' => $req->getText( "survey-question-text-$questionId" ), |
| 154 | + 'type' => $req->getInt( "survey-question-type-$questionId" ), |
157 | 155 | 'required' => 0, // $wgRequest->getCheck( "survey-question-required-$questionId" ), |
158 | 156 | 'answers' => $answers |
159 | 157 | ) ); |
— | — | @@ -181,7 +179,7 @@ |
182 | 180 | * @return array |
183 | 181 | */ |
184 | 182 | protected function getNumericalOptions( array $numbers ) { |
185 | | - $lang = $this->getLang(); |
| 183 | + $lang = $this->getLanguage(); |
186 | 184 | |
187 | 185 | return array_flip( array_map( |
188 | 186 | function( $n ) use( $lang ) { return $lang->formatNum( $n ); }, |
Index: trunk/extensions/Survey/specials/SpecialSurveys.php |
— | — | @@ -34,12 +34,12 @@ |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | | - global $wgRequest, $wgUser; |
| 38 | + $req = $this->getRequest(); |
39 | 39 | |
40 | | - if ( $wgRequest->wasPosted() |
41 | | - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) |
42 | | - && $wgRequest->getCheck( 'newsurvey' ) ) { |
43 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'EditSurvey', $wgRequest->getVal( 'newsurvey' ) )->getLocalURL() ); |
| 40 | + if ( $req->wasPosted() |
| 41 | + && $this->getUser()->matchEditToken( $req->getVal( 'wpEditToken' ) ) |
| 42 | + && $req->getCheck( 'newsurvey' ) ) { |
| 43 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'EditSurvey', $req->getVal( 'newsurvey' ) )->getLocalURL() ); |
44 | 44 | } else { |
45 | 45 | $this->displaySurveys(); |
46 | 46 | } |
Index: trunk/extensions/Survey/Survey.hooks.php |
— | — | @@ -51,54 +51,15 @@ |
52 | 52 | * |
53 | 53 | * @return true |
54 | 54 | */ |
55 | | - public static function onSchemaUpdate( /* DatabaseUpdater */ $updater = null ) { |
| 55 | + public static function onSchemaUpdate( DatabaseUpdater $updater ) { |
56 | 56 | global $wgDBtype; |
57 | 57 | |
58 | 58 | $updater->addExtensionUpdate( array( |
59 | 59 | 'addTable', |
60 | 60 | 'surveys', |
61 | | - dirname( __FILE__ ) . '/Survey.sql', |
| 61 | + dirname( __FILE__ ) . '/sql/Survey.sql', |
62 | 62 | true |
63 | 63 | ) ); |
64 | | - $updater->addExtensionUpdate( array( |
65 | | - 'addTable', |
66 | | - 'survey_questions', |
67 | | - dirname( __FILE__ ) . '/Survey.sql', |
68 | | - true |
69 | | - ) ); |
70 | | - $updater->addExtensionUpdate( array( |
71 | | - 'addTable', |
72 | | - 'survey_submissions', |
73 | | - dirname( __FILE__ ) . '/Survey.sql', |
74 | | - true |
75 | | - ) ); |
76 | | - $updater->addExtensionUpdate( array( |
77 | | - 'addTable', |
78 | | - 'survey_answers', |
79 | | - dirname( __FILE__ ) . '/Survey.sql', |
80 | | - true |
81 | | - ) ); |
82 | | - $updater->addExtensionUpdate( array( |
83 | | - 'addIndex', |
84 | | - 'surveys', |
85 | | - 'surveys_survey_name', |
86 | | - dirname( __FILE__ ) . '/sql/Survey_indexSurveyName.sql', |
87 | | - true |
88 | | - ) ); |
89 | | - $updater->addExtensionUpdate( array( |
90 | | - 'addIndex', |
91 | | - 'survey_answers', |
92 | | - 'surveys_question_id', |
93 | | - dirname( __FILE__ ) . '/sql/Survey_indexQuestionId.sql', |
94 | | - true |
95 | | - ) ); |
96 | | - $updater->addExtensionUpdate( array( |
97 | | - 'addIndex', |
98 | | - 'survey_answers', |
99 | | - 'surveys_submission_id', |
100 | | - dirname( __FILE__ ) . '/sql/Survey_indexSubmissionId.sql', |
101 | | - true |
102 | | - ) ); |
103 | 64 | |
104 | 65 | return true; |
105 | 66 | } |
Index: trunk/extensions/Survey/INSTALL |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | |
10 | 10 | Survey requires: |
11 | 11 | |
12 | | -* MediaWiki 1.17 or above |
| 12 | +* MediaWiki 1.18 or above (Use Survey 0.1.2 if you are running MediaWiki 1.17.x and cannot upgrade to 1.18 or later.) |
13 | 13 | * PHP 5.3 or above |
14 | 14 | |
15 | 15 | == Download == |
— | — | @@ -18,12 +18,12 @@ |
19 | 19 | |
20 | 20 | You can also get the code directly from SVN. Tags can be obtained via |
21 | 21 | |
22 | | - svn checkout <nowiki>http://svn.wikimedia.org/svnroot/mediawiki/tags/extensions/Survey/REL_version</nowiki> |
| 22 | + svn checkout http://svn.wikimedia.org/svnroot/mediawiki/tags/extensions/Survey/REL_version |
23 | 23 | |
24 | 24 | Where 'version' is the version number of the tag, such as 0_1 (see the [http://svn.wikimedia.org/svnroot/mediawiki/tags/extensions/Survey/ available tags]). |
25 | 25 | The latest code can be obtained from trunk: |
26 | 26 | |
27 | | - svn checkout <nowiki>http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/Survey/</nowiki> |
| 27 | + svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/Survey/ |
28 | 28 | |
29 | 29 | == Installation == |
30 | 30 | |
Index: trunk/extensions/Survey/RELEASE-NOTES |
— | — | @@ -4,6 +4,13 @@ |
5 | 5 | Latest version of the release notes: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Survey/RELEASE-NOTES?view=co |
6 | 6 | |
7 | 7 | |
| 8 | +=== Version 0.2 === |
| 9 | +(trunk) |
| 10 | + |
| 11 | +* Dropped compatibility with MediaWiki 1.17. |
| 12 | +* Use of RequestContext methods to get rid of globals. |
| 13 | +* Cleanup of database table index code. |
| 14 | + |
8 | 15 | === Version 0.1.2 === |
9 | 16 | 2011-11-14 |
10 | 17 | |