Merge "Fix trailing whitespace (and mixed spaces) in XSD files"
[lhc/web/wiklou.git] / includes / installer / WebInstallerPage.php
index 544f18c..b6e7717 100644 (file)
@@ -2,6 +2,21 @@
 /**
  * Base code for web installer pages.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup Deployment
  */
@@ -36,6 +51,7 @@ abstract class WebInstallerPage {
         * Is this a slow-running page in the installer? If so, WebInstaller will
         * set_time_limit(0) before calling execute(). Right now this only applies
         * to Install and Upgrade pages
+        * @return bool
         */
        public function isSlow() {
                return false;
@@ -161,6 +177,7 @@ class WebInstaller_Language extends WebInstallerPage {
                $userLang = $r->getVal( 'uselang' );
                $contLang = $r->getVal( 'ContLang' );
 
+               $languages = Language::fetchLanguageNames();
                $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
                if ( !$lifetime ) {
                        $lifetime = 1440; // PHP default
@@ -181,7 +198,6 @@ class WebInstaller_Language extends WebInstallerPage {
                                }
                                $this->parent->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
                        } else {
-                               $languages = Language::getLanguageNames();
                                if ( isset( $languages[$userLang] ) ) {
                                        $this->setVar( '_UserLang', $userLang );
                                }
@@ -232,7 +248,7 @@ class WebInstaller_Language extends WebInstallerPage {
                $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
                                'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
 
-               $languages = Language::getLanguageNames();
+               $languages = Language::fetchLanguageNames();
                ksort( $languages );
                foreach ( $languages as $code => $lang ) {
                        if ( isset( $wgDummyLanguageCodes[$code] ) ) continue;
@@ -280,7 +296,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                        $this->startForm();
                        $this->addHTML( $this->parent->getInfoBox(
                                wfMsgNoTrans( 'config-upgrade-key-missing',
-                                       "<pre>\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
+                                       "<pre dir=\"ltr\">\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
                        ) );
                        $this->endForm( 'continue' );
                        return 'output';
@@ -341,7 +357,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
 
        /**
         * Initiate an upgrade of the existing database
-        * @param $vars Variables from LocalSettings.php and AdminSettings.php
+        * @param $vars array Variables from LocalSettings.php and AdminSettings.php
         * @return Status
         */
        protected function handleExistingUpgrade( $vars ) {
@@ -1250,7 +1266,11 @@ abstract class WebInstaller_Document extends WebInstallerPage {
        }
 
        public function getFileContents() {
-               return file_get_contents( dirname( __FILE__ ) . '/../../' . $this->getFileName() );
+               $file = dirname( __FILE__ ) . '/../../' . $this->getFileName();
+               if( ! file_exists( $file ) ) {
+                       return wfMsgNoTrans( 'config-nofile', $file );
+               }
+               return file_get_contents( $file );
        }
 
 }
@@ -1260,7 +1280,15 @@ class WebInstaller_Readme extends WebInstaller_Document {
 }
 
 class WebInstaller_ReleaseNotes extends WebInstaller_Document {
-       protected function getFileName() { return 'RELEASE-NOTES'; }
+       protected function getFileName() {
+               global $wgVersion;
+
+               if(! preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
+                       throw new MWException('Variable $wgVersion has an invalid value.');
+               }
+
+               return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2];
+       }
 }
 
 class WebInstaller_UpgradeDoc extends WebInstaller_Document {