3 * Core installer web interface.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * Class for the core installer web interface.
30 class WebInstaller
extends Installer
{
33 * @var WebInstallerOutput
45 * Cached session array.
52 * Captured PHP error text. Temporary.
59 * The main sequence of page names. These will be displayed in turn.
61 * To add a new installer page:
62 * * Add it to this WebInstaller::$pageSequence property
63 * * Add a "config-page-<name>" message
64 * * Add a "WebInstaller<name>" class
68 public $pageSequence = array(
82 * Out of sequence pages, selectable by the user at any time.
86 protected $otherPages = array(
91 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
95 * Array of pages which have declared that they have been submitted, have validated
96 * their input, and need no further processing.
100 protected $happyPages;
103 * List of "skipped" pages. These are pages that will automatically continue
104 * to the next page on any GET request. To avoid breaking the "back" button,
105 * they need to be skipped during a back operation.
109 protected $skippedPages;
112 * Flag indicating that session data may have been lost.
116 public $showSessionWarning = false;
119 * Numeric index of the page we're on
123 protected $tabIndex = 1;
126 * Name of the page we're on
130 protected $currentPageName;
135 * @param WebRequest $request
137 public function __construct( WebRequest
$request ) {
138 parent
::__construct();
139 $this->output
= new WebInstallerOutput( $this );
140 $this->request
= $request;
144 $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
145 $wgParser->setHook( 'doclink', array( $this, 'docLink' ) );
151 * @param array[] $session Initial session array
153 * @return array[] New session array
155 public function execute( array $session ) {
156 $this->session
= $session;
158 if ( isset( $session['settings'] ) ) {
159 $this->settings
= $session['settings'] +
$this->settings
;
163 $this->setupLanguage();
165 if ( ( $this->getVar( '_InstallDone' ) ||
$this->getVar( '_UpgradeDone' ) )
166 && $this->request
->getVal( 'localsettings' )
168 $this->request
->response()->header( 'Content-type: application/x-httpd-php' );
169 $this->request
->response()->header(
170 'Content-Disposition: attachment; filename="LocalSettings.php"'
173 $ls = InstallerOverrides
::getLocalSettingsGenerator( $this );
174 $rightsProfile = $this->rightsProfiles
[$this->getVar( '_RightsProfile' )];
175 foreach ( $rightsProfile as $group => $rightsArr ) {
176 $ls->setGroupRights( $group, $rightsArr );
180 return $this->session
;
183 $isCSS = $this->request
->getVal( 'css' );
186 return $this->session
;
189 if ( isset( $session['happyPages'] ) ) {
190 $this->happyPages
= $session['happyPages'];
192 $this->happyPages
= array();
195 if ( isset( $session['skippedPages'] ) ) {
196 $this->skippedPages
= $session['skippedPages'];
198 $this->skippedPages
= array();
201 $lowestUnhappy = $this->getLowestUnhappy();
203 # Special case for Creative Commons partner chooser box.
204 if ( $this->request
->getVal( 'SubmitCC' ) ) {
205 $page = $this->getPageByName( 'Options' );
206 $this->output
->useShortHeader();
207 $this->output
->allowFrames();
210 return $this->finish();
213 if ( $this->request
->getVal( 'ShowCC' ) ) {
214 $page = $this->getPageByName( 'Options' );
215 $this->output
->useShortHeader();
216 $this->output
->allowFrames();
217 $this->output
->addHTML( $page->getCCDoneBox() );
219 return $this->finish();
223 $pageName = $this->request
->getVal( 'page' );
225 if ( in_array( $pageName, $this->otherPages
) ) {
228 $page = $this->getPageByName( $pageName );
231 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
232 $pageId = $lowestUnhappy;
234 $pageId = array_search( $pageName, $this->pageSequence
);
237 # If necessary, move back to the lowest-numbered unhappy page
238 if ( $pageId > $lowestUnhappy ) {
239 $pageId = $lowestUnhappy;
240 if ( $lowestUnhappy == 0 ) {
241 # Knocked back to start, possible loss of session data.
242 $this->showSessionWarning
= true;
246 $pageName = $this->pageSequence
[$pageId];
247 $page = $this->getPageByName( $pageName );
250 # If a back button was submitted, go back without submitting the form data.
251 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
252 if ( $this->request
->getVal( 'lastPage' ) ) {
253 $nextPage = $this->request
->getVal( 'lastPage' );
254 } elseif ( $pageId !== false ) {
256 # Skip the skipped pages
257 $nextPageId = $pageId;
261 $nextPage = $this->pageSequence
[$nextPageId];
262 } while ( isset( $this->skippedPages
[$nextPage] ) );
264 $nextPage = $this->pageSequence
[$lowestUnhappy];
267 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
269 return $this->finish();
273 $this->currentPageName
= $page->getName();
274 $this->startPageWrapper( $pageName );
276 if ( $page->isSlow() ) {
277 $this->disableTimeLimit();
280 $result = $page->execute();
282 $this->endPageWrapper();
284 if ( $result == 'skip' ) {
285 # Page skipped without explicit submission.
286 # Skip it when we click "back" so that we don't just go forward again.
287 $this->skippedPages
[$pageName] = true;
288 $result = 'continue';
290 unset( $this->skippedPages
[$pageName] );
293 # If it was posted, the page can request a continue to the next page.
294 if ( $result === 'continue' && !$this->output
->headerDone() ) {
295 if ( $pageId !== false ) {
296 $this->happyPages
[$pageId] = true;
299 $lowestUnhappy = $this->getLowestUnhappy();
301 if ( $this->request
->getVal( 'lastPage' ) ) {
302 $nextPage = $this->request
->getVal( 'lastPage' );
303 } elseif ( $pageId !== false ) {
304 $nextPage = $this->pageSequence
[$pageId +
1];
306 $nextPage = $this->pageSequence
[$lowestUnhappy];
309 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
310 $nextPage = $this->pageSequence
[$lowestUnhappy];
313 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
316 return $this->finish();
320 * Find the next page in sequence that hasn't been completed
323 public function getLowestUnhappy() {
324 if ( count( $this->happyPages
) == 0 ) {
327 return max( array_keys( $this->happyPages
) ) +
1;
332 * Start the PHP session. This may be called before execute() to start the PHP session.
337 public function startSession() {
338 if ( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
343 $this->phpErrors
= array();
344 set_error_handler( array( $this, 'errorHandler' ) );
346 session_name( 'mw_installer_session' );
348 } catch ( Exception
$e ) {
349 restore_error_handler();
352 restore_error_handler();
354 if ( $this->phpErrors
) {
362 * Get a hash of data identifying this MW installation.
364 * This is used by mw-config/index.php to prevent multiple installations of MW
365 * on the same cookie domain from interfering with each other.
369 public function getFingerprint() {
370 // Get the base URL of the installation
371 $url = $this->request
->getFullRequestURL();
372 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
376 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
377 // This... seems to try to get the base path from
378 // the /mw-config/index.php. Kinda scary though?
382 return md5( serialize( array(
383 'local path' => dirname( __DIR__
),
385 'version' => $GLOBALS['wgVersion']
390 * Show an error message in a box. Parameters are like wfMessage().
393 public function showError( $msg /*...*/ ) {
394 $args = func_get_args();
395 array_shift( $args );
396 $args = array_map( 'htmlspecialchars', $args );
397 $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
398 $this->output
->addHTML( $this->getErrorBox( $msg ) );
402 * Temporary error handler for session start debugging.
404 * @param int $errno Unused
405 * @param string $errstr
407 public function errorHandler( $errno, $errstr ) {
408 $this->phpErrors
[] = $errstr;
412 * Clean up from execute()
416 public function finish() {
417 $this->output
->output();
419 $this->session
['happyPages'] = $this->happyPages
;
420 $this->session
['skippedPages'] = $this->skippedPages
;
421 $this->session
['settings'] = $this->settings
;
423 return $this->session
;
427 * We're restarting the installation, reset the session, happyPages, etc
429 public function reset() {
430 $this->session
= array();
431 $this->happyPages
= array();
432 $this->settings
= array();
436 * Get a URL for submission back to the same script.
438 * @param string[] $query
442 public function getUrl( $query = array() ) {
443 $url = $this->request
->getRequestURL();
444 # Remove existing query
445 $url = preg_replace( '/\?.*$/', '', $url );
448 $url .= '?' . wfArrayToCgi( $query );
455 * Get a WebInstallerPage by name.
457 * @param string $pageName
458 * @return WebInstallerPage
460 public function getPageByName( $pageName ) {
461 $pageClass = 'WebInstaller' . $pageName;
463 return new $pageClass( $this );
467 * Get a session variable.
469 * @param string $name
470 * @param array $default
474 public function getSession( $name, $default = null ) {
475 if ( !isset( $this->session
[$name] ) ) {
478 return $this->session
[$name];
483 * Set a session variable.
485 * @param string $name Key for the variable
486 * @param mixed $value
488 public function setSession( $name, $value ) {
489 $this->session
[$name] = $value;
493 * Get the next tabindex attribute value.
497 public function nextTabIndex() {
498 return $this->tabIndex++
;
502 * Initializes language-related variables.
504 public function setupLanguage() {
505 global $wgLang, $wgContLang, $wgLanguageCode;
507 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
508 $wgLanguageCode = $this->getAcceptLanguage();
509 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
510 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
511 $this->setVar( '_UserLang', $wgLanguageCode );
513 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
514 $wgContLang = Language
::factory( $wgLanguageCode );
519 * Retrieves MediaWiki language from Accept-Language HTTP header.
523 public function getAcceptLanguage() {
524 global $wgLanguageCode, $wgRequest;
526 $mwLanguages = Language
::fetchLanguageNames();
527 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
529 foreach ( $headerLanguages as $lang ) {
530 if ( isset( $mwLanguages[$lang] ) ) {
535 return $wgLanguageCode;
539 * Called by execute() before page output starts, to show a page list.
541 * @param string $currentPageName
543 private function startPageWrapper( $currentPageName ) {
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] );
551 $s .= $this->getPageListItem(
553 $happy ||
$lastHappy == $id - 1,
562 $s .= "</ul><br/><ul>\n";
563 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
565 $s .= "</ul></div>\n";
568 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
569 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
570 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
571 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
572 $s .= Html
::element( 'h2', array(),
573 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
575 $this->output
->addHTMLNoFlush( $s );
579 * Get a list item for the page list.
581 * @param string $pageName
582 * @param bool $enabled
583 * @param string $currentPageName
587 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
588 $s = "<li class=\"config-page-list-item\">";
591 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
592 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
593 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
594 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
595 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
598 $query = array( 'page' => $pageName );
600 if ( !in_array( $pageName, $this->pageSequence
) ) {
601 if ( in_array( $currentPageName, $this->pageSequence
) ) {
602 $query['lastPage'] = $currentPageName;
605 $link = Html
::element( 'a',
607 'href' => $this->getUrl( $query )
612 $link = htmlspecialchars( $name );
615 if ( $pageName == $currentPageName ) {
616 $s .= "<span class=\"config-page-current\">$link</span>";
621 $s .= Html
::element( 'span',
623 'class' => 'config-page-disabled'
635 * Output some stuff after a page is finished.
637 private function endPageWrapper() {
638 $this->output
->addHTMLNoFlush(
639 "<div class=\"visualClear\"></div>\n" .
641 "<div class=\"visualClear\"></div>\n" .
646 * Get HTML for an error box with an icon.
648 * @param string $text Wikitext, get this with wfMessage()->plain()
652 public function getErrorBox( $text ) {
653 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
657 * Get HTML for a warning box with an icon.
659 * @param string $text Wikitext, get this with wfMessage()->plain()
663 public function getWarningBox( $text ) {
664 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
668 * Get HTML for an info box with an icon.
670 * @param string $text Wikitext, get this with wfMessage()->plain()
671 * @param string|bool $icon Icon name, file in mw-config/images. Default: false
672 * @param string|bool $class Additional class name to add to the wrapper div. Default: false.
676 public function getInfoBox( $text, $icon = false, $class = false ) {
677 $text = $this->parse( $text, true );
678 $icon = ( $icon == false ) ?
679 'images/info-32.png' :
681 $alt = wfMessage( 'config-information' )->text();
683 return Html
::infoBox( $text, $icon, $alt, $class );
687 * Get small text indented help for a preceding form field.
688 * Parameters like wfMessage().
693 public function getHelpBox( $msg /*, ... */ ) {
694 $args = func_get_args();
695 array_shift( $args );
696 $args = array_map( 'htmlspecialchars', $args );
697 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
698 $html = $this->parse( $text, true );
700 return "<div class=\"config-help-field-container\">\n" .
701 "<span class=\"config-help-field-hint\" title=\"" .
702 wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
703 wfMessage( 'config-help' )->escaped() . "</span>\n" .
704 "<span class=\"config-help-field-data\">" . $html . "</span>\n" .
710 * @param string $msg Key for wfMessage()
712 public function showHelpBox( $msg /*, ... */ ) {
713 $args = func_get_args();
714 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
715 $this->output
->addHTML( $html );
719 * Show a short informational message.
720 * Output looks like a list.
724 public function showMessage( $msg /*, ... */ ) {
725 $args = func_get_args();
726 array_shift( $args );
727 $html = '<div class="config-message">' .
728 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
730 $this->output
->addHTML( $html );
734 * @param Status $status
736 public function showStatusMessage( Status
$status ) {
737 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
738 foreach ( $errors as $error ) {
739 call_user_func_array( array( $this, 'showMessage' ), $error );
744 * Label a control by wrapping a config-input div around it and putting a
748 * @param string $forId
749 * @param string $contents
750 * @param string $helpData
753 public function label( $msg, $forId, $contents, $helpData = "" ) {
754 if ( strval( $msg ) == '' ) {
755 $labelText = ' ';
757 $labelText = wfMessage( $msg )->escaped();
760 $attributes = array( 'class' => 'config-label' );
763 $attributes['for'] = $forId;
766 return "<div class=\"config-block\">\n" .
767 " <div class=\"config-block-label\">\n" .
774 " <div class=\"config-block-elements\">\n" .
781 * Get a labelled text box to configure a variable.
783 * @param mixed[] $params
785 * var: The variable to be configured (required)
786 * label: The message name for the label (required)
787 * attribs: Additional attributes for the input element (optional)
788 * controlName: The name for the input element (optional)
789 * value: The current value of the variable (optional)
790 * help: The html for the help text (optional)
794 public function getTextBox( $params ) {
795 if ( !isset( $params['controlName'] ) ) {
796 $params['controlName'] = 'config_' . $params['var'];
799 if ( !isset( $params['value'] ) ) {
800 $params['value'] = $this->getVar( $params['var'] );
803 if ( !isset( $params['attribs'] ) ) {
804 $params['attribs'] = array();
806 if ( !isset( $params['help'] ) ) {
807 $params['help'] = "";
812 $params['controlName'],
814 $params['controlName'],
815 30, // intended to be overridden by CSS
817 $params['attribs'] +
array(
818 'id' => $params['controlName'],
819 'class' => 'config-input-text',
820 'tabindex' => $this->nextTabIndex()
828 * Get a labelled textarea to configure a variable
830 * @param mixed[] $params
832 * var: The variable to be configured (required)
833 * label: The message name for the label (required)
834 * attribs: Additional attributes for the input element (optional)
835 * controlName: The name for the input element (optional)
836 * value: The current value of the variable (optional)
837 * help: The html for the help text (optional)
841 public function getTextArea( $params ) {
842 if ( !isset( $params['controlName'] ) ) {
843 $params['controlName'] = 'config_' . $params['var'];
846 if ( !isset( $params['value'] ) ) {
847 $params['value'] = $this->getVar( $params['var'] );
850 if ( !isset( $params['attribs'] ) ) {
851 $params['attribs'] = array();
853 if ( !isset( $params['help'] ) ) {
854 $params['help'] = "";
859 $params['controlName'],
861 $params['controlName'],
865 $params['attribs'] +
array(
866 'id' => $params['controlName'],
867 'class' => 'config-input-text',
868 'tabindex' => $this->nextTabIndex()
876 * Get a labelled password box to configure a variable.
878 * Implements password hiding
879 * @param mixed[] $params
881 * var: The variable to be configured (required)
882 * label: The message name for the label (required)
883 * attribs: Additional attributes for the input element (optional)
884 * controlName: The name for the input element (optional)
885 * value: The current value of the variable (optional)
886 * help: The html for the help text (optional)
890 public function getPasswordBox( $params ) {
891 if ( !isset( $params['value'] ) ) {
892 $params['value'] = $this->getVar( $params['var'] );
895 if ( !isset( $params['attribs'] ) ) {
896 $params['attribs'] = array();
899 $params['value'] = $this->getFakePassword( $params['value'] );
900 $params['attribs']['type'] = 'password';
902 return $this->getTextBox( $params );
906 * Get a labelled checkbox to configure a boolean variable.
908 * @param mixed[] $params
910 * var: The variable to be configured (required)
911 * label: The message name for the label (required)
912 * attribs: Additional attributes for the input element (optional)
913 * controlName: The name for the input element (optional)
914 * value: The current value of the variable (optional)
915 * help: The html for the help text (optional)
919 public function getCheckBox( $params ) {
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'] = array();
931 if ( !isset( $params['help'] ) ) {
932 $params['help'] = "";
934 if ( isset( $params['rawtext'] ) ) {
935 $labelText = $params['rawtext'];
937 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
940 return "<div class=\"config-input-check\">\n" .
944 $params['controlName'],
946 $params['attribs'] +
array(
947 'id' => $params['controlName'],
948 'tabindex' => $this->nextTabIndex(),
957 * Get a set of labelled radio buttons.
959 * @param mixed[] $params
961 * var: The variable to be configured (required)
962 * label: The message name for the label (required)
963 * itemLabelPrefix: The message name prefix for the item labels (required)
964 * itemLabels: List of message names to use for the item labels instead
965 * of itemLabelPrefix, keyed by values
966 * values: List of allowed values (required)
967 * itemAttribs: Array of attribute arrays, outer key is the value name (optional)
968 * commonAttribs: Attribute array applied to all items
969 * controlName: The name for the input element (optional)
970 * value: The current value of the variable (optional)
971 * help: The html for the help text (optional)
975 public function getRadioSet( $params ) {
976 $items = $this->getRadioElements( $params );
978 if ( !isset( $params['label'] ) ) {
981 $label = $params['label'];
984 if ( !isset( $params['controlName'] ) ) {
985 $params['controlName'] = 'config_' . $params['var'];
988 if ( !isset( $params['help'] ) ) {
989 $params['help'] = "";
993 foreach ( $items as $value => $item ) {
994 $s .= "<li>$item</li>\n";
998 return $this->label( $label, $params['controlName'], $s, $params['help'] );
1002 * Get a set of labelled radio buttons. You probably want to use getRadioSet(), not this.
1008 public function getRadioElements( $params ) {
1009 if ( !isset( $params['controlName'] ) ) {
1010 $params['controlName'] = 'config_' . $params['var'];
1013 if ( !isset( $params['value'] ) ) {
1014 $params['value'] = $this->getVar( $params['var'] );
1019 foreach ( $params['values'] as $value ) {
1020 $itemAttribs = array();
1022 if ( isset( $params['commonAttribs'] ) ) {
1023 $itemAttribs = $params['commonAttribs'];
1026 if ( isset( $params['itemAttribs'][$value] ) ) {
1027 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
1030 $checked = $value == $params['value'];
1031 $id = $params['controlName'] . '_' . $value;
1032 $itemAttribs['id'] = $id;
1033 $itemAttribs['tabindex'] = $this->nextTabIndex();
1036 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1038 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
1039 isset( $params['itemLabels'] ) ?
1040 wfMessage( $params['itemLabels'][$value] )->plain() :
1041 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1049 * Output an error or warning box using a Status object.
1051 * @param Status $status
1053 public function showStatusBox( $status ) {
1054 if ( !$status->isGood() ) {
1055 $text = $status->getWikiText();
1057 if ( $status->isOk() ) {
1058 $box = $this->getWarningBox( $text );
1060 $box = $this->getErrorBox( $text );
1063 $this->output
->addHTML( $box );
1068 * Convenience function to set variables based on form data.
1069 * Assumes that variables containing "password" in the name are (potentially
1072 * @param string[] $varNames
1073 * @param string $prefix The prefix added to variables to obtain form names
1077 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1078 $newValues = array();
1080 foreach ( $varNames as $name ) {
1081 $value = $this->request
->getVal( $prefix . $name );
1082 // bug 30524, do not trim passwords
1083 if ( stripos( $name, 'password' ) === false ) {
1084 $value = trim( $value );
1086 $newValues[$name] = $value;
1088 if ( $value === null ) {
1090 $this->setVar( $name, false );
1092 if ( stripos( $name, 'password' ) !== false ) {
1093 $this->setPassword( $name, $value );
1095 $this->setVar( $name, $value );
1104 * Helper for Installer::docLink()
1106 * @param string $page
1110 protected function getDocUrl( $page ) {
1111 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1113 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1114 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1121 * Extension tag hook for a documentation link.
1123 * @param string $linkText
1124 * @param string[] $attribs
1125 * @param Parser $parser Unused
1129 public function docLink( $linkText, $attribs, $parser ) {
1130 $url = $this->getDocUrl( $attribs['href'] );
1132 return '<a href="' . htmlspecialchars( $url ) . '">' .
1133 htmlspecialchars( $linkText ) .
1138 * Helper for "Download LocalSettings" link on WebInstall_Complete
1140 * @param string $text Unused
1141 * @param string[] $attribs Unused
1142 * @param Parser $parser Unused
1144 * @return string Html for download link
1146 public function downloadLinkHook( $text, $attribs, $parser ) {
1147 $anchor = Html
::rawElement( 'a',
1148 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1149 wfMessage( 'config-download-localsettings' )->parse()
1152 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1158 public function envCheckPath() {
1159 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1160 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1161 // to get the path to the current script... hopefully it's reliable. SIGH
1163 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1164 $path = $_SERVER['PHP_SELF'];
1165 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1166 $path = $_SERVER['SCRIPT_NAME'];
1168 if ( $path === false ) {
1169 $this->showError( 'config-no-uri' );
1173 return parent
::envCheckPath();
1176 public function envPrepPath() {
1177 parent
::envPrepPath();
1178 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1179 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1180 // to get the path to the current script... hopefully it's reliable. SIGH
1182 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1183 $path = $_SERVER['PHP_SELF'];
1184 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1185 $path = $_SERVER['SCRIPT_NAME'];
1187 if ( $path !== false ) {
1188 $scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1190 $this->setVar( 'wgScriptPath', "$scriptPath" );
1191 // Update variables set from Setup.php that are derived from wgScriptPath
1192 $this->setVar( 'wgScript', "$scriptPath/index.php" );
1193 $this->setVar( 'wgLoadScript', "$scriptPath/load.php" );
1194 $this->setVar( 'wgStylePath', "$scriptPath/skins" );
1195 $this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
1196 $this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
1197 $this->setVar( 'wgUploadPath', "$scriptPath/images" );
1198 $this->setVar( 'wgResourceBasePath', "$scriptPath" );
1205 protected function envGetDefaultServer() {
1206 return WebRequest
::detectServer();
1210 * Output stylesheet for web installer pages
1212 public function outputCss() {
1213 $this->request
->response()->header( 'Content-type: text/css' );
1214 echo $this->output
->getCSS();
1220 public function getPhpErrors() {
1221 return $this->phpErrors
;