Index: trunk/extensions/Configure/Configure.obj.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | protected $mWiki; // Wiki name |
13 | 13 | protected $mConf = array(); // Our array of settings |
14 | 14 | protected $mOldSettings = null; // Old settings (before applying our overrides) |
15 | | - protected $mDefaults = array(); // Default values |
| 15 | + protected $mDefaults = null; // Default values |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Construct a new object. |
— | — | @@ -84,14 +84,17 @@ |
85 | 85 | // Include files before so that customized settings won't be overridden |
86 | 86 | // by the default ones |
87 | 87 | $this->includeFiles(); |
88 | | - |
89 | | - // Snapshot current settings before overriding. |
90 | | - // -ialex tells me this weird contraption will work |
91 | | - $allSettings = array_keys( ConfigurationSettings::singleton( CONF_SETTINGS_BOTH )->getAllSettings() ); |
92 | | - |
93 | | - foreach( $allSettings as $setting ) { |
94 | | - if ( isset( $GLOBALS[$setting] ) ) |
95 | | - $this->mDefaults[$setting] = $GLOBALS[$setting]; |
| 88 | + |
| 89 | + if (!is_array($this->mDefaults)) { |
| 90 | + $this->mDefaults = array(); |
| 91 | + // Snapshot current settings before overriding. |
| 92 | + // -ialex tells me this weird contraption will work |
| 93 | + $allSettings = array_keys( ConfigurationSettings::singleton( CONF_SETTINGS_BOTH )->getAllSettings() ); |
| 94 | + |
| 95 | + foreach( $allSettings as $setting ) { |
| 96 | + if ( array_key_exists( $setting, $GLOBALS ) ) |
| 97 | + $this->mDefaults[$setting] = $GLOBALS[$setting]; |
| 98 | + } |
96 | 99 | } |
97 | 100 | |
98 | 101 | list( $site, $lang ) = $this->siteFromDB( $this->mWiki ); |
— | — | @@ -164,11 +167,15 @@ |
165 | 168 | |
166 | 169 | /** Recursive doohicky for normalising variables so we can compare them. */ |
167 | 170 | public static function filterVar( $var ) { |
| 171 | + if (empty($var) && !$var) { |
| 172 | + return null; |
| 173 | + } |
| 174 | + |
168 | 175 | if ( is_array( $var ) ) { |
169 | 176 | return array_filter( array_map( array( __CLASS__, 'filterVar' ), $var ) ); |
170 | 177 | } |
171 | 178 | |
172 | | - return $var; |
| 179 | + return trim($var); |
173 | 180 | } |
174 | 181 | |
175 | 182 | /** |
— | — | @@ -227,7 +234,7 @@ |
228 | 235 | foreach ( $keys as $setting ) { |
229 | 236 | if ( isset( $wikiDefaults[$setting] ) && !is_null( $wikiDefaults[$setting] ) ) |
230 | 237 | $ret[$setting] = $wikiDefaults[$setting]; |
231 | | - elseif ( isset( $globalDefaults[$setting] ) ) |
| 238 | + elseif ( array_key_exists( $setting, $globalDefaults ) ) |
232 | 239 | $ret[$setting] = $globalDefaults[$setting]; |
233 | 240 | } |
234 | 241 | return $ret; |
Index: trunk/extensions/Configure/Configure.page.php |
— | — | @@ -477,7 +477,7 @@ |
478 | 478 | $arrType = $this->getArrayType( $name ); |
479 | 479 | switch( $arrType ) { |
480 | 480 | case 'simple': |
481 | | - $text = trim($wgRequest->getText( 'wp' . $name )); |
| 481 | + $text = rtrim($wgRequest->getText( 'wp' . $name )); |
482 | 482 | if ( $text == '' ) |
483 | 483 | $arr = array(); |
484 | 484 | else |
— | — | @@ -524,7 +524,7 @@ |
525 | 525 | global $wgContLang; |
526 | 526 | $arr = array(); |
527 | 527 | foreach ( $wgContLang->getNamespaces() as $ns => $unused ) { |
528 | | - $arr[$ns] = trim( $wgRequest->getVal( 'wp' . $name . '-ns' . strval( $ns ) ) ); |
| 528 | + $arr[$ns] = $wgRequest->getVal( 'wp' . $name . '-ns' . strval( $ns ) ); |
529 | 529 | } |
530 | 530 | $settings[$name] = $arr; |
531 | 531 | break; |
— | — | @@ -543,7 +543,7 @@ |
544 | 544 | foreach ( $wgContLang->getNamespaces() as $ns => $unused ) { |
545 | 545 | if ( $ns < 0 ) |
546 | 546 | continue; |
547 | | - $text = trim( $wgRequest->getText( 'wp' . $name . '-ns' . strval( $ns ) ) ); |
| 547 | + $text = rtrim($wgRequest->getText( 'wp' . $name . '-ns' . strval( $ns ) ) ); |
548 | 548 | if ( $text == '' ) |
549 | 549 | $nsProtection = array(); |
550 | 550 | else |
— | — | @@ -617,7 +617,7 @@ |
618 | 618 | case 'text': |
619 | 619 | case 'lang': |
620 | 620 | case 'image-url': |
621 | | - $setting = trim( $wgRequest->getVal( 'wp' . $name ) ); |
| 621 | + $setting = $wgRequest->getVal( 'wp' . $name ); |
622 | 622 | |
623 | 623 | if ( $file = wfFindFile( $setting ) ) { |
624 | 624 | ## It's actually a local file. |
— | — | @@ -646,12 +646,13 @@ |
647 | 647 | } |
648 | 648 | } |
649 | 649 | |
650 | | - if ( isset( $settings[$name] ) ) { |
| 650 | + if ( array_key_exists( $name, $settings ) ) { |
651 | 651 | $settings[$name] = $this->cleanupSetting( $name, $settings[$name] ); |
652 | 652 | if ( $settings[$name] === null ) |
653 | 653 | unset( $settings[$name] ); |
654 | 654 | } |
655 | 655 | } |
| 656 | + |
656 | 657 | return $settings; |
657 | 658 | } |
658 | 659 | |
— | — | @@ -663,13 +664,27 @@ |
664 | 665 | * @return Mixed |
665 | 666 | */ |
666 | 667 | protected function cleanupSetting( $name, $val ) { |
| 668 | + global $wgConf; |
| 669 | + |
| 670 | + if (!empty($val) || $val) { |
| 671 | + return $val; |
| 672 | + } |
| 673 | + |
667 | 674 | static $list = null; |
668 | 675 | if ( $list === null ) |
669 | 676 | $list = $this->mConfSettings->getEmptyValues(); |
670 | | - if ( isset( $list[$name] ) && empty( $val ) ) |
| 677 | + |
| 678 | + static $defaults = null; |
| 679 | + if ($defaults === null) |
| 680 | + $defaults = $wgConf->getDefaultsForWiki( $this->mWiki ); |
| 681 | + |
| 682 | + if ( array_key_exists( $name, $list ) ) { |
671 | 683 | return $list[$name]; |
672 | | - else |
673 | | - return $val; |
| 684 | + } elseif ( !array_key_exists( $name, $defaults ) ) { |
| 685 | + return null; |
| 686 | + } elseif ( empty( $defaults[$name] ) ) { |
| 687 | + return $defaults[$name]; |
| 688 | + } |
674 | 689 | } |
675 | 690 | |
676 | 691 | /** |
— | — | @@ -928,7 +943,7 @@ |
929 | 944 | return '<code>' . htmlspecialchars( $default ) . '</code>'; |
930 | 945 | $ret = "\n"; |
931 | 946 | foreach ( $type as $val => $name ) { |
932 | | - $ret .= Xml::radioLabel( $name, 'wp' . $conf, $val, 'wp' . $conf . $val, $default == $val ) . "\n"; |
| 947 | + $ret .= Xml::radioLabel( $name, 'wp' . $conf, $val, 'wp' . $conf . $val, $default === $val ) . "\n"; |
933 | 948 | } |
934 | 949 | return $ret; |
935 | 950 | } |
— | — | @@ -1347,9 +1362,11 @@ |
1348 | 1363 | 'value' => $this->getSettingValue( $setting ), |
1349 | 1364 | 'link' => $showlink, |
1350 | 1365 | ); |
| 1366 | + |
| 1367 | + $customised = !array_key_exists( $setting, $defaults ); |
| 1368 | + $customised = $customised || ( WebConfiguration::filterVar( $defaults[$setting] ) != WebConfiguration::filterVar( $params['value'] ) ); |
1351 | 1369 | |
1352 | | - $params['customised'] = ( !isset( $defaults[$setting] ) || |
1353 | | - WebConfiguration::filterVar( $defaults[$setting] ) != WebConfiguration::filterVar( $params['value'] ) ); |
| 1370 | + $params['customised'] = $customised; |
1354 | 1371 | |
1355 | 1372 | $show = $this->mCanEdit ? |
1356 | 1373 | ( isset( $params['edit'] ) ? $params['edit'] : $this->userCanEdit( $setting ) ) : |
Index: trunk/extensions/Configure/Configure.diff.php |
— | — | @@ -145,8 +145,9 @@ |
146 | 146 | foreach ( $groupSettings as $setting => $type ) { |
147 | 147 | $oldSetting = isset( $old[$setting] ) ? $old[$setting] : null; |
148 | 148 | $newSetting = isset( $new[$setting] ) ? $new[$setting] : null; |
149 | | - if ( $oldSetting === $newSetting || !$this->isSettingViewable( $setting ) ) |
| 149 | + if ( $oldSetting === $newSetting || !$this->isSettingViewable( $setting ) ) { |
150 | 150 | continue; |
| 151 | + } |
151 | 152 | else |
152 | 153 | $groupDiff .= $this->processDiffSetting( $setting, $oldSetting, $newSetting, $type ) . "\n"; |
153 | 154 | } |
Index: trunk/extensions/Configure/Configure.settings-core.php |
— | — | @@ -853,12 +853,12 @@ |
854 | 854 | 'wgLocalMessageCache' => null, |
855 | 855 | 'wgInterwikiCache' => false, |
856 | 856 | 'wgReadOnly' => null, |
857 | | - 'wgRateLimitLog' => false, |
| 857 | + 'wgRateLimitLog' => null, |
858 | 858 | 'wgSessionName' => false, |
859 | 859 | 'wgHTTPProxy' => false, |
860 | 860 | 'wgSharedThumbnailScriptPath' => false, |
861 | 861 | 'wgSharedUploadDBname' => false, |
862 | | - 'wgMimeDetectorCommand' => false, |
| 862 | + 'wgMimeDetectorCommand' => null, |
863 | 863 | 'wgCustomConvertCommand' => false, |
864 | 864 | 'wgThumbnailScriptPath' => false, |
865 | 865 | 'wgDjvuDump' => null, |
— | — | @@ -875,6 +875,18 @@ |
876 | 876 | 'wgSearchForwardUrl' => null, |
877 | 877 | 'wgHTCPMulticastAddress' => false, |
878 | 878 | 'wgExternalDiffEngine' => false, |
| 879 | + 'wgSearchType' => null, |
| 880 | + 'wgLocaltimezone' => null, |
| 881 | + 'wgLocalTZoffset' => null, |
| 882 | + 'wgReadOnly' => null, |
| 883 | + 'wgDjvuDump' => null, |
| 884 | + 'wgAntivirus' => null, |
| 885 | + 'wgImportTargetNamespace' => null, |
| 886 | + 'wgCopyrightIcon' => null, |
| 887 | + 'wgSearchForwardUrl' => null, |
| 888 | + 'wgExemptFromUserRobotsControl' => null, |
| 889 | + 'wgArticlePath' => false, |
| 890 | + |
879 | 891 | ); |
880 | 892 | |
881 | 893 | /** |
Index: trunk/extensions/Configure/SpecialConfigure.php |
— | — | @@ -19,10 +19,12 @@ |
20 | 20 | protected function doSubmit() { |
21 | 21 | global $wgConf, $wgOut, $wgConfigureUpdateCacheEpoch, $wgUser, $wgRequest; |
22 | 22 | |
| 23 | + // These two lines left in and commented-out until I figure out what they're for. |
| 24 | + // They seem to break stuff :) |
23 | 25 | $reason = $wgRequest->getText( 'wpReason' ); |
24 | | - $current = $wgConf->getCurrent( $this->mWiki ); |
| 26 | +// $current = $wgConf->getCurrent( $this->mWiki ); |
25 | 27 | $settings = $this->importFromRequest(); |
26 | | - $settings += $current; |
| 28 | +// $settings += $current; |
27 | 29 | $settings = $this->removeDefaults( $settings ); |
28 | 30 | if ( $wgConfigureUpdateCacheEpoch ) |
29 | 31 | $settings['wgCacheEpoch'] = max( $settings['wgCacheEpoch'], wfTimestampNow() ); |