* Removed Skin::reallyGenerateUserStylesheet() nothing uses it and nothing overrides it
[mediawiki.git] / includes / installer / WebInstaller.php
bloba751d03d992393e094d03fce2eef2cf3ed59d0c5
1 <?php
2 /**
3 * Core installer web interface.
5 * @file
6 * @ingroup Deployment
7 */
9 /**
10 * Class for the core installer web interface.
12 * @ingroup Deployment
13 * @since 1.17
15 class WebInstaller extends Installer {
17 /**
18 * @var WebInstallerOutput
20 public $output;
22 /**
23 * WebRequest object.
25 * @var WebRequest
27 public $request;
29 /**
30 * Cached session array.
32 * @var array
34 protected $session;
36 /**
37 * Captured PHP error text. Temporary.
38 * @var array
40 protected $phpErrors;
42 /**
43 * The main sequence of page names. These will be displayed in turn.
44 * To add one:
45 * * Add it here
46 * * Add a config-page-<name> message
47 * * Add a WebInstaller_<name> class
48 * @var array
50 public $pageSequence = array(
51 'Language',
52 'ExistingWiki',
53 'Welcome',
54 'DBConnect',
55 'Upgrade',
56 'DBSettings',
57 'Name',
58 'Options',
59 'Install',
60 'Complete',
63 /**
64 * Out of sequence pages, selectable by the user at any time.
65 * @var array
67 protected $otherPages = array(
68 'Restart',
69 'Readme',
70 'ReleaseNotes',
71 'Copying',
72 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
75 /**
76 * Array of pages which have declared that they have been submitted, have validated
77 * their input, and need no further processing.
78 * @var array
80 protected $happyPages;
82 /**
83 * List of "skipped" pages. These are pages that will automatically continue
84 * to the next page on any GET request. To avoid breaking the "back" button,
85 * they need to be skipped during a back operation.
86 * @var array
88 protected $skippedPages;
90 /**
91 * Flag indicating that session data may have been lost.
92 * @var bool
94 public $showSessionWarning = false;
96 /**
97 * Numeric index of the page we're on
98 * @var int
100 protected $tabIndex = 1;
103 * Name of the page we're on
104 * @var string
106 protected $currentPageName;
109 * Constructor.
111 * @param $request WebRequest
113 public function __construct( WebRequest $request ) {
114 parent::__construct();
115 $this->output = new WebInstallerOutput( $this );
116 $this->request = $request;
118 // Add parser hooks
119 global $wgParser;
120 $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
121 $wgParser->setHook( 'doclink', array( $this, 'docLink' ) );
125 * Main entry point.
127 * @param $session Array: initial session array
129 * @return Array: new session array
131 public function execute( array $session ) {
132 $this->session = $session;
134 if ( isset( $session['settings'] ) ) {
135 $this->settings = $session['settings'] + $this->settings;
138 $this->exportVars();
139 $this->setupLanguage();
141 if( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
142 && $this->request->getVal( 'localsettings' ) )
144 $this->request->response()->header( 'Content-type: application/x-httpd-php' );
145 $this->request->response()->header(
146 'Content-Disposition: attachment; filename="LocalSettings.php"'
149 $ls = new LocalSettingsGenerator( $this );
150 echo $ls->getText();
151 return $this->session;
154 $cssDir = $this->request->getVal( 'css' );
155 if( $cssDir ) {
156 $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' );
157 $this->request->response()->header( 'Content-type: text/css' );
158 echo $this->output->getCSS( $cssDir );
159 return $this->session;
162 if ( isset( $session['happyPages'] ) ) {
163 $this->happyPages = $session['happyPages'];
164 } else {
165 $this->happyPages = array();
168 if ( isset( $session['skippedPages'] ) ) {
169 $this->skippedPages = $session['skippedPages'];
170 } else {
171 $this->skippedPages = array();
174 $lowestUnhappy = $this->getLowestUnhappy();
176 # Special case for Creative Commons partner chooser box.
177 if ( $this->request->getVal( 'SubmitCC' ) ) {
178 $page = $this->getPageByName( 'Options' );
179 $this->output->useShortHeader();
180 $this->output->allowFrames();
181 $page->submitCC();
182 return $this->finish();
185 if ( $this->request->getVal( 'ShowCC' ) ) {
186 $page = $this->getPageByName( 'Options' );
187 $this->output->useShortHeader();
188 $this->output->allowFrames();
189 $this->output->addHTML( $page->getCCDoneBox() );
190 return $this->finish();
193 # Get the page name.
194 $pageName = $this->request->getVal( 'page' );
196 if ( in_array( $pageName, $this->otherPages ) ) {
197 # Out of sequence
198 $pageId = false;
199 $page = $this->getPageByName( $pageName );
200 } else {
201 # Main sequence
202 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
203 $pageId = $lowestUnhappy;
204 } else {
205 $pageId = array_search( $pageName, $this->pageSequence );
208 # If necessary, move back to the lowest-numbered unhappy page
209 if ( $pageId > $lowestUnhappy ) {
210 $pageId = $lowestUnhappy;
211 if ( $lowestUnhappy == 0 ) {
212 # Knocked back to start, possible loss of session data.
213 $this->showSessionWarning = true;
217 $pageName = $this->pageSequence[$pageId];
218 $page = $this->getPageByName( $pageName );
221 # If a back button was submitted, go back without submitting the form data.
222 if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) {
223 if ( $this->request->getVal( 'lastPage' ) ) {
224 $nextPage = $this->request->getVal( 'lastPage' );
225 } elseif ( $pageId !== false ) {
226 # Main sequence page
227 # Skip the skipped pages
228 $nextPageId = $pageId;
230 do {
231 $nextPageId--;
232 $nextPage = $this->pageSequence[$nextPageId];
233 } while( isset( $this->skippedPages[$nextPage] ) );
234 } else {
235 $nextPage = $this->pageSequence[$lowestUnhappy];
238 $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
239 return $this->finish();
242 # Execute the page.
243 $this->currentPageName = $page->getName();
244 $this->startPageWrapper( $pageName );
246 $result = $page->execute();
248 $this->endPageWrapper();
250 if ( $result == 'skip' ) {
251 # Page skipped without explicit submission.
252 # Skip it when we click "back" so that we don't just go forward again.
253 $this->skippedPages[$pageName] = true;
254 $result = 'continue';
255 } else {
256 unset( $this->skippedPages[$pageName] );
259 # If it was posted, the page can request a continue to the next page.
260 if ( $result === 'continue' && !$this->output->headerDone() ) {
261 if ( $pageId !== false ) {
262 $this->happyPages[$pageId] = true;
265 $lowestUnhappy = $this->getLowestUnhappy();
267 if ( $this->request->getVal( 'lastPage' ) ) {
268 $nextPage = $this->request->getVal( 'lastPage' );
269 } elseif ( $pageId !== false ) {
270 $nextPage = $this->pageSequence[$pageId + 1];
271 } else {
272 $nextPage = $this->pageSequence[$lowestUnhappy];
275 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
276 $nextPage = $this->pageSequence[$lowestUnhappy];
279 $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
282 return $this->finish();
286 * Find the next page in sequence that hasn't been completed
287 * @return int
289 public function getLowestUnhappy() {
290 if ( count( $this->happyPages ) == 0 ) {
291 return 0;
292 } else {
293 return max( array_keys( $this->happyPages ) ) + 1;
298 * Start the PHP session. This may be called before execute() to start the PHP session.
300 * @return bool
302 public function startSession() {
303 if( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
304 // Done already
305 return true;
308 $this->phpErrors = array();
309 set_error_handler( array( $this, 'errorHandler' ) );
310 session_start();
311 restore_error_handler();
313 if ( $this->phpErrors ) {
314 $this->showError( 'config-session-error', $this->phpErrors[0] );
315 return false;
318 return true;
322 * Get a hash of data identifying this MW installation.
324 * This is used by mw-config/index.php to prevent multiple installations of MW
325 * on the same cookie domain from interfering with each other.
327 * @return string
329 public function getFingerprint() {
330 // Get the base URL of the installation
331 $url = $this->request->getFullRequestURL();
332 if ( preg_match( '!^(.*\?)!', $url, $m) ) {
333 // Trim query string
334 $url = $m[1];
336 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
337 // This... seems to try to get the base path from
338 // the /mw-config/index.php. Kinda scary though?
339 $url = $m[1];
341 return md5( serialize( array(
342 'local path' => dirname( dirname( __FILE__ ) ),
343 'url' => $url,
344 'version' => $GLOBALS['wgVersion']
345 ) ) );
349 * Show an error message in a box. Parameters are like wfMsg().
351 public function showError( $msg /*...*/ ) {
352 $args = func_get_args();
353 array_shift( $args );
354 $args = array_map( 'htmlspecialchars', $args );
355 $msg = wfMsgReal( $msg, $args, false, false, false );
356 $this->output->addHTML( $this->getErrorBox( $msg ) );
360 * Temporary error handler for session start debugging.
362 public function errorHandler( $errno, $errstr ) {
363 $this->phpErrors[] = $errstr;
367 * Clean up from execute()
369 * @return array
371 public function finish() {
372 $this->output->output();
374 $this->session['happyPages'] = $this->happyPages;
375 $this->session['skippedPages'] = $this->skippedPages;
376 $this->session['settings'] = $this->settings;
378 return $this->session;
382 * We're restarting the installation, reset the session, happyPages, etc
384 public function reset() {
385 $this->session = array();
386 $this->happyPages = array();
387 $this->settings = array();
391 * Get a URL for submission back to the same script.
393 * @param $query array
394 * @return string
396 public function getUrl( $query = array() ) {
397 $url = $this->request->getRequestURL();
398 # Remove existing query
399 $url = preg_replace( '/\?.*$/', '', $url );
401 if ( $query ) {
402 $url .= '?' . wfArrayToCGI( $query );
405 return $url;
409 * Get a WebInstallerPage by name.
411 * @param $pageName String
412 * @return WebInstallerPage
414 public function getPageByName( $pageName ) {
415 $pageClass = 'WebInstaller_' . $pageName;
417 return new $pageClass( $this );
421 * Get a session variable.
423 * @param $name String
424 * @param $default
426 public function getSession( $name, $default = null ) {
427 if ( !isset( $this->session[$name] ) ) {
428 return $default;
429 } else {
430 return $this->session[$name];
435 * Set a session variable.
436 * @param $name String key for the variable
437 * @param $value Mixed
439 public function setSession( $name, $value ) {
440 $this->session[$name] = $value;
444 * Get the next tabindex attribute value.
445 * @return int
447 public function nextTabIndex() {
448 return $this->tabIndex++;
452 * Initializes language-related variables.
454 public function setupLanguage() {
455 global $wgLang, $wgContLang, $wgLanguageCode;
457 if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) {
458 $wgLanguageCode = $this->getAcceptLanguage();
459 $wgLang = $wgContLang = Language::factory( $wgLanguageCode );
460 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
461 $this->setVar( '_UserLang', $wgLanguageCode );
462 } else {
463 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
464 $wgLang = Language::factory( $this->getVar( '_UserLang' ) );
465 $wgContLang = Language::factory( $wgLanguageCode );
470 * Retrieves MediaWiki language from Accept-Language HTTP header.
472 * @return string
474 public function getAcceptLanguage() {
475 global $wgLanguageCode, $wgRequest;
477 $mwLanguages = Language::getLanguageNames();
478 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
480 foreach ( $headerLanguages as $lang ) {
481 if ( isset( $mwLanguages[$lang] ) ) {
482 return $lang;
486 return $wgLanguageCode;
490 * Called by execute() before page output starts, to show a page list.
492 * @param $currentPageName String
494 private function startPageWrapper( $currentPageName ) {
495 $s = "<div class=\"config-page-wrapper\">\n";
496 $s .= "<div class=\"config-page\">\n";
497 $s .= "<div class=\"config-page-list\"><ul>\n";
498 $lastHappy = -1;
500 foreach ( $this->pageSequence as $id => $pageName ) {
501 $happy = !empty( $this->happyPages[$id] );
502 $s .= $this->getPageListItem(
503 $pageName,
504 $happy || $lastHappy == $id - 1,
505 $currentPageName
508 if ( $happy ) {
509 $lastHappy = $id;
513 $s .= "</ul><br/><ul>\n";
514 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
515 $s .= "</ul></div>\n"; // end list pane
516 $s .= Html::element( 'h2', array(),
517 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
519 $this->output->addHTMLNoFlush( $s );
523 * Get a list item for the page list.
525 * @param $pageName String
526 * @param $enabled Boolean
527 * @param $currentPageName String
529 * @return string
531 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
532 $s = "<li class=\"config-page-list-item\">";
533 $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
535 if ( $enabled ) {
536 $query = array( 'page' => $pageName );
538 if ( !in_array( $pageName, $this->pageSequence ) ) {
539 if ( in_array( $currentPageName, $this->pageSequence ) ) {
540 $query['lastPage'] = $currentPageName;
543 $link = Html::element( 'a',
544 array(
545 'href' => $this->getUrl( $query )
547 $name
549 } else {
550 $link = htmlspecialchars( $name );
553 if ( $pageName == $currentPageName ) {
554 $s .= "<span class=\"config-page-current\">$link</span>";
555 } else {
556 $s .= $link;
558 } else {
559 $s .= Html::element( 'span',
560 array(
561 'class' => 'config-page-disabled'
563 $name
567 $s .= "</li>\n";
569 return $s;
573 * Output some stuff after a page is finished.
575 private function endPageWrapper() {
576 $this->output->addHTMLNoFlush(
577 "<div class=\"visualClear\"></div>\n" .
578 "</div>\n" .
579 "<div class=\"visualClear\"></div>\n" .
580 "</div>" );
584 * Get HTML for an error box with an icon.
586 * @param $text String: wikitext, get this with wfMsgNoTrans()
588 * @return string
590 public function getErrorBox( $text ) {
591 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
595 * Get HTML for a warning box with an icon.
597 * @param $text String: wikitext, get this with wfMsgNoTrans()
599 * @return string
601 public function getWarningBox( $text ) {
602 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
606 * Get HTML for an info box with an icon.
608 * @param $text String: wikitext, get this with wfMsgNoTrans()
609 * @param $icon String: icon name, file in skins/common/images
610 * @param $class String: additional class name to add to the wrapper div
612 * @return string
614 public function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
615 $s =
616 "<div class=\"config-info $class\">\n" .
617 "<div class=\"config-info-left\">\n" .
618 Html::element( 'img',
619 array(
620 'src' => '../skins/common/images/' . $icon,
621 'alt' => wfMsg( 'config-information' ),
623 ) . "\n" .
624 "</div>\n" .
625 "<div class=\"config-info-right\">\n" .
626 $this->parse( $text, true ) . "\n" .
627 "</div>\n" .
628 "<div style=\"clear: left;\"></div>\n" .
629 "</div>\n";
630 return $s;
634 * Get small text indented help for a preceding form field.
635 * Parameters like wfMsg().
637 * @return string
639 public function getHelpBox( $msg /*, ... */ ) {
640 $args = func_get_args();
641 array_shift( $args );
642 $args = array_map( 'htmlspecialchars', $args );
643 $text = wfMsgReal( $msg, $args, false, false, false );
644 $html = htmlspecialchars( $text );
645 $html = $this->parse( $text, true );
647 return "<div class=\"mw-help-field-container\">\n" .
648 "<span class=\"mw-help-field-hint\">" . wfMsgHtml( 'config-help' ) . "</span>\n" .
649 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
650 "</div>\n";
654 * Output a help box.
655 * @param $msg String key for wfMsg()
657 public function showHelpBox( $msg /*, ... */ ) {
658 $args = func_get_args();
659 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
660 $this->output->addHTML( $html );
664 * Show a short informational message.
665 * Output looks like a list.
667 * @param $msg string
669 public function showMessage( $msg /*, ... */ ) {
670 $args = func_get_args();
671 array_shift( $args );
672 $html = '<div class="config-message">' .
673 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
674 "</div>\n";
675 $this->output->addHTML( $html );
679 * @param $status Status
681 public function showStatusMessage( Status $status ) {
682 $text = $status->getWikiText();
683 $this->output->addWikiText(
684 "<div class=\"config-message\">\n" .
685 $text .
686 "</div>"
691 * Label a control by wrapping a config-input div around it and putting a
692 * label before it.
694 * @return string
696 public function label( $msg, $forId, $contents, $helpData = "" ) {
697 if ( strval( $msg ) == '' ) {
698 $labelText = '&#160;';
699 } else {
700 $labelText = wfMsgHtml( $msg );
703 $attributes = array( 'class' => 'config-label' );
705 if ( $forId ) {
706 $attributes['for'] = $forId;
709 return
710 "<div class=\"config-block\">\n" .
711 " <div class=\"config-block-label\">\n" .
712 Xml::tags( 'label',
713 $attributes,
714 $labelText ) . "\n" .
715 $helpData .
716 " </div>\n" .
717 " <div class=\"config-block-elements\">\n" .
718 $contents .
719 " </div>\n" .
720 "</div>\n";
724 * Get a labelled text box to configure a variable.
726 * @param $params Array
727 * Parameters are:
728 * var: The variable to be configured (required)
729 * label: The message name for the label (required)
730 * attribs: Additional attributes for the input element (optional)
731 * controlName: The name for the input element (optional)
732 * value: The current value of the variable (optional)
733 * help: The html for the help text (optional)
735 * @return string
737 public function getTextBox( $params ) {
738 if ( !isset( $params['controlName'] ) ) {
739 $params['controlName'] = 'config_' . $params['var'];
742 if ( !isset( $params['value'] ) ) {
743 $params['value'] = $this->getVar( $params['var'] );
746 if ( !isset( $params['attribs'] ) ) {
747 $params['attribs'] = array();
749 if ( !isset( $params['help'] ) ) {
750 $params['help'] = "";
752 return
753 $this->label(
754 $params['label'],
755 $params['controlName'],
756 Xml::input(
757 $params['controlName'],
758 30, // intended to be overridden by CSS
759 $params['value'],
760 $params['attribs'] + array(
761 'id' => $params['controlName'],
762 'class' => 'config-input-text',
763 'tabindex' => $this->nextTabIndex()
766 $params['help']
771 * Get a labelled textarea to configure a variable
773 * @param $params Array
774 * Parameters are:
775 * var: The variable to be configured (required)
776 * label: The message name for the label (required)
777 * attribs: Additional attributes for the input element (optional)
778 * controlName: The name for the input element (optional)
779 * value: The current value of the variable (optional)
780 * help: The html for the help text (optional)
782 * @return string
784 public function getTextArea( $params ) {
785 if ( !isset( $params['controlName'] ) ) {
786 $params['controlName'] = 'config_' . $params['var'];
789 if ( !isset( $params['value'] ) ) {
790 $params['value'] = $this->getVar( $params['var'] );
793 if ( !isset( $params['attribs'] ) ) {
794 $params['attribs'] = array();
796 if ( !isset( $params['help'] ) ) {
797 $params['help'] = "";
799 return
800 $this->label(
801 $params['label'],
802 $params['controlName'],
803 Xml::textarea(
804 $params['controlName'],
805 $params['value'],
808 $params['attribs'] + array(
809 'id' => $params['controlName'],
810 'class' => 'config-input-text',
811 'tabindex' => $this->nextTabIndex()
814 $params['help']
819 * Get a labelled password box to configure a variable.
821 * Implements password hiding
822 * @param $params Array
823 * Parameters are:
824 * var: The variable to be configured (required)
825 * label: The message name for the label (required)
826 * attribs: Additional attributes for the input element (optional)
827 * controlName: The name for the input element (optional)
828 * value: The current value of the variable (optional)
829 * help: The html for the help text (optional)
831 * @return string
833 public function getPasswordBox( $params ) {
834 if ( !isset( $params['value'] ) ) {
835 $params['value'] = $this->getVar( $params['var'] );
838 if ( !isset( $params['attribs'] ) ) {
839 $params['attribs'] = array();
842 $params['value'] = $this->getFakePassword( $params['value'] );
843 $params['attribs']['type'] = 'password';
845 return $this->getTextBox( $params );
849 * Get a labelled checkbox to configure a boolean variable.
851 * @param $params Array
852 * Parameters are:
853 * var: The variable to be configured (required)
854 * label: The message name for the label (required)
855 * attribs: Additional attributes for the input element (optional)
856 * controlName: The name for the input element (optional)
857 * value: The current value of the variable (optional)
858 * help: The html for the help text (optional)
860 * @return string
862 public function getCheckBox( $params ) {
863 if ( !isset( $params['controlName'] ) ) {
864 $params['controlName'] = 'config_' . $params['var'];
867 if ( !isset( $params['value'] ) ) {
868 $params['value'] = $this->getVar( $params['var'] );
871 if ( !isset( $params['attribs'] ) ) {
872 $params['attribs'] = array();
874 if ( !isset( $params['help'] ) ) {
875 $params['help'] = "";
877 if( isset( $params['rawtext'] ) ) {
878 $labelText = $params['rawtext'];
879 } else {
880 $labelText = $this->parse( wfMsg( $params['label'] ) );
883 return
884 "<div class=\"config-input-check\">\n" .
885 $params['help'] .
886 "<label>\n" .
887 Xml::check(
888 $params['controlName'],
889 $params['value'],
890 $params['attribs'] + array(
891 'id' => $params['controlName'],
892 'tabindex' => $this->nextTabIndex(),
895 $labelText . "\n" .
896 "</label>\n" .
897 "</div>\n";
901 * Get a set of labelled radio buttons.
903 * @param $params Array
904 * Parameters are:
905 * var: The variable to be configured (required)
906 * label: The message name for the label (required)
907 * itemLabelPrefix: The message name prefix for the item labels (required)
908 * values: List of allowed values (required)
909 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
910 * commonAttribs Attribute array applied to all items
911 * controlName: The name for the input element (optional)
912 * value: The current value of the variable (optional)
913 * help: The html for the help text (optional)
915 * @return string
917 public function getRadioSet( $params ) {
918 if ( !isset( $params['controlName'] ) ) {
919 $params['controlName'] = 'config_' . $params['var'];
922 if ( !isset( $params['value'] ) ) {
923 $params['value'] = $this->getVar( $params['var'] );
926 if ( !isset( $params['label'] ) ) {
927 $label = '';
928 } else {
929 $label = $params['label'];
931 if ( !isset( $params['help'] ) ) {
932 $params['help'] = "";
934 $s = "<ul>\n";
935 foreach ( $params['values'] as $value ) {
936 $itemAttribs = array();
938 if ( isset( $params['commonAttribs'] ) ) {
939 $itemAttribs = $params['commonAttribs'];
942 if ( isset( $params['itemAttribs'][$value] ) ) {
943 $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs;
946 $checked = $value == $params['value'];
947 $id = $params['controlName'] . '_' . $value;
948 $itemAttribs['id'] = $id;
949 $itemAttribs['tabindex'] = $this->nextTabIndex();
951 $s .=
952 '<li>' .
953 Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
954 '&#160;' .
955 Xml::tags( 'label', array( 'for' => $id ), $this->parse(
956 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
957 ) ) .
958 "</li>\n";
961 $s .= "</ul>\n";
963 return $this->label( $label, $params['controlName'], $s, $params['help'] );
967 * Output an error or warning box using a Status object.
969 public function showStatusBox( $status ) {
970 if( !$status->isGood() ) {
971 $text = $status->getWikiText();
973 if( $status->isOk() ) {
974 $box = $this->getWarningBox( $text );
975 } else {
976 $box = $this->getErrorBox( $text );
979 $this->output->addHTML( $box );
984 * Convenience function to set variables based on form data.
985 * Assumes that variables containing "password" in the name are (potentially
986 * fake) passwords.
988 * @param $varNames Array
989 * @param $prefix String: the prefix added to variables to obtain form names
991 * @return array
993 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
994 $newValues = array();
996 foreach ( $varNames as $name ) {
997 $value = trim( $this->request->getVal( $prefix . $name ) );
998 $newValues[$name] = $value;
1000 if ( $value === null ) {
1001 // Checkbox?
1002 $this->setVar( $name, false );
1003 } else {
1004 if ( stripos( $name, 'password' ) !== false ) {
1005 $this->setPassword( $name, $value );
1006 } else {
1007 $this->setVar( $name, $value );
1012 return $newValues;
1016 * Helper for Installer::docLink()
1018 * @return string
1020 protected function getDocUrl( $page ) {
1021 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1023 if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
1024 $url .= '&lastPage=' . urlencode( $this->currentPageName );
1027 return $url;
1031 * Extension tag hook for a documentation link.
1033 * @return string
1035 public function docLink( $linkText, $attribs, $parser ) {
1036 $url = $this->getDocUrl( $attribs['href'] );
1037 return '<a href="' . htmlspecialchars( $url ) . '">' .
1038 htmlspecialchars( $linkText ) .
1039 '</a>';
1043 * Helper for "Download LocalSettings" link on WebInstall_Complete
1045 * @return String Html for download link
1047 public function downloadLinkHook( $text, $attribs, $parser ) {
1048 $img = Html::element( 'img', array(
1049 'src' => '../skins/common/images/download-32.png',
1050 'width' => '32',
1051 'height' => '32',
1052 ) );
1053 $anchor = Html::rawElement( 'a',
1054 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1055 $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) );
1056 return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );