X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Finstaller%2FWebInstaller.php;h=4f31195e8495b6b7400b550b97d2efdbfb3308c4;hb=4190fe5b697d927427d8026177d479f582e933aa;hp=add4e895d3c7425ab71bd7f93851006d32830440;hpb=b9c560f34324745f887eb8bc83ae87723ac3559f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index add4e895d3..4f31195e84 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -2,6 +2,21 @@ /** * Core installer web interface. * + * 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 */ @@ -146,7 +161,11 @@ class WebInstaller extends Installer { 'Content-Disposition: attachment; filename="LocalSettings.php"' ); - $ls = new LocalSettingsGenerator( $this ); + $ls = InstallerOverrides::getLocalSettingsGenerator( $this ); + $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )]; + foreach( $rightsProfile as $group => $rightsArr ) { + $ls->setGroupRights( $group, $rightsArr ); + } echo $ls->getText(); return $this->session; } @@ -177,6 +196,7 @@ class WebInstaller extends Installer { if ( $this->request->getVal( 'SubmitCC' ) ) { $page = $this->getPageByName( 'Options' ); $this->output->useShortHeader(); + $this->output->allowFrames(); $page->submitCC(); return $this->finish(); } @@ -184,6 +204,7 @@ class WebInstaller extends Installer { if ( $this->request->getVal( 'ShowCC' ) ) { $page = $this->getPageByName( 'Options' ); $this->output->useShortHeader(); + $this->output->allowFrames(); $this->output->addHTML( $page->getCCDoneBox() ); return $this->finish(); } @@ -241,6 +262,10 @@ class WebInstaller extends Installer { $this->currentPageName = $page->getName(); $this->startPageWrapper( $pageName ); + if( $page->isSlow() ) { + $this->disableTimeLimit(); + } + $result = $page->execute(); $this->endPageWrapper(); @@ -294,6 +319,8 @@ class WebInstaller extends Installer { /** * Start the PHP session. This may be called before execute() to start the PHP session. + * + * @return bool */ public function startSession() { if( wfIniGetBool( 'session.auto_start' ) || session_id() ) { @@ -319,11 +346,19 @@ class WebInstaller extends Installer { * * This is used by mw-config/index.php to prevent multiple installations of MW * on the same cookie domain from interfering with each other. + * + * @return string */ public function getFingerprint() { // Get the base URL of the installation $url = $this->request->getFullRequestURL(); + if ( preg_match( '!^(.*\?)!', $url, $m) ) { + // Trim query string + $url = $m[1]; + } if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) { + // This... seems to try to get the base path from + // the /mw-config/index.php. Kinda scary though? $url = $m[1]; } return md5( serialize( array( @@ -335,6 +370,7 @@ class WebInstaller extends Installer { /** * Show an error message in a box. Parameters are like wfMsg(). + * @param $msg */ public function showError( $msg /*...*/ ) { $args = func_get_args(); @@ -346,6 +382,8 @@ class WebInstaller extends Installer { /** * Temporary error handler for session start debugging. + * @param $errno + * @param $errstr string */ public function errorHandler( $errno, $errstr ) { $this->phpErrors[] = $errstr; @@ -378,7 +416,7 @@ class WebInstaller extends Installer { /** * Get a URL for submission back to the same script. * - * @param $query: Array + * @param $query array * @return string */ public function getUrl( $query = array() ) { @@ -400,9 +438,6 @@ class WebInstaller extends Installer { * @return WebInstallerPage */ public function getPageByName( $pageName ) { - // Totally lame way to force autoload of WebInstallerPage.php - class_exists( 'WebInstallerPage' ); - $pageClass = 'WebInstaller_' . $pageName; return new $pageClass( $this ); @@ -413,6 +448,7 @@ class WebInstaller extends Installer { * * @param $name String * @param $default + * @return null */ public function getSession( $name, $default = null ) { if ( !isset( $this->session[$name] ) ) { @@ -452,7 +488,6 @@ class WebInstaller extends Installer { $this->setVar( '_UserLang', $wgLanguageCode ); } else { $wgLanguageCode = $this->getVar( 'wgLanguageCode' ); - $wgLang = Language::factory( $this->getVar( '_UserLang' ) ); $wgContLang = Language::factory( $wgLanguageCode ); } } @@ -465,7 +500,7 @@ class WebInstaller extends Installer { public function getAcceptLanguage() { global $wgLanguageCode, $wgRequest; - $mwLanguages = Language::getLanguageNames(); + $mwLanguages = Language::fetchLanguageNames(); $headerLanguages = array_keys( $wgRequest->getAcceptLang() ); foreach ( $headerLanguages as $lang ) { @@ -575,6 +610,8 @@ class WebInstaller extends Installer { * Get HTML for an error box with an icon. * * @param $text String: wikitext, get this with wfMsgNoTrans() + * + * @return string */ public function getErrorBox( $text ) { return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' ); @@ -584,6 +621,8 @@ class WebInstaller extends Installer { * Get HTML for a warning box with an icon. * * @param $text String: wikitext, get this with wfMsgNoTrans() + * + * @return string */ public function getWarningBox( $text ) { return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' ); @@ -595,42 +634,34 @@ class WebInstaller extends Installer { * @param $text String: wikitext, get this with wfMsgNoTrans() * @param $icon String: icon name, file in skins/common/images * @param $class String: additional class name to add to the wrapper div + * + * @return string */ - public function getInfoBox( $text, $icon = 'info-32.png', $class = false ) { - $s = - "
\n" . - "
\n" . - Html::element( 'img', - array( - 'src' => '../skins/common/images/' . $icon, - 'alt' => wfMsg( 'config-information' ), - ) - ) . "\n" . - "
\n" . - "
\n" . - $this->parse( $text, true ) . "\n" . - "
\n" . - "
\n" . - "
\n"; - return $s; + public function getInfoBox( $text, $icon = false, $class = false ) { + $text = $this->parse( $text, true ); + $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/'.$icon; + $alt = wfMsg( 'config-information' ); + return Html::infoBox( $text, $icon, $alt, $class, false ); } /** * Get small text indented help for a preceding form field. * Parameters like wfMsg(). + * + * @param $msg + * @return string */ public function getHelpBox( $msg /*, ... */ ) { $args = func_get_args(); array_shift( $args ); $args = array_map( 'htmlspecialchars', $args ); $text = wfMsgReal( $msg, $args, false, false, false ); - $html = htmlspecialchars( $text ); $html = $this->parse( $text, true ); return "
\n" . - "" . wfMsgHtml( 'config-help' ) . "\n" . - "" . $html . "\n" . - "
\n"; + "" . wfMsgHtml( 'config-help' ) . "\n" . + "" . $html . "\n" . + "\n"; } /** @@ -662,17 +693,21 @@ class WebInstaller extends Installer { * @param $status Status */ public function showStatusMessage( Status $status ) { - $text = $status->getWikiText(); - $this->output->addWikiText( - "
\n" . - $text . - "
" - ); + $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() ); + foreach ( $errors as $error ) { + call_user_func_array( array( $this, 'showMessage' ), $error ); + } } /** * Label a control by wrapping a config-input div around it and putting a * label before it. + * + * @param $msg + * @param $forId + * @param $contents + * @param $helpData string + * @return string */ public function label( $msg, $forId, $contents, $helpData = "" ) { if ( strval( $msg ) == '' ) { @@ -712,6 +747,8 @@ class WebInstaller extends Installer { * controlName: The name for the input element (optional) * value: The current value of the variable (optional) * help: The html for the help text (optional) + * + * @return string */ public function getTextBox( $params ) { if ( !isset( $params['controlName'] ) ) { @@ -757,6 +794,8 @@ class WebInstaller extends Installer { * controlName: The name for the input element (optional) * value: The current value of the variable (optional) * help: The html for the help text (optional) + * + * @return string */ public function getTextArea( $params ) { if ( !isset( $params['controlName'] ) ) { @@ -804,6 +843,8 @@ class WebInstaller extends Installer { * controlName: The name for the input element (optional) * value: The current value of the variable (optional) * help: The html for the help text (optional) + * + * @return string */ public function getPasswordBox( $params ) { if ( !isset( $params['value'] ) ) { @@ -831,6 +872,8 @@ class WebInstaller extends Installer { * controlName: The name for the input element (optional) * value: The current value of the variable (optional) * help: The html for the help text (optional) + * + * @return string */ public function getCheckBox( $params ) { if ( !isset( $params['controlName'] ) ) { @@ -884,6 +927,8 @@ class WebInstaller extends Installer { * controlName: The name for the input element (optional) * value: The current value of the variable (optional) * help: The html for the help text (optional) + * + * @return string */ public function getRadioSet( $params ) { if ( !isset( $params['controlName'] ) ) { @@ -936,6 +981,8 @@ class WebInstaller extends Installer { /** * Output an error or warning box using a Status object. + * + * @param $status Status */ public function showStatusBox( $status ) { if( !$status->isGood() ) { @@ -958,6 +1005,8 @@ class WebInstaller extends Installer { * * @param $varNames Array * @param $prefix String: the prefix added to variables to obtain form names + * + * @return array */ public function setVarsFromRequest( $varNames, $prefix = 'config_' ) { $newValues = array(); @@ -983,6 +1032,9 @@ class WebInstaller extends Installer { /** * Helper for Installer::docLink() + * + * @param $page + * @return string */ protected function getDocUrl( $page ) { $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page ); @@ -996,6 +1048,11 @@ class WebInstaller extends Installer { /** * Extension tag hook for a documentation link. + * + * @param $linkText + * @param $attribs + * @param $parser + * @return string */ public function docLink( $linkText, $attribs, $parser ) { $url = $this->getDocUrl( $attribs['href'] ); @@ -1003,9 +1060,13 @@ class WebInstaller extends Installer { htmlspecialchars( $linkText ) . ''; } - + /** * Helper for "Download LocalSettings" link on WebInstall_Complete + * + * @param $text + * @param $attribs + * @param $parser * @return String Html for download link */ public function downloadLinkHook( $text, $attribs, $parser ) { @@ -1019,4 +1080,31 @@ class WebInstaller extends Installer { $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) ); return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor ); } + + /** + * @return bool + */ + public function envCheckPath( ) { + // PHP_SELF isn't available sometimes, such as when PHP is CGI but + // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME + // to get the path to the current script... hopefully it's reliable. SIGH + $path = false; + if ( !empty( $_SERVER['PHP_SELF'] ) ) { + $path = $_SERVER['PHP_SELF']; + } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) { + $path = $_SERVER['SCRIPT_NAME']; + } + if ($path !== false) { + $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path ); + $this->setVar( 'wgScriptPath', $uri ); + } else { + $this->showError( 'config-no-uri' ); + return false; + } + return parent::envCheckPath(); + } + + protected function envGetDefaultServer() { + return WebRequest::detectServer(); + } }