r32890 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32889‎ | r32890 | r32891 >
Date:04:45, 7 April 2008
Author:aaron
Status:old
Tags:
Comment:
Inevitable preference bloat ;)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -14,7 +14,7 @@
1515 $wgExtensionCredits['specialpage'][] = array(
1616 'name' => 'Flagged Revisions',
1717 'author' => array( 'Aaron Schulz', 'Joerg Baach' ),
18 - 'version' => '1.026',
 18+ 'version' => '1.027',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs',
2020 'descriptionmsg' => 'flaggedrevs-desc',
2121 );
@@ -340,11 +340,12 @@
341341
342342 /**
343343 * Should this be using a simple icon-based UI?
 344+ * Check the user's preferences first, using the site settings as the default.
344345 */
345346 public static function useSimpleUI() {
346 - global $wgSimpleFlaggedRevsUI;
 347+ global $wgUser, $wgSimpleFlaggedRevsUI;
347348
348 - return $wgSimpleFlaggedRevsUI;
 349+ return $wgUser->getOption( 'flaggedrevssimpleui', intval($wgSimpleFlaggedRevsUI) );
349350 }
350351
351352 /**
@@ -1757,17 +1758,46 @@
17581759 * Add user preference to form HTML
17591760 */
17601761 public static function injectPreferences( $form, $out ) {
 1762+ global $wgUser;
 1763+
17611764 $out->addHTML(
17621765 Xml::openElement( 'fieldset' ) .
17631766 Xml::element( 'legend', null, wfMsgHtml('flaggedrevs-prefs') ) .
1764 - Xml::openElement( 'table' ) . Xml::openElement( 'tr' ) .
1765 - '<td>'.wfCheck( 'wpFlaggedRevsStable', $form->mFlaggedRevsStable,
1766 - array('id' => 'wpFlaggedRevsStable') ) . '</td>' .
1767 - '<td>' . wfLabel( wfMsg( 'flaggedrevs-prefs-stable' ), 'wpFlaggedRevsStable' ) . '</td>' .
1768 - Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' ) .
 1767+ Xml::openElement( 'table' ) .
 1768+ Xml::openElement( 'tr' ) .
 1769+ '<td>' . wfCheck( 'wpFlaggedRevsStable', $form->mFlaggedRevsStable,
 1770+ array('id' => 'wpFlaggedRevsStable') ) . '</td><td> ' .
 1771+ wfLabel( wfMsg( 'flaggedrevs-prefs-stable' ), 'wpFlaggedRevsStable' ) . '</td>' .
 1772+ Xml::closeElement( 'tr' ) .
 1773+ Xml::openElement( 'tr' ) .
 1774+ '<td>' .
 1775+ Xml::radio( 'wpFlaggedRevsSUI', 0, $form->mFlaggedRevsSUI==0, array('id' => 'standardUI') ) .
 1776+ '</td><td> ' .
 1777+ Xml::label( wfMsgHtml('flaggedrevs-pref-UI-0'), 'standardUI' ) .
 1778+ '</td>' .
 1779+ Xml::closeElement( 'tr' ) .
 1780+ Xml::openElement( 'tr' ) .
 1781+ '<td>' .
 1782+ Xml::radio( 'wpFlaggedRevsSUI', 1, $form->mFlaggedRevsSUI==1, array('id' => 'simpleUI') ) .
 1783+ '</td><td> ' .
 1784+ Xml::label( wfMsgHtml('flaggedrevs-pref-UI-1'), 'simpleUI' ) .
 1785+ '</td>'
 1786+ );
 1787+ if( $wgUser->isAllowed( 'review' ) ) {
 1788+ $out->addHTML(
 1789+ Xml::closeElement( 'tr' ) .
 1790+ Xml::openElement( 'tr' ) . '<td><br/></td>' . Xml::closeElement( 'tr' ) .
 1791+ Xml::openElement( 'tr' ) .
 1792+ '<td>' . wfCheck( 'wpFlaggedRevsWatch', $form->mFlaggedRevsWatch, array('id' => 'wpFlaggedRevsWatch') ) .
 1793+ '</td><td> ' . wfLabel( wfMsg( 'flaggedrevs-prefs-watch' ), 'wpFlaggedRevsWatch' ) . '</td>'
 1794+ );
 1795+ }
 1796+ $out->addHTML(
 1797+ Xml::closeElement( 'tr' ) .
 1798+ Xml::closeElement( 'table' ) .
17691799 Xml::closeElement( 'fieldset' )
17701800 );
1771 -
 1801+
17721802 return true;
17731803 }
17741804
@@ -1775,8 +1805,10 @@
17761806 * Add user preference to form object based on submission
17771807 */
17781808 public static function injectFormPreferences( $form, $request ) {
 1809+ global $wgUser;
17791810 $form->mFlaggedRevsStable = $request->getInt( 'wpFlaggedRevsStable' );
1780 -
 1811+ $form->mFlaggedRevsSUI = $request->getInt( 'wpFlaggedRevsSUI' );
 1812+ $form->mFlaggedRevsWatch = $wgUser->isAllowed( 'review' ) ? $request->getInt( 'wpFlaggedRevsWatch' ) : 0;
17811813 return true;
17821814 }
17831815
@@ -1784,8 +1816,10 @@
17851817 * Set preferences on form based on user settings
17861818 */
17871819 public static function resetPreferences( $form, $user ) {
 1820+ global $wgSimpleFlaggedRevsUI;
17881821 $form->mFlaggedRevsStable = $user->getOption( 'flaggedrevsstable' );
1789 -
 1822+ $form->mFlaggedRevsSUI = $user->getOption( 'flaggedrevssimpleui', intval($wgSimpleFlaggedRevsUI) );
 1823+ $form->mFlaggedRevsWatch = $user->getOption( 'flaggedrevswatch' );
17901824 return true;
17911825 }
17921826
@@ -1794,7 +1828,8 @@
17951829 */
17961830 public static function savePreferences( $form, $user, &$msg ) {
17971831 $user->setOption( 'flaggedrevsstable', $form->validateInt( $form->mFlaggedRevsStable, 0, 1 ) );
1798 -
 1832+ $user->setOption( 'flaggedrevssimpleui', $form->validateInt( $form->mFlaggedRevsSUI, 0, 1 ) );
 1833+ $user->setOption( 'flaggedrevswatch', $form->validateInt( $form->mFlaggedRevsWatch, 0, 1 ) );
17991834 return true;
18001835 }
18011836
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -220,6 +220,9 @@
221221
222222 'flaggedrevs-prefs' => 'Stability',
223223 'flaggedrevs-prefs-stable' => 'Always show the stable version of content pages by default (if there is one)',
 224+ 'flaggedrevs-prefs-watch' => 'Add pages I review to my watchlist',
 225+ 'flaggedrevs-pref-UI-0' => 'Use detailed stable version user interface',
 226+ 'flaggedrevs-pref-UI-1' => 'Use simple stable version user interface',
224227 );
225228
226229 /** Aragonese (Aragonés)
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -345,18 +345,20 @@
346346 global $wgFlaggedRevsOverride;
347347
348348 $wgOut->setPageTitle( wfMsgHtml('actioncomplete') );
349 -
 349+ # Show success message
350350 $msg = $approved ? 'revreview-successful' : 'revreview-successful2';
351351 $wgOut->addHtml( "<span class='plainlinks'>" .wfMsgExt( $msg, array('parseinline'),
352352 $this->page->getPrefixedText(), $this->page->getPrefixedUrl() ) . "</span>" );
353 -
354353 if( $wgFlaggedRevsOverride ) {
355354 $wgOut->addHtml( '<p>'.wfMsgExt( 'revreview-text', array('parseinline') ).'</p>' );
356355 } else {
357356 $wgOut->addHtml( '<p>'.wfMsgExt( 'revreview-text2', array('parseinline') ).'</p>' );
358357 }
359 -
360358 $wgOut->returnToMain( false, SpecialPage::getTitleFor( 'Recentchanges' ) );
 359+ # Watch page if set to do so
 360+ if( $wgUser->getOption('flaggedrevswatch') && !$this->page->userIsWatching() ) {
 361+ $wgUser->addWatch( $this->page );
 362+ }
361363 } else {
362364 $wgOut->showErrorPage( 'internalerror', 'revreview-changed', array($this->page->getPrefixedText()) );
363365 }

Status & tagging log