144 parent::__construct();
159 if ( isset(
$session[
'settings'] ) ) {
162 foreach ( $this->settings as $key => $val ) {
163 $GLOBALS[$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 );
524 $mwLanguages = MediaWikiServices::getInstance()
525 ->getLanguageNameUtils()
526 ->getLanguageNames(
null,
'mwfile' );
527 $headerLanguages = array_keys(
$wgRequest->getAcceptLang() );
529 foreach ( $headerLanguages as
$lang ) {
530 if ( isset( $mwLanguages[
$lang] ) ) {
544 $s =
"<div class=\"config-page-wrapper\">\n";
545 $s .=
"<div class=\"config-page\">\n";
546 $s .=
"<div class=\"config-page-list\"><ul>\n";
549 foreach ( $this->pageSequence as $id => $pageName ) {
550 $happy = !empty( $this->happyPages[$id] );
553 $happy || $lastHappy == $id - 1,
562 $s .=
"</ul><br/><ul>\n";
565 $s .=
"</ul></div>\n";
572 $s .= Html::element(
'h2', [],
575 $this->output->addHTMLNoFlush(
$s );
588 $s =
"<li class=\"config-page-list-item\">";
595 $name =
wfMessage(
'config-page-' . strtolower( $pageName ) )->text();
598 $query = [
'page' => $pageName ];
600 if ( !in_array( $pageName, $this->pageSequence ) ) {
605 $link = Html::element(
'a',
607 'href' => $this->
getUrl( $query )
612 $link = htmlspecialchars( $name );
616 $s .=
"<span class=\"config-page-current\">$link</span>";
621 $s .= Html::element(
'span',
623 'class' =>
'config-page-disabled'
638 $this->output->addHTMLNoFlush(
639 "<div class=\"visualClear\"></div>\n" .
641 "<div class=\"visualClear\"></div>\n" .
653 public function getInfoBox( $text, $icon =
false, $class =
false ) {
655 HtmlArmor::getHtml( $text ) :
656 $this->
parse( $text,
true );
658 'images/info-32.png' :
660 $alt =
wfMessage(
'config-information' )->text();
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 ) {
734 public function label( $msg, $forId, $contents, $helpData =
"" ) {
735 if ( strval( $msg ) ==
'' ) {
736 $labelText =
"\u{00A0}";
738 $labelText =
wfMessage( $msg )->escaped();
741 $attributes = [
'class' =>
'config-label' ];
744 $attributes[
'for'] = $forId;
747 return "<div class=\"config-block\">\n" .
748 " <div class=\"config-block-label\">\n" .
755 " <div class=\"config-block-elements\">\n" .
777 if ( !isset( $params[
'controlName'] ) ) {
778 $params[
'controlName'] =
'config_' . $params[
'var'];
781 if ( !isset( $params[
'value'] ) ) {
782 $params[
'value'] = $this->
getVar( $params[
'var'] );
785 if ( !isset( $params[
'attribs'] ) ) {
786 $params[
'attribs'] = [];
788 if ( !isset( $params[
'help'] ) ) {
789 $params[
'help'] =
"";
794 $params[
'controlName'],
796 $params[
'controlName'],
799 $params[
'attribs'] + [
800 'id' => $params[
'controlName'],
801 'class' =>
'config-input-text',
824 if ( !isset( $params[
'controlName'] ) ) {
825 $params[
'controlName'] =
'config_' . $params[
'var'];
828 if ( !isset( $params[
'value'] ) ) {
829 $params[
'value'] = $this->
getVar( $params[
'var'] );
832 if ( !isset( $params[
'attribs'] ) ) {
833 $params[
'attribs'] = [];
835 if ( !isset( $params[
'help'] ) ) {
836 $params[
'help'] =
"";
841 $params[
'controlName'],
843 $params[
'controlName'],
847 $params[
'attribs'] + [
848 'id' => $params[
'controlName'],
849 'class' =>
'config-input-text',
874 if ( !isset( $params[
'value'] ) ) {
875 $params[
'value'] = $this->
getVar( $params[
'var'] );
878 if ( !isset( $params[
'attribs'] ) ) {
879 $params[
'attribs'] = [];
883 $params[
'attribs'][
'type'] =
'password';
905 if ( !isset( $params[
'controlName'] ) ) {
906 $params[
'controlName'] =
'config_' . $params[
'var'];
909 if ( !isset( $params[
'value'] ) ) {
910 $params[
'value'] = $this->
getVar( $params[
'var'] );
913 if ( !isset( $params[
'attribs'] ) ) {
914 $params[
'attribs'] = [];
916 if ( !isset( $params[
'help'] ) ) {
917 $params[
'help'] =
"";
919 if ( !isset( $params[
'labelAttribs'] ) ) {
920 $params[
'labelAttribs'] = [];
922 $labelText = $params[
'rawtext'] ?? $this->
parse(
wfMessage( $params[
'label'] )->plain() );
924 return "<div class=\"config-input-check\">\n" .
928 $params[
'labelAttribs'],
930 $params[
'controlName'],
932 $params[
'attribs'] + [
933 'id' => $params[
'controlName'],
965 $label = $params[
'label'] ??
'';
967 if ( !isset( $params[
'controlName'] ) ) {
968 $params[
'controlName'] =
'config_' . $params[
'var'];
971 if ( !isset( $params[
'help'] ) ) {
972 $params[
'help'] =
"";
976 foreach ( $items as $value => $item ) {
977 $s .=
"<li>$item</li>\n";
981 return $this->
label( $label, $params[
'controlName'],
$s, $params[
'help'] );
994 if ( !isset( $params[
'controlName'] ) ) {
995 $params[
'controlName'] =
'config_' . $params[
'var'];
998 if ( !isset( $params[
'value'] ) ) {
999 $params[
'value'] = $this->
getVar( $params[
'var'] );
1004 foreach ( $params[
'values'] as $value ) {
1007 if ( isset( $params[
'commonAttribs'] ) ) {
1008 $itemAttribs = $params[
'commonAttribs'];
1011 if ( isset( $params[
'itemAttribs'][$value] ) ) {
1012 $itemAttribs = $params[
'itemAttribs'][$value] + $itemAttribs;
1015 $checked = $value == $params[
'value'];
1016 $id = $params[
'controlName'] .
'_' . $value;
1017 $itemAttribs[
'id'] = $id;
1021 Xml::radio( $params[
'controlName'], $value, $checked, $itemAttribs ) .
1023 Xml::tags(
'label', [
'for' => $id ], $this->
parse(
1024 isset( $params[
'itemLabels'] ) ?
1025 wfMessage( $params[
'itemLabels'][$value] )->plain() :
1026 wfMessage( $params[
'itemLabelPrefix'] . strtolower( $value ) )->plain()
1039 if ( !$status->isGood() ) {
1040 $html = $status->getHTML();
1042 if ( $status->isOK() ) {
1043 $box = Html::warningBox( $html,
'config-warning-box' );
1045 $box = Html::errorBox( $html,
'',
'config-error-box' );
1048 $this->output->addHTML( $box );
1065 foreach ( $varNames as $name ) {
1066 $value = $this->request->getVal( $prefix . $name );
1068 if ( stripos( $name,
'password' ) ===
false ) {
1069 $value = trim( $value );
1071 $newValues[$name] = $value;
1073 if ( $value ===
null ) {
1075 $this->
setVar( $name,
false );
1076 } elseif ( stripos( $name,
'password' ) !==
false ) {
1079 $this->
setVar( $name, $value );
1094 $query = [
'page' => $page ];
1096 if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1100 return $this->
getUrl( $query );
1112 return Html::rawElement(
'li', [],
1113 Html::element(
'a', [
'href' => $url ], $linkText )
1124 $anchor = Html::rawElement(
'a',
1125 [
'href' => $this->
getUrl( [
'localsettings' => 1 ] ) ],
1129 return Html::rawElement(
'div', [
'class' =>
'config-download-link' ], $anchor );
1154 if ( !empty( $_SERVER[
'PHP_SELF'] ) ) {
1155 $path = $_SERVER[
'PHP_SELF'];
1156 } elseif ( !empty( $_SERVER[
'SCRIPT_NAME'] ) ) {
1157 $path = $_SERVER[
'SCRIPT_NAME'];
1159 if (
$path ===
false ) {
1164 return parent::envCheckPath();
1168 parent::envPrepPath();
1173 if ( !empty( $_SERVER[
'PHP_SELF'] ) ) {
1174 $path = $_SERVER[
'PHP_SELF'];
1175 } elseif ( !empty( $_SERVER[
'SCRIPT_NAME'] ) ) {
1176 $path = $_SERVER[
'SCRIPT_NAME'];
1178 if (
$path !==
false ) {
1179 $scriptPath = preg_replace(
'{^(.*)/(mw-)?config.*$}',
'$1',
$path );
1181 $this->
setVar(
'wgScriptPath',
"$scriptPath" );
1183 $this->
setVar(
'wgScript',
"$scriptPath/index.php" );
1184 $this->
setVar(
'wgLoadScript',
"$scriptPath/load.php" );
1185 $this->
setVar(
'wgStylePath',
"$scriptPath/skins" );
1186 $this->
setVar(
'wgLocalStylePath',
"$scriptPath/skins" );
1187 $this->
setVar(
'wgExtensionAssetsPath',
"$scriptPath/extensions" );
1188 $this->
setVar(
'wgUploadPath',
"$scriptPath/images" );
1189 $this->
setVar(
'wgResourceBasePath',
"$scriptPath" );
1197 return WebRequest::detectServer();
1204 $this->request->response()->header(
'Content-type: application/x-httpd-php' );
1205 $this->request->response()->header(
1206 'Content-Disposition: attachment; filename="LocalSettings.php"'
1210 $rightsProfile = $this->rightsProfiles[$this->
getVar(
'_RightsProfile' )];
1211 foreach ( $rightsProfile as $group => $rightsArr ) {
1212 $ls->setGroupRights( $group, $rightsArr );
1214 echo $ls->getText();
1221 $this->request->response()->header(
'Content-type: text/css' );
1222 echo $this->output->getCSS();
1242 protected static function infoBox( $rawHtml, $icon, $alt, $class =
'' ) {
1243 $s = Html::openElement(
'div', [
'class' =>
'mw-installer-box-left' ] ) .
1244 Html::element(
'img',
1250 Html::closeElement(
'div' );
1252 $s .= Html::openElement(
'div', [
'class' =>
'mw-installer-box-right' ] ) .
1254 Html::closeElement(
'div' );
1255 $s .= Html::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1257 return Html::warningBox(
$s, $class )
1258 . Html::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
$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.
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.
static infoBox( $rawHtml, $icon, $alt, $class='')
Get HTML for an information message box with an icon.
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...
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s
if(!isset( $args[0])) $lang