Go to the documentation of this file.
145 parent::__construct();
160 if ( isset(
$session[
'settings'] ) ) {
163 foreach ( $this->settings as $key => $val ) {
170 if ( ( $this->
getVar(
'_InstallDone' ) || $this->
getVar(
'_UpgradeDone' ) )
171 && $this->request->getVal(
'localsettings' )
177 $isCSS = $this->request->getVal(
'css' );
183 $this->happyPages =
$session[
'happyPages'] ?? [];
185 $this->skippedPages =
$session[
'skippedPages'] ?? [];
189 # Special case for Creative Commons partner chooser box.
190 if ( $this->request->getVal(
'SubmitCC' ) ) {
193 '@phan-var WebInstallerOptions $page';
194 $this->output->useShortHeader();
195 $this->output->allowFrames();
201 if ( $this->request->getVal(
'ShowCC' ) ) {
204 '@phan-var WebInstallerOptions $page';
205 $this->output->useShortHeader();
206 $this->output->allowFrames();
207 $this->output->addHTML( $page->getCCDoneBox() );
213 $pageName = $this->request->getVal(
'page' );
215 if ( in_array( $pageName, $this->otherPages ) ) {
221 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
222 $pageId = $lowestUnhappy;
224 $pageId = array_search( $pageName, $this->pageSequence );
227 # If necessary, move back to the lowest-numbered unhappy page
228 if ( $pageId > $lowestUnhappy ) {
229 $pageId = $lowestUnhappy;
230 if ( $lowestUnhappy == 0 ) {
231 # Knocked back to start, possible loss of session data.
232 $this->showSessionWarning =
true;
236 $pageName = $this->pageSequence[$pageId];
240 # If a back button was submitted, go back without submitting the form data.
241 if ( $this->request->wasPosted() && $this->request->getBool(
'submit-back' ) ) {
242 if ( $this->request->getVal(
'lastPage' ) ) {
243 $nextPage = $this->request->getVal(
'lastPage' );
244 } elseif ( $pageId !==
false ) {
246 # Skip the skipped pages
247 $nextPageId = $pageId;
251 $nextPage = $this->pageSequence[$nextPageId];
252 }
while ( isset( $this->skippedPages[$nextPage] ) );
254 $nextPage = $this->pageSequence[$lowestUnhappy];
257 $this->output->redirect( $this->
getUrl( [
'page' => $nextPage ] ) );
263 $this->currentPageName = $page->getName();
266 if ( $page->isSlow() ) {
270 $result = $page->execute();
274 if ( $result ==
'skip' ) {
275 # Page skipped without explicit submission.
276 # Skip it when we click "back" so that we don't just go forward again.
277 $this->skippedPages[$pageName] =
true;
278 $result =
'continue';
280 unset( $this->skippedPages[$pageName] );
283 # If it was posted, the page can request a continue to the next page.
284 if ( $result ===
'continue' && !$this->output->headerDone() ) {
285 if ( $pageId !==
false ) {
286 $this->happyPages[$pageId] =
true;
291 if ( $this->request->getVal(
'lastPage' ) ) {
292 $nextPage = $this->request->getVal(
'lastPage' );
293 } elseif ( $pageId !==
false ) {
294 $nextPage = $this->pageSequence[$pageId + 1];
296 $nextPage = $this->pageSequence[$lowestUnhappy];
299 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
300 $nextPage = $this->pageSequence[$lowestUnhappy];
303 $this->output->redirect( $this->
getUrl( [
'page' => $nextPage ] ) );
314 if ( count( $this->happyPages ) == 0 ) {
317 return max( array_keys( $this->happyPages ) ) + 1;
328 if (
wfIniGetBool(
'session.auto_start' ) || session_id() ) {
333 $this->phpErrors = [];
334 set_error_handler( [ $this,
'errorHandler' ] );
336 session_name(
'mw_installer_session' );
338 }
catch ( Exception $e ) {
339 restore_error_handler();
342 restore_error_handler();
344 if ( $this->phpErrors ) {
361 $url = $this->request->getFullRequestURL();
362 if ( preg_match(
'!^(.*\?)!', $url, $m ) ) {
366 if ( preg_match(
'!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
373 'local path' => dirname( __DIR__ ),
386 if ( !( $msg instanceof
Message ) ) {
389 array_map(
'htmlspecialchars', $params )
392 $text = $msg->useDatabase(
false )->plain();
393 $box = Html::errorBox( $text,
'',
'config-error-box' );
394 $this->output->addHTML( $box );
404 $this->phpErrors[] = $errstr;
413 $this->output->output();
427 $this->happyPages = [];
428 $this->settings = [];
439 $url = $this->request->getRequestURL();
440 # Remove existing query
441 $url = preg_replace(
'/\?.*$/',
'', $url );
457 $pageClass =
'WebInstaller' . $pageName;
459 return new $pageClass( $this );
471 return $this->session[$name] ?? $default;
481 $this->session[$name] = $value;
490 return $this->tabIndex++;
499 if ( $this->
getSession(
'test' ) ===
null && !$this->request->wasPosted() ) {
503 $this->
setVar(
'wgLanguageCode', $wgLanguageCode );
504 $this->
setVar(
'_UserLang', $wgLanguageCode );
508 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
520 $headerLanguages = array_keys(
$wgRequest->getAcceptLang() );
522 foreach ( $headerLanguages as
$lang ) {
523 if ( isset( $mwLanguages[
$lang] ) ) {
537 $s =
"<div class=\"config-page-wrapper\">\n";
538 $s .=
"<div class=\"config-page\">\n";
539 $s .=
"<div class=\"config-page-list\"><ul>\n";
542 foreach ( $this->pageSequence as $id => $pageName ) {
543 $happy = !empty( $this->happyPages[$id] );
546 $happy || $lastHappy == $id - 1,
555 $s .=
"</ul><br/><ul>\n";
558 $s .=
"</ul></div>\n";
565 $s .= Html::element(
'h2', [],
568 $this->output->addHTMLNoFlush(
$s );
581 $s =
"<li class=\"config-page-list-item\">";
588 $name =
wfMessage(
'config-page-' . strtolower( $pageName ) )->text();
591 $query = [
'page' => $pageName ];
593 if ( !in_array( $pageName, $this->pageSequence ) ) {
598 $link = Html::element(
'a',
600 'href' => $this->
getUrl( $query )
605 $link = htmlspecialchars( $name );
609 $s .=
"<span class=\"config-page-current\">$link</span>";
614 $s .= Html::element(
'span',
616 'class' =>
'config-page-disabled'
631 $this->output->addHTMLNoFlush(
632 "<div class=\"visualClear\"></div>\n" .
634 "<div class=\"visualClear\"></div>\n" .
648 return $this->
getInfoBox( $text,
'critical-32.png',
'config-error-box' );
661 return $this->
getInfoBox( $text,
'warning-32.png',
'config-warning-box' );
673 public function getInfoBox( $text, $icon =
false, $class =
false ) {
677 $this->
parse( $text,
true );
678 $icon = ( $icon == false ) ?
679 'images/info-32.png' :
681 $alt =
wfMessage(
'config-information' )->text();
683 return Html::infoBox( $html, $icon, $alt, $class );
694 $args = array_map(
'htmlspecialchars',
$args );
696 $html = $this->
parse( $text,
true );
697 $id =
'helpBox-' . $this->helpBoxId++;
699 return "<div class=\"config-help-field-container\">\n" .
700 "<input type=\"checkbox\" class=\"config-help-field-checkbox\" id=\"$id\" />" .
701 "<label class=\"config-help-field-hint\" for=\"$id\" title=\"" .
702 wfMessage(
'config-help-tooltip' )->escaped() .
"\">" .
703 wfMessage(
'config-help' )->escaped() .
"</label>\n" .
704 "<div class=\"config-help-field-data\">" . $html .
"</div>\n" .
714 $html = $this->
getHelpBox( $msg, ...$params );
715 $this->output->addHTML( $html );
726 $html =
'<div class="config-message">' .
727 $this->
parse(
wfMessage( $msg, $params )->useDatabase(
false )->plain() ) .
729 $this->output->addHTML( $html );
736 $errors = array_merge(
$status->getErrorsArray(),
$status->getWarningsArray() );
737 foreach ( $errors as $error ) {
752 public function label( $msg, $forId, $contents, $helpData =
"" ) {
753 if ( strval( $msg ) ==
'' ) {
754 $labelText =
"\u{00A0}";
756 $labelText =
wfMessage( $msg )->escaped();
759 $attributes = [
'class' =>
'config-label' ];
762 $attributes[
'for'] = $forId;
765 return "<div class=\"config-block\">\n" .
766 " <div class=\"config-block-label\">\n" .
773 " <div class=\"config-block-elements\">\n" .
794 if ( !isset( $params[
'controlName'] ) ) {
795 $params[
'controlName'] =
'config_' . $params[
'var'];
798 if ( !isset( $params[
'value'] ) ) {
799 $params[
'value'] = $this->
getVar( $params[
'var'] );
802 if ( !isset( $params[
'attribs'] ) ) {
803 $params[
'attribs'] = [];
805 if ( !isset( $params[
'help'] ) ) {
806 $params[
'help'] =
"";
811 $params[
'controlName'],
813 $params[
'controlName'],
816 $params[
'attribs'] + [
817 'id' => $params[
'controlName'],
818 'class' =>
'config-input-text',
841 if ( !isset( $params[
'controlName'] ) ) {
842 $params[
'controlName'] =
'config_' . $params[
'var'];
845 if ( !isset( $params[
'value'] ) ) {
846 $params[
'value'] = $this->
getVar( $params[
'var'] );
849 if ( !isset( $params[
'attribs'] ) ) {
850 $params[
'attribs'] = [];
852 if ( !isset( $params[
'help'] ) ) {
853 $params[
'help'] =
"";
858 $params[
'controlName'],
860 $params[
'controlName'],
864 $params[
'attribs'] + [
865 'id' => $params[
'controlName'],
866 'class' =>
'config-input-text',
890 if ( !isset( $params[
'value'] ) ) {
891 $params[
'value'] = $this->
getVar( $params[
'var'] );
894 if ( !isset( $params[
'attribs'] ) ) {
895 $params[
'attribs'] = [];
899 $params[
'attribs'][
'type'] =
'password';
920 if ( !isset( $params[
'controlName'] ) ) {
921 $params[
'controlName'] =
'config_' . $params[
'var'];
924 if ( !isset( $params[
'value'] ) ) {
925 $params[
'value'] = $this->
getVar( $params[
'var'] );
928 if ( !isset( $params[
'attribs'] ) ) {
929 $params[
'attribs'] = [];
931 if ( !isset( $params[
'help'] ) ) {
932 $params[
'help'] =
"";
934 if ( !isset( $params[
'labelAttribs'] ) ) {
935 $params[
'labelAttribs'] = [];
937 $labelText = $params[
'rawtext'] ?? $this->
parse(
wfMessage( $params[
'label'] )->plain() );
939 return "<div class=\"config-input-check\">\n" .
943 $params[
'labelAttribs'],
945 $params[
'controlName'],
947 $params[
'attribs'] + [
948 'id' => $params[
'controlName'],
979 $label = $params[
'label'] ??
'';
981 if ( !isset( $params[
'controlName'] ) ) {
982 $params[
'controlName'] =
'config_' . $params[
'var'];
985 if ( !isset( $params[
'help'] ) ) {
986 $params[
'help'] =
"";
990 foreach ( $items as $value => $item ) {
991 $s .=
"<li>$item</li>\n";
995 return $this->
label( $label, $params[
'controlName'],
$s, $params[
'help'] );
1007 if ( !isset( $params[
'controlName'] ) ) {
1008 $params[
'controlName'] =
'config_' . $params[
'var'];
1011 if ( !isset( $params[
'value'] ) ) {
1012 $params[
'value'] = $this->
getVar( $params[
'var'] );
1017 foreach ( $params[
'values'] as $value ) {
1020 if ( isset( $params[
'commonAttribs'] ) ) {
1021 $itemAttribs = $params[
'commonAttribs'];
1024 if ( isset( $params[
'itemAttribs'][$value] ) ) {
1025 $itemAttribs = $params[
'itemAttribs'][$value] + $itemAttribs;
1028 $checked = $value == $params[
'value'];
1029 $id = $params[
'controlName'] .
'_' . $value;
1030 $itemAttribs[
'id'] = $id;
1034 Xml::radio( $params[
'controlName'], $value, $checked, $itemAttribs ) .
1037 isset( $params[
'itemLabels'] ) ?
1038 wfMessage( $params[
'itemLabels'][$value] )->plain() :
1039 wfMessage( $params[
'itemLabelPrefix'] . strtolower( $value ) )->plain()
1053 $text =
$status->getWikiText();
1056 $box = Html::warningBox( $text,
'config-warning-box' );
1058 $box = Html::errorBox( $text,
'',
'config-error-box' );
1061 $this->output->addHTML( $box );
1078 foreach ( $varNames as $name ) {
1079 $value = $this->request->getVal( $prefix . $name );
1081 if ( stripos( $name,
'password' ) ===
false ) {
1082 $value = trim( $value );
1084 $newValues[$name] = $value;
1086 if ( $value ===
null ) {
1088 $this->
setVar( $name,
false );
1089 } elseif ( stripos( $name,
'password' ) !==
false ) {
1092 $this->
setVar( $name, $value );
1107 $query = [
'page' => $page ];
1109 if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1113 return $this->
getUrl( $query );
1125 return Html::rawElement(
'li', [],
1126 Html::element(
'a', [
'href' => $url ], $linkText )
1137 $anchor = Html::rawElement(
'a',
1138 [
'href' => $this->
getUrl( [
'localsettings' => 1 ] ) ],
1142 return Html::rawElement(
'div', [
'class' =>
'config-download-link' ], $anchor );
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 ) {
1177 return parent::envCheckPath();
1181 parent::envPrepPath();
1186 if ( !empty( $_SERVER[
'PHP_SELF'] ) ) {
1187 $path = $_SERVER[
'PHP_SELF'];
1188 } elseif ( !empty( $_SERVER[
'SCRIPT_NAME'] ) ) {
1189 $path = $_SERVER[
'SCRIPT_NAME'];
1191 if (
$path !==
false ) {
1192 $scriptPath = preg_replace(
'{^(.*)/(mw-)?config.*$}',
'$1',
$path );
1194 $this->
setVar(
'wgScriptPath',
"$scriptPath" );
1196 $this->
setVar(
'wgScript',
"$scriptPath/index.php" );
1197 $this->
setVar(
'wgLoadScript',
"$scriptPath/load.php" );
1198 $this->
setVar(
'wgStylePath',
"$scriptPath/skins" );
1199 $this->
setVar(
'wgLocalStylePath',
"$scriptPath/skins" );
1200 $this->
setVar(
'wgExtensionAssetsPath',
"$scriptPath/extensions" );
1201 $this->
setVar(
'wgUploadPath',
"$scriptPath/images" );
1202 $this->
setVar(
'wgResourceBasePath',
"$scriptPath" );
1219 $this->request->response()->header(
'Content-type: application/x-httpd-php' );
1220 $this->request->response()->header(
1221 'Content-Disposition: attachment; filename="LocalSettings.php"'
1225 $rightsProfile = $this->rightsProfiles[$this->
getVar(
'_RightsProfile' )];
1226 foreach ( $rightsProfile as $group => $rightsArr ) {
1227 $ls->setGroupRights( $group, $rightsArr );
1229 echo $ls->getText();
1236 $this->request->response()->header(
'Content-type: text/css' );
1237 echo $this->output->getCSS();
getAcceptLanguage()
Retrieves MediaWiki language from Accept-Language HTTP header.
makeLinkItem( $url, $linkText)
Helper for sidebar links.
Marks HTML that shouldn't be escaped.
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
startPageWrapper( $currentPageName)
Called by execute() before page output starts, to show a page list.
if(!isset( $args[0])) $lang
getRadioElements( $params)
Get a set of labelled radio buttons.
label( $msg, $forId, $contents, $helpData="")
Label a control by wrapping a config-input div around it and putting a label before it.
getPageListItem( $pageName, $enabled, $currentPageName)
Get a list item for the page list.
startSession()
Start the PHP session.
bool $showSessionWarning
Flag indicating that session data may have been lost.
showStatusMessage(Status $status)
string[] $pageSequence
The main sequence of page names.
array[] $session
Cached session array.
setupLanguage()
Initializes language-related variables.
getCheckBox( $params)
Get a labelled checkbox to configure a boolean variable.
Class for the core installer web interface.
int $helpBoxId
Numeric index of the help box.
static textarea( $name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
static radio( $name, $value, $checked=false, $attribs=[])
Convenience function to build an HTML radio button.
getWarningBox( $text)
Get HTML for a warning box with an icon.
int $tabIndex
Numeric index of the page we're on.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
getPageByName( $pageName)
Get a WebInstallerPage by name.
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
__construct(WebRequest $request)
bool[] $happyPages
Array of pages which have declared that they have been submitted, have validated their input,...
showStatusBox( $status)
Output an error or warning box using a Status object.
getLowestUnhappy()
Find the next page in sequence that hasn't been completed.
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
getInfoBox( $text, $icon=false, $class=false)
Get HTML for an information message box with an icon.
Output class modelled on OutputPage.
WebInstallerOutput $output
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getRadioSet( $params)
Get a set of labelled radio buttons.
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
showHelpBox( $msg,... $params)
Output a help box.
getTextArea( $params)
Get a labelled textarea to configure a variable.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
setSession( $name, $value)
Set a session variable.
WebRequest $request
WebRequest object.
execute(array $session)
Main entry point.
static getHtml( $input)
Provide a string or HtmlArmor object and get safe HTML back.
nextTabIndex()
Get the next tabindex attribute value.
bool[] $skippedPages
List of "skipped" pages.
errorHandler( $errno, $errstr)
Temporary error handler for session start debugging.
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
getFingerprint()
Get a hash of data identifying this MW installation.
showError( $msg,... $params)
Show an error message in a box.
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
outputLS()
Actually output LocalSettings.php for download.
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
string[] $phpErrors
Captured PHP error text.
string[] $otherPages
Out of sequence pages, selectable by the user at any time.
string $currentPageName
Name of the page we're on.
getPasswordBox( $params)
Get a labelled password box to configure a variable.
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
$wgLanguageCode
Site language code.
reset()
We're restarting the installation, reset the session, happyPages, etc.
setVarsFromRequest( $varNames, $prefix='config_')
Convenience function to set variables based on form data.
outputCss()
Output stylesheet for web installer pages.
static getMain()
Get the RequestContext object associated with the main request.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
endPageWrapper()
Output some stuff after a page is finished.
makeDownloadLinkHtml()
Helper for "Download LocalSettings" link.
getLocalSettingsLocation()
If the software package wants the LocalSettings.php file to be placed in a specific location,...
getErrorBox( $text)
Get HTML for an error box with an icon.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
getHelpBox( $msg,... $args)
Get small text indented help for a preceding form field.
getDocUrl( $page)
Helper for WebInstallerOutput.
static detectServer()
Work out an appropriate URL prefix containing scheme and host, based on information detected from $_S...
disableTimeLimit()
Disable the time limit for execution.
getTextBox( $params)
Get a labelled text box to configure a variable.
static factory( $code)
Get a cached or new language object for a given language code.
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
if(! $wgDBerrorLogTZ) $wgRequest
static fetchLanguageNames( $inLanguage=self::AS_AUTONYMS, $include='mw')
Get an array of language names, indexed by code.
getSession( $name, $default=null)
Get a session variable.
finish()
Clean up from execute()
showMessage( $msg,... $params)
Show a short informational message.
getUrl( $query=[])
Get a URL for submission back to the same script.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....