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 $request WebRequest
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' ) );
340 restore_error_handler();
342 if ( $this->phpErrors
) {
343 $this->showError( 'config-session-error', $this->phpErrors
[0] );
352 * Get a hash of data identifying this MW installation.
354 * This is used by mw-config/index.php to prevent multiple installations of MW
355 * on the same cookie domain from interfering with each other.
359 public function getFingerprint() {
360 // Get the base URL of the installation
361 $url = $this->request
->getFullRequestURL();
362 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
366 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
367 // This... seems to try to get the base path from
368 // the /mw-config/index.php. Kinda scary though?
372 return md5( serialize( array(
373 'local path' => dirname( __DIR__
),
375 'version' => $GLOBALS['wgVersion']
380 * Show an error message in a box. Parameters are like wfMessage().
383 public function showError( $msg /*...*/ ) {
384 $args = func_get_args();
385 array_shift( $args );
386 $args = array_map( 'htmlspecialchars', $args );
387 $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
388 $this->output
->addHTML( $this->getErrorBox( $msg ) );
392 * Temporary error handler for session start debugging.
394 * @param $errstr string
396 public function errorHandler( $errno, $errstr ) {
397 $this->phpErrors
[] = $errstr;
401 * Clean up from execute()
405 public function finish() {
406 $this->output
->output();
408 $this->session
['happyPages'] = $this->happyPages
;
409 $this->session
['skippedPages'] = $this->skippedPages
;
410 $this->session
['settings'] = $this->settings
;
412 return $this->session
;
416 * We're restarting the installation, reset the session, happyPages, etc
418 public function reset() {
419 $this->session
= array();
420 $this->happyPages
= array();
421 $this->settings
= array();
425 * Get a URL for submission back to the same script.
427 * @param $query array
430 public function getUrl( $query = array() ) {
431 $url = $this->request
->getRequestURL();
432 # Remove existing query
433 $url = preg_replace( '/\?.*$/', '', $url );
436 $url .= '?' . wfArrayToCgi( $query );
443 * Get a WebInstallerPage by name.
445 * @param $pageName String
446 * @return WebInstallerPage
448 public function getPageByName( $pageName ) {
449 $pageClass = 'WebInstaller_' . $pageName;
451 return new $pageClass( $this );
455 * Get a session variable.
457 * @param $name String
461 public function getSession( $name, $default = null ) {
462 if ( !isset( $this->session
[$name] ) ) {
465 return $this->session
[$name];
470 * Set a session variable.
471 * @param string $name key for the variable
472 * @param $value Mixed
474 public function setSession( $name, $value ) {
475 $this->session
[$name] = $value;
479 * Get the next tabindex attribute value.
482 public function nextTabIndex() {
483 return $this->tabIndex++
;
487 * Initializes language-related variables.
489 public function setupLanguage() {
490 global $wgLang, $wgContLang, $wgLanguageCode;
492 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
493 $wgLanguageCode = $this->getAcceptLanguage();
494 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
495 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
496 $this->setVar( '_UserLang', $wgLanguageCode );
498 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
499 $wgContLang = Language
::factory( $wgLanguageCode );
504 * Retrieves MediaWiki language from Accept-Language HTTP header.
508 public function getAcceptLanguage() {
509 global $wgLanguageCode, $wgRequest;
511 $mwLanguages = Language
::fetchLanguageNames();
512 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
514 foreach ( $headerLanguages as $lang ) {
515 if ( isset( $mwLanguages[$lang] ) ) {
520 return $wgLanguageCode;
524 * Called by execute() before page output starts, to show a page list.
526 * @param $currentPageName string
528 private function startPageWrapper( $currentPageName ) {
529 $s = "<div class=\"config-page-wrapper\">\n";
530 $s .= "<div class=\"config-page\">\n";
531 $s .= "<div class=\"config-page-list\"><ul>\n";
534 foreach ( $this->pageSequence
as $id => $pageName ) {
535 $happy = !empty( $this->happyPages
[$id] );
536 $s .= $this->getPageListItem(
538 $happy ||
$lastHappy == $id - 1,
547 $s .= "</ul><br/><ul>\n";
548 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
550 $s .= "</ul></div>\n";
553 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
554 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
555 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
556 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
557 $s .= Html
::element( 'h2', array(),
558 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
560 $this->output
->addHTMLNoFlush( $s );
564 * Get a list item for the page list.
566 * @param $pageName string
567 * @param $enabled boolean
568 * @param $currentPageName string
572 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
573 $s = "<li class=\"config-page-list-item\">";
576 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
577 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
578 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
579 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
580 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
583 $query = array( 'page' => $pageName );
585 if ( !in_array( $pageName, $this->pageSequence
) ) {
586 if ( in_array( $currentPageName, $this->pageSequence
) ) {
587 $query['lastPage'] = $currentPageName;
590 $link = Html
::element( 'a',
592 'href' => $this->getUrl( $query )
597 $link = htmlspecialchars( $name );
600 if ( $pageName == $currentPageName ) {
601 $s .= "<span class=\"config-page-current\">$link</span>";
606 $s .= Html
::element( 'span',
608 'class' => 'config-page-disabled'
620 * Output some stuff after a page is finished.
622 private function endPageWrapper() {
623 $this->output
->addHTMLNoFlush(
624 "<div class=\"visualClear\"></div>\n" .
626 "<div class=\"visualClear\"></div>\n" .
631 * Get HTML for an error box with an icon.
633 * @param string $text wikitext, get this with wfMessage()->plain()
637 public function getErrorBox( $text ) {
638 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
642 * Get HTML for a warning box with an icon.
644 * @param string $text wikitext, get this with wfMessage()->plain()
648 public function getWarningBox( $text ) {
649 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
653 * Get HTML for an info box with an icon.
655 * @param string $text wikitext, get this with wfMessage()->plain()
656 * @param string $icon icon name, file in skins/common/images
657 * @param string $class additional class name to add to the wrapper div
661 public function getInfoBox( $text, $icon = false, $class = false ) {
662 $text = $this->parse( $text, true );
663 $icon = ( $icon == false ) ?
'../skins/common/images/info-32.png' : '../skins/common/images/' . $icon;
664 $alt = wfMessage( 'config-information' )->text();
666 return Html
::infoBox( $text, $icon, $alt, $class, false );
670 * Get small text indented help for a preceding form field.
671 * Parameters like wfMessage().
676 public function getHelpBox( $msg /*, ... */ ) {
677 $args = func_get_args();
678 array_shift( $args );
679 $args = array_map( 'htmlspecialchars', $args );
680 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
681 $html = $this->parse( $text, true );
683 return "<div class=\"mw-help-field-container\">\n" .
684 "<span class=\"mw-help-field-hint\">" . wfMessage( 'config-help' )->escaped() .
686 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
692 * @param string $msg key for wfMessage()
694 public function showHelpBox( $msg /*, ... */ ) {
695 $args = func_get_args();
696 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
697 $this->output
->addHTML( $html );
701 * Show a short informational message.
702 * Output looks like a list.
706 public function showMessage( $msg /*, ... */ ) {
707 $args = func_get_args();
708 array_shift( $args );
709 $html = '<div class="config-message">' .
710 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
712 $this->output
->addHTML( $html );
716 * @param $status Status
718 public function showStatusMessage( Status
$status ) {
719 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
720 foreach ( $errors as $error ) {
721 call_user_func_array( array( $this, 'showMessage' ), $error );
726 * Label a control by wrapping a config-input div around it and putting a
732 * @param $helpData string
735 public function label( $msg, $forId, $contents, $helpData = "" ) {
736 if ( strval( $msg ) == '' ) {
737 $labelText = ' ';
739 $labelText = wfMessage( $msg )->escaped();
742 $attributes = array( 'class' => 'config-label' );
745 $attributes['for'] = $forId;
748 return "<div class=\"config-block\">\n" .
749 " <div class=\"config-block-label\">\n" .
756 " <div class=\"config-block-elements\">\n" .
763 * Get a labelled text box to configure a variable.
765 * @param $params Array
767 * var: The variable to be configured (required)
768 * label: The message name for the label (required)
769 * attribs: Additional attributes for the input element (optional)
770 * controlName: The name for the input element (optional)
771 * value: The current value of the variable (optional)
772 * help: The html for the help text (optional)
776 public function getTextBox( $params ) {
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'] = array();
788 if ( !isset( $params['help'] ) ) {
789 $params['help'] = "";
794 $params['controlName'],
796 $params['controlName'],
797 30, // intended to be overridden by CSS
799 $params['attribs'] +
array(
800 'id' => $params['controlName'],
801 'class' => 'config-input-text',
802 'tabindex' => $this->nextTabIndex()
810 * Get a labelled textarea to configure a variable
812 * @param $params Array
814 * var: The variable to be configured (required)
815 * label: The message name for the label (required)
816 * attribs: Additional attributes for the input element (optional)
817 * controlName: The name for the input element (optional)
818 * value: The current value of the variable (optional)
819 * help: The html for the help text (optional)
823 public function getTextArea( $params ) {
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'] = array();
835 if ( !isset( $params['help'] ) ) {
836 $params['help'] = "";
841 $params['controlName'],
843 $params['controlName'],
847 $params['attribs'] +
array(
848 'id' => $params['controlName'],
849 'class' => 'config-input-text',
850 'tabindex' => $this->nextTabIndex()
858 * Get a labelled password box to configure a variable.
860 * Implements password hiding
861 * @param $params Array
863 * var: The variable to be configured (required)
864 * label: The message name for the label (required)
865 * attribs: Additional attributes for the input element (optional)
866 * controlName: The name for the input element (optional)
867 * value: The current value of the variable (optional)
868 * help: The html for the help text (optional)
872 public function getPasswordBox( $params ) {
873 if ( !isset( $params['value'] ) ) {
874 $params['value'] = $this->getVar( $params['var'] );
877 if ( !isset( $params['attribs'] ) ) {
878 $params['attribs'] = array();
881 $params['value'] = $this->getFakePassword( $params['value'] );
882 $params['attribs']['type'] = 'password';
884 return $this->getTextBox( $params );
888 * Get a labelled checkbox to configure a boolean variable.
890 * @param $params Array
892 * var: The variable to be configured (required)
893 * label: The message name for the label (required)
894 * attribs: Additional attributes for the input element (optional)
895 * controlName: The name for the input element (optional)
896 * value: The current value of the variable (optional)
897 * help: The html for the help text (optional)
901 public function getCheckBox( $params ) {
902 if ( !isset( $params['controlName'] ) ) {
903 $params['controlName'] = 'config_' . $params['var'];
906 if ( !isset( $params['value'] ) ) {
907 $params['value'] = $this->getVar( $params['var'] );
910 if ( !isset( $params['attribs'] ) ) {
911 $params['attribs'] = array();
913 if ( !isset( $params['help'] ) ) {
914 $params['help'] = "";
916 if ( isset( $params['rawtext'] ) ) {
917 $labelText = $params['rawtext'];
919 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
922 return "<div class=\"config-input-check\">\n" .
926 $params['controlName'],
928 $params['attribs'] +
array(
929 'id' => $params['controlName'],
930 'tabindex' => $this->nextTabIndex(),
939 * Get a set of labelled radio buttons.
941 * @param $params Array
943 * var: The variable to be configured (required)
944 * label: The message name for the label (required)
945 * itemLabelPrefix: The message name prefix for the item labels (required)
946 * values: List of allowed values (required)
947 * itemAttribs: Array of attribute arrays, outer key is the value name (optional)
948 * commonAttribs: Attribute array applied to all items
949 * controlName: The name for the input element (optional)
950 * value: The current value of the variable (optional)
951 * help: The html for the help text (optional)
955 public function getRadioSet( $params ) {
956 if ( !isset( $params['controlName'] ) ) {
957 $params['controlName'] = 'config_' . $params['var'];
960 if ( !isset( $params['value'] ) ) {
961 $params['value'] = $this->getVar( $params['var'] );
964 if ( !isset( $params['label'] ) ) {
967 $label = $params['label'];
969 if ( !isset( $params['help'] ) ) {
970 $params['help'] = "";
973 foreach ( $params['values'] as $value ) {
974 $itemAttribs = array();
976 if ( isset( $params['commonAttribs'] ) ) {
977 $itemAttribs = $params['commonAttribs'];
980 if ( isset( $params['itemAttribs'][$value] ) ) {
981 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
984 $checked = $value == $params['value'];
985 $id = $params['controlName'] . '_' . $value;
986 $itemAttribs['id'] = $id;
987 $itemAttribs['tabindex'] = $this->nextTabIndex();
991 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
993 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
994 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1001 return $this->label( $label, $params['controlName'], $s, $params['help'] );
1005 * Output an error or warning box using a Status object.
1007 * @param $status Status
1009 public function showStatusBox( $status ) {
1010 if ( !$status->isGood() ) {
1011 $text = $status->getWikiText();
1013 if ( $status->isOk() ) {
1014 $box = $this->getWarningBox( $text );
1016 $box = $this->getErrorBox( $text );
1019 $this->output
->addHTML( $box );
1024 * Convenience function to set variables based on form data.
1025 * Assumes that variables containing "password" in the name are (potentially
1028 * @param $varNames Array
1029 * @param string $prefix the prefix added to variables to obtain form names
1033 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1034 $newValues = array();
1036 foreach ( $varNames as $name ) {
1037 $value = trim( $this->request
->getVal( $prefix . $name ) );
1038 $newValues[$name] = $value;
1040 if ( $value === null ) {
1042 $this->setVar( $name, false );
1044 if ( stripos( $name, 'password' ) !== false ) {
1045 $this->setPassword( $name, $value );
1047 $this->setVar( $name, $value );
1056 * Helper for Installer::docLink()
1061 protected function getDocUrl( $page ) {
1062 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1064 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1065 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1072 * Extension tag hook for a documentation link.
1079 public function docLink( $linkText, $attribs, $parser ) {
1080 $url = $this->getDocUrl( $attribs['href'] );
1082 return '<a href="' . htmlspecialchars( $url ) . '">' .
1083 htmlspecialchars( $linkText ) .
1088 * Helper for "Download LocalSettings" link on WebInstall_Complete
1093 * @return String Html for download link
1095 public function downloadLinkHook( $text, $attribs, $parser ) {
1096 $img = Html
::element( 'img', array(
1097 'src' => '../skins/common/images/download-32.png',
1101 $anchor = Html
::rawElement( 'a',
1102 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1103 $img . ' ' . wfMessage( 'config-download-localsettings' )->parse() );
1105 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1111 public function envCheckPath() {
1112 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1113 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1114 // to get the path to the current script... hopefully it's reliable. SIGH
1116 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1117 $path = $_SERVER['PHP_SELF'];
1118 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1119 $path = $_SERVER['SCRIPT_NAME'];
1121 if ( $path !== false ) {
1122 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1123 $this->setVar( 'wgScriptPath', $uri );
1125 $this->showError( 'config-no-uri' );
1130 return parent
::envCheckPath();
1133 protected function envGetDefaultServer() {
1134 return WebRequest
::detectServer();