144 parent::__construct();
159 if ( isset(
$session[
'settings'] ) ) {
162 foreach ( $this->settings as $key => $val ) {
169 if ( ( $this->
getVar(
'_InstallDone' ) || $this->
getVar(
'_UpgradeDone' ) )
170 && $this->request->getVal(
'localsettings' )
176 $isCSS = $this->request->getVal(
'css' );
182 $this->happyPages =
$session[
'happyPages'] ?? [];
184 $this->skippedPages =
$session[
'skippedPages'] ?? [];
188 # Special case for Creative Commons partner chooser box.
189 if ( $this->request->getVal(
'SubmitCC' ) ) {
192 '@phan-var WebInstallerOptions $page';
193 $this->output->useShortHeader();
194 $this->output->allowFrames();
200 if ( $this->request->getVal(
'ShowCC' ) ) {
203 '@phan-var WebInstallerOptions $page';
204 $this->output->useShortHeader();
205 $this->output->allowFrames();
206 $this->output->addHTML( $page->getCCDoneBox() );
212 $pageName = $this->request->getVal(
'page' );
214 if ( in_array( $pageName, $this->otherPages ) ) {
220 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
221 $pageId = $lowestUnhappy;
223 $pageId = array_search( $pageName, $this->pageSequence );
226 # If necessary, move back to the lowest-numbered unhappy page
227 if ( $pageId > $lowestUnhappy ) {
228 $pageId = $lowestUnhappy;
229 if ( $lowestUnhappy == 0 ) {
230 # Knocked back to start, possible loss of session data.
231 $this->showSessionWarning =
true;
235 $pageName = $this->pageSequence[$pageId];
239 # If a back button was submitted, go back without submitting the form data.
240 if ( $this->request->wasPosted() && $this->request->getBool(
'submit-back' ) ) {
241 if ( $this->request->getVal(
'lastPage' ) ) {
242 $nextPage = $this->request->getVal(
'lastPage' );
243 } elseif ( $pageId !==
false ) {
245 # Skip the skipped pages
246 $nextPageId = $pageId;
250 $nextPage = $this->pageSequence[$nextPageId];
251 }
while ( isset( $this->skippedPages[$nextPage] ) );
253 $nextPage = $this->pageSequence[$lowestUnhappy];
256 $this->output->redirect( $this->
getUrl( [
'page' => $nextPage ] ) );
262 $this->currentPageName = $page->getName();
265 if ( $page->isSlow() ) {
269 $result = $page->execute();
273 if ( $result ==
'skip' ) {
274 # Page skipped without explicit submission.
275 # Skip it when we click "back" so that we don't just go forward again.
276 $this->skippedPages[$pageName] =
true;
277 $result =
'continue';
279 unset( $this->skippedPages[$pageName] );
282 # If it was posted, the page can request a continue to the next page.
283 if ( $result ===
'continue' && !$this->output->headerDone() ) {
284 if ( $pageId !==
false ) {
285 $this->happyPages[$pageId] =
true;
290 if ( $this->request->getVal(
'lastPage' ) ) {
291 $nextPage = $this->request->getVal(
'lastPage' );
292 } elseif ( $pageId !==
false ) {
293 $nextPage = $this->pageSequence[$pageId + 1];
295 $nextPage = $this->pageSequence[$lowestUnhappy];
298 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
299 $nextPage = $this->pageSequence[$lowestUnhappy];
302 $this->output->redirect( $this->
getUrl( [
'page' => $nextPage ] ) );
313 if ( count( $this->happyPages ) == 0 ) {
316 return max( array_keys( $this->happyPages ) ) + 1;
327 if (
wfIniGetBool(
'session.auto_start' ) || session_id() ) {
334 if ( $this->request->getProtocol() ===
'https' ) {
335 $options[
'cookie_secure'] =
'1';
338 $this->phpErrors = [];
339 set_error_handler( [ $this,
'errorHandler' ] );
341 session_name(
'mw_installer_session' );
342 session_start( $options );
343 }
catch ( Exception $e ) {
344 restore_error_handler();
347 restore_error_handler();
349 if ( $this->phpErrors ) {
366 $url = $this->request->getFullRequestURL();
367 if ( preg_match(
'!^(.*\?)!', $url, $m ) ) {
371 if ( preg_match(
'!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
378 'local path' => dirname( __DIR__ ),
391 if ( !( $msg instanceof
Message ) ) {
394 array_map(
'htmlspecialchars', $params )
397 $text = $msg->useDatabase(
false )->parse();
398 $box = Html::errorBox( $text,
'',
'config-error-box' );
399 $this->output->addHTML( $box );
409 $this->phpErrors[] = $errstr;
418 $this->output->output();
432 $this->happyPages = [];
433 $this->settings = [];
444 $url = $this->request->getRequestURL();
445 # Remove existing query
446 $url = preg_replace(
'/\?.*$/',
'', $url );
462 $pageClass =
'WebInstaller' . $pageName;
464 return new $pageClass( $this );
476 return $this->session[$name] ?? $default;
486 $this->session[$name] = $value;
495 return $this->tabIndex++;
504 if ( $this->
getSession(
'test' ) ===
null && !$this->request->wasPosted() ) {
506 $wgLang = MediaWikiServices::getInstance()->getLanguageFactory()
508 RequestContext::getMain()->setLanguage(
$wgLang );
509 $this->
setVar(
'wgLanguageCode', $wgLanguageCode );
510 $this->
setVar(
'_UserLang', $wgLanguageCode );
514 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
525 $mwLanguages = MediaWikiServices::getInstance()
526 ->getLanguageNameUtils()
527 ->getLanguageNames(
null,
'mwfile' );
528 $headerLanguages = array_keys(
$wgRequest->getAcceptLang() );
530 foreach ( $headerLanguages as
$lang ) {
531 if ( isset( $mwLanguages[
$lang] ) ) {
545 $s =
"<div class=\"config-page-wrapper\">\n";
546 $s .=
"<div class=\"config-page\">\n";
547 $s .=
"<div class=\"config-page-list\"><ul>\n";
550 foreach ( $this->pageSequence as $id => $pageName ) {
551 $happy = !empty( $this->happyPages[$id] );
554 $happy || $lastHappy == $id - 1,
563 $s .=
"</ul><br/><ul>\n";
566 $s .=
"</ul></div>\n";
573 $s .= Html::element(
'h2', [],
576 $this->output->addHTMLNoFlush(
$s );
589 $s =
"<li class=\"config-page-list-item\">";
596 $name =
wfMessage(
'config-page-' . strtolower( $pageName ) )->text();
599 $query = [
'page' => $pageName ];
601 if ( !in_array( $pageName, $this->pageSequence ) ) {
606 $link = Html::element(
'a',
608 'href' => $this->
getUrl( $query )
613 $link = htmlspecialchars( $name );
617 $s .=
"<span class=\"config-page-current\">$link</span>";
622 $s .= Html::element(
'span',
624 'class' =>
'config-page-disabled'
639 $this->output->addHTMLNoFlush(
640 "<div class=\"visualClear\"></div>\n" .
642 "<div class=\"visualClear\"></div>\n" .
654 public function getInfoBox( $text, $icon =
false, $class =
false ) {
656 HtmlArmor::getHtml( $text ) :
657 $this->
parse( $text,
true );
658 $icon = ( $icon == false ) ?
659 'images/info-32.png' :
661 $alt =
wfMessage(
'config-information' )->text();
663 return Html::infoBox( $html, $icon, $alt, $class );
675 $args = array_map(
'htmlspecialchars',
$args );
677 $html = $this->
parse( $text,
true );
678 $id =
'helpBox-' . $this->helpBoxId++;
680 return "<div class=\"config-help-field-container\">\n" .
681 "<input type=\"checkbox\" class=\"config-help-field-checkbox\" id=\"$id\" />" .
682 "<label class=\"config-help-field-hint\" for=\"$id\" title=\"" .
683 wfMessage(
'config-help-tooltip' )->escaped() .
"\">" .
684 wfMessage(
'config-help' )->escaped() .
"</label>\n" .
685 "<div class=\"config-help-field-data\">" . $html .
"</div>\n" .
695 $html = $this->
getHelpBox( $msg, ...$params );
696 $this->output->addHTML( $html );
707 $html =
'<div class="config-message">' .
708 $this->
parse(
wfMessage( $msg, $params )->useDatabase(
false )->plain() ) .
710 $this->output->addHTML( $html );
718 foreach ( $errors as $error ) {
733 public function label( $msg, $forId, $contents, $helpData =
"" ) {
734 if ( strval( $msg ) ==
'' ) {
735 $labelText =
"\u{00A0}";
737 $labelText =
wfMessage( $msg )->escaped();
740 $attributes = [
'class' =>
'config-label' ];
743 $attributes[
'for'] = $forId;
746 return "<div class=\"config-block\">\n" .
747 " <div class=\"config-block-label\">\n" .
754 " <div class=\"config-block-elements\">\n" .
775 if ( !isset( $params[
'controlName'] ) ) {
776 $params[
'controlName'] =
'config_' . $params[
'var'];
779 if ( !isset( $params[
'value'] ) ) {
780 $params[
'value'] = $this->
getVar( $params[
'var'] );
783 if ( !isset( $params[
'attribs'] ) ) {
784 $params[
'attribs'] = [];
786 if ( !isset( $params[
'help'] ) ) {
787 $params[
'help'] =
"";
792 $params[
'controlName'],
794 $params[
'controlName'],
797 $params[
'attribs'] + [
798 'id' => $params[
'controlName'],
799 'class' =>
'config-input-text',
822 if ( !isset( $params[
'controlName'] ) ) {
823 $params[
'controlName'] =
'config_' . $params[
'var'];
826 if ( !isset( $params[
'value'] ) ) {
827 $params[
'value'] = $this->
getVar( $params[
'var'] );
830 if ( !isset( $params[
'attribs'] ) ) {
831 $params[
'attribs'] = [];
833 if ( !isset( $params[
'help'] ) ) {
834 $params[
'help'] =
"";
839 $params[
'controlName'],
841 $params[
'controlName'],
845 $params[
'attribs'] + [
846 'id' => $params[
'controlName'],
847 'class' =>
'config-input-text',
871 if ( !isset( $params[
'value'] ) ) {
872 $params[
'value'] = $this->
getVar( $params[
'var'] );
875 if ( !isset( $params[
'attribs'] ) ) {
876 $params[
'attribs'] = [];
880 $params[
'attribs'][
'type'] =
'password';
901 if ( !isset( $params[
'controlName'] ) ) {
902 $params[
'controlName'] =
'config_' . $params[
'var'];
905 if ( !isset( $params[
'value'] ) ) {
906 $params[
'value'] = $this->
getVar( $params[
'var'] );
909 if ( !isset( $params[
'attribs'] ) ) {
910 $params[
'attribs'] = [];
912 if ( !isset( $params[
'help'] ) ) {
913 $params[
'help'] =
"";
915 if ( !isset( $params[
'labelAttribs'] ) ) {
916 $params[
'labelAttribs'] = [];
918 $labelText = $params[
'rawtext'] ?? $this->
parse(
wfMessage( $params[
'label'] )->plain() );
920 return "<div class=\"config-input-check\">\n" .
924 $params[
'labelAttribs'],
926 $params[
'controlName'],
928 $params[
'attribs'] + [
929 'id' => $params[
'controlName'],
960 $label = $params[
'label'] ??
'';
962 if ( !isset( $params[
'controlName'] ) ) {
963 $params[
'controlName'] =
'config_' . $params[
'var'];
966 if ( !isset( $params[
'help'] ) ) {
967 $params[
'help'] =
"";
971 foreach ( $items as $value => $item ) {
972 $s .=
"<li>$item</li>\n";
976 return $this->
label( $label, $params[
'controlName'],
$s, $params[
'help'] );
988 if ( !isset( $params[
'controlName'] ) ) {
989 $params[
'controlName'] =
'config_' . $params[
'var'];
992 if ( !isset( $params[
'value'] ) ) {
993 $params[
'value'] = $this->
getVar( $params[
'var'] );
998 foreach ( $params[
'values'] as $value ) {
1001 if ( isset( $params[
'commonAttribs'] ) ) {
1002 $itemAttribs = $params[
'commonAttribs'];
1005 if ( isset( $params[
'itemAttribs'][$value] ) ) {
1006 $itemAttribs = $params[
'itemAttribs'][$value] + $itemAttribs;
1009 $checked = $value == $params[
'value'];
1010 $id = $params[
'controlName'] .
'_' . $value;
1011 $itemAttribs[
'id'] = $id;
1015 Xml::radio( $params[
'controlName'], $value, $checked, $itemAttribs ) .
1017 Xml::tags(
'label', [
'for' => $id ], $this->
parse(
1018 isset( $params[
'itemLabels'] ) ?
1019 wfMessage( $params[
'itemLabels'][$value] )->plain() :
1020 wfMessage( $params[
'itemLabelPrefix'] . strtolower( $value ) )->plain()
1033 if ( !$status->isGood() ) {
1034 $html = $status->getHTML();
1036 if ( $status->isOK() ) {
1037 $box = Html::warningBox( $html,
'config-warning-box' );
1039 $box = Html::errorBox( $html,
'',
'config-error-box' );
1042 $this->output->addHTML( $box );
1059 foreach ( $varNames as $name ) {
1060 $value = $this->request->getVal( $prefix . $name );
1062 if ( $value !==
null && stripos( $name,
'password' ) ===
false ) {
1063 $value = trim( $value );
1065 $newValues[$name] = $value;
1067 if ( $value ===
null ) {
1069 $this->
setVar( $name,
false );
1070 } elseif ( stripos( $name,
'password' ) !==
false ) {
1073 $this->
setVar( $name, $value );
1088 $query = [
'page' => $page ];
1090 if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1094 return $this->
getUrl( $query );
1106 return Html::rawElement(
'li', [],
1107 Html::element(
'a', [
'href' => $url ], $linkText )
1118 $anchor = Html::rawElement(
'a',
1119 [
'href' => $this->
getUrl( [
'localsettings' => 1 ] ) ],
1123 return Html::rawElement(
'div', [
'class' =>
'config-download-link' ], $anchor );
1148 if ( !empty( $_SERVER[
'PHP_SELF'] ) ) {
1149 $path = $_SERVER[
'PHP_SELF'];
1150 } elseif ( !empty( $_SERVER[
'SCRIPT_NAME'] ) ) {
1151 $path = $_SERVER[
'SCRIPT_NAME'];
1153 if (
$path ===
false ) {
1158 return parent::envCheckPath();
1162 parent::envPrepPath();
1167 if ( !empty( $_SERVER[
'PHP_SELF'] ) ) {
1168 $path = $_SERVER[
'PHP_SELF'];
1169 } elseif ( !empty( $_SERVER[
'SCRIPT_NAME'] ) ) {
1170 $path = $_SERVER[
'SCRIPT_NAME'];
1172 if (
$path !==
false ) {
1173 $scriptPath = preg_replace(
'{^(.*)/(mw-)?config.*$}',
'$1',
$path );
1175 $this->
setVar(
'wgScriptPath',
"$scriptPath" );
1177 $this->
setVar(
'wgScript',
"$scriptPath/index.php" );
1178 $this->
setVar(
'wgLoadScript',
"$scriptPath/load.php" );
1179 $this->
setVar(
'wgStylePath',
"$scriptPath/skins" );
1180 $this->
setVar(
'wgLocalStylePath',
"$scriptPath/skins" );
1181 $this->
setVar(
'wgExtensionAssetsPath',
"$scriptPath/extensions" );
1182 $this->
setVar(
'wgUploadPath',
"$scriptPath/images" );
1183 $this->
setVar(
'wgResourceBasePath',
"$scriptPath" );
1191 return WebRequest::detectServer();
1200 $this->request->response()->header(
'Content-type: application/x-httpd-php' );
1201 $this->request->response()->header(
1202 'Content-Disposition: attachment; filename="LocalSettings.php"'
1206 $rightsProfile = $this->rightsProfiles[$this->
getVar(
'_RightsProfile' )];
1207 foreach ( $rightsProfile as $group => $rightsArr ) {
1208 $ls->setGroupRights( $group, $rightsArr );
1210 echo $ls->getText();
1217 $this->request->response()->header(
'Content-type: text/css' );
1218 echo $this->output->getCSS();
$wgLanguageCode
Site language code.
const MW_VERSION
The running version of MediaWiki.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(! $wgDBerrorLogTZ) $wgRequest
Marks HTML that shouldn't be escaped.
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
disableTimeLimit()
Disable the time limit for execution.
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
The Message class deals with fetching and processing of interface message into a variety of formats.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getErrorsArray()
Get the list of errors (but not warnings)
getWarningsArray()
Get the list of warnings (but not errors)
Output class modelled on OutputPage.
Class for the core installer web interface.
makeDownloadLinkHtml()
Helper for "Download LocalSettings" link.
setupLanguage()
Initializes language-related variables.
WebInstallerOutput $output
finish()
Clean up from execute()
getTextBox( $params)
Get a labelled text box to configure a variable.
getAcceptLanguage()
Retrieves MediaWiki language from Accept-Language HTTP header.
nextTabIndex()
Get the next tabindex attribute value.
startPageWrapper( $currentPageName)
Called by execute() before page output starts, to show a page list.
showStatusBox( $status)
Output an error or warning box using a Status object.
setVarsFromRequest( $varNames, $prefix='config_')
Convenience function to set variables based on form data.
getPageByName( $pageName)
Get a WebInstallerPage by name.
errorHandler( $errno, $errstr)
Temporary error handler for session start debugging.
bool[] $happyPages
Array of pages which have declared that they have been submitted, have validated their input,...
getSession( $name, $default=null)
Get a session variable.
outputCss()
Output stylesheet for web installer pages.
getLowestUnhappy()
Find the next page in sequence that hasn't been completed.
showHelpBox( $msg,... $params)
Output a help box.
label( $msg, $forId, $contents, $helpData="")
Label a control by wrapping a config-input div around it and putting a label before it.
execute(array $session)
Main entry point.
getLocalSettingsLocation()
If the software package wants the LocalSettings.php file to be placed in a specific location,...
getDocUrl( $page)
Helper for WebInstallerOutput.
bool[] $skippedPages
List of "skipped" pages.
endPageWrapper()
Output some stuff after a page is finished.
outputLS()
Actually output LocalSettings.php for download.
getRadioElements( $params)
Get a set of labelled radio buttons.
showMessage( $msg,... $params)
Show a short informational message.
showError( $msg,... $params)
Show an error message in a box.
setSession( $name, $value)
Set a session variable.
reset()
We're restarting the installation, reset the session, happyPages, etc.
string $currentPageName
Name of the page we're on.
getHelpBox( $msg,... $args)
Get small text indented help for a preceding form field.
getRadioSet( $params)
Get a set of labelled radio buttons.
getPasswordBox( $params)
Get a labelled password box to configure a variable.
WebRequest $request
WebRequest object.
__construct(WebRequest $request)
getTextArea( $params)
Get a labelled textarea to configure a variable.
getFingerprint()
Get a hash of data identifying this MW installation.
string[] $otherPages
Out of sequence pages, selectable by the user at any time.
string[] $pageSequence
The main sequence of page names.
string[] $phpErrors
Captured PHP error text.
bool $showSessionWarning
Flag indicating that session data may have been lost.
getPageListItem( $pageName, $enabled, $currentPageName)
Get a list item for the page list.
showStatusMessage(Status $status)
getCheckBox( $params)
Get a labelled checkbox to configure a boolean variable.
getInfoBox( $text, $icon=false, $class=false)
Get HTML for an information message box with an icon.
makeLinkItem( $url, $linkText)
Helper for sidebar links.
startSession()
Start the PHP session.
int $tabIndex
Numeric index of the page we're on.
array[] $session
Cached session array.
getUrl( $query=[])
Get a URL for submission back to the same script.
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
int $helpBoxId
Numeric index of the help box.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
if(!isset( $args[0])) $lang