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' ) );
347 } catch ( Exception
$e ) {
348 restore_error_handler();
351 restore_error_handler();
353 if ( $this->phpErrors
) {
361 * Get a hash of data identifying this MW installation.
363 * This is used by mw-config/index.php to prevent multiple installations of MW
364 * on the same cookie domain from interfering with each other.
368 public function getFingerprint() {
369 // Get the base URL of the installation
370 $url = $this->request
->getFullRequestURL();
371 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
375 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
376 // This... seems to try to get the base path from
377 // the /mw-config/index.php. Kinda scary though?
381 return md5( serialize( array(
382 'local path' => dirname( __DIR__
),
384 'version' => $GLOBALS['wgVersion']
389 * Show an error message in a box. Parameters are like wfMessage().
392 public function showError( $msg /*...*/ ) {
393 $args = func_get_args();
394 array_shift( $args );
395 $args = array_map( 'htmlspecialchars', $args );
396 $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
397 $this->output
->addHTML( $this->getErrorBox( $msg ) );
401 * Temporary error handler for session start debugging.
403 * @param int $errno Unused
404 * @param string $errstr
406 public function errorHandler( $errno, $errstr ) {
407 $this->phpErrors
[] = $errstr;
411 * Clean up from execute()
415 public function finish() {
416 $this->output
->output();
418 $this->session
['happyPages'] = $this->happyPages
;
419 $this->session
['skippedPages'] = $this->skippedPages
;
420 $this->session
['settings'] = $this->settings
;
422 return $this->session
;
426 * We're restarting the installation, reset the session, happyPages, etc
428 public function reset() {
429 $this->session
= array();
430 $this->happyPages
= array();
431 $this->settings
= array();
435 * Get a URL for submission back to the same script.
437 * @param string[] $query
441 public function getUrl( $query = array() ) {
442 $url = $this->request
->getRequestURL();
443 # Remove existing query
444 $url = preg_replace( '/\?.*$/', '', $url );
447 $url .= '?' . wfArrayToCgi( $query );
454 * Get a WebInstallerPage by name.
456 * @param string $pageName
457 * @return WebInstallerPage
459 public function getPageByName( $pageName ) {
460 $pageClass = 'WebInstaller' . $pageName;
462 return new $pageClass( $this );
466 * Get a session variable.
468 * @param string $name
469 * @param array $default
473 public function getSession( $name, $default = null ) {
474 if ( !isset( $this->session
[$name] ) ) {
477 return $this->session
[$name];
482 * Set a session variable.
484 * @param string $name Key for the variable
485 * @param mixed $value
487 public function setSession( $name, $value ) {
488 $this->session
[$name] = $value;
492 * Get the next tabindex attribute value.
496 public function nextTabIndex() {
497 return $this->tabIndex++
;
501 * Initializes language-related variables.
503 public function setupLanguage() {
504 global $wgLang, $wgContLang, $wgLanguageCode;
506 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
507 $wgLanguageCode = $this->getAcceptLanguage();
508 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
509 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
510 $this->setVar( '_UserLang', $wgLanguageCode );
512 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
513 $wgContLang = Language
::factory( $wgLanguageCode );
518 * Retrieves MediaWiki language from Accept-Language HTTP header.
522 public function getAcceptLanguage() {
523 global $wgLanguageCode, $wgRequest;
525 $mwLanguages = Language
::fetchLanguageNames();
526 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
528 foreach ( $headerLanguages as $lang ) {
529 if ( isset( $mwLanguages[$lang] ) ) {
534 return $wgLanguageCode;
538 * Called by execute() before page output starts, to show a page list.
540 * @param string $currentPageName
542 private function startPageWrapper( $currentPageName ) {
543 $s = "<div class=\"config-page-wrapper\">\n";
544 $s .= "<div class=\"config-page\">\n";
545 $s .= "<div class=\"config-page-list\"><ul>\n";
548 foreach ( $this->pageSequence
as $id => $pageName ) {
549 $happy = !empty( $this->happyPages
[$id] );
550 $s .= $this->getPageListItem(
552 $happy ||
$lastHappy == $id - 1,
561 $s .= "</ul><br/><ul>\n";
562 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
564 $s .= "</ul></div>\n";
567 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
568 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
569 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
570 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
571 $s .= Html
::element( 'h2', array(),
572 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
574 $this->output
->addHTMLNoFlush( $s );
578 * Get a list item for the page list.
580 * @param string $pageName
581 * @param bool $enabled
582 * @param string $currentPageName
586 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
587 $s = "<li class=\"config-page-list-item\">";
590 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
591 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
592 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
593 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
594 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
597 $query = array( 'page' => $pageName );
599 if ( !in_array( $pageName, $this->pageSequence
) ) {
600 if ( in_array( $currentPageName, $this->pageSequence
) ) {
601 $query['lastPage'] = $currentPageName;
604 $link = Html
::element( 'a',
606 'href' => $this->getUrl( $query )
611 $link = htmlspecialchars( $name );
614 if ( $pageName == $currentPageName ) {
615 $s .= "<span class=\"config-page-current\">$link</span>";
620 $s .= Html
::element( 'span',
622 'class' => 'config-page-disabled'
634 * Output some stuff after a page is finished.
636 private function endPageWrapper() {
637 $this->output
->addHTMLNoFlush(
638 "<div class=\"visualClear\"></div>\n" .
640 "<div class=\"visualClear\"></div>\n" .
645 * Get HTML for an error box with an icon.
647 * @param string $text Wikitext, get this with wfMessage()->plain()
651 public function getErrorBox( $text ) {
652 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
656 * Get HTML for a warning box with an icon.
658 * @param string $text Wikitext, get this with wfMessage()->plain()
662 public function getWarningBox( $text ) {
663 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
667 * Get HTML for an info box with an icon.
669 * @param string $text Wikitext, get this with wfMessage()->plain()
670 * @param string|bool $icon Icon name, file in skins/common/images. Default: false
671 * @param string|bool $class Additional class name to add to the wrapper div. Default: false.
675 public function getInfoBox( $text, $icon = false, $class = false ) {
676 $text = $this->parse( $text, true );
677 $icon = ( $icon == false ) ?
678 '../skins/common/images/info-32.png' :
679 '../skins/common/images/' . $icon;
680 $alt = wfMessage( 'config-information' )->text();
682 return Html
::infoBox( $text, $icon, $alt, $class, false );
686 * Get small text indented help for a preceding form field.
687 * Parameters like wfMessage().
692 public function getHelpBox( $msg /*, ... */ ) {
693 $args = func_get_args();
694 array_shift( $args );
695 $args = array_map( 'htmlspecialchars', $args );
696 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
697 $html = $this->parse( $text, true );
699 return "<div class=\"mw-help-field-container\">\n" .
700 "<span class=\"mw-help-field-hint\" title=\"" .
701 wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
702 wfMessage( 'config-help' )->escaped() . "</span>\n" .
703 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
709 * @param string $msg Key for wfMessage()
711 public function showHelpBox( $msg /*, ... */ ) {
712 $args = func_get_args();
713 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
714 $this->output
->addHTML( $html );
718 * Show a short informational message.
719 * Output looks like a list.
723 public function showMessage( $msg /*, ... */ ) {
724 $args = func_get_args();
725 array_shift( $args );
726 $html = '<div class="config-message">' .
727 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
729 $this->output
->addHTML( $html );
733 * Label a control by wrapping a config-input div around it and putting a
737 * @param string $forId
738 * @param string $contents
739 * @param string $helpData
742 public function label( $msg, $forId, $contents, $helpData = "" ) {
743 if ( strval( $msg ) == '' ) {
744 $labelText = ' ';
746 $labelText = wfMessage( $msg )->escaped();
749 $attributes = array( 'class' => 'config-label' );
752 $attributes['for'] = $forId;
755 return "<div class=\"config-block\">\n" .
756 " <div class=\"config-block-label\">\n" .
763 " <div class=\"config-block-elements\">\n" .
770 * Get a labelled text box to configure a variable.
772 * @param mixed[] $params
774 * var: The variable to be configured (required)
775 * label: The message name for the label (required)
776 * attribs: Additional attributes for the input element (optional)
777 * controlName: The name for the input element (optional)
778 * value: The current value of the variable (optional)
779 * help: The html for the help text (optional)
783 public function getTextBox( $params ) {
784 if ( !isset( $params['controlName'] ) ) {
785 $params['controlName'] = 'config_' . $params['var'];
788 if ( !isset( $params['value'] ) ) {
789 $params['value'] = $this->getVar( $params['var'] );
792 if ( !isset( $params['attribs'] ) ) {
793 $params['attribs'] = array();
795 if ( !isset( $params['help'] ) ) {
796 $params['help'] = "";
801 $params['controlName'],
803 $params['controlName'],
804 30, // intended to be overridden by CSS
806 $params['attribs'] +
array(
807 'id' => $params['controlName'],
808 'class' => 'config-input-text',
809 'tabindex' => $this->nextTabIndex()
817 * Get a labelled textarea to configure a variable
819 * @param mixed[] $params
821 * var: The variable to be configured (required)
822 * label: The message name for the label (required)
823 * attribs: Additional attributes for the input element (optional)
824 * controlName: The name for the input element (optional)
825 * value: The current value of the variable (optional)
826 * help: The html for the help text (optional)
830 public function getTextArea( $params ) {
831 if ( !isset( $params['controlName'] ) ) {
832 $params['controlName'] = 'config_' . $params['var'];
835 if ( !isset( $params['value'] ) ) {
836 $params['value'] = $this->getVar( $params['var'] );
839 if ( !isset( $params['attribs'] ) ) {
840 $params['attribs'] = array();
842 if ( !isset( $params['help'] ) ) {
843 $params['help'] = "";
848 $params['controlName'],
850 $params['controlName'],
854 $params['attribs'] +
array(
855 'id' => $params['controlName'],
856 'class' => 'config-input-text',
857 'tabindex' => $this->nextTabIndex()
865 * Get a labelled password box to configure a variable.
867 * Implements password hiding
868 * @param mixed[] $params
870 * var: The variable to be configured (required)
871 * label: The message name for the label (required)
872 * attribs: Additional attributes for the input element (optional)
873 * controlName: The name for the input element (optional)
874 * value: The current value of the variable (optional)
875 * help: The html for the help text (optional)
879 public function getPasswordBox( $params ) {
880 if ( !isset( $params['value'] ) ) {
881 $params['value'] = $this->getVar( $params['var'] );
884 if ( !isset( $params['attribs'] ) ) {
885 $params['attribs'] = array();
888 $params['value'] = $this->getFakePassword( $params['value'] );
889 $params['attribs']['type'] = 'password';
891 return $this->getTextBox( $params );
895 * Get a labelled checkbox to configure a boolean variable.
897 * @param mixed[] $params
899 * var: The variable to be configured (required)
900 * label: The message name for the label (required)
901 * attribs: Additional attributes for the input element (optional)
902 * controlName: The name for the input element (optional)
903 * value: The current value of the variable (optional)
904 * help: The html for the help text (optional)
908 public function getCheckBox( $params ) {
909 if ( !isset( $params['controlName'] ) ) {
910 $params['controlName'] = 'config_' . $params['var'];
913 if ( !isset( $params['value'] ) ) {
914 $params['value'] = $this->getVar( $params['var'] );
917 if ( !isset( $params['attribs'] ) ) {
918 $params['attribs'] = array();
920 if ( !isset( $params['help'] ) ) {
921 $params['help'] = "";
923 if ( isset( $params['rawtext'] ) ) {
924 $labelText = $params['rawtext'];
926 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
929 return "<div class=\"config-input-check\">\n" .
933 $params['controlName'],
935 $params['attribs'] +
array(
936 'id' => $params['controlName'],
937 'tabindex' => $this->nextTabIndex(),
946 * Get a set of labelled radio buttons.
948 * @param mixed[] $params
950 * var: The variable to be configured (required)
951 * label: The message name for the label (required)
952 * itemLabelPrefix: The message name prefix for the item labels (required)
953 * itemLabels: List of message names to use for the item labels instead of itemLabelPrefix, keyed by values
954 * values: List of allowed values (required)
955 * itemAttribs: Array of attribute arrays, outer key is the value name (optional)
956 * commonAttribs: Attribute array applied to all items
957 * controlName: The name for the input element (optional)
958 * value: The current value of the variable (optional)
959 * help: The html for the help text (optional)
963 public function getRadioSet( $params ) {
964 $items = $this->getRadioElements( $params );
966 if ( !isset( $params['label'] ) ) {
969 $label = $params['label'];
972 if ( !isset( $params['controlName'] ) ) {
973 $params['controlName'] = 'config_' . $params['var'];
976 if ( !isset( $params['help'] ) ) {
977 $params['help'] = "";
981 foreach ( $items as $value => $item ) {
982 $s .= "<li>$item</li>\n";
986 return $this->label( $label, $params['controlName'], $s, $params['help'] );
990 * Get a set of labelled radio buttons. You probably want to use getRadioSet(), not this.
996 public function getRadioElements( $params ) {
997 if ( !isset( $params['controlName'] ) ) {
998 $params['controlName'] = 'config_' . $params['var'];
1001 if ( !isset( $params['value'] ) ) {
1002 $params['value'] = $this->getVar( $params['var'] );
1007 foreach ( $params['values'] as $value ) {
1008 $itemAttribs = array();
1010 if ( isset( $params['commonAttribs'] ) ) {
1011 $itemAttribs = $params['commonAttribs'];
1014 if ( isset( $params['itemAttribs'][$value] ) ) {
1015 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
1018 $checked = $value == $params['value'];
1019 $id = $params['controlName'] . '_' . $value;
1020 $itemAttribs['id'] = $id;
1021 $itemAttribs['tabindex'] = $this->nextTabIndex();
1024 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1026 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
1027 isset( $params['itemLabels'] ) ?
1028 wfMessage( $params['itemLabels'][$value] )->plain() :
1029 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1037 * Output an error or warning box using a Status object.
1039 * @param Status $status
1041 public function showStatusBox( $status ) {
1042 if ( !$status->isGood() ) {
1043 $text = $status->getWikiText();
1045 if ( $status->isOk() ) {
1046 $box = $this->getWarningBox( $text );
1048 $box = $this->getErrorBox( $text );
1051 $this->output
->addHTML( $box );
1056 * Convenience function to set variables based on form data.
1057 * Assumes that variables containing "password" in the name are (potentially
1060 * @param string[] $varNames
1061 * @param string $prefix The prefix added to variables to obtain form names
1065 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1066 $newValues = array();
1068 foreach ( $varNames as $name ) {
1069 $value = trim( $this->request
->getVal( $prefix . $name ) );
1070 $newValues[$name] = $value;
1072 if ( $value === null ) {
1074 $this->setVar( $name, false );
1076 if ( stripos( $name, 'password' ) !== false ) {
1077 $this->setPassword( $name, $value );
1079 $this->setVar( $name, $value );
1088 * Helper for Installer::docLink()
1090 * @param string $page
1094 protected function getDocUrl( $page ) {
1095 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1097 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1098 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1105 * Extension tag hook for a documentation link.
1107 * @param string $linkText
1108 * @param string[] $attribs
1109 * @param Parser $parser Unused
1113 public function docLink( $linkText, $attribs, $parser ) {
1114 $url = $this->getDocUrl( $attribs['href'] );
1116 return '<a href="' . htmlspecialchars( $url ) . '">' .
1117 htmlspecialchars( $linkText ) .
1122 * Helper for "Download LocalSettings" link on WebInstall_Complete
1124 * @param string $text Unused
1125 * @param string[] $attribs Unused
1126 * @param Parser $parser Unused
1128 * @return string Html for download link
1130 public function downloadLinkHook( $text, $attribs, $parser ) {
1131 $anchor = Html
::rawElement( 'a',
1132 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1133 wfMessage( 'config-download-localsettings' )->parse()
1136 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1142 public function envCheckPath() {
1143 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1144 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1145 // to get the path to the current script... hopefully it's reliable. SIGH
1147 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1148 $path = $_SERVER['PHP_SELF'];
1149 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1150 $path = $_SERVER['SCRIPT_NAME'];
1152 if ( $path !== false ) {
1153 $scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1154 $scriptExtension = $this->getVar( 'wgScriptExtension' );
1156 $this->setVar( 'wgScriptPath', "$scriptPath" );
1157 // Update variables set from Setup.php that are derived from wgScriptPath
1158 $this->setVar( 'wgScript', "$scriptPath/index$scriptExtension" );
1159 $this->setVar( 'wgLoadScript', "$scriptPath/load$scriptExtension" );
1160 $this->setVar( 'wgStylePath', "$scriptPath/skins" );
1161 $this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
1162 $this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
1163 $this->setVar( 'wgUploadPath', "$scriptPath/images" );
1166 $this->showError( 'config-no-uri' );
1171 return parent
::envCheckPath();
1177 protected function envGetDefaultServer() {
1178 return WebRequest
::detectServer();
1182 * Output stylesheet for web installer pages
1184 public function outputCss() {
1185 $this->request
->response()->header( 'Content-type: text/css' );
1186 echo $this->output
->getCSS();
1192 public function getPhpErrors() {
1193 return $this->phpErrors
;