MediaWiki REL1_35
WebInstaller.php
Go to the documentation of this file.
1<?php
25
32class WebInstaller extends Installer {
33
37 public $output;
38
44 public $request;
45
51 protected $session;
52
58 protected $phpErrors;
59
70 public $pageSequence = [
71 'Language',
72 'ExistingWiki',
73 'Welcome',
74 'DBConnect',
75 'Upgrade',
76 'DBSettings',
77 'Name',
78 'Options',
79 'Install',
80 'Complete',
81 ];
82
88 protected $otherPages = [
89 'Restart',
90 'ReleaseNotes',
91 'Copying',
92 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
93 ];
94
101 protected $happyPages;
102
110 protected $skippedPages;
111
117 public $showSessionWarning = false;
118
124 protected $tabIndex = 1;
125
131 protected $helpBoxId = 1;
132
139
143 public function __construct( WebRequest $request ) {
144 parent::__construct();
145 $this->output = new WebInstallerOutput( $this );
146 $this->request = $request;
147 }
148
156 public function execute( array $session ) {
157 $this->session = $session;
158
159 if ( isset( $session['settings'] ) ) {
160 $this->settings = $session['settings'] + $this->settings;
161 // T187586 MediaWikiServices works with globals
162 foreach ( $this->settings as $key => $val ) {
163 $GLOBALS[$key] = $val;
164 }
165 }
166
167 $this->setupLanguage();
168
169 if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
170 && $this->request->getVal( 'localsettings' )
171 ) {
172 $this->outputLS();
173 return $this->session;
174 }
175
176 $isCSS = $this->request->getVal( 'css' );
177 if ( $isCSS ) {
178 $this->outputCss();
179 return $this->session;
180 }
181
182 $this->happyPages = $session['happyPages'] ?? [];
183
184 $this->skippedPages = $session['skippedPages'] ?? [];
185
186 $lowestUnhappy = $this->getLowestUnhappy();
187
188 # Special case for Creative Commons partner chooser box.
189 if ( $this->request->getVal( 'SubmitCC' ) ) {
191 $page = $this->getPageByName( 'Options' );
192 '@phan-var WebInstallerOptions $page';
193 $this->output->useShortHeader();
194 $this->output->allowFrames();
195 $page->submitCC();
196
197 return $this->finish();
198 }
199
200 if ( $this->request->getVal( 'ShowCC' ) ) {
202 $page = $this->getPageByName( 'Options' );
203 '@phan-var WebInstallerOptions $page';
204 $this->output->useShortHeader();
205 $this->output->allowFrames();
206 $this->output->addHTML( $page->getCCDoneBox() );
207
208 return $this->finish();
209 }
210
211 # Get the page name.
212 $pageName = $this->request->getVal( 'page' );
213
214 if ( in_array( $pageName, $this->otherPages ) ) {
215 # Out of sequence
216 $pageId = false;
217 $page = $this->getPageByName( $pageName );
218 } else {
219 # Main sequence
220 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
221 $pageId = $lowestUnhappy;
222 } else {
223 $pageId = array_search( $pageName, $this->pageSequence );
224 }
225
226 # If necessary, move back to the lowest-numbered unhappy page
227 if ( $pageId > $lowestUnhappy ) {
228 $pageId = $lowestUnhappy;
229 if ( $lowestUnhappy == 0 ) {
230 # Knocked back to start, possible loss of session data.
231 $this->showSessionWarning = true;
232 }
233 }
234
235 $pageName = $this->pageSequence[$pageId];
236 $page = $this->getPageByName( $pageName );
237 }
238
239 # If a back button was submitted, go back without submitting the form data.
240 if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) {
241 if ( $this->request->getVal( 'lastPage' ) ) {
242 $nextPage = $this->request->getVal( 'lastPage' );
243 } elseif ( $pageId !== false ) {
244 # Main sequence page
245 # Skip the skipped pages
246 $nextPageId = $pageId;
247
248 do {
249 $nextPageId--;
250 $nextPage = $this->pageSequence[$nextPageId];
251 } while ( isset( $this->skippedPages[$nextPage] ) );
252 } else {
253 $nextPage = $this->pageSequence[$lowestUnhappy];
254 }
255
256 $this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
257
258 return $this->finish();
259 }
260
261 # Execute the page.
262 $this->currentPageName = $page->getName();
263 $this->startPageWrapper( $pageName );
264
265 if ( $page->isSlow() ) {
266 $this->disableTimeLimit();
267 }
268
269 $result = $page->execute();
270
271 $this->endPageWrapper();
272
273 if ( $result == 'skip' ) {
274 # Page skipped without explicit submission.
275 # Skip it when we click "back" so that we don't just go forward again.
276 $this->skippedPages[$pageName] = true;
277 $result = 'continue';
278 } else {
279 unset( $this->skippedPages[$pageName] );
280 }
281
282 # If it was posted, the page can request a continue to the next page.
283 if ( $result === 'continue' && !$this->output->headerDone() ) {
284 if ( $pageId !== false ) {
285 $this->happyPages[$pageId] = true;
286 }
287
288 $lowestUnhappy = $this->getLowestUnhappy();
289
290 if ( $this->request->getVal( 'lastPage' ) ) {
291 $nextPage = $this->request->getVal( 'lastPage' );
292 } elseif ( $pageId !== false ) {
293 $nextPage = $this->pageSequence[$pageId + 1];
294 } else {
295 $nextPage = $this->pageSequence[$lowestUnhappy];
296 }
297
298 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
299 $nextPage = $this->pageSequence[$lowestUnhappy];
300 }
301
302 $this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
303 }
304
305 return $this->finish();
306 }
307
312 public function getLowestUnhappy() {
313 if ( count( $this->happyPages ) == 0 ) {
314 return 0;
315 } else {
316 return max( array_keys( $this->happyPages ) ) + 1;
317 }
318 }
319
326 public function startSession() {
327 if ( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
328 // Done already
329 return true;
330 }
331
332 // Use secure cookies if we are on HTTPS
333 $options = [];
334 if ( $this->request->getProtocol() === 'https' ) {
335 $options['cookie_secure'] = '1';
336 }
337
338 $this->phpErrors = [];
339 set_error_handler( [ $this, 'errorHandler' ] );
340 try {
341 session_name( 'mw_installer_session' );
342 session_start( $options );
343 } catch ( Exception $e ) {
344 restore_error_handler();
345 throw $e;
346 }
347 restore_error_handler();
348
349 if ( $this->phpErrors ) {
350 return false;
351 }
352
353 return true;
354 }
355
364 public function getFingerprint() {
365 // Get the base URL of the installation
366 $url = $this->request->getFullRequestURL();
367 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
368 // Trim query string
369 $url = $m[1];
370 }
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?
374 $url = $m[1];
375 }
376
377 return md5( serialize( [
378 'local path' => dirname( __DIR__ ),
379 'url' => $url,
380 'version' => MW_VERSION
381 ] ) );
382 }
383
390 public function showError( $msg, ...$params ) {
391 if ( !( $msg instanceof Message ) ) {
392 $msg = wfMessage(
393 $msg,
394 array_map( 'htmlspecialchars', $params )
395 );
396 }
397 $text = $msg->useDatabase( false )->parse();
398 $box = Html::errorBox( $text, '', 'config-error-box' );
399 $this->output->addHTML( $box );
400 }
401
408 public function errorHandler( $errno, $errstr ) {
409 $this->phpErrors[] = $errstr;
410 }
411
417 public function finish() {
418 $this->output->output();
419
420 $this->session['happyPages'] = $this->happyPages;
421 $this->session['skippedPages'] = $this->skippedPages;
422 $this->session['settings'] = $this->settings;
423
424 return $this->session;
425 }
426
430 public function reset() {
431 $this->session = [];
432 $this->happyPages = [];
433 $this->settings = [];
434 }
435
443 public function getUrl( $query = [] ) {
444 $url = $this->request->getRequestURL();
445 # Remove existing query
446 $url = preg_replace( '/\?.*$/', '', $url );
447
448 if ( $query ) {
449 $url .= '?' . wfArrayToCgi( $query );
450 }
451
452 return $url;
453 }
454
461 public function getPageByName( $pageName ) {
462 $pageClass = 'WebInstaller' . $pageName;
463
464 return new $pageClass( $this );
465 }
466
475 public function getSession( $name, $default = null ) {
476 return $this->session[$name] ?? $default;
477 }
478
485 public function setSession( $name, $value ) {
486 $this->session[$name] = $value;
487 }
488
494 public function nextTabIndex() {
495 return $this->tabIndex++;
496 }
497
501 public function setupLanguage() {
503
504 if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) {
506 $wgLang = MediaWikiServices::getInstance()->getLanguageFactory()
507 ->getLanguage( $wgLanguageCode );
508 RequestContext::getMain()->setLanguage( $wgLang );
509 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
510 $this->setVar( '_UserLang', $wgLanguageCode );
511 } else {
512 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
513 }
514 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
515 }
516
522 public function getAcceptLanguage() {
524
525 $mwLanguages = MediaWikiServices::getInstance()
526 ->getLanguageNameUtils()
527 ->getLanguageNames( null, 'mwfile' );
528 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
529
530 foreach ( $headerLanguages as $lang ) {
531 if ( isset( $mwLanguages[$lang] ) ) {
532 return $lang;
533 }
534 }
535
536 return $wgLanguageCode;
537 }
538
544 private function startPageWrapper( $currentPageName ) {
545 $s = "<div class=\"config-page-wrapper\">\n";
546 $s .= "<div class=\"config-page\">\n";
547 $s .= "<div class=\"config-page-list\"><ul>\n";
548 $lastHappy = -1;
549
550 foreach ( $this->pageSequence as $id => $pageName ) {
551 $happy = !empty( $this->happyPages[$id] );
552 $s .= $this->getPageListItem(
553 $pageName,
554 $happy || $lastHappy == $id - 1,
556 );
557
558 if ( $happy ) {
559 $lastHappy = $id;
560 }
561 }
562
563 $s .= "</ul><br/><ul>\n";
564 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
565 // End list pane
566 $s .= "</ul></div>\n";
567
568 // Messages:
569 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
570 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
571 // config-page-complete, config-page-restart, config-page-releasenotes,
572 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
573 $s .= Html::element( 'h2', [],
574 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
575
576 $this->output->addHTMLNoFlush( $s );
577 }
578
588 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
589 $s = "<li class=\"config-page-list-item\">";
590
591 // Messages:
592 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
593 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
594 // config-page-complete, config-page-restart, config-page-releasenotes,
595 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
596 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
597
598 if ( $enabled ) {
599 $query = [ 'page' => $pageName ];
600
601 if ( !in_array( $pageName, $this->pageSequence ) ) {
602 if ( in_array( $currentPageName, $this->pageSequence ) ) {
603 $query['lastPage'] = $currentPageName;
604 }
605
606 $link = Html::element( 'a',
607 [
608 'href' => $this->getUrl( $query )
609 ],
610 $name
611 );
612 } else {
613 $link = htmlspecialchars( $name );
614 }
615
616 if ( $pageName == $currentPageName ) {
617 $s .= "<span class=\"config-page-current\">$link</span>";
618 } else {
619 $s .= $link;
620 }
621 } else {
622 $s .= Html::element( 'span',
623 [
624 'class' => 'config-page-disabled'
625 ],
626 $name
627 );
628 }
629
630 $s .= "</li>\n";
631
632 return $s;
633 }
634
638 private function endPageWrapper() {
639 $this->output->addHTMLNoFlush(
640 "<div class=\"visualClear\"></div>\n" .
641 "</div>\n" .
642 "<div class=\"visualClear\"></div>\n" .
643 "</div>" );
644 }
645
654 public function getInfoBox( $text, $icon = false, $class = false ) {
655 $html = ( $text instanceof HtmlArmor ) ?
656 HtmlArmor::getHtml( $text ) :
657 $this->parse( $text, true );
658 $icon = ( $icon == false ) ?
659 'images/info-32.png' :
660 'images/' . $icon;
661 $alt = wfMessage( 'config-information' )->text();
662
663 return Html::infoBox( $html, $icon, $alt, $class );
664 }
665
674 public function getHelpBox( $msg, ...$args ) {
675 $args = array_map( 'htmlspecialchars', $args );
676 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
677 $html = $this->parse( $text, true );
678 $id = 'helpBox-' . $this->helpBoxId++;
679
680 return "<div class=\"config-help-field-container\">\n" .
681 "<input type=\"checkbox\" class=\"config-help-field-checkbox\" id=\"$id\" />" .
682 "<label class=\"config-help-field-hint\" for=\"$id\" title=\"" .
683 wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
684 wfMessage( 'config-help' )->escaped() . "</label>\n" .
685 "<div class=\"config-help-field-data\">" . $html . "</div>\n" .
686 "</div>\n";
687 }
688
694 public function showHelpBox( $msg, ...$params ) {
695 $html = $this->getHelpBox( $msg, ...$params );
696 $this->output->addHTML( $html );
697 }
698
706 public function showMessage( $msg, ...$params ) {
707 $html = '<div class="config-message">' .
708 $this->parse( wfMessage( $msg, $params )->useDatabase( false )->plain() ) .
709 "</div>\n";
710 $this->output->addHTML( $html );
711 }
712
716 public function showStatusMessage( Status $status ) {
717 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
718 foreach ( $errors as $error ) {
719 $this->showMessage( ...$error );
720 }
721 }
722
733 public function label( $msg, $forId, $contents, $helpData = "" ) {
734 if ( strval( $msg ) == '' ) {
735 $labelText = "\u{00A0}";
736 } else {
737 $labelText = wfMessage( $msg )->escaped();
738 }
739
740 $attributes = [ 'class' => 'config-label' ];
741
742 if ( $forId ) {
743 $attributes['for'] = $forId;
744 }
745
746 return "<div class=\"config-block\">\n" .
747 " <div class=\"config-block-label\">\n" .
748 Xml::tags( 'label',
749 $attributes,
750 $labelText
751 ) . "\n" .
752 $helpData .
753 " </div>\n" .
754 " <div class=\"config-block-elements\">\n" .
755 $contents .
756 " </div>\n" .
757 "</div>\n";
758 }
759
774 public function getTextBox( $params ) {
775 if ( !isset( $params['controlName'] ) ) {
776 $params['controlName'] = 'config_' . $params['var'];
777 }
778
779 if ( !isset( $params['value'] ) ) {
780 $params['value'] = $this->getVar( $params['var'] );
781 }
782
783 if ( !isset( $params['attribs'] ) ) {
784 $params['attribs'] = [];
785 }
786 if ( !isset( $params['help'] ) ) {
787 $params['help'] = "";
788 }
789
790 return $this->label(
791 $params['label'],
792 $params['controlName'],
793 Xml::input(
794 $params['controlName'],
795 30, // intended to be overridden by CSS
796 $params['value'],
797 $params['attribs'] + [
798 'id' => $params['controlName'],
799 'class' => 'config-input-text',
800 'tabindex' => $this->nextTabIndex()
801 ]
802 ),
803 $params['help']
804 );
805 }
806
821 public function getTextArea( $params ) {
822 if ( !isset( $params['controlName'] ) ) {
823 $params['controlName'] = 'config_' . $params['var'];
824 }
825
826 if ( !isset( $params['value'] ) ) {
827 $params['value'] = $this->getVar( $params['var'] );
828 }
829
830 if ( !isset( $params['attribs'] ) ) {
831 $params['attribs'] = [];
832 }
833 if ( !isset( $params['help'] ) ) {
834 $params['help'] = "";
835 }
836
837 return $this->label(
838 $params['label'],
839 $params['controlName'],
840 Xml::textarea(
841 $params['controlName'],
842 $params['value'],
843 30,
844 5,
845 $params['attribs'] + [
846 'id' => $params['controlName'],
847 'class' => 'config-input-text',
848 'tabindex' => $this->nextTabIndex()
849 ]
850 ),
851 $params['help']
852 );
853 }
854
870 public function getPasswordBox( $params ) {
871 if ( !isset( $params['value'] ) ) {
872 $params['value'] = $this->getVar( $params['var'] );
873 }
874
875 if ( !isset( $params['attribs'] ) ) {
876 $params['attribs'] = [];
877 }
878
879 $params['value'] = $this->getFakePassword( $params['value'] );
880 $params['attribs']['type'] = 'password';
881
882 return $this->getTextBox( $params );
883 }
884
900 public function getCheckBox( $params ) {
901 if ( !isset( $params['controlName'] ) ) {
902 $params['controlName'] = 'config_' . $params['var'];
903 }
904
905 if ( !isset( $params['value'] ) ) {
906 $params['value'] = $this->getVar( $params['var'] );
907 }
908
909 if ( !isset( $params['attribs'] ) ) {
910 $params['attribs'] = [];
911 }
912 if ( !isset( $params['help'] ) ) {
913 $params['help'] = "";
914 }
915 if ( !isset( $params['labelAttribs'] ) ) {
916 $params['labelAttribs'] = [];
917 }
918 $labelText = $params['rawtext'] ?? $this->parse( wfMessage( $params['label'] )->plain() );
919
920 return "<div class=\"config-input-check\">\n" .
921 $params['help'] .
922 Html::rawElement(
923 'label',
924 $params['labelAttribs'],
925 Xml::check(
926 $params['controlName'],
927 $params['value'],
928 $params['attribs'] + [
929 'id' => $params['controlName'],
930 'tabindex' => $this->nextTabIndex(),
931 ]
932 ) .
933 $labelText . "\n"
934 ) .
935 "</div>\n";
936 }
937
957 public function getRadioSet( $params ) {
958 $items = $this->getRadioElements( $params );
959
960 $label = $params['label'] ?? '';
961
962 if ( !isset( $params['controlName'] ) ) {
963 $params['controlName'] = 'config_' . $params['var'];
964 }
965
966 if ( !isset( $params['help'] ) ) {
967 $params['help'] = "";
968 }
969
970 $s = "<ul>\n";
971 foreach ( $items as $value => $item ) {
972 $s .= "<li>$item</li>\n";
973 }
974 $s .= "</ul>\n";
975
976 return $this->label( $label, $params['controlName'], $s, $params['help'] );
977 }
978
987 public function getRadioElements( $params ) {
988 if ( !isset( $params['controlName'] ) ) {
989 $params['controlName'] = 'config_' . $params['var'];
990 }
991
992 if ( !isset( $params['value'] ) ) {
993 $params['value'] = $this->getVar( $params['var'] );
994 }
995
996 $items = [];
997
998 foreach ( $params['values'] as $value ) {
999 $itemAttribs = [];
1000
1001 if ( isset( $params['commonAttribs'] ) ) {
1002 $itemAttribs = $params['commonAttribs'];
1003 }
1004
1005 if ( isset( $params['itemAttribs'][$value] ) ) {
1006 $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs;
1007 }
1008
1009 $checked = $value == $params['value'];
1010 $id = $params['controlName'] . '_' . $value;
1011 $itemAttribs['id'] = $id;
1012 $itemAttribs['tabindex'] = $this->nextTabIndex();
1013
1014 $items[$value] =
1015 Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1016 "\u{00A0}" .
1017 Xml::tags( 'label', [ 'for' => $id ], $this->parse(
1018 isset( $params['itemLabels'] ) ?
1019 wfMessage( $params['itemLabels'][$value] )->plain() :
1020 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1021 ) );
1022 }
1023
1024 return $items;
1025 }
1026
1032 public function showStatusBox( $status ) {
1033 if ( !$status->isGood() ) {
1034 $html = $status->getHTML();
1035
1036 if ( $status->isOK() ) {
1037 $box = Html::warningBox( $html, 'config-warning-box' );
1038 } else {
1039 $box = Html::errorBox( $html, '', 'config-error-box' );
1040 }
1041
1042 $this->output->addHTML( $box );
1043 }
1044 }
1045
1056 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1057 $newValues = [];
1058
1059 foreach ( $varNames as $name ) {
1060 $value = $this->request->getVal( $prefix . $name );
1061 // T32524, do not trim passwords
1062 if ( $value !== null && stripos( $name, 'password' ) === false ) {
1063 $value = trim( $value );
1064 }
1065 $newValues[$name] = $value;
1066
1067 if ( $value === null ) {
1068 // Checkbox?
1069 $this->setVar( $name, false );
1070 } elseif ( stripos( $name, 'password' ) !== false ) {
1071 $this->setPassword( $name, $value );
1072 } else {
1073 $this->setVar( $name, $value );
1074 }
1075 }
1076
1077 return $newValues;
1078 }
1079
1087 public function getDocUrl( $page ) {
1088 $query = [ 'page' => $page ];
1089
1090 if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1091 $query['lastPage'] = $this->currentPageName;
1092 }
1093
1094 return $this->getUrl( $query );
1095 }
1096
1105 public function makeLinkItem( $url, $linkText ) {
1106 return Html::rawElement( 'li', [],
1107 Html::element( 'a', [ 'href' => $url ], $linkText )
1108 );
1109 }
1110
1117 public function makeDownloadLinkHtml() {
1118 $anchor = Html::rawElement( 'a',
1119 [ 'href' => $this->getUrl( [ 'localsettings' => 1 ] ) ],
1120 wfMessage( 'config-download-localsettings' )->parse()
1121 );
1122
1123 return Html::rawElement( 'div', [ 'class' => 'config-download-link' ], $anchor );
1124 }
1125
1136 public function getLocalSettingsLocation() {
1137 return false;
1138 }
1139
1143 public function envCheckPath() {
1144 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1145 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1146 // to get the path to the current script... hopefully it's reliable. SIGH
1147 $path = false;
1148 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1149 $path = $_SERVER['PHP_SELF'];
1150 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1151 $path = $_SERVER['SCRIPT_NAME'];
1152 }
1153 if ( $path === false ) {
1154 $this->showError( 'config-no-uri' );
1155 return false;
1156 }
1157
1158 return parent::envCheckPath();
1159 }
1160
1161 public function envPrepPath() {
1162 parent::envPrepPath();
1163 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1164 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1165 // to get the path to the current script... hopefully it's reliable. SIGH
1166 $path = false;
1167 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1168 $path = $_SERVER['PHP_SELF'];
1169 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1170 $path = $_SERVER['SCRIPT_NAME'];
1171 }
1172 if ( $path !== false ) {
1173 $scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1174
1175 $this->setVar( 'wgScriptPath', "$scriptPath" );
1176 // Update variables set from Setup.php that are derived from wgScriptPath
1177 $this->setVar( 'wgScript', "$scriptPath/index.php" );
1178 $this->setVar( 'wgLoadScript', "$scriptPath/load.php" );
1179 $this->setVar( 'wgStylePath', "$scriptPath/skins" );
1180 $this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
1181 $this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
1182 $this->setVar( 'wgUploadPath', "$scriptPath/images" );
1183 $this->setVar( 'wgResourceBasePath', "$scriptPath" );
1184 }
1185 }
1186
1190 protected function envGetDefaultServer() {
1191 return WebRequest::detectServer();
1192 }
1193
1199 private function outputLS() {
1200 $this->request->response()->header( 'Content-type: application/x-httpd-php' );
1201 $this->request->response()->header(
1202 'Content-Disposition: attachment; filename="LocalSettings.php"'
1203 );
1204
1206 $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
1207 foreach ( $rightsProfile as $group => $rightsArr ) {
1208 $ls->setGroupRights( $group, $rightsArr );
1209 }
1210 echo $ls->getText();
1211 }
1212
1216 public function outputCss() {
1217 $this->request->response()->header( 'Content-type: text/css' );
1218 echo $this->output->getCSS();
1219 }
1220
1224 public function getPhpErrors() {
1225 return $this->phpErrors;
1226 }
1227
1228}
serialize()
$GLOBALS['IP']
$wgLanguageCode
Site language code.
const MW_VERSION
The running version of MediaWiki.
Definition Defines.php:40
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
$wgContLang
Definition Setup.php:700
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:643
$wgLang
Definition Setup.php:781
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
Base installer class.
Definition Installer.php:54
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
disableTimeLimit()
Disable the time limit for execution.
array $settings
Definition Installer.php:73
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
MediaWikiServices is the service locator for the application scope of MediaWiki.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:161
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
getErrorsArray()
Get the list of errors (but not warnings)
Definition Status.php:355
getWarningsArray()
Get the list of warnings (but not errors)
Definition Status.php:366
Output class modelled on OutputPage.
Class for the core installer web interface.
makeDownloadLinkHtml()
Helper for "Download LocalSettings" link.
setupLanguage()
Initializes language-related variables.
WebInstallerOutput $output
finish()
Clean up from execute()
getTextBox( $params)
Get a labelled text box to configure a variable.
getAcceptLanguage()
Retrieves MediaWiki language from Accept-Language HTTP header.
nextTabIndex()
Get the next tabindex attribute value.
startPageWrapper( $currentPageName)
Called by execute() before page output starts, to show a page list.
showStatusBox( $status)
Output an error or warning box using a Status object.
setVarsFromRequest( $varNames, $prefix='config_')
Convenience function to set variables based on form data.
getPageByName( $pageName)
Get a WebInstallerPage by name.
errorHandler( $errno, $errstr)
Temporary error handler for session start debugging.
bool[] $happyPages
Array of pages which have declared that they have been submitted, have validated their input,...
getSession( $name, $default=null)
Get a session variable.
outputCss()
Output stylesheet for web installer pages.
getLowestUnhappy()
Find the next page in sequence that hasn't been completed.
showHelpBox( $msg,... $params)
Output a help box.
label( $msg, $forId, $contents, $helpData="")
Label a control by wrapping a config-input div around it and putting a label before it.
execute(array $session)
Main entry point.
getLocalSettingsLocation()
If the software package wants the LocalSettings.php file to be placed in a specific location,...
getDocUrl( $page)
Helper for WebInstallerOutput.
bool[] $skippedPages
List of "skipped" pages.
endPageWrapper()
Output some stuff after a page is finished.
outputLS()
Actually output LocalSettings.php for download.
getRadioElements( $params)
Get a set of labelled radio buttons.
showMessage( $msg,... $params)
Show a short informational message.
showError( $msg,... $params)
Show an error message in a box.
setSession( $name, $value)
Set a session variable.
reset()
We're restarting the installation, reset the session, happyPages, etc.
string $currentPageName
Name of the page we're on.
getHelpBox( $msg,... $args)
Get small text indented help for a preceding form field.
getRadioSet( $params)
Get a set of labelled radio buttons.
getPasswordBox( $params)
Get a labelled password box to configure a variable.
WebRequest $request
WebRequest object.
__construct(WebRequest $request)
getTextArea( $params)
Get a labelled textarea to configure a variable.
getFingerprint()
Get a hash of data identifying this MW installation.
string[] $otherPages
Out of sequence pages, selectable by the user at any time.
string[] $pageSequence
The main sequence of page names.
string[] $phpErrors
Captured PHP error text.
bool $showSessionWarning
Flag indicating that session data may have been lost.
getPageListItem( $pageName, $enabled, $currentPageName)
Get a list item for the page list.
showStatusMessage(Status $status)
getCheckBox( $params)
Get a labelled checkbox to configure a boolean variable.
getInfoBox( $text, $icon=false, $class=false)
Get HTML for an information message box with an icon.
makeLinkItem( $url, $linkText)
Helper for sidebar links.
startSession()
Start the PHP session.
int $tabIndex
Numeric index of the page we're on.
array[] $session
Cached session array.
getUrl( $query=[])
Get a URL for submission back to the same script.
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
int $helpBoxId
Numeric index of the help box.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
if( $line===false) $args
Definition mcc.php:124
if(!isset( $args[0])) $lang