Merge "Update comment about enabled extensions"
[lhc/web/wiklou.git] / includes / installer / LocalSettingsGenerator.php
index 8724e0d..5a2dd1a 100644 (file)
@@ -34,6 +34,7 @@ class LocalSettingsGenerator {
        protected $groupPermissions = array();
        protected $dbSettings = '';
        protected $safeMode = false;
+       protected $IP;
 
        /**
         * @var Installer
@@ -50,12 +51,13 @@ class LocalSettingsGenerator {
 
                $this->extensions = $installer->getVar( '_Extensions' );
                $this->skins = $installer->getVar( '_Skins' );
+               $this->IP = $installer->getVar( 'IP' );
 
                $db = $installer->getDBInstaller( $installer->getVar( 'wgDBtype' ) );
 
                $confItems = array_merge(
                        array(
-                               'wgServer', 'wgScriptPath', 'wgScriptExtension',
+                               'wgServer', 'wgScriptPath',
                                'wgPasswordSender', 'wgImageMagickConvertCommand', 'wgShellLocale',
                                'wgLanguageCode', 'wgEnableEmail', 'wgEnableUserEmail', 'wgDiff3',
                                'wgEnotifUserTalk', 'wgEnotifWatchlist', 'wgEmailAuthentication',
@@ -143,8 +145,7 @@ class LocalSettingsGenerator {
 # The following skins were automatically enabled:\n";
 
                        foreach ( $this->skins as $skinName ) {
-                               $encSkinName = self::escapePhpString( $skinName );
-                               $localSettings .= "require_once \"\$IP/skins/$encSkinName/$encSkinName.php\";\n";
+                               $localSettings .= $this->generateExtEnableLine( 'skins', $skinName );
                        }
 
                        $localSettings .= "\n";
@@ -152,13 +153,13 @@ class LocalSettingsGenerator {
 
                if ( count( $this->extensions ) ) {
                        $localSettings .= "
-# Enabled Extensions. Most extensions are enabled by including the base extension file here
-# but check specific extension documentation for more details
+# Enabled extensions. Most of the extensions are enabled by adding
+# wfLoadExtensions('ExtensionName');
+# to LocalSettings.php. Check specific extension documentation for more details.
 # The following extensions were automatically enabled:\n";
 
                        foreach ( $this->extensions as $extName ) {
-                               $encExtName = self::escapePhpString( $extName );
-                               $localSettings .= "require_once \"\$IP/extensions/$encExtName/$encExtName.php\";\n";
+                               $localSettings .= $this->generateExtEnableLine( 'extensions', $extName );
                        }
 
                        $localSettings .= "\n";
@@ -171,6 +172,34 @@ class LocalSettingsGenerator {
                return $localSettings;
        }
 
+       /**
+        * Generate the appropriate line to enable the given extension or skin
+        *
+        * @param string $dir Either "extensions" or "skins"
+        * @param string $name Name of extension/skin
+        * @throws InvalidArgumentException
+        * @return string
+        */
+       private function generateExtEnableLine( $dir, $name ) {
+               if ( $dir === 'extensions' ) {
+                       $jsonFile = 'extension.json';
+                       $function = 'wfLoadExtension';
+               } elseif ( $dir === 'skins' ) {
+                       $jsonFile = 'skin.json';
+                       $function = 'wfLoadSkin';
+               } else {
+                       throw new InvalidArgumentException( '$dir was not "extensions" or "skins' );
+               }
+
+               $encName = self::escapePhpString( $name );
+
+               if ( file_exists( "{$this->IP}/$dir/$encName/$jsonFile" ) ) {
+                       return "$function( '$encName' );\n";
+               } else {
+                       return "require_once \"\$IP/$dir/$encName/$encName.php\";\n";
+               }
+       }
+
        /**
         * Write the generated LocalSettings to a file
         *
@@ -303,10 +332,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 ## (like /w/index.php/Page_title to /wiki/Page_title) please see:
 ## https://www.mediawiki.org/wiki/Manual:Short_URL
 \$wgScriptPath = \"{$this->values['wgScriptPath']}\";
-\$wgScriptExtension = \"{$this->values['wgScriptExtension']}\";
 ${serverSetting}
-## The relative URL path to the skins directory
-\$wgStylePath = \"\$wgScriptPath/skins\";
 
 ## The relative URL path to the logo.  Make sure you change this from the default,
 ## or else you'll overwrite your logo when you upgrade!
@@ -343,7 +369,7 @@ ${serverSetting}
 {$magic}\$wgUseImageMagick = true;
 {$magic}\$wgImageMagickConvertCommand = \"{$this->values['wgImageMagickConvertCommand']}\";
 
-# InstantCommons allows wiki to use images from http://commons.wikimedia.org
+# InstantCommons allows wiki to use images from https://commons.wikimedia.org
 \$wgUseInstantCommons = {$this->values['wgUseInstantCommons']};
 
 ## If you use ImageMagick (or any other shell command) on a