From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/installer/LocalSettingsGenerator.php | 87 +++++++++++++++++---------- 1 file changed, 56 insertions(+), 31 deletions(-) (limited to 'includes/installer/LocalSettingsGenerator.php') diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 53939826..c0ba300d 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -43,12 +43,13 @@ class LocalSettingsGenerator { /** * Constructor. * - * @param $installer Installer subclass + * @param Installer $installer */ public function __construct( Installer $installer ) { $this->installer = $installer; $this->extensions = $installer->getVar( '_Extensions' ); + $this->skins = $installer->getVar( '_Skins' ); $db = $installer->getDBInstaller( $installer->getVar( 'wgDBtype' ) ); @@ -105,9 +106,9 @@ class LocalSettingsGenerator { /** * Returns the escaped version of a string of php code. * - * @param $string String + * @param string $string * - * @return String + * @return string */ public static function escapePhpString( $string ) { if ( is_array( $string ) || is_object( $string ) ) { @@ -129,33 +130,42 @@ class LocalSettingsGenerator { /** * Return the full text of the generated LocalSettings.php file, - * including the extensions + * including the extensions and skins. * - * @return String + * @return string */ public function getText() { $localSettings = $this->getDefaultText(); + if ( count( $this->skins ) ) { + $localSettings .= " +# Enabled skins. +# 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 .= "\n"; + } + if ( count( $this->extensions ) ) { - $extensions = $this->installer->findExtensions(); $localSettings .= " # Enabled Extensions. Most extensions are enabled by including the base extension file here # but check specific extension documentation for more details # The following extensions were automatically enabled:\n"; - $ip = $this->installer->getVar( 'IP' ); - foreach ( $this->extensions as $ext) { - $path = str_replace( $ip, '', $extensions[$ext]['path'] ); - $prefix = ''; - if ( $path !== $extensions[$ext]['path'] ) { - $prefix = '$IP'; - } - $path = $prefix . self::escapePhpString( $path ); - $localSettings .= "require_once \"$path\";\n"; + foreach ( $this->extensions as $extName ) { + $encExtName = self::escapePhpString( $extName ); + $localSettings .= "require_once \"\$IP/extensions/$encExtName/$encExtName.php\";\n"; } + + $localSettings .= "\n"; } - $localSettings .= "\n\n# End of automatically generated settings. + $localSettings .= " +# End of automatically generated settings. # Add more configuration options below.\n\n"; return $localSettings; @@ -171,7 +181,7 @@ class LocalSettingsGenerator { } /** - * @return String + * @return string */ protected function buildMemcachedServerList() { $servers = $this->values['_MemCachedServers']; @@ -192,7 +202,7 @@ class LocalSettingsGenerator { } /** - * @return String + * @return string */ protected function getDefaultText() { if ( !$this->values['wgImageMagickConvertCommand'] ) { @@ -209,7 +219,6 @@ class LocalSettingsGenerator { $locale = ''; } - //$rightsUrl = $this->values['wgRightsUrl'] ? '' : '#'; // @todo FIXME: I'm unused! $hashedUploads = $this->safeMode ? '' : '#'; $metaNamespace = ''; if ( $this->values['wgMetaNamespace'] !== $this->values['wgSitename'] ) { @@ -217,6 +226,7 @@ class LocalSettingsGenerator { } $groupRights = ''; + $noFollow = ''; if ( $this->groupPermissions ) { $groupRights .= "# The following permissions were set based on your choice in the installer\n"; foreach ( $this->groupPermissions as $group => $rightArr ) { @@ -227,12 +237,28 @@ class LocalSettingsGenerator { wfBoolToStr( $perm ) . ";\n"; } } + $groupRights .= "\n"; + + if ( ( isset( $this->groupPermissions['*']['edit'] ) && + $this->groupPermissions['*']['edit'] === false ) + && ( isset( $this->groupPermissions['*']['createaccount'] ) && + $this->groupPermissions['*']['createaccount'] === false ) + && ( isset( $this->groupPermissions['*']['read'] ) && + $this->groupPermissions['*']['read'] !== false ) + ) { + $noFollow = "# Set \$wgNoFollowLinks to true if you open up your wiki to editing by\n" + . "# the general public and wish to apply nofollow to external links as a\n" + . "# deterrent to spammers. Nofollow is not a comprehensive anti-spam solution\n" + . "# and open wikis will generally require other anti-spam measures; for more\n" + . "# information, see https://www.mediawiki.org/wiki/Manual:Combating_spam\n" + . "\$wgNoFollowLinks = false;\n\n"; + } } - $wgServerSetting = ""; + $serverSetting = ""; if ( array_key_exists( 'wgServer', $this->values ) && $this->values['wgServer'] !== null ) { - $wgServerSetting = "\n## The protocol and server name to use in fully-qualified URLs\n"; - $wgServerSetting .= "\$wgServer = \"{$this->values['wgServer']}\";\n"; + $serverSetting = "\n## The protocol and server name to use in fully-qualified URLs\n"; + $serverSetting .= "\$wgServer = \"{$this->values['wgServer']}\";\n"; } switch ( $this->values['wgMainCacheType'] ) { @@ -259,7 +285,7 @@ class LocalSettingsGenerator { # file, not there. # # Further documentation for configuration settings may be found at: -# http://www.mediawiki.org/wiki/Manual:Configuration_settings +# https://www.mediawiki.org/wiki/Manual:Configuration_settings # Protect against web entry if ( !defined( 'MEDIAWIKI' ) ) { @@ -275,16 +301,16 @@ if ( !defined( 'MEDIAWIKI' ) ) { ## defaults for all runtime URL paths are based off of this. ## For more information on customizing the URLs ## (like /w/index.php/Page_title to /wiki/Page_title) please see: -## http://www.mediawiki.org/wiki/Manual:Short_URL +## https://www.mediawiki.org/wiki/Manual:Short_URL \$wgScriptPath = \"{$this->values['wgScriptPath']}\"; \$wgScriptExtension = \"{$this->values['wgScriptExtension']}\"; -${wgServerSetting} +${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! -\$wgLogo = \"{$this->values['wgLogo']}\"; +\$wgLogo = \"{$this->values['wgLogo']}\"; ## UPO means: this is also a user preference option @@ -345,10 +371,6 @@ ${wgServerSetting} # web installer while LocalSettings.php is in place \$wgUpgradeKey = \"{$this->values['wgUpgradeKey']}\"; -## Default skin: you can change the default skin. Use the internal symbolic -## names, ie 'cologneblue', 'monobook', 'vector': -\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\"; - ## For attaching licensing metadata to pages, and displaying an ## appropriate copyright notice / icon. GNU Free Documentation ## License and Creative Commons licenses are supported so far. @@ -360,6 +382,9 @@ ${wgServerSetting} # Path to the GNU diff3 utility. Used for conflict resolution. \$wgDiff3 = \"{$this->values['wgDiff3']}\"; -{$groupRights}"; +{$groupRights}{$noFollow}## Default skin: you can change the default skin. Use the internal symbolic +## names, ie 'vector', 'monobook': +\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\"; +"; } } -- cgit v1.2.2