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 );
171 return $this->session
;
174 $cssDir = $this->request
->getVal( 'css' );
176 $cssDir = ( $cssDir == 'rtl' ?
'rtl' : 'ltr' );
177 $this->request
->response()->header( 'Content-type: text/css' );
178 echo $this->output
->getCSS( $cssDir );
179 return $this->session
;
182 if ( isset( $session['happyPages'] ) ) {
183 $this->happyPages
= $session['happyPages'];
185 $this->happyPages
= array();
188 if ( isset( $session['skippedPages'] ) ) {
189 $this->skippedPages
= $session['skippedPages'];
191 $this->skippedPages
= array();
194 $lowestUnhappy = $this->getLowestUnhappy();
196 # Special case for Creative Commons partner chooser box.
197 if ( $this->request
->getVal( 'SubmitCC' ) ) {
198 $page = $this->getPageByName( 'Options' );
199 $this->output
->useShortHeader();
200 $this->output
->allowFrames();
202 return $this->finish();
205 if ( $this->request
->getVal( 'ShowCC' ) ) {
206 $page = $this->getPageByName( 'Options' );
207 $this->output
->useShortHeader();
208 $this->output
->allowFrames();
209 $this->output
->addHTML( $page->getCCDoneBox() );
210 return $this->finish();
214 $pageName = $this->request
->getVal( 'page' );
216 if ( in_array( $pageName, $this->otherPages
) ) {
219 $page = $this->getPageByName( $pageName );
222 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
223 $pageId = $lowestUnhappy;
225 $pageId = array_search( $pageName, $this->pageSequence
);
228 # If necessary, move back to the lowest-numbered unhappy page
229 if ( $pageId > $lowestUnhappy ) {
230 $pageId = $lowestUnhappy;
231 if ( $lowestUnhappy == 0 ) {
232 # Knocked back to start, possible loss of session data.
233 $this->showSessionWarning
= true;
237 $pageName = $this->pageSequence
[$pageId];
238 $page = $this->getPageByName( $pageName );
241 # If a back button was submitted, go back without submitting the form data.
242 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
243 if ( $this->request
->getVal( 'lastPage' ) ) {
244 $nextPage = $this->request
->getVal( 'lastPage' );
245 } elseif ( $pageId !== false ) {
247 # Skip the skipped pages
248 $nextPageId = $pageId;
252 $nextPage = $this->pageSequence
[$nextPageId];
253 } while ( isset( $this->skippedPages
[$nextPage] ) );
255 $nextPage = $this->pageSequence
[$lowestUnhappy];
258 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
259 return $this->finish();
263 $this->currentPageName
= $page->getName();
264 $this->startPageWrapper( $pageName );
266 if ( $page->isSlow() ) {
267 $this->disableTimeLimit();
270 $result = $page->execute();
272 $this->endPageWrapper();
274 if ( $result == 'skip' ) {
275 # Page skipped without explicit submission.
276 # Skip it when we click "back" so that we don't just go forward again.
277 $this->skippedPages
[$pageName] = true;
278 $result = 'continue';
280 unset( $this->skippedPages
[$pageName] );
283 # If it was posted, the page can request a continue to the next page.
284 if ( $result === 'continue' && !$this->output
->headerDone() ) {
285 if ( $pageId !== false ) {
286 $this->happyPages
[$pageId] = true;
289 $lowestUnhappy = $this->getLowestUnhappy();
291 if ( $this->request
->getVal( 'lastPage' ) ) {
292 $nextPage = $this->request
->getVal( 'lastPage' );
293 } elseif ( $pageId !== false ) {
294 $nextPage = $this->pageSequence
[$pageId +
1];
296 $nextPage = $this->pageSequence
[$lowestUnhappy];
299 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
300 $nextPage = $this->pageSequence
[$lowestUnhappy];
303 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
306 return $this->finish();
310 * Find the next page in sequence that hasn't been completed
313 public function getLowestUnhappy() {
314 if ( count( $this->happyPages
) == 0 ) {
317 return max( array_keys( $this->happyPages
) ) +
1;
322 * Start the PHP session. This may be called before execute() to start the PHP session.
326 public function startSession() {
327 if ( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
332 $this->phpErrors
= array();
333 set_error_handler( array( $this, 'errorHandler' ) );
335 restore_error_handler();
337 if ( $this->phpErrors
) {
338 $this->showError( 'config-session-error', $this->phpErrors
[0] );
346 * Get a hash of data identifying this MW installation.
348 * This is used by mw-config/index.php to prevent multiple installations of MW
349 * on the same cookie domain from interfering with each other.
353 public function getFingerprint() {
354 // Get the base URL of the installation
355 $url = $this->request
->getFullRequestURL();
356 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
360 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
361 // This... seems to try to get the base path from
362 // the /mw-config/index.php. Kinda scary though?
365 return md5( serialize( array(
366 'local path' => dirname( __DIR__
),
368 'version' => $GLOBALS['wgVersion']
373 * Show an error message in a box. Parameters are like wfMessage().
376 public function showError( $msg /*...*/ ) {
377 $args = func_get_args();
378 array_shift( $args );
379 $args = array_map( 'htmlspecialchars', $args );
380 $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
381 $this->output
->addHTML( $this->getErrorBox( $msg ) );
385 * Temporary error handler for session start debugging.
387 * @param $errstr string
389 public function errorHandler( $errno, $errstr ) {
390 $this->phpErrors
[] = $errstr;
394 * Clean up from execute()
398 public function finish() {
399 $this->output
->output();
401 $this->session
['happyPages'] = $this->happyPages
;
402 $this->session
['skippedPages'] = $this->skippedPages
;
403 $this->session
['settings'] = $this->settings
;
405 return $this->session
;
409 * We're restarting the installation, reset the session, happyPages, etc
411 public function reset() {
412 $this->session
= array();
413 $this->happyPages
= array();
414 $this->settings
= array();
418 * Get a URL for submission back to the same script.
420 * @param $query array
423 public function getUrl( $query = array() ) {
424 $url = $this->request
->getRequestURL();
425 # Remove existing query
426 $url = preg_replace( '/\?.*$/', '', $url );
429 $url .= '?' . wfArrayToCgi( $query );
436 * Get a WebInstallerPage by name.
438 * @param $pageName String
439 * @return WebInstallerPage
441 public function getPageByName( $pageName ) {
442 $pageClass = 'WebInstaller_' . $pageName;
444 return new $pageClass( $this );
448 * Get a session variable.
450 * @param $name String
454 public function getSession( $name, $default = null ) {
455 if ( !isset( $this->session
[$name] ) ) {
458 return $this->session
[$name];
463 * Set a session variable.
464 * @param string $name key for the variable
465 * @param $value Mixed
467 public function setSession( $name, $value ) {
468 $this->session
[$name] = $value;
472 * Get the next tabindex attribute value.
475 public function nextTabIndex() {
476 return $this->tabIndex++
;
480 * Initializes language-related variables.
482 public function setupLanguage() {
483 global $wgLang, $wgContLang, $wgLanguageCode;
485 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
486 $wgLanguageCode = $this->getAcceptLanguage();
487 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
488 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
489 $this->setVar( '_UserLang', $wgLanguageCode );
491 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
492 $wgContLang = Language
::factory( $wgLanguageCode );
497 * Retrieves MediaWiki language from Accept-Language HTTP header.
501 public function getAcceptLanguage() {
502 global $wgLanguageCode, $wgRequest;
504 $mwLanguages = Language
::fetchLanguageNames();
505 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
507 foreach ( $headerLanguages as $lang ) {
508 if ( isset( $mwLanguages[$lang] ) ) {
513 return $wgLanguageCode;
517 * Called by execute() before page output starts, to show a page list.
519 * @param $currentPageName String
521 private function startPageWrapper( $currentPageName ) {
522 $s = "<div class=\"config-page-wrapper\">\n";
523 $s .= "<div class=\"config-page\">\n";
524 $s .= "<div class=\"config-page-list\"><ul>\n";
527 foreach ( $this->pageSequence
as $id => $pageName ) {
528 $happy = !empty( $this->happyPages
[$id] );
529 $s .= $this->getPageListItem(
531 $happy ||
$lastHappy == $id - 1,
540 $s .= "</ul><br/><ul>\n";
541 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
542 $s .= "</ul></div>\n"; // end list pane
543 // Give grep a chance to find the usages:
544 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
545 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
546 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
547 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
548 $s .= Html
::element( 'h2', array(),
549 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
551 $this->output
->addHTMLNoFlush( $s );
555 * Get a list item for the page list.
557 * @param $pageName String
558 * @param $enabled Boolean
559 * @param $currentPageName String
563 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
564 $s = "<li class=\"config-page-list-item\">";
565 // Give grep a chance to find the usages:
566 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
567 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
568 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
569 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
570 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
573 $query = array( 'page' => $pageName );
575 if ( !in_array( $pageName, $this->pageSequence
) ) {
576 if ( in_array( $currentPageName, $this->pageSequence
) ) {
577 $query['lastPage'] = $currentPageName;
580 $link = Html
::element( 'a',
582 'href' => $this->getUrl( $query )
587 $link = htmlspecialchars( $name );
590 if ( $pageName == $currentPageName ) {
591 $s .= "<span class=\"config-page-current\">$link</span>";
596 $s .= Html
::element( 'span',
598 'class' => 'config-page-disabled'
610 * Output some stuff after a page is finished.
612 private function endPageWrapper() {
613 $this->output
->addHTMLNoFlush(
614 "<div class=\"visualClear\"></div>\n" .
616 "<div class=\"visualClear\"></div>\n" .
621 * Get HTML for an error box with an icon.
623 * @param string $text wikitext, get this with wfMessage()->plain()
627 public function getErrorBox( $text ) {
628 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
632 * Get HTML for a warning box with an icon.
634 * @param string $text wikitext, get this with wfMessage()->plain()
638 public function getWarningBox( $text ) {
639 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
643 * Get HTML for an info box with an icon.
645 * @param string $text wikitext, get this with wfMessage()->plain()
646 * @param string $icon icon name, file in skins/common/images
647 * @param string $class additional class name to add to the wrapper div
651 public function getInfoBox( $text, $icon = false, $class = false ) {
652 $text = $this->parse( $text, true );
653 $icon = ( $icon == false ) ?
'../skins/common/images/info-32.png' : '../skins/common/images/' . $icon;
654 $alt = wfMessage( 'config-information' )->text();
655 return Html
::infoBox( $text, $icon, $alt, $class, false );
659 * Get small text indented help for a preceding form field.
660 * Parameters like wfMessage().
665 public function getHelpBox( $msg /*, ... */ ) {
666 $args = func_get_args();
667 array_shift( $args );
668 $args = array_map( 'htmlspecialchars', $args );
669 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
670 $html = $this->parse( $text, true );
672 return "<div class=\"mw-help-field-container\">\n" .
673 "<span class=\"mw-help-field-hint\">" . wfMessage( 'config-help' )->escaped() .
675 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
681 * @param string $msg key for wfMessage()
683 public function showHelpBox( $msg /*, ... */ ) {
684 $args = func_get_args();
685 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
686 $this->output
->addHTML( $html );
690 * Show a short informational message.
691 * Output looks like a list.
695 public function showMessage( $msg /*, ... */ ) {
696 $args = func_get_args();
697 array_shift( $args );
698 $html = '<div class="config-message">' .
699 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
701 $this->output
->addHTML( $html );
705 * @param $status Status
707 public function showStatusMessage( Status
$status ) {
708 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
709 foreach ( $errors as $error ) {
710 call_user_func_array( array( $this, 'showMessage' ), $error );
715 * Label a control by wrapping a config-input div around it and putting a
721 * @param $helpData string
724 public function label( $msg, $forId, $contents, $helpData = "" ) {
725 if ( strval( $msg ) == '' ) {
726 $labelText = ' ';
728 $labelText = wfMessage( $msg )->escaped();
731 $attributes = array( 'class' => 'config-label' );
734 $attributes['for'] = $forId;
737 return "<div class=\"config-block\">\n" .
738 " <div class=\"config-block-label\">\n" .
741 $labelText ) . "\n" .
744 " <div class=\"config-block-elements\">\n" .
751 * Get a labelled text box to configure a variable.
753 * @param $params Array
755 * var: The variable to be configured (required)
756 * label: The message name for the label (required)
757 * attribs: Additional attributes for the input element (optional)
758 * controlName: The name for the input element (optional)
759 * value: The current value of the variable (optional)
760 * help: The html for the help text (optional)
764 public function getTextBox( $params ) {
765 if ( !isset( $params['controlName'] ) ) {
766 $params['controlName'] = 'config_' . $params['var'];
769 if ( !isset( $params['value'] ) ) {
770 $params['value'] = $this->getVar( $params['var'] );
773 if ( !isset( $params['attribs'] ) ) {
774 $params['attribs'] = array();
776 if ( !isset( $params['help'] ) ) {
777 $params['help'] = "";
781 $params['controlName'],
783 $params['controlName'],
784 30, // intended to be overridden by CSS
786 $params['attribs'] +
array(
787 'id' => $params['controlName'],
788 'class' => 'config-input-text',
789 'tabindex' => $this->nextTabIndex()
797 * Get a labelled textarea to configure a variable
799 * @param $params Array
801 * var: The variable to be configured (required)
802 * label: The message name for the label (required)
803 * attribs: Additional attributes for the input element (optional)
804 * controlName: The name for the input element (optional)
805 * value: The current value of the variable (optional)
806 * help: The html for the help text (optional)
810 public function getTextArea( $params ) {
811 if ( !isset( $params['controlName'] ) ) {
812 $params['controlName'] = 'config_' . $params['var'];
815 if ( !isset( $params['value'] ) ) {
816 $params['value'] = $this->getVar( $params['var'] );
819 if ( !isset( $params['attribs'] ) ) {
820 $params['attribs'] = array();
822 if ( !isset( $params['help'] ) ) {
823 $params['help'] = "";
827 $params['controlName'],
829 $params['controlName'],
833 $params['attribs'] +
array(
834 'id' => $params['controlName'],
835 'class' => 'config-input-text',
836 'tabindex' => $this->nextTabIndex()
844 * Get a labelled password box to configure a variable.
846 * Implements password hiding
847 * @param $params Array
849 * var: The variable to be configured (required)
850 * label: The message name for the label (required)
851 * attribs: Additional attributes for the input element (optional)
852 * controlName: The name for the input element (optional)
853 * value: The current value of the variable (optional)
854 * help: The html for the help text (optional)
858 public function getPasswordBox( $params ) {
859 if ( !isset( $params['value'] ) ) {
860 $params['value'] = $this->getVar( $params['var'] );
863 if ( !isset( $params['attribs'] ) ) {
864 $params['attribs'] = array();
867 $params['value'] = $this->getFakePassword( $params['value'] );
868 $params['attribs']['type'] = 'password';
870 return $this->getTextBox( $params );
874 * Get a labelled checkbox to configure a boolean variable.
876 * @param $params Array
878 * var: The variable to be configured (required)
879 * label: The message name for the label (required)
880 * attribs: Additional attributes for the input element (optional)
881 * controlName: The name for the input element (optional)
882 * value: The current value of the variable (optional)
883 * help: The html for the help text (optional)
887 public function getCheckBox( $params ) {
888 if ( !isset( $params['controlName'] ) ) {
889 $params['controlName'] = 'config_' . $params['var'];
892 if ( !isset( $params['value'] ) ) {
893 $params['value'] = $this->getVar( $params['var'] );
896 if ( !isset( $params['attribs'] ) ) {
897 $params['attribs'] = array();
899 if ( !isset( $params['help'] ) ) {
900 $params['help'] = "";
902 if ( isset( $params['rawtext'] ) ) {
903 $labelText = $params['rawtext'];
905 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
908 return "<div class=\"config-input-check\">\n" .
912 $params['controlName'],
914 $params['attribs'] +
array(
915 'id' => $params['controlName'],
916 'tabindex' => $this->nextTabIndex(),
925 * Get a set of labelled radio buttons.
927 * @param $params Array
929 * var: The variable to be configured (required)
930 * label: The message name for the label (required)
931 * itemLabelPrefix: The message name prefix for the item labels (required)
932 * values: List of allowed values (required)
933 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
934 * commonAttribs Attribute array applied to all items
935 * controlName: The name for the input element (optional)
936 * value: The current value of the variable (optional)
937 * help: The html for the help text (optional)
941 public function getRadioSet( $params ) {
942 if ( !isset( $params['controlName'] ) ) {
943 $params['controlName'] = 'config_' . $params['var'];
946 if ( !isset( $params['value'] ) ) {
947 $params['value'] = $this->getVar( $params['var'] );
950 if ( !isset( $params['label'] ) ) {
953 $label = $params['label'];
955 if ( !isset( $params['help'] ) ) {
956 $params['help'] = "";
959 foreach ( $params['values'] as $value ) {
960 $itemAttribs = array();
962 if ( isset( $params['commonAttribs'] ) ) {
963 $itemAttribs = $params['commonAttribs'];
966 if ( isset( $params['itemAttribs'][$value] ) ) {
967 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
970 $checked = $value == $params['value'];
971 $id = $params['controlName'] . '_' . $value;
972 $itemAttribs['id'] = $id;
973 $itemAttribs['tabindex'] = $this->nextTabIndex();
977 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
979 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
980 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
987 return $this->label( $label, $params['controlName'], $s, $params['help'] );
991 * Output an error or warning box using a Status object.
993 * @param $status Status
995 public function showStatusBox( $status ) {
996 if ( !$status->isGood() ) {
997 $text = $status->getWikiText();
999 if ( $status->isOk() ) {
1000 $box = $this->getWarningBox( $text );
1002 $box = $this->getErrorBox( $text );
1005 $this->output
->addHTML( $box );
1010 * Convenience function to set variables based on form data.
1011 * Assumes that variables containing "password" in the name are (potentially
1014 * @param $varNames Array
1015 * @param string $prefix the prefix added to variables to obtain form names
1019 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1020 $newValues = array();
1022 foreach ( $varNames as $name ) {
1023 $value = trim( $this->request
->getVal( $prefix . $name ) );
1024 $newValues[$name] = $value;
1026 if ( $value === null ) {
1028 $this->setVar( $name, false );
1030 if ( stripos( $name, 'password' ) !== false ) {
1031 $this->setPassword( $name, $value );
1033 $this->setVar( $name, $value );
1042 * Helper for Installer::docLink()
1047 protected function getDocUrl( $page ) {
1048 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1050 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1051 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1058 * Extension tag hook for a documentation link.
1065 public function docLink( $linkText, $attribs, $parser ) {
1066 $url = $this->getDocUrl( $attribs['href'] );
1067 return '<a href="' . htmlspecialchars( $url ) . '">' .
1068 htmlspecialchars( $linkText ) .
1073 * Helper for "Download LocalSettings" link on WebInstall_Complete
1078 * @return String Html for download link
1080 public function downloadLinkHook( $text, $attribs, $parser ) {
1081 $img = Html
::element( 'img', array(
1082 'src' => '../skins/common/images/download-32.png',
1086 $anchor = Html
::rawElement( 'a',
1087 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1088 $img . ' ' . wfMessage( 'config-download-localsettings' )->parse() );
1089 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1095 public function envCheckPath() {
1096 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1097 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1098 // to get the path to the current script... hopefully it's reliable. SIGH
1100 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1101 $path = $_SERVER['PHP_SELF'];
1102 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1103 $path = $_SERVER['SCRIPT_NAME'];
1105 if ( $path !== false ) {
1106 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1107 $this->setVar( 'wgScriptPath', $uri );
1109 $this->showError( 'config-no-uri' );
1112 return parent
::envCheckPath();
1115 protected function envGetDefaultServer() {
1116 return WebRequest
::detectServer();