r43992 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43991‎ | r43992 | r43993 >
Date:11:40, 27 November 2008
Author:ialex
Status:deferred
Tags:
Comment:
Added $wgConfigureExtensionsVar and $wgConfigureOnlyUseVarForExt to allow enabling extensions by setting a variable rather than directly include the file.
See Configure.php for further doc about those settings.
Modified paths:
  • /trunk/extensions/Configure/CHANGELOG (modified) (history)
  • /trunk/extensions/Configure/Configure.ext.php (modified) (history)
  • /trunk/extensions/Configure/Configure.php (modified) (history)
  • /trunk/extensions/Configure/Configure.settings.php (modified) (history)
  • /trunk/extensions/Configure/SpecialExtensions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/CHANGELOG
@@ -1,14 +1,19 @@
22 This file lists changes on this extension.
33 Localisation updates are done on betawiki and aren't listed here.
44
 5+0.10.9 - 27 November 2008
 6+ Added $wgConfigureExtensionsVar and $wgConfigureOnlyUseVarForExt to allow
 7+ enabling extensions by setting a variable rather than directly include the
 8+ file.
 9+
510 0.10.8 - 26 November 2008
6 - * Stopped displaying settings which can't be edited in Special:Configure.
7 - These can be viewed at Special:ViewConfig.
8 - * Introduced explicit whitelisting of settings, rather than blacklisting
9 - of other settings.
10 - * Some usability cleanup.
11 - * Fixed javascript bug with 'Delete this entry' buttons in previous version.
12 - * Fixed type of $wgRightsUrl
 11+ * Stopped displaying settings which can't be edited in Special:Configure.
 12+ These can be viewed at Special:ViewConfig.
 13+ * Introduced explicit whitelisting of settings, rather than blacklisting
 14+ of other settings.
 15+ * Some usability cleanup.
 16+ * Fixed javascript bug with 'Delete this entry' buttons in previous version.
 17+ * Fixed type of $wgRightsUrl
1318
1419 0.10.7 - 25 November 2008
1520 * Added diff links for the versions at the top of Special:Configure and
Index: trunk/extensions/Configure/Configure.settings.php
@@ -97,9 +97,11 @@
9898 if ( !isset( $extArr ) ) {
9999 $extArr = array();
100100 foreach ( $this->getAllExtensionsObjects() as $ext ) {
101 - $name = $ext->getName();
102 - if ( count( $ext->getSettings() ) )
103 - $extArr['mw-extensions'][$name] = $ext->getSettings();
 101+ $extSettings = $ext->getSettings();
 102+ if ( $ext->useVariable() )
 103+ $extSettings[$ext->getVariable()] = 'bool';
 104+ if ( count( $extSettings ) )
 105+ $extArr['mw-extensions'][$ext->getName()] = $extSettings;
104106 }
105107 }
106108 $ret += $extArr;
Index: trunk/extensions/Configure/Configure.ext.php
@@ -18,6 +18,7 @@
1919 protected $mDir;
2020 protected $mFile;
2121 protected $mDoc;
 22+ protected $mExtVar = null;
2223
2324 /**
2425 * Construct a new object.
@@ -25,6 +26,8 @@
2627 * @param array $conf
2728 */
2829 public function __construct( /*array*/ $conf ) {
 30+ global $wgConfigureExtensionsVar;
 31+
2932 $this->mName = $conf['name'];
3033 $this->mSettings = isset( $conf['settings'] ) ? $conf['settings'] : array();
3134 $this->mDbChange = isset( $conf['schema'] ) && $conf['schema'];
@@ -35,6 +38,9 @@
3639 $this->mViewRestricted = isset( $conf['view-restricted'] ) ? $conf['view-restricted'] : array();
3740 $this->mEditRestricted = isset( $conf['edit-restricted'] ) ? $conf['edit-restricted'] : array();
3841 $this->mDoc = isset( $conf['url'] ) ? $conf['url'] : null;
 42+ if ( isset( $wgConfigureExtensionsVar[$this->mName] ) ) {
 43+ $this->mExtVar = $wgConfigureExtensionsVar[$this->mName];
 44+ }
3945 }
4046
4147 /**
@@ -177,17 +183,38 @@
178184 * should be activated
179185 */
180186 public function getCheckName() {
181 - return 'wpUse' . $this->mName;
 187+ if( $this->useVariable() )
 188+ return 'wp'.$this->mExtVar;
 189+ else
 190+ return 'wpUse'.$this->mName;
182191 }
183192
 193+ /**
 194+ * Whether this extension
 195+ */
 196+ public function useVariable(){
 197+ return !is_null( $this->mExtVar );
 198+ }
 199+
 200+ /**
 201+ * Get the varibale for this extension
 202+ */
 203+ public function getVariable(){
 204+ return $this->mExtVar;
 205+ }
 206+
184207 /**
185208 * Is this extension activated?
186209 *
187210 * @return bool
188211 */
189212 public function isActivated() {
190 - global $wgConf;
191 - return in_array( $this->getFile(), $wgConf->getIncludedFiles() );
 213+ if( $this->useVariable() ) {
 214+ return isset( $GLOBALS[$this->getVariable()] ) && $GLOBALS[$this->getVariable()];
 215+ } else {
 216+ global $wgConf;
 217+ return in_array( $this->getFile(), $wgConf->getIncludedFiles() );
 218+ }
192219 }
193220
194221 /**
@@ -196,6 +223,11 @@
197224 * @return bool
198225 */
199226 public function isInstalled() {
 227+ if( $this->useVariable() )
 228+ return true;
 229+ global $wgConfigureOnlyUseVarForExt;
 230+ if( $wgConfigureOnlyUseVarForExt )
 231+ return false;
200232 return file_exists( $this->getFile() );
201233 }
202234 }
Index: trunk/extensions/Configure/Configure.php
@@ -2,7 +2,7 @@
33 if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 /**
6 - * Special page to allow users to configure the wiki by a web based interface
 6+ * Special page to allow users to configure the wiki via a web based interface
77 * Require MediaWiki version 1.13.0 or greater
88 *
99 * @file
@@ -17,7 +17,7 @@
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:Configure',
1919 'description' => 'Allow authorised users to configure the wiki via a web-based interface',
2020 'descriptionmsg' => 'configure-desc',
21 - 'version' => '0.10.8',
 21+ 'version' => '0.10.9',
2222 );
2323
2424 # Configuration part
@@ -84,6 +84,21 @@
8585 $wgConfigureAdditionalExtensions = array();
8686
8787 /**
 88+ * Allows to enable an extension by setting a variable instead of directly
 89+ * include the file.
 90+ * You'll need to handle the variable and include yourself the extension's file.
 91+ * Format is $wgConfigureExtensionsVar['ExtensionName'] = 'VarName';
 92+ */
 93+$wgConfigureExtensionsVar = array();
 94+
 95+/**
 96+ * If this true, extensions will be considered as installed *only* if they are
 97+ * defined in $wgConfigureExtensionsVar, Configure won't check anymore for
 98+ * extensions in the file system.
 99+ */
 100+$wgConfigureOnlyUseVarForExt = false;
 101+
 102+/**
88103 * Array of supplementary view restrictions. Format is
89104 * $wgConfigureViewRestrictions['wgSetting'] = array( 'right1', 'right2' );
90105 * if multiple rights are given, the user must have *all* of them to see the
Index: trunk/extensions/Configure/SpecialExtensions.php
@@ -54,9 +54,13 @@
5555 * @return array
5656 */
5757 protected function getRequiredFiles() {
58 - global $wgRequest;
 58+ global $wgRequest, $wgConfigureOnlyUseVarForExt;
 59+ if ( $wgConfigureOnlyUseVarForExt )
 60+ return array();
5961 $arr = array();
6062 foreach ( $this->mConfSettings->getAllExtensionsObjects() as $ext ) {
 63+ if ( $ext->useVariable() )
 64+ continue;
6165 if ( $wgRequest->getCheck( $ext->getCheckName() ) )
6266 $arr[] = $ext->getFile();
6367 }
@@ -88,7 +92,7 @@
8993 foreach ( $this->mConfSettings->getAllExtensionsObjects() as $ext ) {
9094 $settings = $ext->getSettings();
9195 foreach ( $settings as $setting => $type ) {
92 - if ( !isset( $GLOBALS[$setting] ) && !isset( $this->conf[$setting] ) ) {
 96+ if ( !isset( $GLOBALS[$setting] ) && !isset( $this->conf[$setting] ) && file_exists( $ext->getFile() ) ) {
9397 if ( !$globalDone ) {
9498 extract( $GLOBALS, EXTR_REFS );
9599 $__hooks__ = $wgHooks;

Status & tagging log