r64529 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64528‎ | r64529 | r64530 >
Date:20:38, 2 April 2010
Author:tparscal
Status:ok
Tags:
Comment:
Fixed more stuff - like bugs and whatnot...
Modified paths:
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.sql (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php
@@ -29,7 +29,7 @@
3030 __METHOD__
3131 );
3232 foreach( $res as $row ) {
33 - $loaded[$row->pss_field] = array( $row->pss_answer, $row->pss_answer_data );
 33+ $loaded[$row->pss_question] = array( $row->pss_answer, $row->pss_answer_data );
3434 }
3535 }
3636 $html = Xml::openElement( 'dl' );
@@ -45,11 +45,11 @@
4646 $html .= Xml::closeElement( 'dl' );
4747 return $html;
4848 }
49 - public static function save( $survey, $name ) {
 49+ public static function save( $name, $survey ) {
5050 global $wgRequest, $wgUser;
5151 $dbw = wfGetDb( DB_MASTER );
5252 $now = $dbw->timestamp( wfTimestamp() );
53 - foreach ( $survey as $question => $config ) {
 53+ foreach ( $survey['questions'] as $question => $config ) {
5454 if ( in_array( 'PrefSwitchSurveyField', class_implements( self::$fieldTypes[$config['type']] ) ) ) {
5555 $dbw->insert(
5656 'prefswitch_survey',
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php
@@ -56,6 +56,8 @@
5757 'prefswitch-survey-answer-os-linux' => 'Linux',
5858 'prefswitch-survey-answer-os-other' => 'Other operating system:',
5959 'prefswitch-survey-question-res' => 'What is the resolution of your screen?',
 60+ 'prefswitch-return' => '<hr>
 61+Return to <span class="plainlinks">[$1 $2]</span>.',
6062 'prefswitch-main' => 'We\'ve been working hard to make things easier for our users. We\'re excited to share some improvements, including a new look and feel and simplified editing features. Improving the usability of the site is an ongoing effort here at Wikimedia and we\'ll be sharing more updates in the future.
6163
6264 Here\'s what we\'ve recently launched:
@@ -63,14 +65,15 @@
6466 * Editing toolbar improvements: We\'ve reorganized the editing toolbar to make easier to use. Now, formatting articles is simpler and more intuitive.
6567 * Link wizard: An easy-to-use tool allows you to add links to other Wikipedia articles as well as links to external sites.
6668 * Search improvements: We\'ve improved search suggestions to get you to the article you\'re looking for more quickly.
67 -* Other new features: We\'ve also introduced a table wizard to make creating tables easier and find and a replace feature to simplify article editing.
68 -
69 -Return to [$1 $2].',
 69+* Other new features: We\'ve also introduced a table wizard to make creating tables easier and find and a replace feature to simplify article editing.',
7070 'prefswitch-main-on' => '
7171 ;Feedback?
72 -We\'ve love to hear from you. Please visit our [$1 feedback page].
 72+We\'ve love to hear from you. Please visit our <span class="plainlinks">[$1 feedback page]</span>.
7373 ;Take me back!
74 -If you would like to turn off the new features, please [$2 click here].',
 74+If you would like to turn off the new features, please <span class="plainlinks">[$2 click here]</span>.',
 75+ 'prefswitch-main-off' => '
 76+;Try them out!
 77+If you would like to turn on the new features, please <span class="plainlinks">[$1 click here]</span>.',
7578 'prefswitch-survey-intro-feedback' => 'We\'d love to hear from you. Please fill out the optional survey below.',
7679 'prefswitch-survey-intro-off' => 'Thanks for trying out our new features. To help us improve them, please fill out the optional survey below ',
7780 );
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.php
@@ -32,9 +32,9 @@
3333 'usebetatoolbar-cgd'=> 0,
3434 ),
3535 'on' => array(
36 - 'skin' => null,
37 - 'usebetatoolbar' => null,
38 - 'usebetatoolbar-cgd' => null,
 36+ 'skin' => 'vector',
 37+ 'usebetatoolbar' => 1,
 38+ 'usebetatoolbar-cgd' => 1,
3939 ),
4040 );
4141
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php
@@ -14,7 +14,8 @@
1515 private $originTitle = null;
1616 private $originQuery = '';
1717 private $originLink = '';
18 - private $originUrl = '';
 18+ private $originLinkUrl = '';
 19+ private $originFullUrl = '';
1920
2021 /* Static Functions */
2122
@@ -39,7 +40,7 @@
4041 }
4142 // Swtiched on means any of the preferences in the set are turned on
4243 foreach ( $wgPrefSwitchPrefs['on'] as $pref => $value ) {
43 - if ( $pref != 'skin' && $user->getOption( $pref ) == $value ) {
 44+ if ( $user->getOption( $pref ) == $value ) {
4445 return true;
4546 }
4647 }
@@ -75,7 +76,7 @@
7677 wfLoadExtensionMessages( 'PrefSwitch' );
7778 }
7879 public function execute( $par ) {
79 - global $wgRequest, $wgOut, $wgUser, $wgPrefSwitchSurvey, $wgPrefSwitchStyleVersion;
 80+ global $wgRequest, $wgOut, $wgUser, $wgPrefSwitchSurveys, $wgPrefSwitchStyleVersion;
8081 // Get the origin from the request
8182 $par = $wgRequest->getVal( 'from', $par );
8283 $this->originTitle = Title::newFromText( $par );
@@ -92,7 +93,8 @@
9394 $this->origin = $this->originTitle->getPrefixedDBKey();
9495 $this->originQuery = $wgRequest->getVal( 'fromquery' );
9596 $this->originLink = $wgUser->getSkin()->link( $this->originTitle, null, array(), $this->originQuery );
96 - $this->originUrl = $this->originTitle->getLinkUrl( $this->originQuery );
 97+ $this->originLinkUrl = $this->originTitle->getLinkUrl( $this->originQuery );
 98+ $this->originFullUrl = $this->originTitle->getFullUrl( $this->originQuery );
9799 }
98100 // Begin output
99101 $this->setHeaders();
@@ -149,9 +151,9 @@
150152 // Switch off
151153 if ( self::checkToken() && self::isSwitchedOn( $wgUser ) && $wgRequest->wasPosted() ) {
152154 self::switchOff( $wgUser );
153 - PrefSwitchSurvey::save( 'feedback', $wgPrefSwitchSurveys['feedback'] );
 155+ PrefSwitchSurvey::save( 'off', $wgPrefSwitchSurveys['feedback'] );
154156 $wgOut->addWikiMsg( 'prefswitch-success-off' );
155 - } else if ( self::isSwitchedOn( $wgUser ) ) {
 157+ } else if ( !self::isSwitchedOn( $wgUser ) ) {
156158 // User is already switched off then reloaded the page or tried to switch off again
157159 $wgOut->addWikiMsg( 'prefswitch-success-off' );
158160 } else {
@@ -173,6 +175,9 @@
174176 } else {
175177 $this->render( 'main' );
176178 }
 179+ $wgOut->addWikiMsgArray(
 180+ 'prefswitch-return', array( $this->originFullUrl, $this->originTitle ), array( 'parse' )
 181+ );
177182 }
178183
179184 /* Private Functions */
@@ -212,18 +217,28 @@
213218 $html .= Xml::closeElement( 'form' );
214219 $wgOut->addHtml( $html );
215220 } else {
216 - $wgOut->addWikiMsgArray(
217 - 'prefswitch-main', array( $this->originUrl, $this->originTitle ), array( 'parse' )
 221+ $wgOut->addWikiMsg(
 222+ 'prefswitch-main', array( 'parse' )
218223 );
219224 if ( self::isSwitchedOn( $wgUser ) ) {
220225 $wgOut->addWikiMsgArray(
221226 'prefswitch-main-on',
222227 array(
223 - $this->getTitle()->getLinkURL( array_merge( $query, array( 'mode' => 'off' ) ) ),
224 - $this->getTitle()->getLinkURL( array_merge( $query, array( 'mode' => 'feedback' ) ) )
 228+ $this->getTitle()->getFullURL( array_merge( $query, array( 'mode' => 'feedback' ) ) ),
 229+ $this->getTitle()->getFullURL( array_merge( $query, array( 'mode' => 'off' ) ) )
225230 ),
226231 array( 'parse' )
227232 );
 233+ } else {
 234+ $wgOut->addWikiMsgArray(
 235+ 'prefswitch-main-off',
 236+ array(
 237+ $this->getTitle()->getFullURL(
 238+ array_merge( $query, array( 'mode' => 'on', 'token' => $wgUser->editToken() ) )
 239+ )
 240+ ),
 241+ array( 'parse' )
 242+ );
228243 }
229244 }
230245 }
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.sql
@@ -22,4 +22,4 @@
2323 pss_answer_data text NULL
2424 ) /*$wgDBTableOptions*/;
2525
26 -CREATE UNIQUE INDEX /*i*/pss_user_timestamp_question ON /*_*/prefswitch_survey (pss_user, pss_timestamp, pss_question);
 26+CREATE UNIQUE INDEX /*i*/pss_user_timestamp_question ON /*_*/prefswitch_survey (pss_user, pss_timestamp, pss_question, pss_name);

Status & tagging log