MediaWiki r44184 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r44183‎ | r44184 (on ViewVC)‎ | r44185 >
Date:19:16, 3 December 2008
Author:ialex
Status:ok
Tags:
Comment:
Added a search box at the top Special:ViewConfig to display versions for a specific wiki
Modified paths:

Diff [purge]

Index: trunk/extensions/Configure/SpecialViewConfig.php
===================================================================
--- trunk/extensions/Configure/SpecialViewConfig.php	(revision 44183)
+++ trunk/extensions/Configure/SpecialViewConfig.php	(revision 44184)
@@ -44,7 +44,6 @@
 				}
 
 				$this->version = $version;
-				$this->wiki = $wiki;
 
 				if ( $diff = $wgRequest->getVal( 'diff' ) ) {
 					if ( !in_array( $diff, $versions ) && $diff != 'default' ) {
@@ -82,7 +81,7 @@
 	 */
 	protected function showDiff() {
 		global $wgOut;
-		$wikis = $this->isUserAllowedAll() ? true : array( $this->wiki );
+		$wikis = $this->isUserAllowedAll() ? true : array( $this->mWiki );
 		$diffEngine = new HistoryConfigurationDiff( $this->diff, $this->version, $wikis );
 		$diffEngine->setViewCallback( array( $this, 'userCanRead' ) );
 		$wgOut->addHTML( $diffEngine->getHTML() );
@@ -117,16 +116,19 @@
 
 	/**
 	 * Build links to old version of the configuration
-	 *
 	 */
 	protected function buildOldVersionSelect() {
-		global $wgConf, $wgLang, $wgUser, $wgScript;
+		global $wgConf, $wgLang, $wgUser, $wgRequest, $wgScript;
 		if ( !$this->isWebConfig )
 			return '';
 
 		$self = $this->getTitle();
 		$pager = $wgConf->getPager();
 		$pager->setFormatCallback( array( $this, 'formatVersionRow' ) );
+
+		$wiki = $this->isUserAllowedInterwiki() && $wgRequest->getVal( 'view', 'all' ) == 'all' ? false : $this->mWiki;
+		$pager->setWiki( $wiki );
+
 		$showDiff = $pager->getNumRows() > 1;
 
 		$formatConf = array(
@@ -150,6 +152,8 @@
 		$this->formatConf = $formatConf;
 
 		$text = wfMsgExt( 'configure-old-versions', array( 'parse' ) );
+		if( $this->isUserAllowedInterwiki() )
+			$text .= $this->getWikiSelectForm();
 		$text .= $pager->getNavigationBar();
 		if ( $showDiff ) {
 			$text .= Xml::openElement( 'form', array( 'action' => $wgScript ) ) . "\n" .
@@ -259,6 +263,31 @@
 	}
 
 	/**
+	 * Get a form to select the wiki to configure
+	 */
+	protected function getWikiSelectForm() {
+		global $wgConfigureWikis, $wgScript, $wgRequest;
+		if ( $wgConfigureWikis === false || !$this->isUserAllowedInterwiki() )
+			return '';
+		$form = '<fieldset><legend>' . wfMsgHtml( 'configure-select-wiki' ) . '</legend>';
+		$form .= wfMsgExt( 'configure-select-wiki-view-desc', array( 'parse' ) );
+		$form .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
+		$form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBkey() );
+		if ( is_array( $wgConfigureWikis ) ) {
+			$form .= wfMsgExt( 'configure-select-wiki-available',
+				array( 'parse' ), implode( ', ', $wgConfigureWikis ) );
+		}
+		$all = ( $wgRequest->getVal( 'view', 'all' ) == 'all' );
+		$form .= Xml::radioLabel( wfMsg( 'configure-select-wiki-view-all' ), 'view', 'all', 'wiki-all', $all );
+		$form .= "<br />\n";
+		$form .= Xml::radioLabel( wfMsg( 'configure-select-wiki-view-specific' ), 'view', 'specific', 'wiki-specific', !$all ) . ' ';
+		$form .= Xml::input( 'wiki', false, $this->mWiki ) . "<br />\n";
+		$form .= Xml::submitButton( wfMsg( 'configure-select-wiki-submit' ) );
+		$form .= '</form></fieldset>';
+		return $form;
+	}
+
+	/**
 	 * Taken from PageHistory.php
 	 */
 	protected function getButton() {
Index: trunk/extensions/Configure/CHANGELOG
===================================================================
--- trunk/extensions/Configure/CHANGELOG	(revision 44183)
+++ trunk/extensions/Configure/CHANGELOG	(revision 44184)
@@ -5,6 +5,8 @@
   * JavaScript-based setting search in Special:Configure, Special:Extensions
     and Special:ViewConfig
   * Hidden settings now have a summary
+  * Added a search box at the top Special:ViewConfig to display versions for a
+    specific wiki
 
 0.10.12 - 2 December 2008
   * Fix a problem of duplicate files with the same timestamp if two users save
Index: trunk/extensions/Configure/Configure.i18n.php
===================================================================
--- trunk/extensions/Configure/Configure.i18n.php	(revision 44183)
+++ trunk/extensions/Configure/Configure.i18n.php	(revision 44184)
@@ -25,8 +25,8 @@
 	'configure-ext-settings'              => 'Settings',
 	'configure-ext-use-extension'         => 'Use this extension',
 	'configure-ext-use'                   => 'Use',
-	'configure-form-reason'		      => 'Reason for change:',
-	'configure-customised'		      => "''This setting has been customised''",
+	'configure-form-reason'               => 'Reason for change:',
+	'configure-customised'                => "''This setting has been customised''",
 
 	'configure-arrayinput-oneperline'     => "''(one per line)''",
 	'configure-summary'                   => 'This special page allows you to configure this wiki, see [http://www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings] for more information.',
@@ -46,10 +46,10 @@
 	'configure-js-get-image-url' 	      => 'Convert file name to URL',
 	'configure-js-image-error'            => 'An error occured while fetching the URL. Please check that the file exists.',
 	'configure-js-biglist-shown'	      => 'Setting details can be hidden',
-	'configure-js-biglist-hidden'	      => 'Setting details hidden',
-	'configure-js-biglist-show'	      => '[show details]',
-	'configure-js-biglist-hide'	      => '[hide details]',
-	'configure-js-summary-none'	      => 'No settings',
+	'configure-js-biglist-hidden'         => 'Setting details hidden',
+	'configure-js-biglist-show'           => '[show details]',
+	'configure-js-biglist-hide'           => '[hide details]',
+	'configure-js-summary-none'           => 'No settings',
 	'configure-js-search-legend'	      => 'Search settings',
 	'configure-js-search-prompt' 	      => 'Query: ',
 	'configure-no-diff'                   => 'There are no changes between selected versions.',
@@ -61,11 +61,11 @@
 	'configure-old'                       => 'Old versions',
 	'configure-old-versions'              => 'List of old versions of the configuration:',
 	'configure-old-not-available'         => 'The old version of the settings you requested, $1, is not available',
-	'configure-old-changes'		      => 'changes',
-	'configure-old-summary'		      => '$1 by $2 $4 $3',
+	'configure-old-changes'               => 'changes',
+	'configure-old-summary'               => '$1 by $2 $4 $3',
 	'configure-saved'                     => 'The configuration has been saved',
 	'configure-backlink'                  => 'Return to form',
-	'configure-section-robots'	      => 'Web crawlers',
+	'configure-section-robots'            => 'Web crawlers',
 	'configure-section-features'	      => 'Features',
 	'configure-section-general'           => 'General settings',
 	'configure-section-paths'             => 'Paths',
@@ -125,15 +125,18 @@
 	'configure-section-copyright'         => 'Copyright',
 	'configure-section-htcp'              => 'HTCP multicast',
 	'configure-section-misc'              => 'Miscellaneous',
-	'configure-section-filter' 	      => 'Filtering',
+	'configure-section-filter'            => 'Filtering',
 	'configure-section-mw-extensions'     => 'MediaWiki extensions',
 	'configure-section-external-tools'    => 'External tools',
 	'configure-section-filesystem'        => 'Filesystem and Shell interaction',
 	'configure-section-thumbnail'         => 'Image thumbnailing',
-	'configure-section-output'	      => 'Output',
+	'configure-section-output'            => 'Output',
 	'configure-select-wiki'               => 'Wiki selection',
 	'configure-select-wiki-available'     => 'Authorized values: $1',
 	'configure-select-wiki-desc'          => 'Select the wiki you want to configure.',
+	'configure-select-wiki-view-desc'     => 'Select a wiki for which you want to see the versions.',
+	'configure-select-wiki-view-all'      => 'All wikis',
+	'configure-select-wiki-view-specific' => 'Specific wiki:',
 	'configure-select-wiki-submit'        => 'Validate',
 	'configure-setting-not-available'     => 'This setting is not available in this version of MediaWiki',
 	'configure-transwiki-not-in-range'    => 'The requested wiki, $1, is not in allowed values ($2).',
@@ -141,7 +144,7 @@
 	'configure-view-all-versions'         => 'Full list of versions',
 	'configure-view-default'              => 'Default settings',
 	'configure-view-not-allowed'          => 'You are not allowed to see this setting',
-	'configure-viewconfig-line'	      => '$1 $2 by $3 $5: $4',
+	'configure-viewconfig-line'           => '$1 $2 by $3 $5: $4',
 	'extensions'                          => 'Configure the extensions',
 	'right-configure'                     => 'Configure the wiki',
 	'right-configure-all'                 => 'Configure all wiki settings',
@@ -1113,6 +1116,9 @@
 	'configure-select-wiki-available' => 'Valeurs autorisées : $1',
 	'configure-select-wiki-desc' => 'Sélectionnez le wiki que vous voulez configurer.',
 	'configure-select-wiki-submit' => 'Valider',
+	'configure-select-wiki-view-desc' => 'Sélectionnez le wiki pour lequel vous voulez voir les versions.',
+	'configure-select-wiki-view-all' => 'Tous les wikis',
+	'configure-select-wiki-view-specific' => 'Un wiki spécifique :',
 	'configure-setting-not-available' => "Ce paramètre n'est pas disponible sur cette version de MediaWiki",
 	'configure-transwiki-not-in-range' => "Le wiki demandé, $1, n'est pas dans les valeurs autorisées ($2).",
 	'configure-view' => 'Voir',
Index: trunk/extensions/Configure/Configure.pager-db.php
===================================================================
--- trunk/extensions/Configure/Configure.pager-db.php	(revision 44183)
+++ trunk/extensions/Configure/Configure.pager-db.php	(revision 44184)
@@ -8,7 +8,7 @@
  * @author Alexandre Emsenhuber
  */
 class ConfigurationPagerDb extends ReverseChronologicalPager {
-	protected $mHandler, $mCallback, $mCounter = 0;
+	protected $mHandler, $mCallback, $mCounter = 0, $mWiki = false;
 
 	function __construct( ConfigureHandlerDb $handler ) {
 		parent::__construct();
@@ -16,14 +16,22 @@
 		$this->mDb = $handler->getSlaveDB();
 	}
 
+	function setWiki( $wiki ) {
+		$this->mWiki = $wiki;
+	}
+
 	function getQueryInfo() {
-		$queryInfo = array(
+		$conds = array();
+		if( $this->mWiki ) {
+			$conds['cv_wiki'] = $this->mWiki;
+		}
+
+		return array(
 			'tables'  => array( 'config_version' ),
 			'fields'  => array( '*' ),
-			'conds'   => array(),
+			'conds'   => $conds,
 			'options' => array()
 		);
-		return $queryInfo;
 	}
 
 	function getIndexField() {
Index: trunk/extensions/Configure/Configure.pager-files.php
===================================================================
--- trunk/extensions/Configure/Configure.pager-files.php	(revision 44183)
+++ trunk/extensions/Configure/Configure.pager-files.php	(revision 44184)
@@ -7,14 +7,25 @@
  * @author Alexandre Emsenhuber
  */
 class ConfigurationPagerFiles implements Pager {
-	protected $mHandler, $mCallback;
+	protected $mHandler, $mCallback, $mWiki = false;
 
 	function __construct( ConfigureHandler $handler ) {
 		$this->mHandler = $handler;
 	}
 
+	function setWiki( $wiki ) {
+		$this->mWiki = $wiki;
+	}
+
+	function getVersionOptions() {
+		$ret = array();
+		if( $this->mWiki )
+			$ret['wiki'] = $this->mWiki;
+		return $ret;	
+	}
+
 	function getBody() {
-		$versions = $this->mHandler->getArchiveVersions();
+		$versions = $this->mHandler->getArchiveVersions( $this->getVersionOptions() );
 		if ( empty( $versions ) ) {
 			return wfMsgExt( 'configure-no-old', array( 'parse' ) );
 		}
@@ -39,13 +50,17 @@
 	}
 
 	function getNumRows() {
-		return count( $this->mHandler->listArchiveVersions() );
+		return count( $this->mHandler->listArchiveVersions( $this->getVersionOptions() ) );
 	}
 
 	function getNavigationBar() {
 		return '';
 	}
 
+	function getSearchForm() {
+		return '';
+	}
+
 	function setFormatCallback( $callback ) {
 		$this->mCallback = $callback;
 	}

Status & tagging log

Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox