MediaWiki  1.23.8
WebInstaller.php
Go to the documentation of this file.
1 <?php
30 class WebInstaller extends Installer {
31 
35  public $output;
36 
42  public $request;
43 
49  protected $session;
50 
56  protected $phpErrors;
57 
68  public $pageSequence = array(
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 = array(
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 
130  protected $currentPageName;
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', array( $this, 'downloadLinkHook' ) );
145  $wgParser->setHook( 'doclink', array( $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->exportVars();
163  $this->setupLanguage();
164 
165  if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
166  && $this->request->getVal( 'localsettings' )
167  ) {
168  $this->request->response()->header( 'Content-type: application/x-httpd-php' );
169  $this->request->response()->header(
170  'Content-Disposition: attachment; filename="LocalSettings.php"'
171  );
172 
174  $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
175  foreach ( $rightsProfile as $group => $rightsArr ) {
176  $ls->setGroupRights( $group, $rightsArr );
177  }
178  echo $ls->getText();
179 
180  return $this->session;
181  }
182 
183  $cssDir = $this->request->getVal( 'css' );
184  if ( $cssDir ) {
185  $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' );
186  $this->request->response()->header( 'Content-type: text/css' );
187  echo $this->output->getCSS( $cssDir );
188 
189  return $this->session;
190  }
191 
192  if ( isset( $session['happyPages'] ) ) {
193  $this->happyPages = $session['happyPages'];
194  } else {
195  $this->happyPages = array();
196  }
197 
198  if ( isset( $session['skippedPages'] ) ) {
199  $this->skippedPages = $session['skippedPages'];
200  } else {
201  $this->skippedPages = array();
202  }
203 
204  $lowestUnhappy = $this->getLowestUnhappy();
205 
206  # Special case for Creative Commons partner chooser box.
207  if ( $this->request->getVal( 'SubmitCC' ) ) {
208  $page = $this->getPageByName( 'Options' );
209  $this->output->useShortHeader();
210  $this->output->allowFrames();
211  $page->submitCC();
212 
213  return $this->finish();
214  }
215 
216  if ( $this->request->getVal( 'ShowCC' ) ) {
217  $page = $this->getPageByName( 'Options' );
218  $this->output->useShortHeader();
219  $this->output->allowFrames();
220  $this->output->addHTML( $page->getCCDoneBox() );
221 
222  return $this->finish();
223  }
224 
225  # Get the page name.
226  $pageName = $this->request->getVal( 'page' );
227 
228  if ( in_array( $pageName, $this->otherPages ) ) {
229  # Out of sequence
230  $pageId = false;
231  $page = $this->getPageByName( $pageName );
232  } else {
233  # Main sequence
234  if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
235  $pageId = $lowestUnhappy;
236  } else {
237  $pageId = array_search( $pageName, $this->pageSequence );
238  }
239 
240  # If necessary, move back to the lowest-numbered unhappy page
241  if ( $pageId > $lowestUnhappy ) {
242  $pageId = $lowestUnhappy;
243  if ( $lowestUnhappy == 0 ) {
244  # Knocked back to start, possible loss of session data.
245  $this->showSessionWarning = true;
246  }
247  }
248 
249  $pageName = $this->pageSequence[$pageId];
250  $page = $this->getPageByName( $pageName );
251  }
252 
253  # If a back button was submitted, go back without submitting the form data.
254  if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) {
255  if ( $this->request->getVal( 'lastPage' ) ) {
256  $nextPage = $this->request->getVal( 'lastPage' );
257  } elseif ( $pageId !== false ) {
258  # Main sequence page
259  # Skip the skipped pages
260  $nextPageId = $pageId;
261 
262  do {
263  $nextPageId--;
264  $nextPage = $this->pageSequence[$nextPageId];
265  } while ( isset( $this->skippedPages[$nextPage] ) );
266  } else {
267  $nextPage = $this->pageSequence[$lowestUnhappy];
268  }
269 
270  $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
271 
272  return $this->finish();
273  }
274 
275  # Execute the page.
276  $this->currentPageName = $page->getName();
277  $this->startPageWrapper( $pageName );
278 
279  if ( $page->isSlow() ) {
280  $this->disableTimeLimit();
281  }
282 
283  $result = $page->execute();
284 
285  $this->endPageWrapper();
286 
287  if ( $result == 'skip' ) {
288  # Page skipped without explicit submission.
289  # Skip it when we click "back" so that we don't just go forward again.
290  $this->skippedPages[$pageName] = true;
291  $result = 'continue';
292  } else {
293  unset( $this->skippedPages[$pageName] );
294  }
295 
296  # If it was posted, the page can request a continue to the next page.
297  if ( $result === 'continue' && !$this->output->headerDone() ) {
298  if ( $pageId !== false ) {
299  $this->happyPages[$pageId] = true;
300  }
301 
302  $lowestUnhappy = $this->getLowestUnhappy();
303 
304  if ( $this->request->getVal( 'lastPage' ) ) {
305  $nextPage = $this->request->getVal( 'lastPage' );
306  } elseif ( $pageId !== false ) {
307  $nextPage = $this->pageSequence[$pageId + 1];
308  } else {
309  $nextPage = $this->pageSequence[$lowestUnhappy];
310  }
311 
312  if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
313  $nextPage = $this->pageSequence[$lowestUnhappy];
314  }
315 
316  $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
317  }
318 
319  return $this->finish();
320  }
321 
326  public function getLowestUnhappy() {
327  if ( count( $this->happyPages ) == 0 ) {
328  return 0;
329  } else {
330  return max( array_keys( $this->happyPages ) ) + 1;
331  }
332  }
333 
340  public function startSession() {
341  if ( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
342  // Done already
343  return true;
344  }
345 
346  $this->phpErrors = array();
347  set_error_handler( array( $this, 'errorHandler' ) );
348  try {
349  session_start();
350  } catch ( Exception $e ) {
351  restore_error_handler();
352  throw $e;
353  }
354  restore_error_handler();
355 
356  if ( $this->phpErrors ) {
357  $this->showError( 'config-session-error', $this->phpErrors[0] );
358 
359  return false;
360  }
361 
362  return true;
363  }
364 
373  public function getFingerprint() {
374  // Get the base URL of the installation
375  $url = $this->request->getFullRequestURL();
376  if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
377  // Trim query string
378  $url = $m[1];
379  }
380  if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
381  // This... seems to try to get the base path from
382  // the /mw-config/index.php. Kinda scary though?
383  $url = $m[1];
384  }
385 
386  return md5( serialize( array(
387  'local path' => dirname( __DIR__ ),
388  'url' => $url,
389  'version' => $GLOBALS['wgVersion']
390  ) ) );
391  }
392 
397  public function showError( $msg /*...*/ ) {
398  $args = func_get_args();
399  array_shift( $args );
400  $args = array_map( 'htmlspecialchars', $args );
401  $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
402  $this->output->addHTML( $this->getErrorBox( $msg ) );
403  }
404 
411  public function errorHandler( $errno, $errstr ) {
412  $this->phpErrors[] = $errstr;
413  }
414 
420  public function finish() {
421  $this->output->output();
422 
423  $this->session['happyPages'] = $this->happyPages;
424  $this->session['skippedPages'] = $this->skippedPages;
425  $this->session['settings'] = $this->settings;
426 
427  return $this->session;
428  }
429 
433  public function reset() {
434  $this->session = array();
435  $this->happyPages = array();
436  $this->settings = array();
437  }
438 
446  public function getUrl( $query = array() ) {
447  $url = $this->request->getRequestURL();
448  # Remove existing query
449  $url = preg_replace( '/\?.*$/', '', $url );
450 
451  if ( $query ) {
452  $url .= '?' . wfArrayToCgi( $query );
453  }
454 
455  return $url;
456  }
457 
464  public function getPageByName( $pageName ) {
465  $pageClass = 'WebInstaller_' . $pageName;
466 
467  return new $pageClass( $this );
468  }
469 
478  public function getSession( $name, $default = null ) {
479  if ( !isset( $this->session[$name] ) ) {
480  return $default;
481  } else {
482  return $this->session[$name];
483  }
484  }
485 
492  public function setSession( $name, $value ) {
493  $this->session[$name] = $value;
494  }
495 
501  public function nextTabIndex() {
502  return $this->tabIndex++;
503  }
504 
508  public function setupLanguage() {
509  global $wgLang, $wgContLang, $wgLanguageCode;
510 
511  if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) {
512  $wgLanguageCode = $this->getAcceptLanguage();
513  $wgLang = $wgContLang = Language::factory( $wgLanguageCode );
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() {
528  global $wgLanguageCode, $wgRequest;
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', array(),
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 = array( '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  array(
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  array(
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  '../skins/common/images/info-32.png' :
684  '../skins/common/images/' . $icon;
685  $alt = wfMessage( 'config-information' )->text();
686 
687  return Html::infoBox( $text, $icon, $alt, $class, false );
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=\"mw-help-field-container\">\n" .
705  "<span class=\"mw-help-field-hint\">" . wfMessage( 'config-help' )->escaped() .
706  "</span>\n" .
707  "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
708  "</div>\n";
709  }
710 
715  public function showHelpBox( $msg /*, ... */ ) {
716  $args = func_get_args();
717  $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
718  $this->output->addHTML( $html );
719  }
720 
727  public function showMessage( $msg /*, ... */ ) {
728  $args = func_get_args();
729  array_shift( $args );
730  $html = '<div class="config-message">' .
731  $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
732  "</div>\n";
733  $this->output->addHTML( $html );
734  }
735 
739  public function showStatusMessage( Status $status ) {
740  $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
741  foreach ( $errors as $error ) {
742  call_user_func_array( array( $this, 'showMessage' ), $error );
743  }
744  }
745 
756  public function label( $msg, $forId, $contents, $helpData = "" ) {
757  if ( strval( $msg ) == '' ) {
758  $labelText = '&#160;';
759  } else {
760  $labelText = wfMessage( $msg )->escaped();
761  }
762 
763  $attributes = array( 'class' => 'config-label' );
764 
765  if ( $forId ) {
766  $attributes['for'] = $forId;
767  }
768 
769  return "<div class=\"config-block\">\n" .
770  " <div class=\"config-block-label\">\n" .
771  Xml::tags( 'label',
772  $attributes,
773  $labelText
774  ) . "\n" .
775  $helpData .
776  " </div>\n" .
777  " <div class=\"config-block-elements\">\n" .
778  $contents .
779  " </div>\n" .
780  "</div>\n";
781  }
782 
797  public function getTextBox( $params ) {
798  if ( !isset( $params['controlName'] ) ) {
799  $params['controlName'] = 'config_' . $params['var'];
800  }
801 
802  if ( !isset( $params['value'] ) ) {
803  $params['value'] = $this->getVar( $params['var'] );
804  }
805 
806  if ( !isset( $params['attribs'] ) ) {
807  $params['attribs'] = array();
808  }
809  if ( !isset( $params['help'] ) ) {
810  $params['help'] = "";
811  }
812 
813  return $this->label(
814  $params['label'],
815  $params['controlName'],
816  Xml::input(
817  $params['controlName'],
818  30, // intended to be overridden by CSS
819  $params['value'],
820  $params['attribs'] + array(
821  'id' => $params['controlName'],
822  'class' => 'config-input-text',
823  'tabindex' => $this->nextTabIndex()
824  )
825  ),
826  $params['help']
827  );
828  }
829 
844  public function getTextArea( $params ) {
845  if ( !isset( $params['controlName'] ) ) {
846  $params['controlName'] = 'config_' . $params['var'];
847  }
848 
849  if ( !isset( $params['value'] ) ) {
850  $params['value'] = $this->getVar( $params['var'] );
851  }
852 
853  if ( !isset( $params['attribs'] ) ) {
854  $params['attribs'] = array();
855  }
856  if ( !isset( $params['help'] ) ) {
857  $params['help'] = "";
858  }
859 
860  return $this->label(
861  $params['label'],
862  $params['controlName'],
864  $params['controlName'],
865  $params['value'],
866  30,
867  5,
868  $params['attribs'] + array(
869  'id' => $params['controlName'],
870  'class' => 'config-input-text',
871  'tabindex' => $this->nextTabIndex()
872  )
873  ),
874  $params['help']
875  );
876  }
877 
893  public function getPasswordBox( $params ) {
894  if ( !isset( $params['value'] ) ) {
895  $params['value'] = $this->getVar( $params['var'] );
896  }
897 
898  if ( !isset( $params['attribs'] ) ) {
899  $params['attribs'] = array();
900  }
901 
902  $params['value'] = $this->getFakePassword( $params['value'] );
903  $params['attribs']['type'] = 'password';
904 
905  return $this->getTextBox( $params );
906  }
907 
922  public function getCheckBox( $params ) {
923  if ( !isset( $params['controlName'] ) ) {
924  $params['controlName'] = 'config_' . $params['var'];
925  }
926 
927  if ( !isset( $params['value'] ) ) {
928  $params['value'] = $this->getVar( $params['var'] );
929  }
930 
931  if ( !isset( $params['attribs'] ) ) {
932  $params['attribs'] = array();
933  }
934  if ( !isset( $params['help'] ) ) {
935  $params['help'] = "";
936  }
937  if ( isset( $params['rawtext'] ) ) {
938  $labelText = $params['rawtext'];
939  } else {
940  $labelText = $this->parse( wfMessage( $params['label'] )->text() );
941  }
942 
943  return "<div class=\"config-input-check\">\n" .
944  $params['help'] .
945  "<label>\n" .
946  Xml::check(
947  $params['controlName'],
948  $params['value'],
949  $params['attribs'] + array(
950  'id' => $params['controlName'],
951  'tabindex' => $this->nextTabIndex(),
952  )
953  ) .
954  $labelText . "\n" .
955  "</label>\n" .
956  "</div>\n";
957  }
958 
976  public function getRadioSet( $params ) {
977  if ( !isset( $params['controlName'] ) ) {
978  $params['controlName'] = 'config_' . $params['var'];
979  }
980 
981  if ( !isset( $params['value'] ) ) {
982  $params['value'] = $this->getVar( $params['var'] );
983  }
984 
985  if ( !isset( $params['label'] ) ) {
986  $label = '';
987  } else {
988  $label = $params['label'];
989  }
990  if ( !isset( $params['help'] ) ) {
991  $params['help'] = "";
992  }
993  $s = "<ul>\n";
994  foreach ( $params['values'] as $value ) {
995  $itemAttribs = array();
996 
997  if ( isset( $params['commonAttribs'] ) ) {
998  $itemAttribs = $params['commonAttribs'];
999  }
1000 
1001  if ( isset( $params['itemAttribs'][$value] ) ) {
1002  $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs;
1003  }
1004 
1005  $checked = $value == $params['value'];
1006  $id = $params['controlName'] . '_' . $value;
1007  $itemAttribs['id'] = $id;
1008  $itemAttribs['tabindex'] = $this->nextTabIndex();
1009 
1010  $s .=
1011  '<li>' .
1012  Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1013  '&#160;' .
1014  Xml::tags( 'label', array( 'for' => $id ), $this->parse(
1015  wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1016  ) ) .
1017  "</li>\n";
1018  }
1020  $s .= "</ul>\n";
1021 
1022  return $this->label( $label, $params['controlName'], $s, $params['help'] );
1023  }
1024 
1030  public function showStatusBox( $status ) {
1031  if ( !$status->isGood() ) {
1032  $text = $status->getWikiText();
1033 
1034  if ( $status->isOk() ) {
1035  $box = $this->getWarningBox( $text );
1036  } else {
1037  $box = $this->getErrorBox( $text );
1038  }
1039 
1040  $this->output->addHTML( $box );
1041  }
1042  }
1054  public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1055  $newValues = array();
1056 
1057  foreach ( $varNames as $name ) {
1058  $value = trim( $this->request->getVal( $prefix . $name ) );
1059  $newValues[$name] = $value;
1060 
1061  if ( $value === null ) {
1062  // Checkbox?
1063  $this->setVar( $name, false );
1064  } else {
1065  if ( stripos( $name, 'password' ) !== false ) {
1066  $this->setPassword( $name, $value );
1067  } else {
1068  $this->setVar( $name, $value );
1069  }
1070  }
1071  }
1073  return $newValues;
1074  }
1075 
1083  protected function getDocUrl( $page ) {
1084  $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1085 
1086  if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1087  $url .= '&lastPage=' . urlencode( $this->currentPageName );
1088  }
1089 
1090  return $url;
1091  }
1092 
1102  public function docLink( $linkText, $attribs, $parser ) {
1103  $url = $this->getDocUrl( $attribs['href'] );
1104 
1105  return '<a href="' . htmlspecialchars( $url ) . '">' .
1106  htmlspecialchars( $linkText ) .
1107  '</a>';
1108  }
1109 
1119  public function downloadLinkHook( $text, $attribs, $parser ) {
1120  $img = Html::element( 'img', array(
1121  'src' => '../skins/common/images/download-32.png',
1122  'width' => '32',
1123  'height' => '32',
1124  ) );
1125  $anchor = Html::rawElement( 'a',
1126  array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1127  $img . ' ' . wfMessage( 'config-download-localsettings' )->parse() );
1128 
1129  return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1130  }
1131 
1135  public function envCheckPath() {
1136  // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1137  // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1138  // to get the path to the current script... hopefully it's reliable. SIGH
1139  $path = false;
1140  if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1141  $path = $_SERVER['PHP_SELF'];
1142  } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1143  $path = $_SERVER['SCRIPT_NAME'];
1144  }
1145  if ( $path !== false ) {
1146  $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1147  $this->setVar( 'wgScriptPath', $uri );
1148  } else {
1149  $this->showError( 'config-no-uri' );
1150 
1151  return false;
1152  }
1153 
1154  return parent::envCheckPath();
1155  }
1156 
1160  protected function envGetDefaultServer() {
1161  return WebRequest::detectServer();
1162  }
1163 
1164 }
WebInstaller\getAcceptLanguage
getAcceptLanguage()
Retrieves MediaWiki language from Accept-Language HTTP header.
Definition: WebInstaller.php:516
Installer\__construct
__construct()
Constructor, always call this from child classes.
Definition: Installer.php:337
$result
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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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. 'LinkBegin':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:1528
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
WebInstaller\getHelpBox
getHelpBox( $msg)
Get small text indented help for a preceding form field.
Definition: WebInstaller.php:686
$html
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:1530
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
Installer\parse
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
Definition: Installer.php:594
WebInstaller\startPageWrapper
startPageWrapper( $currentPageName)
Called by execute() before page output starts, to show a page list.
Definition: WebInstaller.php:536
WebInstaller\label
label( $msg, $forId, $contents, $helpData="")
Label a control by wrapping a config-input div around it and putting a label before it.
Definition: WebInstaller.php:745
WebInstaller\getPageListItem
getPageListItem( $pageName, $enabled, $currentPageName)
Get a list item for the page list.
Definition: WebInstaller.php:580
WebInstaller\startSession
startSession()
Start the PHP session.
Definition: WebInstaller.php:329
text
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:12
WebInstaller\$showSessionWarning
bool $showSessionWarning
Flag indicating that session data may have been lost.
Definition: WebInstaller.php:107
WebInstaller\showStatusMessage
showStatusMessage(Status $status)
Definition: WebInstaller.php:728
WebInstaller\$pageSequence
string[] $pageSequence
The main sequence of page names.
Definition: WebInstaller.php:63
WebInstaller\$session
array[] $session
Cached session array.
Definition: WebInstaller.php:46
WebInstaller\setupLanguage
setupLanguage()
Initializes language-related variables.
Definition: WebInstaller.php:497
WebInstaller\getCheckBox
getCheckBox( $params)
Get a labelled checkbox to configure a boolean variable.
Definition: WebInstaller.php:911
WebInstaller
Class for the core installer web interface.
Definition: WebInstaller.php:30
Installer\$settings
array $settings
Definition: Installer.php:54
WebInstaller\getWarningBox
getWarningBox( $text)
Get HTML for a warning box with an icon.
Definition: WebInstaller.php:656
$params
$params
Definition: styleTest.css.php:40
WebInstaller\$tabIndex
int $tabIndex
Numeric index of the page we're on.
Definition: WebInstaller.php:113
WebInstaller\showHelpBox
showHelpBox( $msg)
Output a help box.
Definition: WebInstaller.php:704
$s
$s
Definition: mergeMessageFileList.php:156
$wgContLang
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 content language as $wgContLang
Definition: design.txt:56
WebInstaller\getPageByName
getPageByName( $pageName)
Get a WebInstallerPage by name.
Definition: WebInstaller.php:453
Installer\setPassword
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
Definition: Installer.php:546
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2149
WebInstaller\__construct
__construct(WebRequest $request)
Constructor.
Definition: WebInstaller.php:126
WebInstaller\$happyPages
bool[] $happyPages
Array of pages which have declared that they have been submitted, have validated their input,...
Definition: WebInstaller.php:93
OutputPage\addHTML
addHTML( $text)
Append $text to the body HTML.
Definition: OutputPage.php:1369
WebInstaller\showStatusBox
showStatusBox( $status)
Output an error or warning box using a Status object.
Definition: WebInstaller.php:1019
WebInstaller\getLowestUnhappy
getLowestUnhappy()
Find the next page in sequence that hasn't been completed.
Definition: WebInstaller.php:315
Installer\setVar
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:443
WebInstaller\getInfoBox
getInfoBox( $text, $icon=false, $class=false)
Get HTML for an info box with an icon.
Definition: WebInstaller.php:669
Status\isGood
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Definition: Status.php:100
WebInstaller\getUrl
getUrl( $query=array())
Get a URL for submission back to the same script.
Definition: WebInstaller.php:435
WebInstallerOutput
Output class modelled on OutputPage.
Definition: WebInstallerOutput.php:35
WebInstaller\$output
WebInstallerOutput $output
Definition: WebInstaller.php:34
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:40
WebInstaller\getRadioSet
getRadioSet( $params)
Get a set of labelled radio buttons.
Definition: WebInstaller.php:965
WebInstaller\showMessage
showMessage( $msg)
Show a short informational message.
Definition: WebInstaller.php:716
Installer\getFakePassword
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
Definition: Installer.php:535
WebInstaller\getTextArea
getTextArea( $params)
Get a labelled textarea to configure a variable.
Definition: WebInstaller.php:833
Language\fetchLanguageNames
static fetchLanguageNames( $inLanguage=null, $include='mw')
Get an array of language names, indexed by code.
Definition: Language.php:875
WebInstaller\setSession
setSession( $name, $value)
Set a session variable.
Definition: WebInstaller.php:481
OutputPage\output
output()
Finally, all the text has been munged and accumulated into the object, let's actually output it:
Definition: OutputPage.php:2017
WebInstaller\$request
WebRequest $request
WebRequest object.
Definition: WebInstaller.php:40
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:148
WebInstaller\execute
execute(array $session)
Main entry point.
Definition: WebInstaller.php:144
WebInstaller\nextTabIndex
nextTabIndex()
Get the next tabindex attribute value.
Definition: WebInstaller.php:490
WebInstaller\$skippedPages
bool[] $skippedPages
List of "skipped" pages.
Definition: WebInstaller.php:101
WebInstaller\errorHandler
errorHandler( $errno, $errstr)
Temporary error handler for session start debugging.
Definition: WebInstaller.php:400
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:1956
WebInstaller\getFingerprint
getFingerprint()
Get a hash of data identifying this MW installation.
Definition: WebInstaller.php:362
wfMessage
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 after in associative array form externallinks including delete and has completed for all link tables 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
Installer\exportVars
exportVars()
Exports all wg* variables stored by the installer into global scope.
Definition: Installer.php:660
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
InstallerOverrides\getLocalSettingsGenerator
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
Definition: overrides.php:57
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
WebInstaller\downloadLinkHook
downloadLinkHook( $text, $attribs, $parser)
Helper for "Download LocalSettings" link on WebInstall_Complete.
Definition: WebInstaller.php:1108
settings
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:25
Installer\getVar
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:457
Html\infoBox
static infoBox( $text, $icon, $alt, $class=false, $useStylePath=true)
Get HTML for an info box with an icon.
Definition: Html.php:865
WebInstaller\$phpErrors
string[] $phpErrors
Captured PHP error text.
Definition: WebInstaller.php:52
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:188
WebInstaller\$otherPages
string[] $otherPages
Out of sequence pages, selectable by the user at any time.
Definition: WebInstaller.php:80
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
WebInstaller\$currentPageName
string $currentPageName
Name of the page we're on.
Definition: WebInstaller.php:119
$value
$value
Definition: styleTest.css.php:45
WebInstaller\envCheckPath
envCheckPath()
Definition: WebInstaller.php:1124
WebInstaller\getPasswordBox
getPasswordBox( $params)
Get a labelled password box to configure a variable.
Definition: WebInstaller.php:882
Xml\check
static check( $name, $checked=false, $attribs=array())
Convenience function to build an HTML checkbox.
Definition: Xml.php:339
WebInstaller\reset
reset()
We're restarting the installation, reset the session, happyPages, etc.
Definition: WebInstaller.php:422
WebInstaller\setVarsFromRequest
setVarsFromRequest( $varNames, $prefix='config_')
Convenience function to set variables based on form data.
Definition: WebInstaller.php:1043
Xml\textarea
static textarea( $name, $content, $cols=40, $rows=5, $attribs=array())
Shortcut for creating textareas.
Definition: Xml.php:589
wfIniGetBool
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
Definition: GlobalFunctions.php:2685
WebInstaller\endPageWrapper
endPageWrapper()
Output some stuff after a page is finished.
Definition: WebInstaller.php:630
WebInstaller\showError
showError( $msg)
Show an error message in a box.
Definition: WebInstaller.php:386
WebInstaller\getErrorBox
getErrorBox( $text)
Get HTML for an error box with an icon.
Definition: WebInstaller.php:645
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
Definition: WebRequest.php:38
WebInstaller\docLink
docLink( $linkText, $attribs, $parser)
Extension tag hook for a documentation link.
Definition: WebInstaller.php:1091
WebInstaller\envGetDefaultServer
envGetDefaultServer()
Definition: WebInstaller.php:1149
$args
if( $line===false) $args
Definition: cdb.php:62
$wgLang
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
$wgParser
$wgParser
Definition: Setup.php:567
output
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
Status\getWarningsArray
getWarningsArray()
Get the list of warnings (but not errors)
Definition: Status.php:351
Xml\radio
static radio( $name, $value, $checked=false, $attribs=array())
Convenience function to build an HTML radio button.
Definition: Xml.php:357
OutputPage\redirect
redirect( $url, $responsecode='302')
Redirect to $url rather than displaying the normal page.
Definition: OutputPage.php:285
$path
$path
Definition: NoLocalSettings.php:35
as
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
Definition: distributors.txt:9
WebInstaller\getDocUrl
getDocUrl( $page)
Helper for Installer::docLink()
Definition: WebInstaller.php:1072
WebRequest\detectServer
static detectServer()
Work out an appropriate URL prefix containing scheme and host, based on information detected from $_S...
Definition: WebRequest.php:165
Installer\disableTimeLimit
disableTimeLimit()
Disable the time limit for execution.
Definition: Installer.php:1742
WebInstaller\getTextBox
getTextBox( $params)
Get a labelled text box to configure a variable.
Definition: WebInstaller.php:786
Installer
Base installer class.
Definition: Installer.php:39
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:184
Xml\input
static input( $name, $size=false, $value=false, $attribs=array())
Convenience function to build an HTML text input field.
Definition: Xml.php:294
$error
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
Definition: hooks.txt:2573
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
Status\getErrorsArray
getErrorsArray()
Get the list of errors (but not warnings)
Definition: Status.php:341
$e
if( $useReadline) $e
Definition: eval.php:66
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
WebInstaller\getSession
getSession( $name, $default=null)
Get a session variable.
Definition: WebInstaller.php:467
$attribs
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:1530
WebInstaller\finish
finish()
Clean up from execute()
Definition: WebInstaller.php:409
request
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LoginAuthenticateAudit' this hook is for auditing only etc 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:1632
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
Status\getWikiText
getWikiText( $shortContext=false, $longContext=false)
Get the error list as a wikitext formatted list.
Definition: Status.php:185
wfArrayToCgi
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes two arrays as input, and returns a CGI-style string, e.g.
Definition: GlobalFunctions.php:367