MediaWiki REL1_28
WebInstaller.php
Go to the documentation of this file.
1<?php
30class WebInstaller extends Installer {
31
35 public $output;
36
42 public $request;
43
49 protected $session;
50
56 protected $phpErrors;
57
68 public $pageSequence = [
69 'Language',
70 'ExistingWiki',
71 'Welcome',
72 'DBConnect',
73 'Upgrade',
74 'DBSettings',
75 'Name',
76 'Options',
77 'Install',
78 'Complete',
79 ];
80
86 protected $otherPages = [
87 'Restart',
88 'Readme',
89 'ReleaseNotes',
90 'Copying',
91 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
92 ];
93
100 protected $happyPages;
101
109 protected $skippedPages;
110
116 public $showSessionWarning = false;
117
123 protected $tabIndex = 1;
124
131
137 public function __construct( WebRequest $request ) {
138 parent::__construct();
139 $this->output = new WebInstallerOutput( $this );
140 $this->request = $request;
141
142 // Add parser hooks
144 $wgParser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] );
145 $wgParser->setHook( 'doclink', [ $this, 'docLink' ] );
146 }
147
155 public function execute( array $session ) {
156 $this->session = $session;
157
158 if ( isset( $session['settings'] ) ) {
159 $this->settings = $session['settings'] + $this->settings;
160 }
161
162 $this->setupLanguage();
163
164 if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
165 && $this->request->getVal( 'localsettings' )
166 ) {
167 $this->request->response()->header( 'Content-type: application/x-httpd-php' );
168 $this->request->response()->header(
169 'Content-Disposition: attachment; filename="LocalSettings.php"'
170 );
171
173 $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
174 foreach ( $rightsProfile as $group => $rightsArr ) {
175 $ls->setGroupRights( $group, $rightsArr );
176 }
177 echo $ls->getText();
178
179 return $this->session;
180 }
181
182 $isCSS = $this->request->getVal( 'css' );
183 if ( $isCSS ) {
184 $this->outputCss();
185 return $this->session;
186 }
187
188 if ( isset( $session['happyPages'] ) ) {
189 $this->happyPages = $session['happyPages'];
190 } else {
191 $this->happyPages = [];
192 }
193
194 if ( isset( $session['skippedPages'] ) ) {
195 $this->skippedPages = $session['skippedPages'];
196 } else {
197 $this->skippedPages = [];
198 }
199
200 $lowestUnhappy = $this->getLowestUnhappy();
201
202 # Special case for Creative Commons partner chooser box.
203 if ( $this->request->getVal( 'SubmitCC' ) ) {
204 $page = $this->getPageByName( 'Options' );
205 $this->output->useShortHeader();
206 $this->output->allowFrames();
207 $page->submitCC();
208
209 return $this->finish();
210 }
211
212 if ( $this->request->getVal( 'ShowCC' ) ) {
213 $page = $this->getPageByName( 'Options' );
214 $this->output->useShortHeader();
215 $this->output->allowFrames();
216 $this->output->addHTML( $page->getCCDoneBox() );
217
218 return $this->finish();
219 }
220
221 # Get the page name.
222 $pageName = $this->request->getVal( 'page' );
223
224 if ( in_array( $pageName, $this->otherPages ) ) {
225 # Out of sequence
226 $pageId = false;
227 $page = $this->getPageByName( $pageName );
228 } else {
229 # Main sequence
230 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
231 $pageId = $lowestUnhappy;
232 } else {
233 $pageId = array_search( $pageName, $this->pageSequence );
234 }
235
236 # If necessary, move back to the lowest-numbered unhappy page
237 if ( $pageId > $lowestUnhappy ) {
238 $pageId = $lowestUnhappy;
239 if ( $lowestUnhappy == 0 ) {
240 # Knocked back to start, possible loss of session data.
241 $this->showSessionWarning = true;
242 }
243 }
244
245 $pageName = $this->pageSequence[$pageId];
246 $page = $this->getPageByName( $pageName );
247 }
248
249 # If a back button was submitted, go back without submitting the form data.
250 if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) {
251 if ( $this->request->getVal( 'lastPage' ) ) {
252 $nextPage = $this->request->getVal( 'lastPage' );
253 } elseif ( $pageId !== false ) {
254 # Main sequence page
255 # Skip the skipped pages
256 $nextPageId = $pageId;
257
258 do {
259 $nextPageId--;
260 $nextPage = $this->pageSequence[$nextPageId];
261 } while ( isset( $this->skippedPages[$nextPage] ) );
262 } else {
263 $nextPage = $this->pageSequence[$lowestUnhappy];
264 }
265
266 $this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
267
268 return $this->finish();
269 }
270
271 # Execute the page.
272 $this->currentPageName = $page->getName();
273 $this->startPageWrapper( $pageName );
274
275 if ( $page->isSlow() ) {
276 $this->disableTimeLimit();
277 }
278
279 $result = $page->execute();
280
281 $this->endPageWrapper();
282
283 if ( $result == 'skip' ) {
284 # Page skipped without explicit submission.
285 # Skip it when we click "back" so that we don't just go forward again.
286 $this->skippedPages[$pageName] = true;
287 $result = 'continue';
288 } else {
289 unset( $this->skippedPages[$pageName] );
290 }
291
292 # If it was posted, the page can request a continue to the next page.
293 if ( $result === 'continue' && !$this->output->headerDone() ) {
294 if ( $pageId !== false ) {
295 $this->happyPages[$pageId] = true;
296 }
297
298 $lowestUnhappy = $this->getLowestUnhappy();
299
300 if ( $this->request->getVal( 'lastPage' ) ) {
301 $nextPage = $this->request->getVal( 'lastPage' );
302 } elseif ( $pageId !== false ) {
303 $nextPage = $this->pageSequence[$pageId + 1];
304 } else {
305 $nextPage = $this->pageSequence[$lowestUnhappy];
306 }
307
308 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
309 $nextPage = $this->pageSequence[$lowestUnhappy];
310 }
311
312 $this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
313 }
314
315 return $this->finish();
316 }
317
322 public function getLowestUnhappy() {
323 if ( count( $this->happyPages ) == 0 ) {
324 return 0;
325 } else {
326 return max( array_keys( $this->happyPages ) ) + 1;
327 }
328 }
329
336 public function startSession() {
337 if ( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
338 // Done already
339 return true;
340 }
341
342 $this->phpErrors = [];
343 set_error_handler( [ $this, 'errorHandler' ] );
344 try {
345 session_name( 'mw_installer_session' );
346 session_start();
347 } catch ( Exception $e ) {
348 restore_error_handler();
349 throw $e;
350 }
351 restore_error_handler();
352
353 if ( $this->phpErrors ) {
354 return false;
355 }
356
357 return true;
358 }
359
368 public function getFingerprint() {
369 // Get the base URL of the installation
370 $url = $this->request->getFullRequestURL();
371 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
372 // Trim query string
373 $url = $m[1];
374 }
375 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
376 // This... seems to try to get the base path from
377 // the /mw-config/index.php. Kinda scary though?
378 $url = $m[1];
379 }
380
381 return md5( serialize( [
382 'local path' => dirname( __DIR__ ),
383 'url' => $url,
384 'version' => $GLOBALS['wgVersion']
385 ] ) );
386 }
387
393 public function showError( $msg /*...*/ ) {
394 if ( !( $msg instanceof Message ) ) {
395 $args = func_get_args();
396 array_shift( $args );
397 $args = array_map( 'htmlspecialchars', $args );
398 $msg = wfMessage( $msg, $args );
399 }
400 $text = $msg->useDatabase( false )->plain();
401 $this->output->addHTML( $this->getErrorBox( $text ) );
402 }
403
410 public function errorHandler( $errno, $errstr ) {
411 $this->phpErrors[] = $errstr;
412 }
413
419 public function finish() {
420 $this->output->output();
421
422 $this->session['happyPages'] = $this->happyPages;
423 $this->session['skippedPages'] = $this->skippedPages;
424 $this->session['settings'] = $this->settings;
425
426 return $this->session;
427 }
428
432 public function reset() {
433 $this->session = [];
434 $this->happyPages = [];
435 $this->settings = [];
436 }
437
445 public function getUrl( $query = [] ) {
446 $url = $this->request->getRequestURL();
447 # Remove existing query
448 $url = preg_replace( '/\?.*$/', '', $url );
449
450 if ( $query ) {
451 $url .= '?' . wfArrayToCgi( $query );
452 }
453
454 return $url;
455 }
456
463 public function getPageByName( $pageName ) {
464 $pageClass = 'WebInstaller' . $pageName;
465
466 return new $pageClass( $this );
467 }
468
477 public function getSession( $name, $default = null ) {
478 if ( !isset( $this->session[$name] ) ) {
479 return $default;
480 } else {
481 return $this->session[$name];
482 }
483 }
484
491 public function setSession( $name, $value ) {
492 $this->session[$name] = $value;
493 }
494
500 public function nextTabIndex() {
501 return $this->tabIndex++;
502 }
503
507 public function setupLanguage() {
509
510 if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) {
512 $wgLang = $wgContLang = Language::factory( $wgLanguageCode );
513 RequestContext::getMain()->setLanguage( $wgLang );
514 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
515 $this->setVar( '_UserLang', $wgLanguageCode );
516 } else {
517 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
518 $wgContLang = Language::factory( $wgLanguageCode );
519 }
520 }
521
527 public function getAcceptLanguage() {
529
530 $mwLanguages = Language::fetchLanguageNames();
531 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
532
533 foreach ( $headerLanguages as $lang ) {
534 if ( isset( $mwLanguages[$lang] ) ) {
535 return $lang;
536 }
537 }
538
539 return $wgLanguageCode;
540 }
541
547 private function startPageWrapper( $currentPageName ) {
548 $s = "<div class=\"config-page-wrapper\">\n";
549 $s .= "<div class=\"config-page\">\n";
550 $s .= "<div class=\"config-page-list\"><ul>\n";
551 $lastHappy = -1;
552
553 foreach ( $this->pageSequence as $id => $pageName ) {
554 $happy = !empty( $this->happyPages[$id] );
555 $s .= $this->getPageListItem(
556 $pageName,
557 $happy || $lastHappy == $id - 1,
559 );
560
561 if ( $happy ) {
562 $lastHappy = $id;
563 }
564 }
565
566 $s .= "</ul><br/><ul>\n";
567 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
568 // End list pane
569 $s .= "</ul></div>\n";
570
571 // Messages:
572 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
573 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
574 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
575 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
576 $s .= Html::element( 'h2', [],
577 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
578
579 $this->output->addHTMLNoFlush( $s );
580 }
581
591 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
592 $s = "<li class=\"config-page-list-item\">";
593
594 // Messages:
595 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
596 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
597 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
598 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
599 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
600
601 if ( $enabled ) {
602 $query = [ 'page' => $pageName ];
603
604 if ( !in_array( $pageName, $this->pageSequence ) ) {
605 if ( in_array( $currentPageName, $this->pageSequence ) ) {
606 $query['lastPage'] = $currentPageName;
607 }
608
609 $link = Html::element( 'a',
610 [
611 'href' => $this->getUrl( $query )
612 ],
613 $name
614 );
615 } else {
616 $link = htmlspecialchars( $name );
617 }
618
619 if ( $pageName == $currentPageName ) {
620 $s .= "<span class=\"config-page-current\">$link</span>";
621 } else {
622 $s .= $link;
623 }
624 } else {
625 $s .= Html::element( 'span',
626 [
627 'class' => 'config-page-disabled'
628 ],
629 $name
630 );
631 }
632
633 $s .= "</li>\n";
634
635 return $s;
636 }
637
641 private function endPageWrapper() {
642 $this->output->addHTMLNoFlush(
643 "<div class=\"visualClear\"></div>\n" .
644 "</div>\n" .
645 "<div class=\"visualClear\"></div>\n" .
646 "</div>" );
647 }
648
656 public function getErrorBox( $text ) {
657 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
658 }
659
667 public function getWarningBox( $text ) {
668 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
669 }
670
680 public function getInfoBox( $text, $icon = false, $class = false ) {
681 $text = $this->parse( $text, true );
682 $icon = ( $icon == false ) ?
683 'images/info-32.png' :
684 'images/' . $icon;
685 $alt = wfMessage( 'config-information' )->text();
686
687 return Html::infoBox( $text, $icon, $alt, $class );
688 }
689
697 public function getHelpBox( $msg /*, ... */ ) {
698 $args = func_get_args();
699 array_shift( $args );
700 $args = array_map( 'htmlspecialchars', $args );
701 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
702 $html = $this->parse( $text, true );
703
704 return "<div class=\"config-help-field-container\">\n" .
705 "<span class=\"config-help-field-hint\" title=\"" .
706 wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
707 wfMessage( 'config-help' )->escaped() . "</span>\n" .
708 "<span class=\"config-help-field-data\">" . $html . "</span>\n" .
709 "</div>\n";
710 }
711
716 public function showHelpBox( $msg /*, ... */ ) {
717 $args = func_get_args();
718 $html = call_user_func_array( [ $this, 'getHelpBox' ], $args );
719 $this->output->addHTML( $html );
720 }
721
728 public function showMessage( $msg /*, ... */ ) {
729 $args = func_get_args();
730 array_shift( $args );
731 $html = '<div class="config-message">' .
732 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
733 "</div>\n";
734 $this->output->addHTML( $html );
735 }
736
740 public function showStatusMessage( Status $status ) {
741 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
742 foreach ( $errors as $error ) {
743 call_user_func_array( [ $this, 'showMessage' ], $error );
744 }
745 }
746
757 public function label( $msg, $forId, $contents, $helpData = "" ) {
758 if ( strval( $msg ) == '' ) {
759 $labelText = '&#160;';
760 } else {
761 $labelText = wfMessage( $msg )->escaped();
762 }
763
764 $attributes = [ 'class' => 'config-label' ];
765
766 if ( $forId ) {
767 $attributes['for'] = $forId;
768 }
769
770 return "<div class=\"config-block\">\n" .
771 " <div class=\"config-block-label\">\n" .
772 Xml::tags( 'label',
773 $attributes,
774 $labelText
775 ) . "\n" .
776 $helpData .
777 " </div>\n" .
778 " <div class=\"config-block-elements\">\n" .
779 $contents .
780 " </div>\n" .
781 "</div>\n";
782 }
783
798 public function getTextBox( $params ) {
799 if ( !isset( $params['controlName'] ) ) {
800 $params['controlName'] = 'config_' . $params['var'];
801 }
802
803 if ( !isset( $params['value'] ) ) {
804 $params['value'] = $this->getVar( $params['var'] );
805 }
806
807 if ( !isset( $params['attribs'] ) ) {
808 $params['attribs'] = [];
809 }
810 if ( !isset( $params['help'] ) ) {
811 $params['help'] = "";
812 }
813
814 return $this->label(
815 $params['label'],
816 $params['controlName'],
818 $params['controlName'],
819 30, // intended to be overridden by CSS
820 $params['value'],
821 $params['attribs'] + [
822 'id' => $params['controlName'],
823 'class' => 'config-input-text',
824 'tabindex' => $this->nextTabIndex()
825 ]
826 ),
827 $params['help']
828 );
829 }
830
845 public function getTextArea( $params ) {
846 if ( !isset( $params['controlName'] ) ) {
847 $params['controlName'] = 'config_' . $params['var'];
848 }
849
850 if ( !isset( $params['value'] ) ) {
851 $params['value'] = $this->getVar( $params['var'] );
852 }
853
854 if ( !isset( $params['attribs'] ) ) {
855 $params['attribs'] = [];
856 }
857 if ( !isset( $params['help'] ) ) {
858 $params['help'] = "";
859 }
860
861 return $this->label(
862 $params['label'],
863 $params['controlName'],
865 $params['controlName'],
866 $params['value'],
867 30,
868 5,
869 $params['attribs'] + [
870 'id' => $params['controlName'],
871 'class' => 'config-input-text',
872 'tabindex' => $this->nextTabIndex()
873 ]
874 ),
875 $params['help']
876 );
877 }
878
894 public function getPasswordBox( $params ) {
895 if ( !isset( $params['value'] ) ) {
896 $params['value'] = $this->getVar( $params['var'] );
897 }
898
899 if ( !isset( $params['attribs'] ) ) {
900 $params['attribs'] = [];
901 }
902
903 $params['value'] = $this->getFakePassword( $params['value'] );
904 $params['attribs']['type'] = 'password';
905
906 return $this->getTextBox( $params );
907 }
908
923 public function getCheckBox( $params ) {
924 if ( !isset( $params['controlName'] ) ) {
925 $params['controlName'] = 'config_' . $params['var'];
926 }
927
928 if ( !isset( $params['value'] ) ) {
929 $params['value'] = $this->getVar( $params['var'] );
930 }
931
932 if ( !isset( $params['attribs'] ) ) {
933 $params['attribs'] = [];
934 }
935 if ( !isset( $params['help'] ) ) {
936 $params['help'] = "";
937 }
938 if ( isset( $params['rawtext'] ) ) {
939 $labelText = $params['rawtext'];
940 } else {
941 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
942 }
943
944 return "<div class=\"config-input-check\">\n" .
945 $params['help'] .
946 "<label>\n" .
948 $params['controlName'],
949 $params['value'],
950 $params['attribs'] + [
951 'id' => $params['controlName'],
952 'tabindex' => $this->nextTabIndex(),
953 ]
954 ) .
955 $labelText . "\n" .
956 "</label>\n" .
957 "</div>\n";
958 }
959
979 public function getRadioSet( $params ) {
980 $items = $this->getRadioElements( $params );
981
982 if ( !isset( $params['label'] ) ) {
983 $label = '';
984 } else {
985 $label = $params['label'];
986 }
987
988 if ( !isset( $params['controlName'] ) ) {
989 $params['controlName'] = 'config_' . $params['var'];
990 }
991
992 if ( !isset( $params['help'] ) ) {
993 $params['help'] = "";
994 }
995
996 $s = "<ul>\n";
997 foreach ( $items as $value => $item ) {
998 $s .= "<li>$item</li>\n";
999 }
1000 $s .= "</ul>\n";
1001
1002 return $this->label( $label, $params['controlName'], $s, $params['help'] );
1003 }
1004
1012 public function getRadioElements( $params ) {
1013 if ( !isset( $params['controlName'] ) ) {
1014 $params['controlName'] = 'config_' . $params['var'];
1015 }
1016
1017 if ( !isset( $params['value'] ) ) {
1018 $params['value'] = $this->getVar( $params['var'] );
1019 }
1020
1021 $items = [];
1022
1023 foreach ( $params['values'] as $value ) {
1024 $itemAttribs = [];
1025
1026 if ( isset( $params['commonAttribs'] ) ) {
1027 $itemAttribs = $params['commonAttribs'];
1028 }
1029
1030 if ( isset( $params['itemAttribs'][$value] ) ) {
1031 $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs;
1032 }
1033
1034 $checked = $value == $params['value'];
1035 $id = $params['controlName'] . '_' . $value;
1036 $itemAttribs['id'] = $id;
1037 $itemAttribs['tabindex'] = $this->nextTabIndex();
1038
1039 $items[$value] =
1040 Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1041 '&#160;' .
1042 Xml::tags( 'label', [ 'for' => $id ], $this->parse(
1043 isset( $params['itemLabels'] ) ?
1044 wfMessage( $params['itemLabels'][$value] )->plain() :
1045 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1046 ) );
1047 }
1048
1049 return $items;
1050 }
1051
1057 public function showStatusBox( $status ) {
1058 if ( !$status->isGood() ) {
1059 $text = $status->getWikiText();
1060
1061 if ( $status->isOK() ) {
1062 $box = $this->getWarningBox( $text );
1063 } else {
1064 $box = $this->getErrorBox( $text );
1065 }
1066
1067 $this->output->addHTML( $box );
1068 }
1069 }
1070
1081 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1082 $newValues = [];
1083
1084 foreach ( $varNames as $name ) {
1085 $value = $this->request->getVal( $prefix . $name );
1086 // bug 30524, do not trim passwords
1087 if ( stripos( $name, 'password' ) === false ) {
1088 $value = trim( $value );
1089 }
1090 $newValues[$name] = $value;
1091
1092 if ( $value === null ) {
1093 // Checkbox?
1094 $this->setVar( $name, false );
1095 } else {
1096 if ( stripos( $name, 'password' ) !== false ) {
1097 $this->setPassword( $name, $value );
1098 } else {
1099 $this->setVar( $name, $value );
1100 }
1101 }
1102 }
1103
1104 return $newValues;
1105 }
1106
1114 protected function getDocUrl( $page ) {
1115 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1116
1117 if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1118 $url .= '&lastPage=' . urlencode( $this->currentPageName );
1119 }
1120
1121 return $url;
1122 }
1123
1133 public function docLink( $linkText, $attribs, $parser ) {
1134 $url = $this->getDocUrl( $attribs['href'] );
1135
1136 return '<a href="' . htmlspecialchars( $url ) . '">' .
1137 htmlspecialchars( $linkText ) .
1138 '</a>';
1139 }
1140
1150 public function downloadLinkHook( $text, $attribs, $parser ) {
1151 $anchor = Html::rawElement( 'a',
1152 [ 'href' => $this->getUrl( [ 'localsettings' => 1 ] ) ],
1153 wfMessage( 'config-download-localsettings' )->parse()
1154 );
1155
1156 return Html::rawElement( 'div', [ 'class' => 'config-download-link' ], $anchor );
1157 }
1158
1169 public function getLocalSettingsLocation() {
1170 return false;
1171 }
1172
1176 public function envCheckPath() {
1177 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1178 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1179 // to get the path to the current script... hopefully it's reliable. SIGH
1180 $path = false;
1181 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1182 $path = $_SERVER['PHP_SELF'];
1183 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1184 $path = $_SERVER['SCRIPT_NAME'];
1185 }
1186 if ( $path === false ) {
1187 $this->showError( 'config-no-uri' );
1188 return false;
1189 }
1190
1191 return parent::envCheckPath();
1192 }
1193
1194 public function envPrepPath() {
1195 parent::envPrepPath();
1196 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1197 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1198 // to get the path to the current script... hopefully it's reliable. SIGH
1199 $path = false;
1200 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1201 $path = $_SERVER['PHP_SELF'];
1202 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1203 $path = $_SERVER['SCRIPT_NAME'];
1204 }
1205 if ( $path !== false ) {
1206 $scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1207
1208 $this->setVar( 'wgScriptPath', "$scriptPath" );
1209 // Update variables set from Setup.php that are derived from wgScriptPath
1210 $this->setVar( 'wgScript', "$scriptPath/index.php" );
1211 $this->setVar( 'wgLoadScript', "$scriptPath/load.php" );
1212 $this->setVar( 'wgStylePath', "$scriptPath/skins" );
1213 $this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
1214 $this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
1215 $this->setVar( 'wgUploadPath', "$scriptPath/images" );
1216 $this->setVar( 'wgResourceBasePath', "$scriptPath" );
1217 }
1218 }
1219
1223 protected function envGetDefaultServer() {
1224 return WebRequest::detectServer();
1225 }
1226
1230 public function outputCss() {
1231 $this->request->response()->header( 'Content-type: text/css' );
1232 echo $this->output->getCSS();
1233 }
1234
1238 public function getPhpErrors() {
1239 return $this->phpErrors;
1240 }
1241
1242}
serialize()
$GLOBALS['IP']
$wgLanguageCode
Site language code.
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....
$wgParser
Definition Setup.php:821
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:664
if( $line===false) $args
Definition cdb.php:64
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
Base installer class.
Definition Installer.php:43
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:56
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.
The Message class provides methods which fulfil two basic services:
Definition Message.php:159
output( $return=false)
Finally, all the text has been munged and accumulated into the object, let's actually output it:
redirect( $url, $responsecode='302')
Redirect to $url rather than displaying the normal page.
addHTML( $text)
Append $text to the body HTML.
static getMain()
Static methods.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:40
Output class modelled on OutputPage.
Class for the core installer web interface.
setupLanguage()
Initializes language-related variables.
getHelpBox( $msg)
Get small text indented help for a preceding form field.
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.
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 Installer::docLink()
bool[] $skippedPages
List of "skipped" pages.
showHelpBox( $msg)
Output a help box.
endPageWrapper()
Output some stuff after a page is finished.
downloadLinkHook( $text, $attribs, $parser)
Helper for "Download LocalSettings" link on WebInstall_Complete.
getRadioElements( $params)
Get a set of labelled radio buttons.
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.
getRadioSet( $params)
Get a set of labelled radio buttons.
getWarningBox( $text)
Get HTML for a warning box with an icon.
getPasswordBox( $params)
Get a labelled password box to configure a variable.
WebRequest $request
WebRequest object.
__construct(WebRequest $request)
Constructor.
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.
showError( $msg)
Show an error message in a box.
bool $showSessionWarning
Flag indicating that session data may have been lost.
getErrorBox( $text)
Get HTML for an error box with an icon.
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 info box with an icon.
docLink( $linkText, $attribs, $parser)
Extension tag hook for a documentation link.
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.
showMessage( $msg)
Show a short informational message.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
static textarea( $name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
Definition Xml.php:604
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
Definition Xml.php:324
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition Xml.php:275
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition Xml.php:131
static radio( $name, $value, $checked=false, $attribs=[])
Convenience function to build an HTML radio button.
Definition Xml.php:342
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
Definition globals.txt:37
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead $parser
Definition hooks.txt:2259
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition hooks.txt:1937
either a plain
Definition hooks.txt:1990
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
returning false will NOT prevent logging a wrapping ErrorException instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters create2 Corresponds to logging log_action database field and which is displayed in the UI similar to $comment this hook should only be used to add variables that depend on the current page request
Definition hooks.txt:2158
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:1957
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2900
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:1958
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1595
processing should stop and the error should be shown to the user * false
Definition hooks.txt:189
returning false will NOT prevent logging $e
Definition hooks.txt:2110
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
$params
if(!isset( $args[0])) $lang