r76894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76893‎ | r76894 | r76895 >
Date:18:31, 17 November 2010
Author:reedy
Status:deferred
Tags:
Comment:
Tagging REL0_1 of SimpleSurvey
Modified paths:
  • /tags/extensions/SimpleSurvey/REL0_1 (added) (history)

Diff [purge]

Index: tags/extensions/SimpleSurvey/REL0_1/Surveys.php
@@ -0,0 +1,88 @@
 2+<?php
 3+
 4+$wgSimpleSurveyRedirectURL = "";
 5+
 6+$wgValidSurveys[] = 'vitals-07-2010';
 7+
 8+$wgPrefSwitchSurveys['vitals-07-2010'] = array(
 9+ 'submit-msg' => 'vitals-07-2010-submit',
 10+ 'intro-msg' => 'simple-survey-intro-vitals-07-2010',
 11+ 'updatable' => false,
 12+ 'questions' => array(
 13+ 'use' => array(
 14+ 'question' => 'vitals-07-2010-question-use',
 15+ 'type' => 'select',
 16+ 'answers' => array(
 17+ 'blank' => 'vitals-07-2010-blank',
 18+ 'daily' => 'vitals-07-2010-answer-daily',
 19+ 'weekly' => 'vitals-07-2010-answer-weekly',
 20+ 'monthly' => 'vitals-07-2010-answer-monthly',
 21+ 'rarely' => 'vitals-07-2010-answer-rarely',
 22+ 'first' => 'vitals-07-2010-answer-firsttime',
 23+ ),
 24+ ),
 25+ 'edit' => array(
 26+ 'question' => 'vitals-07-2010-question-edit',
 27+ 'type' => 'select',
 28+ 'answers' => array(
 29+ 'blank' => 'vitals-07-2010-blank',
 30+ 'daily' => 'vitals-07-2010-answer-y-daily',
 31+ 'weekly' => 'vitals-07-2010-answer-y-weekly',
 32+ 'monthly' => 'vitals-07-2010-answer-y-monthly',
 33+ 'rarely' => 'vitals-07-2010-answer-y-rarely',
 34+ 'never' => 'vitals-07-2010-answer-n-never',
 35+ 'dunno' => 'vitals-07-2010-answer-dunno-edit',
 36+ ),
 37+ ),
 38+ 'nonprofit' => array(
 39+ 'question' => 'vitals-07-2010-question-nonprofit',
 40+ 'type' => 'select',
 41+ 'answers' => array(
 42+ 'blank' => 'vitals-07-2010-blank',
 43+ 'knew' => 'vitals-07-2010-answer-nonprof-knew',
 44+ 'business' => 'vitals-07-2010-answer-nonprof-business',
 45+ 'nothink' => 'vitals-07-2010-answer-nonprof-think',
 46+ ),
 47+ ),
 48+ 'wikimediafoundation' => array(
 49+ 'question' => 'vitals-07-2010-question-wikimedia',
 50+ 'type' => 'select',
 51+ 'answers' => array(
 52+ 'blank' => 'vitals-07-2010-blank',
 53+ 'notknow' => 'vitals-07-2010-answer-never-heard',
 54+ 'exists' => 'vitals-07-2010-answer-heard-nothing',
 55+ 'hosted' => 'vitals-07-2010-answer-hosted',
 56+ 'familiar' => 'vitals-07-2010-answer-know',
 57+ ),
 58+ ),
 59+ 'computerexp' => array(
 60+ 'question' => 'vitals-07-2010-question-computerexp',
 61+ 'type' => 'select',
 62+ 'answers' => array(
 63+ 'blank' => 'vitals-07-2010-blank',
 64+ 'beginner' => 'vitals-07-2010-answer-beginner',
 65+ 'one' => 'vitals-07-2010-answer-one-lang',
 66+ 'many' => 'vitals-07-2010-answer-many-lang',
 67+ 'none' => 'vitals-07-2010-answer-no-lang',
 68+ ),
 69+ ),
 70+ 'age' => array(
 71+ 'question' => 'vitals-07-2010-question-age',
 72+ 'type' => 'smallinput',
 73+ ),
 74+ 'gender' => array(
 75+ 'question' => 'vitals-07-2010-question-gender',
 76+ 'type' => 'select',
 77+ 'answers' => array(
 78+ 'blank' => 'vitals-07-2010-blank',
 79+ 'm' => 'vitals-07-2010-answer-male',
 80+ 'f' => 'vitals-07-2010-answer-female',
 81+ 'o' => 'vitals-07-2010-answer-other',
 82+ ),
 83+ ),
 84+ 'story' => array(
 85+ 'question' => 'vitals-07-2010-question-story',
 86+ 'type' => 'text',
 87+ ),
 88+ ),
 89+);
Property changes on: tags/extensions/SimpleSurvey/REL0_1/Surveys.php
___________________________________________________________________
Added: svn:eol-style
190 + native
Index: tags/extensions/SimpleSurvey/REL0_1/SimpleSurvey.classes.php
@@ -0,0 +1,110 @@
 2+<?php
 3+class SimpleSurvey extends PrefSwitchSurvey {
 4+ // Correlation between names of field types and implementation classes
 5+ /* Static Functions */
 6+
 7+ /* update schema*/
 8+ public static function schema( $updater = null ) {
 9+ if ( $updater === null ) {
 10+ global $wgExtNewTables;
 11+ $wgExtNewTables[] = array(
 12+ 'prefswitch_survey',
 13+ dirname( dirname( __FILE__ ) ) . "/PrefSwitch/patches/PrefSwitch.sql"
 14+ );
 15+ } else {
 16+ $updater->addExtensionUpdate( array( 'addTable', 'prefswitch_survey',
 17+ dirname( dirname( __FILE__ ) ) . "/PrefSwitch/patches/PrefSwitch.sql", true ) );
 18+ }
 19+ return true;
 20+ }
 21+
 22+ /**
 23+ * creates a random token
 24+ * @return a random token
 25+ */
 26+ public static function generateRandomCookieID() {
 27+ global $wgUser;
 28+ return wfGenerateToken( array( $wgUser, time() ) );
 29+ }
 30+
 31+
 32+ /**
 33+ * Render the HTML for a survey.
 34+ * @param $name string Survey name
 35+ * @param $questions array Array containing question data
 36+ * @param $loadFromDB bool Load previous survey data from the database
 37+ * @return string HTML
 38+ */
 39+ public static function render( $name, $questions, $loadFromDB = false ) {
 40+ global $wgUser;
 41+
 42+ $html = Xml::openElement( 'dl' );
 43+ foreach ( $questions as $field => $config ) {
 44+ $answer = null;
 45+ $answerData = null;
 46+ $invisible = false;
 47+ if ( isset( $config['visibility'] ) && $config['visibility'] == 'hidden' ) {
 48+ $invisible = true;
 49+ }
 50+ if ( $invisible ) {
 51+ $html .= Xml::openElement( 'div', array( "style" => "display:none;" ) );
 52+ }
 53+ $html .= call_user_func( array( self::$fieldTypes[$config['type']], 'render' ),
 54+ $field, $config, $answer, $answerData
 55+ );
 56+ if ( $invisible ) {
 57+ $html .= Xml::closeElement( 'div' );
 58+ }
 59+ }
 60+ $html .= Xml::closeElement( 'dl' );
 61+ return $html;
 62+ }
 63+
 64+ /**
 65+ * Save a survey to the database
 66+ * @param $name string Survey name
 67+ * @param $survey array Survey configuration data
 68+ */
 69+ public static function save( $name, $survey ) {
 70+ global $wgRequest, $wgUser;
 71+ $dbw = wfGetDb( DB_MASTER );
 72+ $now = $dbw->timestamp();
 73+ /*$cookieID = $wgRequest->getCookie( "vitals-survey" );
 74+ if ( $cookieID == null ) {
 75+ $cookieID = self::generateRandomCookieID();
 76+ $wgRequest->response()->setcookie( "vitals-survey", $cookieID );
 77+ }*/
 78+
 79+ foreach ( $survey['questions'] as $question => $config ) {
 80+ $dbw->insert(
 81+ 'prefswitch_survey',
 82+ array_merge(
 83+ array(
 84+ 'pss_user' => $wgUser->getId(),
 85+ 'pss_user_text' => $wgUser->getName(),
 86+ 'pss_timestamp' => $now,
 87+ 'pss_name' => $name,
 88+ 'pss_question' => $question,
 89+ ),
 90+ call_user_func( array( self::$fieldTypes[$config['type']], 'save' ), $question, $wgRequest )
 91+ ),
 92+ __METHOD__
 93+ );
 94+ }
 95+
 96+ // pseudoquestion, logged in? IP address?
 97+ $dbw->insert(
 98+ 'prefswitch_survey',
 99+ array(
 100+ 'pss_user' => $wgUser->getId(),
 101+ 'pss_user_text' => $wgUser->getName(),
 102+ 'pss_timestamp' => $now,
 103+ 'pss_name' => $name,
 104+ 'pss_question' => "logged_in",
 105+ 'pss_answer' => $wgUser->isLoggedIn() ? "yes" : "no",
 106+ 'pss_answer_data' => wfGetIP(),
 107+ ),
 108+ __METHOD__
 109+ );
 110+ }
 111+}
\ No newline at end of file
Property changes on: tags/extensions/SimpleSurvey/REL0_1/SimpleSurvey.classes.php
___________________________________________________________________
Added: svn:eol-style
1112 + native
Index: tags/extensions/SimpleSurvey/REL0_1/SimpleSurvey.i18n.php
@@ -0,0 +1,62 @@
 2+<?php
 3+
 4+$messages = array();
 5+
 6+/** English
 7+ * @author Nimish Gautam
 8+ */
 9+$messages['en'] = array(
 10+ 'simplesurvey' => 'Take a quick survey',
 11+ 'simple-survey-invalid' => 'That is not a valid survey at this time',
 12+ 'simple-survey-back' => 'Go back',
 13+ 'simple-survey-title' => 'Simple Survey',
 14+ 'simple-survey-confirm' => 'Thanks! Your data has been submitted.',
 15+
 16+ /*vitals 07 2010 */
 17+ 'simple-survey-intro-vitals-07-2010' => 'This is a quick survey to give us a better idea of who you are',
 18+ 'vitals-07-2010-submit' => 'Submit',
 19+
 20+ 'vitals-07-2010-question-use' => 'How often do you use Wikipedia?',
 21+ 'vitals-07-2010-question-edit' => 'Do you edit Wikipedia?',
 22+ 'vitals-07-2010-question-nonprofit' => 'Did you know Wikipedia is a non-profit project?',
 23+ 'vitals-07-2010-question-wikimedia' => 'Which of these describes your knowledge of the Wikimedia Foundation, the organization that hosts Wikipedia and its sister projects such as Wiktionary and Wikiquote:',
 24+ 'vitals-07-2010-question-age' => 'Please tell us your age',
 25+ 'vitals-07-2010-question-programming' => 'Please tell us which one of these describes you:',
 26+ 'vitals-07-2010-question-gender' => 'Please tell us your gender',
 27+ 'vitals-07-2010-question-story' => 'We love hearing about ways Wikipedia has impacted your life! Please feel free to share any stories, explain any of your answers, or leave a comment for the Wikimedia Foundation here:',
 28+ 'vitals-07-2010-question-computerexp' => "Which one of the following describes your computer experience?",
 29+
 30+ 'vitals-07-2010-blank' => '',
 31+ 'vitals-07-2010-answer-daily' => 'Daily',
 32+ 'vitals-07-2010-answer-weekly' => 'Weekly',
 33+ 'vitals-07-2010-answer-monthly' => 'Monthly',
 34+ 'vitals-07-2010-answer-rarely' => 'less than monthly',
 35+ 'vitals-07-2010-answer-firsttime' => 'This was my first time',
 36+ 'vitals-07-2010-answer-never' => 'Never',
 37+
 38+ 'vitals-07-2010-answer-y-daily' => 'Yes, daily',
 39+ 'vitals-07-2010-answer-y-weekly' => 'Yes, weekly',
 40+ 'vitals-07-2010-answer-y-monthly' => 'Yes, monthly',
 41+ 'vitals-07-2010-answer-y-rarely' => 'Yes, but less than monthly',
 42+ 'vitals-07-2010-answer-n-never' => 'No, never',
 43+ 'vitals-07-2010-answer-dunno-edit' => "I didn't know you could edit",
 44+
 45+ 'vitals-07-2010-answer-nonprof-knew' => "I knew it was a non-profit",
 46+ 'vitals-07-2010-answer-nonprof-business' => "I assumed it was a for-profit business",
 47+ 'vitals-07-2010-answer-nonprof-think' => "I've never thought about it",
 48+
 49+ 'vitals-07-2010-answer-never-heard' => "I've never heard of it",
 50+ 'vitals-07-2010-answer-heard-nothing' => "I guess I've heard of it, but don't know anything about it",
 51+ 'vitals-07-2010-answer-hosted' => "I know that Wikipedia is hosted by the Wikimedia Foundation, but that's about it",
 52+ 'vitals-07-2010-answer-know' => "I'm familiar with the Wikimedia Foundation",
 53+
 54+ 'vitals-07-2010-answer-beginner' => "I am a beginner with at least one programming language (eg HTML, PHP, Java, C)",
 55+ 'vitals-07-2010-answer-one-lang' => "I am comfortable with at least one programming language",
 56+ 'vitals-07-2010-answer-many-lang' => "I am comfortable with many programming languages",
 57+ 'vitals-07-2010-answer-no-lang' => "Programming? Not me!",
 58+
 59+ 'vitals-07-2010-answer-male' => 'Male',
 60+ 'vitals-07-2010-answer-female' => 'Female',
 61+ 'vitals-07-2010-answer-other' => 'Other',
 62+ );
 63+
Property changes on: tags/extensions/SimpleSurvey/REL0_1/SimpleSurvey.i18n.php
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: tags/extensions/SimpleSurvey/REL0_1/README
@@ -0,0 +1,6 @@
 2+#
 3+# THIS EXTENSION DEPENDS ON CODE THAT HAS BEEN MOVED TO A BRANCH, AND NO LONGER EXISTS IN TRUNK!
 4+#
 5+# TO SATISTFY THE DEPENDENCIES OF THIS CODE, YOU MUST GET THE UsabilityInitiative EXTENSION FROM ONE OF THE FOLLOWING:
 6+# /branches/REL1_16/extensions/UsabilityInitiative/ -- official release version
 7+# /branches/usability-initiative-1_16/ -- intermediate version with more recent patches, should be merged soon
\ No newline at end of file
Property changes on: tags/extensions/SimpleSurvey/REL0_1/README
___________________________________________________________________
Added: svn:eol-style
18 + native
Index: tags/extensions/SimpleSurvey/REL0_1/SimpleSurvey.php
@@ -0,0 +1,107 @@
 2+<?php
 3+
 4+$dir = dirname( __FILE__ ) . '/';
 5+
 6+// from prefswitch in usability initiative
 7+$prefswitchdir = dirname( dirname( __FILE__ ) ) . "/PrefSwitch";
 8+// Horrible back for back compat with pre-r73480 installs
 9+if ( !is_dir( $prefswitchdir ) ) {
 10+ $prefswitchdir = dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative/PrefSwitch";
 11+}
 12+
 13+// Use this to override the URL of ext.prefSwitch.{js,css} if needed
 14+$wgSimpleSurveyJSPath = null;
 15+$wgSimpleSurveyCSSPath = null;
 16+
 17+// Adds Autoload Classes
 18+$wgAutoloadClasses = array_merge(
 19+ $wgAutoloadClasses,
 20+ array(
 21+ 'PrefSwitchSurvey' => $prefswitchdir . '/PrefSwitch.classes.php',
 22+ 'PrefSwitchSurveyField' => $prefswitchdir . '/PrefSwitch.classes.php',
 23+ 'PrefSwitchSurveyFieldSelect' => $prefswitchdir . '/PrefSwitch.classes.php',
 24+ 'PrefSwitchSurveyFieldRadios' => $prefswitchdir . '/PrefSwitch.classes.php',
 25+ 'PrefSwitchSurveyFieldChecks' => $prefswitchdir . '/PrefSwitch.classes.php',
 26+ 'PrefSwitchSurveyFieldBoolean' => $prefswitchdir . '/PrefSwitch.classes.php',
 27+ 'PrefSwitchSurveyFieldDimensions' => $prefswitchdir . '/PrefSwitch.classes.php',
 28+ 'PrefSwitchSurveyFieldText' => $prefswitchdir . '/PrefSwitch.classes.php',
 29+ 'SimpleSurvey' => $dir . "SimpleSurvey.classes.php",
 30+ 'SpecialSimpleSurvey' => $dir . 'SpecialSimpleSurvey.php',
 31+ )
 32+);
 33+
 34+// add special pages
 35+$wgSpecialPages['SimpleSurvey'] = 'SpecialSimpleSurvey';
 36+$wgSpecialPageGroups['SimpleSurvey'] = 'wiki';
 37+$wgExtensionMessagesFiles['SimpleSurvey'] = $dir . 'SimpleSurvey.i18n.php';
 38+
 39+
 40+$wgExtensionCredits['other'][] = array(
 41+ 'path' => __FILE__,
 42+ 'name' => 'SimpleSurvey',
 43+ 'author' => array( 'Nimish Gautam' ),
 44+ 'version' => '0.1',
 45+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UsabilityInitiative',
 46+);
 47+
 48+// Register database operations
 49+$wgHooks['LoadExtensionSchemaUpdates'][] = 'SimpleSurvey::schema';
 50+
 51+$wgValidSurveys = array();
 52+
 53+// add surveys
 54+require_once( $dir . "Surveys.php" );
 55+
 56+// Always include the browser stuff...
 57+foreach ( $wgPrefSwitchSurveys as &$survey ) {
 58+ $survey['questions']['browser'] = array(
 59+ 'question' => 'prefswitch-survey-question-browser',
 60+ 'type' => 'select',
 61+ 'answers' => array(
 62+ 'ie5' => 'prefswitch-survey-answer-browser-ie5',
 63+ 'ie6' => 'prefswitch-survey-answer-browser-ie6',
 64+ 'ie7' => 'prefswitch-survey-answer-browser-ie7',
 65+ 'ie8' => 'prefswitch-survey-answer-browser-ie8',
 66+ 'ie9' => 'prefswitch-survey-answer-browser-ie9',
 67+ 'ffb' => 'prefswitch-survey-answer-browser-ffb',
 68+ 'ff1' => 'prefswitch-survey-answer-browser-ff1',
 69+ 'ff2' => 'prefswitch-survey-answer-browser-ff2',
 70+ 'ff3' => 'prefswitch-survey-answer-browser-ff3',
 71+ 'cb' => 'prefswitch-survey-answer-browser-cb',
 72+ 'cd' => 'prefswitch-survey-answer-browser-cd',
 73+ 'c1' => 'prefswitch-survey-answer-browser-c1',
 74+ 'c2' => 'prefswitch-survey-answer-browser-c2',
 75+ 'c3' => 'prefswitch-survey-answer-browser-c3',
 76+ 'c4' => 'prefswitch-survey-answer-browser-c4',
 77+ 'c5' => 'prefswitch-survey-answer-browser-c5',
 78+ 's3' => 'prefswitch-survey-answer-browser-s3',
 79+ 's4' => 'prefswitch-survey-answer-browser-s4',
 80+ 's5' => 'prefswitch-survey-answer-browser-s5',
 81+ 'o9' => 'prefswitch-survey-answer-browser-o9',
 82+ 'o9.5' => 'prefswitch-survey-answer-browser-o9.5',
 83+ 'o10' => 'prefswitch-survey-answer-browser-o10',
 84+ ),
 85+ 'other' => 'prefswitch-survey-answer-browser-other',
 86+ );
 87+ $survey['questions']['os'] = array(
 88+ 'question' => 'prefswitch-survey-question-os',
 89+ 'type' => 'select',
 90+ 'answers' => array(
 91+ 'windows' => 'prefswitch-survey-answer-os-windows',
 92+ 'windowsmobile' => 'prefswitch-survey-answer-os-windowsmobile',
 93+ 'macos' => 'prefswitch-survey-answer-os-macos',
 94+ 'iphoneos' => 'prefswitch-survey-answer-os-iphoneos',
 95+ 'ios' => 'prefswitch-survey-answer-os-ios',
 96+ 'linux' => 'prefswitch-survey-answer-os-linux',
 97+ ),
 98+ 'other' => 'prefswitch-survey-answer-os-other',
 99+ );
 100+ $survey['questions']['res'] = array(
 101+ 'question' => 'prefswitch-survey-question-res',
 102+ 'type' => 'dimensions',
 103+ );
 104+}
 105+unset( $survey );
 106+
 107+
 108+
Property changes on: tags/extensions/SimpleSurvey/REL0_1/SimpleSurvey.php
___________________________________________________________________
Added: svn:eol-style
1109 + native
Index: tags/extensions/SimpleSurvey/REL0_1/SpecialSimpleSurvey.php
@@ -0,0 +1,159 @@
 2+<?php
 3+/**
 4+ * Special:PrefSwitch
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+class SpecialSimpleSurvey extends SpecialPage {
 11+
 12+ /* Private Members */
 13+
 14+ private $origin = '';
 15+ private $originTitle = null;
 16+ private $originQuery = '';
 17+ private $originLink = '';
 18+ private $originLinkUrl = '';
 19+ private $originFullUrl = '';
 20+ private $tokenToCheck = '';
 21+
 22+ /* Functions */
 23+
 24+ /**
 25+ * Quick token matching wrapper for form processing
 26+ */
 27+ public function checkToken() {
 28+ global $wgRequest;
 29+ $this->tokenToCheck = $_SESSION['wsSimpleSurveyToken'];
 30+ if ( $this->tokenToCheck != "" &&
 31+ ( $wgRequest->getVal( 'token' ) == $this->tokenToCheck ) ) {
 32+ return true;
 33+ } else {
 34+ return false;
 35+ }
 36+ }
 37+
 38+ public function setToken() {
 39+ $this->tokenToCheck = wfGenerateToken( array( $this, time() ) );
 40+ wfSetupSession();
 41+ $_SESSION['wsSimpleSurveyToken'] = $this->tokenToCheck;
 42+ }
 43+
 44+ public function __construct() {
 45+ parent::__construct( 'SimpleSurvey' );
 46+ wfLoadExtensionMessages( 'SimpleSurvey' );
 47+ }
 48+
 49+
 50+ public function execute( $par ) {
 51+ global $wgRequest, $wgOut, $wgUser, $wgPrefSwitchSurveys, $wgPrefSwitchStyleVersion, $wgValidSurveys, $wgSimpleSurveyRedirectURL;
 52+ $this->setHeaders();
 53+ // Set page title
 54+ $wgOut->setPageTitle( wfMsg( 'simple-survey-title' ) );
 55+ $surveyName = $wgRequest->getVal( "survey" );
 56+
 57+ if ( $wgRequest->wasPosted() ) {
 58+ if ( $surveyName && in_array( $surveyName, $wgValidSurveys ) && $this->checkToken() ) {
 59+ SimpleSurvey::save( $surveyName, $wgPrefSwitchSurveys[$surveyName] );
 60+ $wgOut->addHtml( '<strong class="simplesurvey-success">' . wfMsgHtml( 'simple-survey-confirm' ) . '</strong>' );
 61+ }
 62+ // forward to new page
 63+ if ( $wgSimpleSurveyRedirectURL ) {
 64+ $wgOut->redirect( $wgSimpleSurveyRedirectURL );
 65+ }
 66+
 67+ return;
 68+ }
 69+
 70+ $this->setToken();
 71+ // Get the origin from the request
 72+ $par = $wgRequest->getVal( 'from', $par );
 73+ $this->originTitle = Title::newFromText( $par );
 74+ // $this->originTitle should never be Special:Userlogout
 75+ if (
 76+ $this->originTitle &&
 77+ $this->originTitle->isSpecial( 'Userlogout' )
 78+ ) {
 79+ $this->originTitle = null;
 80+ }
 81+ // Get some other useful information about the origin
 82+ if ( $this->originTitle ) {
 83+ $this->origin = $this->originTitle->getPrefixedDBKey();
 84+ $this->originQuery = $wgRequest->getVal( 'fromquery' );
 85+ $this->originLink = $wgUser->getSkin()->link( $this->originTitle, null, array(), $this->originQuery );
 86+ $this->originLinkUrl = $this->originTitle->getLinkUrl( $this->originQuery );
 87+ $this->originFullUrl = $this->originTitle->getFullUrl( $this->originQuery );
 88+ }
 89+
 90+ // Begin output
 91+ $this->setHeaders();
 92+
 93+ global $wgExtensionAssetsPath, $wgSimpleSurveyJSPath, $wgSimpleSurveyCSSPath;
 94+ $script = Html::linkedScript( wfAppendQuery( $wgSimpleSurveyJSPath ? $wgSimpleSurveyJSPath :
 95+ "$wgExtensionAssetsPath/PrefSwitch/modules/ext.prefSwitch.js", $wgPrefSwitchStyleVersion ) );
 96+ $wgOut->addScript( $script );
 97+ $wgOut->addExtensionStyle( wfAppendQuery( $wgSimpleSurveyCSSPath ? $wgSimpleSurveyCSSPath :
 98+ "$wgExtensionAssetsPath/PrefSwitch/modules/ext.prefSwitch.css", $wgPrefSwitchStyleVersion ) );
 99+
 100+ // Handle various modes
 101+ $renderedSurvey = $this->render( $wgRequest->getVal( "survey" ) );
 102+
 103+ $wgOut->addHtml( '<div class="plainlinks">' );
 104+ $wgOut->addHtml( $renderedSurvey );
 105+ $wgOut->addHtml( '</div>' );
 106+
 107+ // Handle raw mode
 108+ // Only output the <form> and the <script>
 109+ if ( $wgRequest->getBool( 'raw' ) ) {
 110+ $wgOut->disable();
 111+ echo $renderedSurvey . $script;
 112+ }
 113+ }
 114+
 115+ /* Private Functions */
 116+
 117+ private function render( $mode = null ) {
 118+ global $wgUser, $wgOut, $wgPrefSwitchSurveys, $wgValidSurveys;
 119+ // Make sure links will retain the origin
 120+ $query = array( 'from' => $this->origin, 'fromquery' => $this->originQuery );
 121+
 122+ if ( !isset( $wgPrefSwitchSurveys[$mode] ) && !in_array( $mode, $wgValidSurveys ) ) {
 123+ $wgOut->addWikiMsg( "simple-survey-invalid" );
 124+ if ( $this->originTitle ) {
 125+ $wgOut->addHTML( wfMsg( "simple-survey-back", $this->originLink ) );
 126+ }
 127+ return;
 128+ }
 129+
 130+ if ( isset( $wgPrefSwitchSurveys[$mode]['intro-msg'] ) ) {
 131+ $wgOut->addWikiMsg( $wgPrefSwitchSurveys[$mode]['intro-msg'] );
 132+ }
 133+
 134+ // Setup a form
 135+ $html = Xml::openElement(
 136+ 'form', array(
 137+ 'method' => 'post',
 138+ 'action' => $this->getTitle()->getLinkURL( $query ),
 139+ 'class' => 'simple-survey',
 140+ 'id' => "simple-survey-{$mode}"
 141+ )
 142+ );
 143+ $html .= Html::hidden( 'survey', $mode );
 144+ $html .= Html::hidden( 'token', $this->tokenToCheck );
 145+ // Render a survey
 146+ $html .= SimpleSurvey::render(
 147+ $mode,
 148+ $wgPrefSwitchSurveys[$mode]['questions']
 149+ );
 150+ // Finish out the form
 151+ $html .= Xml::openElement( 'dt', array( 'class' => 'prefswitch-survey-submit' ) );
 152+ $html .= Xml::submitButton(
 153+ wfMsg( $wgPrefSwitchSurveys[$mode]['submit-msg'] ),
 154+ array( 'id' => "simple-survey-submit-{$mode}", 'class' => 'prefswitch-survey-submit' )
 155+ );
 156+ $html .= Xml::closeElement( 'dt' );
 157+ $html .= Xml::closeElement( 'form' );
 158+ return $html;
 159+ }
 160+}
Property changes on: tags/extensions/SimpleSurvey/REL0_1/SpecialSimpleSurvey.php
___________________________________________________________________
Added: svn:eol-style
1161 + native

Status & tagging log