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.
58 * The main sequence of page names. These will be displayed in turn.
60 * To add a new installer page:
61 * * Add it to this WebInstaller::$pageSequence property
62 * * Add a "config-page-<name>" message
63 * * Add a "WebInstaller_<name>" class
66 public $pageSequence = array(
80 * Out of sequence pages, selectable by the user at any time.
83 protected $otherPages = array(
88 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
92 * Array of pages which have declared that they have been submitted, have validated
93 * their input, and need no further processing.
96 protected $happyPages;
99 * List of "skipped" pages. These are pages that will automatically continue
100 * to the next page on any GET request. To avoid breaking the "back" button,
101 * they need to be skipped during a back operation.
104 protected $skippedPages;
107 * Flag indicating that session data may have been lost.
110 public $showSessionWarning = false;
113 * Numeric index of the page we're on
116 protected $tabIndex = 1;
119 * Name of the page we're on
122 protected $currentPageName;
127 * @param WebRequest $request
129 public function __construct( WebRequest
$request ) {
130 parent
::__construct();
131 $this->output
= new WebInstallerOutput( $this );
132 $this->request
= $request;
136 $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
137 $wgParser->setHook( 'doclink', array( $this, 'docLink' ) );
143 * @param array $session initial session array
145 * @return array New session array
147 public function execute( array $session ) {
148 $this->session
= $session;
150 if ( isset( $session['settings'] ) ) {
151 $this->settings
= $session['settings'] +
$this->settings
;
155 $this->setupLanguage();
157 if ( ( $this->getVar( '_InstallDone' ) ||
$this->getVar( '_UpgradeDone' ) )
158 && $this->request
->getVal( 'localsettings' )
160 $this->request
->response()->header( 'Content-type: application/x-httpd-php' );
161 $this->request
->response()->header(
162 'Content-Disposition: attachment; filename="LocalSettings.php"'
165 $ls = InstallerOverrides
::getLocalSettingsGenerator( $this );
166 $rightsProfile = $this->rightsProfiles
[$this->getVar( '_RightsProfile' )];
167 foreach ( $rightsProfile as $group => $rightsArr ) {
168 $ls->setGroupRights( $group, $rightsArr );
172 return $this->session
;
175 $cssDir = $this->request
->getVal( 'css' );
177 $cssDir = ( $cssDir == 'rtl' ?
'rtl' : 'ltr' );
178 $this->request
->response()->header( 'Content-type: text/css' );
179 echo $this->output
->getCSS( $cssDir );
181 return $this->session
;
184 if ( isset( $session['happyPages'] ) ) {
185 $this->happyPages
= $session['happyPages'];
187 $this->happyPages
= array();
190 if ( isset( $session['skippedPages'] ) ) {
191 $this->skippedPages
= $session['skippedPages'];
193 $this->skippedPages
= array();
196 $lowestUnhappy = $this->getLowestUnhappy();
198 # Special case for Creative Commons partner chooser box.
199 if ( $this->request
->getVal( 'SubmitCC' ) ) {
200 $page = $this->getPageByName( 'Options' );
201 $this->output
->useShortHeader();
202 $this->output
->allowFrames();
205 return $this->finish();
208 if ( $this->request
->getVal( 'ShowCC' ) ) {
209 $page = $this->getPageByName( 'Options' );
210 $this->output
->useShortHeader();
211 $this->output
->allowFrames();
212 $this->output
->addHTML( $page->getCCDoneBox() );
214 return $this->finish();
218 $pageName = $this->request
->getVal( 'page' );
220 if ( in_array( $pageName, $this->otherPages
) ) {
223 $page = $this->getPageByName( $pageName );
226 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
227 $pageId = $lowestUnhappy;
229 $pageId = array_search( $pageName, $this->pageSequence
);
232 # If necessary, move back to the lowest-numbered unhappy page
233 if ( $pageId > $lowestUnhappy ) {
234 $pageId = $lowestUnhappy;
235 if ( $lowestUnhappy == 0 ) {
236 # Knocked back to start, possible loss of session data.
237 $this->showSessionWarning
= true;
241 $pageName = $this->pageSequence
[$pageId];
242 $page = $this->getPageByName( $pageName );
245 # If a back button was submitted, go back without submitting the form data.
246 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
247 if ( $this->request
->getVal( 'lastPage' ) ) {
248 $nextPage = $this->request
->getVal( 'lastPage' );
249 } elseif ( $pageId !== false ) {
251 # Skip the skipped pages
252 $nextPageId = $pageId;
256 $nextPage = $this->pageSequence
[$nextPageId];
257 } while ( isset( $this->skippedPages
[$nextPage] ) );
259 $nextPage = $this->pageSequence
[$lowestUnhappy];
262 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
264 return $this->finish();
268 $this->currentPageName
= $page->getName();
269 $this->startPageWrapper( $pageName );
271 if ( $page->isSlow() ) {
272 $this->disableTimeLimit();
275 $result = $page->execute();
277 $this->endPageWrapper();
279 if ( $result == 'skip' ) {
280 # Page skipped without explicit submission.
281 # Skip it when we click "back" so that we don't just go forward again.
282 $this->skippedPages
[$pageName] = true;
283 $result = 'continue';
285 unset( $this->skippedPages
[$pageName] );
288 # If it was posted, the page can request a continue to the next page.
289 if ( $result === 'continue' && !$this->output
->headerDone() ) {
290 if ( $pageId !== false ) {
291 $this->happyPages
[$pageId] = true;
294 $lowestUnhappy = $this->getLowestUnhappy();
296 if ( $this->request
->getVal( 'lastPage' ) ) {
297 $nextPage = $this->request
->getVal( 'lastPage' );
298 } elseif ( $pageId !== false ) {
299 $nextPage = $this->pageSequence
[$pageId +
1];
301 $nextPage = $this->pageSequence
[$lowestUnhappy];
304 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
305 $nextPage = $this->pageSequence
[$lowestUnhappy];
308 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
311 return $this->finish();
315 * Find the next page in sequence that hasn't been completed
318 public function getLowestUnhappy() {
319 if ( count( $this->happyPages
) == 0 ) {
322 return max( array_keys( $this->happyPages
) ) +
1;
327 * Start the PHP session. This may be called before execute() to start the PHP session.
331 public function startSession() {
332 if ( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
337 $this->phpErrors
= array();
338 set_error_handler( array( $this, 'errorHandler' ) );
341 } catch ( Exception
$e ) {
342 restore_error_handler();
345 restore_error_handler();
347 if ( $this->phpErrors
) {
348 $this->showError( 'config-session-error', $this->phpErrors
[0] );
357 * Get a hash of data identifying this MW installation.
359 * This is used by mw-config/index.php to prevent multiple installations of MW
360 * on the same cookie domain from interfering with each other.
364 public function getFingerprint() {
365 // Get the base URL of the installation
366 $url = $this->request
->getFullRequestURL();
367 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
371 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
372 // This... seems to try to get the base path from
373 // the /mw-config/index.php. Kinda scary though?
377 return md5( serialize( array(
378 'local path' => dirname( __DIR__
),
380 'version' => $GLOBALS['wgVersion']
385 * Show an error message in a box. Parameters are like wfMessage().
388 public function showError( $msg /*...*/ ) {
389 $args = func_get_args();
390 array_shift( $args );
391 $args = array_map( 'htmlspecialchars', $args );
392 $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
393 $this->output
->addHTML( $this->getErrorBox( $msg ) );
397 * Temporary error handler for session start debugging.
399 * @param string $errstr
401 public function errorHandler( $errno, $errstr ) {
402 $this->phpErrors
[] = $errstr;
406 * Clean up from execute()
410 public function finish() {
411 $this->output
->output();
413 $this->session
['happyPages'] = $this->happyPages
;
414 $this->session
['skippedPages'] = $this->skippedPages
;
415 $this->session
['settings'] = $this->settings
;
417 return $this->session
;
421 * We're restarting the installation, reset the session, happyPages, etc
423 public function reset() {
424 $this->session
= array();
425 $this->happyPages
= array();
426 $this->settings
= array();
430 * Get a URL for submission back to the same script.
432 * @param array $query
435 public function getUrl( $query = array() ) {
436 $url = $this->request
->getRequestURL();
437 # Remove existing query
438 $url = preg_replace( '/\?.*$/', '', $url );
441 $url .= '?' . wfArrayToCgi( $query );
448 * Get a WebInstallerPage by name.
450 * @param string $pageName
451 * @return WebInstallerPage
453 public function getPageByName( $pageName ) {
454 $pageClass = 'WebInstaller_' . $pageName;
456 return new $pageClass( $this );
460 * Get a session variable.
462 * @param string $name
466 public function getSession( $name, $default = null ) {
467 if ( !isset( $this->session
[$name] ) ) {
470 return $this->session
[$name];
475 * Set a session variable.
476 * @param string $name Key for the variable
477 * @param mixed $value
479 public function setSession( $name, $value ) {
480 $this->session
[$name] = $value;
484 * Get the next tabindex attribute value.
487 public function nextTabIndex() {
488 return $this->tabIndex++
;
492 * Initializes language-related variables.
494 public function setupLanguage() {
495 global $wgLang, $wgContLang, $wgLanguageCode;
497 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
498 $wgLanguageCode = $this->getAcceptLanguage();
499 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
500 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
501 $this->setVar( '_UserLang', $wgLanguageCode );
503 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
504 $wgContLang = Language
::factory( $wgLanguageCode );
509 * Retrieves MediaWiki language from Accept-Language HTTP header.
513 public function getAcceptLanguage() {
514 global $wgLanguageCode, $wgRequest;
516 $mwLanguages = Language
::fetchLanguageNames();
517 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
519 foreach ( $headerLanguages as $lang ) {
520 if ( isset( $mwLanguages[$lang] ) ) {
525 return $wgLanguageCode;
529 * Called by execute() before page output starts, to show a page list.
531 * @param string $currentPageName
533 private function startPageWrapper( $currentPageName ) {
534 $s = "<div class=\"config-page-wrapper\">\n";
535 $s .= "<div class=\"config-page\">\n";
536 $s .= "<div class=\"config-page-list\"><ul>\n";
539 foreach ( $this->pageSequence
as $id => $pageName ) {
540 $happy = !empty( $this->happyPages
[$id] );
541 $s .= $this->getPageListItem(
543 $happy ||
$lastHappy == $id - 1,
552 $s .= "</ul><br/><ul>\n";
553 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
555 $s .= "</ul></div>\n";
558 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
559 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
560 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
561 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
562 $s .= Html
::element( 'h2', array(),
563 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
565 $this->output
->addHTMLNoFlush( $s );
569 * Get a list item for the page list.
571 * @param string $pageName
572 * @param bool $enabled
573 * @param string $currentPageName
577 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
578 $s = "<li class=\"config-page-list-item\">";
581 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
582 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
583 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
584 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
585 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
588 $query = array( 'page' => $pageName );
590 if ( !in_array( $pageName, $this->pageSequence
) ) {
591 if ( in_array( $currentPageName, $this->pageSequence
) ) {
592 $query['lastPage'] = $currentPageName;
595 $link = Html
::element( 'a',
597 'href' => $this->getUrl( $query )
602 $link = htmlspecialchars( $name );
605 if ( $pageName == $currentPageName ) {
606 $s .= "<span class=\"config-page-current\">$link</span>";
611 $s .= Html
::element( 'span',
613 'class' => 'config-page-disabled'
625 * Output some stuff after a page is finished.
627 private function endPageWrapper() {
628 $this->output
->addHTMLNoFlush(
629 "<div class=\"visualClear\"></div>\n" .
631 "<div class=\"visualClear\"></div>\n" .
636 * Get HTML for an error box with an icon.
638 * @param string $text Wikitext, get this with wfMessage()->plain()
642 public function getErrorBox( $text ) {
643 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
647 * Get HTML for a warning box with an icon.
649 * @param string $text Wikitext, get this with wfMessage()->plain()
653 public function getWarningBox( $text ) {
654 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
658 * Get HTML for an info box with an icon.
660 * @param string $text Wikitext, get this with wfMessage()->plain()
661 * @param string|bool $icon Icon name, file in skins/common/images. Default: false
662 * @param string|bool $class Additional class name to add to the wrapper div. Default: false.
666 public function getInfoBox( $text, $icon = false, $class = false ) {
667 $text = $this->parse( $text, true );
668 $icon = ( $icon == false ) ?
669 '../skins/common/images/info-32.png' :
670 '../skins/common/images/' . $icon;
671 $alt = wfMessage( 'config-information' )->text();
673 return Html
::infoBox( $text, $icon, $alt, $class, false );
677 * Get small text indented help for a preceding form field.
678 * Parameters like wfMessage().
683 public function getHelpBox( $msg /*, ... */ ) {
684 $args = func_get_args();
685 array_shift( $args );
686 $args = array_map( 'htmlspecialchars', $args );
687 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
688 $html = $this->parse( $text, true );
690 return "<div class=\"mw-help-field-container\">\n" .
691 "<span class=\"mw-help-field-hint\">" . wfMessage( 'config-help' )->escaped() .
693 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
699 * @param string $msg Key for wfMessage()
701 public function showHelpBox( $msg /*, ... */ ) {
702 $args = func_get_args();
703 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
704 $this->output
->addHTML( $html );
708 * Show a short informational message.
709 * Output looks like a list.
713 public function showMessage( $msg /*, ... */ ) {
714 $args = func_get_args();
715 array_shift( $args );
716 $html = '<div class="config-message">' .
717 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
719 $this->output
->addHTML( $html );
723 * @param Status $status
725 public function showStatusMessage( Status
$status ) {
726 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
727 foreach ( $errors as $error ) {
728 call_user_func_array( array( $this, 'showMessage' ), $error );
733 * Label a control by wrapping a config-input div around it and putting a
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 array $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 array $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 array $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 array $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 array $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 * values: List of allowed values (required)
954 * itemAttribs: Array of attribute arrays, outer key is the value name (optional)
955 * commonAttribs: Attribute array applied to all items
956 * controlName: The name for the input element (optional)
957 * value: The current value of the variable (optional)
958 * help: The html for the help text (optional)
962 public function getRadioSet( $params ) {
963 if ( !isset( $params['controlName'] ) ) {
964 $params['controlName'] = 'config_' . $params['var'];
967 if ( !isset( $params['value'] ) ) {
968 $params['value'] = $this->getVar( $params['var'] );
971 if ( !isset( $params['label'] ) ) {
974 $label = $params['label'];
976 if ( !isset( $params['help'] ) ) {
977 $params['help'] = "";
980 foreach ( $params['values'] as $value ) {
981 $itemAttribs = array();
983 if ( isset( $params['commonAttribs'] ) ) {
984 $itemAttribs = $params['commonAttribs'];
987 if ( isset( $params['itemAttribs'][$value] ) ) {
988 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
991 $checked = $value == $params['value'];
992 $id = $params['controlName'] . '_' . $value;
993 $itemAttribs['id'] = $id;
994 $itemAttribs['tabindex'] = $this->nextTabIndex();
998 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1000 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
1001 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1008 return $this->label( $label, $params['controlName'], $s, $params['help'] );
1012 * Output an error or warning box using a Status object.
1014 * @param Status $status
1016 public function showStatusBox( $status ) {
1017 if ( !$status->isGood() ) {
1018 $text = $status->getWikiText();
1020 if ( $status->isOk() ) {
1021 $box = $this->getWarningBox( $text );
1023 $box = $this->getErrorBox( $text );
1026 $this->output
->addHTML( $box );
1031 * Convenience function to set variables based on form data.
1032 * Assumes that variables containing "password" in the name are (potentially
1035 * @param array $varNames
1036 * @param string $prefix The prefix added to variables to obtain form names
1040 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1041 $newValues = array();
1043 foreach ( $varNames as $name ) {
1044 $value = trim( $this->request
->getVal( $prefix . $name ) );
1045 $newValues[$name] = $value;
1047 if ( $value === null ) {
1049 $this->setVar( $name, false );
1051 if ( stripos( $name, 'password' ) !== false ) {
1052 $this->setPassword( $name, $value );
1054 $this->setVar( $name, $value );
1063 * Helper for Installer::docLink()
1068 protected function getDocUrl( $page ) {
1069 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1071 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1072 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1079 * Extension tag hook for a documentation link.
1086 public function docLink( $linkText, $attribs, $parser ) {
1087 $url = $this->getDocUrl( $attribs['href'] );
1089 return '<a href="' . htmlspecialchars( $url ) . '">' .
1090 htmlspecialchars( $linkText ) .
1095 * Helper for "Download LocalSettings" link on WebInstall_Complete
1100 * @return string Html for download link
1102 public function downloadLinkHook( $text, $attribs, $parser ) {
1103 $img = Html
::element( 'img', array(
1104 'src' => '../skins/common/images/download-32.png',
1108 $anchor = Html
::rawElement( 'a',
1109 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1110 $img . ' ' . wfMessage( 'config-download-localsettings' )->parse() );
1112 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1118 public function envCheckPath() {
1119 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1120 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1121 // to get the path to the current script... hopefully it's reliable. SIGH
1123 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1124 $path = $_SERVER['PHP_SELF'];
1125 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1126 $path = $_SERVER['SCRIPT_NAME'];
1128 if ( $path !== false ) {
1129 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1130 $this->setVar( 'wgScriptPath', $uri );
1132 $this->showError( 'config-no-uri' );
1137 return parent
::envCheckPath();
1140 protected function envGetDefaultServer() {
1141 return WebRequest
::detectServer();