3 class WebInstaller
extends Installer
{
4 /** WebRequest object */
7 /** Cached session array */
10 /** Captured PHP error text. Temporary.
15 * The main sequence of page names. These will be displayed in turn.
18 * * Add a config-page-<name> message
19 * * Add a WebInstaller_<name> class
21 var $pageSequence = array(
34 * Out of sequence pages, selectable by the user at any time
36 var $otherPages = array(
41 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
45 * Array of pages which have declared that they have been submitted, have validated
46 * their input, and need no further processing
51 * List of "skipped" pages. These are pages that will automatically continue
52 * to the next page on any GET request. To avoid breaking the "back" button,
53 * they need to be skipped during a back operation.
58 * Flag indicating that session data may have been lost
60 var $showSessionWarning = false;
68 function __construct( $request ) {
69 parent
::__construct();
70 $this->output
= new WebInstallerOutput( $this );
71 $this->request
= $request;
76 * @param array $session Initial session array
77 * @return array New session array
79 function execute( $session ) {
80 $this->session
= $session;
81 if ( isset( $session['settings'] ) ) {
82 $this->settings
= $session['settings'] +
$this->settings
;
85 $this->setupLanguage();
87 if ( isset( $session['happyPages'] ) ) {
88 $this->happyPages
= $session['happyPages'];
90 $this->happyPages
= array();
92 if ( isset( $session['skippedPages'] ) ) {
93 $this->skippedPages
= $session['skippedPages'];
95 $this->skippedPages
= array();
97 $lowestUnhappy = $this->getLowestUnhappy();
99 # Special case for Creative Commons partner chooser box
100 if ( $this->request
->getVal( 'SubmitCC' ) ) {
101 $page = $this->getPageByName( 'Options' );
102 $this->output
->useShortHeader();
104 return $this->finish();
106 if ( $this->request
->getVal( 'ShowCC' ) ) {
107 $page = $this->getPageByName( 'Options' );
108 $this->output
->useShortHeader();
109 $this->output
->addHTML( $page->getCCDoneBox() );
110 return $this->finish();
114 $pageName = $this->request
->getVal( 'page' );
116 if ( in_array( $pageName, $this->otherPages
) ) {
119 $page = $this->getPageByName( $pageName );
122 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
123 $pageId = $lowestUnhappy;
125 $pageId = array_search( $pageName, $this->pageSequence
);
128 # If necessary, move back to the lowest-numbered unhappy page
129 if ( $pageId > $lowestUnhappy ) {
130 $pageId = $lowestUnhappy;
131 if ( $lowestUnhappy == 0 ) {
132 # Knocked back to start, possible loss of session data
133 $this->showSessionWarning
= true;
136 $pageName = $this->pageSequence
[$pageId];
137 $page = $this->getPageByName( $pageName );
140 # If a back button was submitted, go back without submitting the form data
141 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
142 if ( $this->request
->getVal( 'lastPage' ) ) {
143 $nextPage = $this->request
->getVal( 'lastPage' );
144 } elseif ( $pageId !== false ) {
146 # Skip the skipped pages
147 $nextPageId = $pageId;
150 $nextPage = $this->pageSequence
[$nextPageId];
151 } while( isset( $this->skippedPages
[$nextPage] ) );
153 $nextPage = $this->pageSequence
[$lowestUnhappy];
155 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
156 return $this->finish();
160 $this->currentPageName
= $page->getName();
161 $this->startPageWrapper( $pageName );
162 $result = $page->execute();
163 $this->endPageWrapper();
165 if ( $result == 'skip' ) {
166 # Page skipped without explicit submission
167 # Skip it when we click "back" so that we don't just go forward again
168 $this->skippedPages
[$pageName] = true;
169 $result = 'continue';
171 unset( $this->skippedPages
[$pageName] );
174 # If it was posted, the page can request a continue to the next page
175 if ( $result === 'continue' && !$this->output
->headerDone() ) {
176 if ( $pageId !== false ) {
177 $this->happyPages
[$pageId] = true;
179 $lowestUnhappy = $this->getLowestUnhappy();
181 if ( $this->request
->getVal( 'lastPage' ) ) {
182 $nextPage = $this->request
->getVal( 'lastPage' );
183 } elseif ( $pageId !== false ) {
184 $nextPage = $this->pageSequence
[$pageId +
1];
186 $nextPage = $this->pageSequence
[$lowestUnhappy];
188 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
189 $nextPage = $this->pageSequence
[$lowestUnhappy];
191 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
193 return $this->finish();
196 function getLowestUnhappy() {
197 if ( count( $this->happyPages
) == 0 ) {
200 return max( array_keys( $this->happyPages
) ) +
1;
205 * Start the PHP session. This may be called before execute() to start the PHP session.
207 function startSession() {
208 $sessPath = $this->getSessionSavePath();
209 if( $sessPath != '' ) {
210 if( !is_dir( $sessPath ) ||
!is_writeable( $sessPath ) ) {
211 $this->showError( 'config-session-path-bad', $sessPath );
215 // If the path is unset it'll default to some system bit, which *probably* is ok...
216 // not sure how to actually get what will be used.
218 if( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
223 $this->phpErrors
= array();
224 set_error_handler( array( $this, 'errorHandler' ) );
226 restore_error_handler();
227 if ( $this->phpErrors
) {
228 $this->showError( 'config-session-error', $this->phpErrors
[0] );
235 * Get the value of session.save_path
237 * Per http://www.php.net/manual/en/ref.session.php#ini.session.save-path,
238 * this might have some additional preceding parts which need to be
243 private function getSessionSavePath() {
244 $path = ini_get( 'session.save_path' );
245 $path = ltrim( substr( $path, strrpos( $path, ';' ) ), ';');
251 * Show an error message in a box. Parameters are like wfMsg().
253 function showError( $msg /*...*/ ) {
254 $args = func_get_args();
255 array_shift( $args );
256 $args = array_map( 'htmlspecialchars', $args );
257 $msg = wfMsgReal( $msg, $args, false, false, false );
258 $this->output
->addHTML( $this->getErrorBox( $msg ) );
262 * Temporary error handler for session start debugging
264 function errorHandler( $errno, $errstr ) {
265 $this->phpErrors
[] = $errstr;
269 * Clean up from execute()
273 $this->output
->output();
274 $this->session
['happyPages'] = $this->happyPages
;
275 $this->session
['skippedPages'] = $this->skippedPages
;
276 $this->session
['settings'] = $this->settings
;
277 return $this->session
;
281 * Get a URL for submission back to the same script
283 function getUrl( $query = array() ) {
284 $url = $this->request
->getRequestURL();
285 # Remove existing query
286 $url = preg_replace( '/\?.*$/', '', $url );
288 $url .= '?' . wfArrayToCGI( $query );
294 * Get a WebInstallerPage from the main sequence, by ID
296 function getPageById( $id ) {
297 $pageName = $this->pageSequence
[$id];
298 $pageClass = 'WebInstaller_' . $pageName;
299 return new $pageClass( $this );
303 * Get a WebInstallerPage by name
305 function getPageByName( $pageName ) {
306 $pageClass = 'WebInstaller_' . $pageName;
307 return new $pageClass( $this );
311 * Get a session variable
313 function getSession( $name, $default = null ) {
314 if ( !isset( $this->session
[$name] ) ) {
317 return $this->session
[$name];
322 * Set a session variable
324 function setSession( $name, $value ) {
325 $this->session
[$name] = $value;
329 * Get the next tabindex attribute value
331 function nextTabIndex() {
332 return $this->tabIndex++
;
336 * Initializes language-related variables
338 function setupLanguage() {
339 global $wgLang, $wgContLang, $wgLanguageCode;
340 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
341 $wgLanguageCode = $this->getAcceptLanguage();
342 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
343 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
344 $this->setVar( '_UserLang', $wgLanguageCode );
346 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
347 $wgLang = Language
::factory( $this->getVar( '_UserLang' ) );
348 $wgContLang = Language
::factory( $wgLanguageCode );
353 * Retrieves MediaWiki language from Accept-Language HTTP header
355 function getAcceptLanguage() {
356 global $wgLanguageCode;
358 $mwLanguages = Language
::getLanguageNames();
359 $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
360 foreach ( explode( ';', $langs ) as $splitted ) {
361 foreach ( explode( ',', $splitted ) as $lang ) {
362 $lang = trim( strtolower( $lang ) );
363 if ( $lang == '' ||
$lang[0] == 'q' ) {
366 if ( isset( $mwLanguages[$lang] ) ) {
369 $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang );
370 if ( $lang != '' && isset( $mwLanguages[$lang] ) ) {
375 return $wgLanguageCode;
379 * Called by execute() before page output starts, to show a page list
381 function startPageWrapper( $currentPageName ) {
382 $s = "<div class=\"config-page-wrapper\">\n" .
383 "<div class=\"config-page-list\"><ul>\n";
385 foreach ( $this->pageSequence
as $id => $pageName ) {
386 $happy = !empty( $this->happyPages
[$id] );
387 $s .= $this->getPageListItem( $pageName,
388 $happy ||
$lastHappy == $id - 1, $currentPageName );
393 $s .= "</ul><br/><ul>\n";
394 foreach ( $this->otherPages
as $pageName ) {
395 $s .= $this->getPageListItem( $pageName, true, $currentPageName );
397 $s .= "</ul></div>\n". // end list pane
398 "<div class=\"config-page\">\n" .
399 Xml
::element( 'h2', array(),
400 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
402 $this->output
->addHTMLNoFlush( $s );
406 * Get a list item for the page list
408 function getPageListItem( $pageName, $enabled, $currentPageName ) {
409 $s = "<li class=\"config-page-list-item\">";
410 $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
412 $query = array( 'page' => $pageName );
413 if ( !in_array( $pageName, $this->pageSequence
) ) {
414 if ( in_array( $currentPageName, $this->pageSequence
) ) {
415 $query['lastPage'] = $currentPageName;
417 $link = Xml
::element( 'a',
419 'href' => $this->getUrl( $query )
424 $link = htmlspecialchars( $name );
426 if ( $pageName == $currentPageName ) {
427 $s .= "<span class=\"config-page-current\">$link</span>";
432 $s .= Xml
::element( 'span',
434 'class' => 'config-page-disabled'
444 * Output some stuff after a page is finished
446 function endPageWrapper() {
447 $this->output
->addHTMLNoFlush(
449 "<br style=\"clear:both\"/>\n" .
454 * Get HTML for an error box with an icon
455 * @param string $text Wikitext, get this with wfMsgNoTrans()
457 function getErrorBox( $text ) {
458 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
462 * Get HTML for a warning box with an icon
463 * @param string $text Wikitext, get this with wfMsgNoTrans()
465 function getWarningBox( $text ) {
466 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
470 * Get HTML for an info box with an icon
471 * @param string $text Wikitext, get this with wfMsgNoTrans()
472 * @param string $icon Icon name, file in skins/common/images
473 * @param string $class Additional class name to add to the wrapper div
475 function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
477 "<div class=\"config-info $class\">\n" .
478 "<div class=\"config-info-left\">\n" .
481 'src' => '../skins/common/images/' . $icon,
482 'alt' => wfMsg( 'config-information' ),
486 "<div class=\"config-info-right\">\n" .
487 $this->parse( $text ) . "\n" .
489 "<div style=\"clear: left;\"></div>\n" .
495 * Get small text indented help for a preceding form field.
496 * Parameters like wfMsg().
498 function getHelpBox( $msg /*, ... */ ) {
499 $args = func_get_args();
500 array_shift( $args );
501 $args = array_map( 'htmlspecialchars', $args );
502 $text = wfMsgReal( $msg, $args, false, false, false );
503 $html = $this->parse( $text, true );
504 $id = $this->helpId++
;
505 $alt = wfMsg( 'help' );
508 "<div class=\"config-help-wrapper\">\n" .
509 "<div class=\"config-help-message\">\n" .
512 "<div class=\"config-show-help\">\n" .
514 wfMsgHtml( 'config-show-help' ) .
516 "<div class=\"config-hide-help\">\n" .
518 wfMsgHtml( 'config-hide-help' ) .
519 "</a></div>\n</div>\n";
525 function showHelpBox( $msg /*, ... */ ) {
526 $args = func_get_args();
527 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
528 $this->output
->addHTML( $html );
532 * Show a short informational message
533 * Output looks like a list.
535 function showMessage( $msg /*, ... */ ) {
536 $args = func_get_args();
537 array_shift( $args );
538 $html = '<div class="config-message">' .
539 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
541 $this->output
->addHTML( $html );
545 * Label a control by wrapping a config-input div around it and putting a
548 function label( $msg, $forId, $contents ) {
549 if ( strval( $msg ) == '' ) {
550 $labelText = ' ';
552 $labelText = wfMsgHtml( $msg );
554 $attributes = array( 'class' => 'config-label' );
556 $attributes['for'] = $forId;
559 "<div class=\"config-input\">\n" .
562 $labelText ) . "\n" .
568 * Get a labelled text box to configure a variable
569 * @param array $params
571 * var: The variable to be configured (required)
572 * label: The message name for the label (required)
573 * attribs: Additional attributes for the input element (optional)
574 * controlName: The name for the input element (optional)
575 * value: The current value of the variable (optional)
577 function getTextBox( $params ) {
578 if ( !isset( $params['controlName'] ) ) {
579 $params['controlName'] = 'config_' . $params['var'];
581 if ( !isset( $params['value'] ) ) {
582 $params['value'] = $this->getVar( $params['var'] );
584 if ( !isset( $params['attribs'] ) ) {
585 $params['attribs'] = array();
590 $params['controlName'],
592 $params['controlName'],
593 30, // intended to be overridden by CSS
595 $params['attribs'] +
array(
596 'id' => $params['controlName'],
597 'class' => 'config-input-text',
598 'tabindex' => $this->nextTabIndex()
605 * Get a labelled password box to configure a variable
606 * Implements password hiding
607 * @param array $params
609 * var: The variable to be configured (required)
610 * label: The message name for the label (required)
611 * attribs: Additional attributes for the input element (optional)
612 * controlName: The name for the input element (optional)
613 * value: The current value of the variable (optional)
615 function getPasswordBox( $params ) {
616 if ( !isset( $params['value'] ) ) {
617 $params['value'] = $this->getVar( $params['var'] );
619 if ( !isset( $params['attribs'] ) ) {
620 $params['attribs'] = array();
622 $params['value'] = $this->getFakePassword( $params['value'] );
623 $params['attribs']['type'] = 'password';
624 return $this->getTextBox( $params );
628 * Get a labelled checkbox to configure a boolean variable
629 * @param array $params
631 * var: The variable to be configured (required)
632 * label: The message name for the label (required)
633 * attribs: Additional attributes for the input element (optional)
634 * controlName: The name for the input element (optional)
635 * value: The current value of the variable (optional)
637 function getCheckBox( $params ) {
638 if ( !isset( $params['controlName'] ) ) {
639 $params['controlName'] = 'config_' . $params['var'];
641 if ( !isset( $params['value'] ) ) {
642 $params['value'] = $this->getVar( $params['var'] );
644 if ( !isset( $params['attribs'] ) ) {
645 $params['attribs'] = array();
647 if( isset( $params['rawtext'] ) ) {
648 $labelText = $params['rawtext'];
650 $labelText = $this->parse( wfMsg( $params['label'] ) );
653 "<div class=\"config-input-check\">\n" .
656 $params['controlName'],
658 $params['attribs'] +
array(
659 'id' => $params['controlName'],
660 'class' => 'config-input-text',
661 'tabindex' => $this->nextTabIndex(),
670 * Get a set of labelled radio buttons
672 * @param array $params
674 * var: The variable to be configured (required)
675 * label: The message name for the label (required)
676 * itemLabelPrefix: The message name prefix for the item labels (required)
677 * values: List of allowed values (required)
678 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
679 * commonAttribs Attribute array applied to all items
680 * controlName: The name for the input element (optional)
681 * value: The current value of the variable (optional)
683 function getRadioSet( $params ) {
684 if ( !isset( $params['controlName'] ) ) {
685 $params['controlName'] = 'config_' . $params['var'];
687 if ( !isset( $params['value'] ) ) {
688 $params['value'] = $this->getVar( $params['var'] );
690 if ( !isset( $params['label'] ) ) {
693 $label = $this->parse( wfMsgNoTrans( $params['label'] ) );
695 $s = "<label class=\"config-label\">\n" .
698 "<ul class=\"config-settings-block\">\n";
699 foreach ( $params['values'] as $value ) {
700 $itemAttribs = array();
701 if ( isset( $params['commonAttribs'] ) ) {
702 $itemAttribs = $params['commonAttribs'];
704 if ( isset( $params['itemAttribs'][$value] ) ) {
705 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
707 $checked = $value == $params['value'];
708 $id = $params['controlName'] . '_' . $value;
709 $itemAttribs['id'] = $id;
710 $itemAttribs['tabindex'] = $this->nextTabIndex();
713 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
715 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
716 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
725 * Output an error box using a Status object
727 function showStatusErrorBox( $status ) {
728 $text = $status->getWikiText();
729 $this->output
->addHTML( $this->getErrorBox( $text ) );
732 function showStatusError( $status ) {
733 $text = $status->getWikiText();
734 $this->output
->addWikiText(
735 "<div class=\"config-message\">\n" .
742 * Convenience function to set variables based on form data.
743 * Assumes that variables containing "password" in the name are (potentially
745 * @param array $varNames
746 * @param string $prefix The prefix added to variables to obtain form names
748 function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
749 $newValues = array();
750 foreach ( $varNames as $name ) {
751 $value = trim( $this->request
->getVal( $prefix . $name ) );
752 $newValues[$name] = $value;
753 if ( $value === null ) {
755 $this->setVar( $name, false );
757 if ( stripos( $name, 'password' ) !== false ) {
758 $this->setPassword( $name, $value );
760 $this->setVar( $name, $value );
768 * Get the starting tags of a fieldset
769 * @param string $legend Message name
771 function getFieldsetStart( $legend ) {
772 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
776 * Get the end tag of a fieldset
778 function getFieldsetEnd() {
779 return "</fieldset>\n";
783 * Helper for Installer::docLink()
785 function getDocUrl( $page ) {
786 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
787 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
788 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
794 class WebInstallerPage
{
795 function __construct( $parent ) {
796 $this->parent
= $parent;
799 function addHTML( $html ) {
800 $this->parent
->output
->addHTML( $html );
803 function startForm() {
805 "<div class=\"config-section\">\n" .
810 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
816 function endForm( $continue = 'continue' ) {
817 $this->parent
->output
->outputWarnings();
818 $s = "<div class=\"config-submit\">\n";
819 $id = $this->getId();
820 if ( $id === false ) {
821 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
824 // Fake submit button for enter keypress
825 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
826 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
829 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
831 'name' => 'submit-back',
832 'tabindex' => $this->parent
->nextTabIndex()
836 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
838 'name' => "submit-$continue",
839 'tabindex' => $this->parent
->nextTabIndex(),
842 $s .= "</div></form></div>\n";
843 $this->addHTML( $s );
847 return str_replace( 'WebInstaller_', '', get_class( $this ) );
851 return array_search( $this->getName(), $this->parent
->pageSequence
);
855 if ( $this->parent
->request
->wasPosted() ) {
859 $this->addHTML( 'Mockup' );
864 function getVar( $var ) {
865 return $this->parent
->getVar( $var );
868 function setVar( $name, $value ) {
869 $this->parent
->setVar( $name, $value );
873 class WebInstaller_Language
extends WebInstallerPage
{
876 $r = $this->parent
->request
;
877 $userLang = $r->getVal( 'UserLang' );
878 $contLang = $r->getVal( 'ContLang' );
880 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
882 $lifetime = 1440; // PHP default
885 if ( $r->wasPosted() ) {
887 if ( $this->parent
->getSession( 'test' ) === null ) {
888 $requestTime = $r->getVal( 'LanguageRequestTime' );
889 if ( !$requestTime ) {
890 // The most likely explanation is that the user was knocked back
891 // from another page on POST due to session expiry
892 $msg = 'config-session-expired';
893 } elseif ( time() - $requestTime > $lifetime ) {
894 $msg = 'config-session-expired';
896 $msg = 'config-no-session';
898 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
900 $languages = Language
::getLanguageNames();
901 if ( isset( $languages[$userLang] ) ) {
902 $this->setVar( '_UserLang', $userLang );
904 if ( isset( $languages[$contLang] ) ) {
905 $this->setVar( 'wgLanguageCode', $contLang );
906 if ( $this->getVar( '_AdminName' ) === null ) {
907 // Load localised sysop username in *content* language
908 $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) );
913 } elseif ( $this->parent
->showSessionWarning
) {
914 # The user was knocked back from another page to the start
915 # This probably indicates a session expiry
916 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
919 $this->parent
->setSession( 'test', true );
921 if ( !isset( $languages[$userLang] ) ) {
922 $userLang = $this->getVar( '_UserLang', 'en' );
924 if ( !isset( $languages[$contLang] ) ) {
925 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
929 Xml
::hidden( 'LanguageRequestTime', time() ) .
930 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
931 $this->parent
->getHelpBox( 'config-your-language-help' ) .
932 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
933 $this->parent
->getHelpBox( 'config-wiki-language-help' );
936 $this->addHTML( $s );
941 * Get a <select> for selecting languages
943 function getLanguageSelector( $name, $label, $selectedCode ) {
944 global $wgDummyLanguageCodes;
945 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
947 $languages = Language
::getLanguageNames();
949 $dummies = array_flip( $wgDummyLanguageCodes );
950 foreach ( $languages as $code => $lang ) {
951 if ( isset( $dummies[$code] ) ) continue;
952 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
954 $s .= "\n</select>\n";
955 return $this->parent
->label( $label, $name, $s );
959 class WebInstaller_Welcome
extends WebInstallerPage
{
961 if ( $this->parent
->request
->wasPosted() ) {
962 if ( $this->getVar( '_Environment' ) ) {
966 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
967 $status = $this->parent
->doEnvironmentChecks();
969 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
976 class WebInstaller_DBConnect
extends WebInstallerPage
{
978 $r = $this->parent
->request
;
979 if ( $r->wasPosted() ) {
980 $status = $this->submit();
981 if ( $status->isGood() ) {
982 $this->setVar( '_UpgradeDone', false );
985 $this->parent
->showStatusErrorBox( $status );
992 $types = "<ul class=\"config-settings-block\">\n";
994 $defaultType = $this->getVar( 'wgDBtype' );
995 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
996 $installer = $this->parent
->getDBInstaller( $type );
1000 $installer->getReadableName(),
1004 $type == $defaultType,
1005 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1010 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1011 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1012 $installer->getConnectForm() .
1015 $types .= "</ul><br clear=\"left\"/>\n";
1018 $this->parent
->label( 'config-db-type', false, $types ) .
1026 $r = $this->parent
->request
;
1027 $type = $r->getVal( 'DBType' );
1028 $this->setVar( 'wgDBtype', $type );
1029 $installer = $this->parent
->getDBInstaller( $type );
1030 if ( !$installer ) {
1031 return Status
::newFatal( 'config-invalid-db-type' );
1033 return $installer->submitConnectForm();
1037 class WebInstaller_Upgrade
extends WebInstallerPage
{
1038 function execute() {
1039 if ( $this->getVar( '_UpgradeDone' ) ) {
1040 if ( $this->parent
->request
->wasPosted() ) {
1041 // Done message acknowledged
1044 // Back button click
1045 // Show the done message again
1046 // Make them click back again if they want to do the upgrade again
1047 $this->showDoneMessage();
1052 // wgDBtype is generally valid here because otherwise the previous page
1053 // (connect) wouldn't have declared its happiness
1054 $type = $this->getVar( 'wgDBtype' );
1055 $installer = $this->parent
->getDBInstaller( $type );
1057 if ( !$installer->needsUpgrade() ) {
1061 if ( $this->parent
->request
->wasPosted() ) {
1063 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1064 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1065 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1067 $this->parent
->output
->flush();
1068 $result = $installer->doUpgrade();
1069 $this->addHTML( '</textarea>
1070 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1071 $this->parent
->output
->flush();
1073 $this->setVar( '_UpgradeDone', true );
1074 $this->showDoneMessage();
1080 $this->addHTML( $this->parent
->getInfoBox(
1081 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1085 function showDoneMessage() {
1088 $this->parent
->getInfoBox(
1089 wfMsgNoTrans( 'config-upgrade-done',
1090 $GLOBALS['wgServer'] .
1091 $this->getVar( 'wgScriptPath' ) . '/index' .
1092 $this->getVar( 'wgScriptExtension' )
1096 $this->endForm( 'regenerate' );
1100 class WebInstaller_DBSettings
extends WebInstallerPage
{
1101 function execute() {
1102 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1104 $r = $this->parent
->request
;
1105 if ( $r->wasPosted() ) {
1106 $status = $installer->submitSettingsForm();
1107 if ( $status === false ) {
1109 } elseif ( $status->isGood() ) {
1112 $this->parent
->showStatusErrorBox( $status );
1116 $form = $installer->getSettingsForm();
1117 if ( $form === false ) {
1122 $this->addHTML( $form );
1128 class WebInstaller_Name
extends WebInstallerPage
{
1129 function execute() {
1130 $r = $this->parent
->request
;
1131 if ( $r->wasPosted() ) {
1132 if ( $this->submit() ) {
1139 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1140 $this->setVar( 'wgSitename', '' );
1143 // Set wgMetaNamespace to something valid before we show the form.
1144 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1145 $metaNS = $this->getVar( 'wgMetaNamespace' );
1146 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1149 $this->parent
->getTextBox( array(
1150 'var' => 'wgSitename',
1151 'label' => 'config-site-name',
1153 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1154 $this->parent
->getRadioSet( array(
1155 'var' => '_NamespaceType',
1156 'label' => 'config-project-namespace',
1157 'itemLabelPrefix' => 'config-ns-',
1158 'values' => array( 'site-name', 'generic', 'other' ),
1159 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1161 $this->parent
->getTextBox( array(
1162 'var' => 'wgMetaNamespace',
1164 'attribs' => array( 'disabled' => '' ),
1166 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1167 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1168 $this->parent
->getTextBox( array(
1169 'var' => '_AdminName',
1170 'label' => 'config-admin-name'
1172 $this->parent
->getPasswordBox( array(
1173 'var' => '_AdminPassword',
1174 'label' => 'config-admin-password',
1176 $this->parent
->getPasswordBox( array(
1177 'var' => '_AdminPassword2',
1178 'label' => 'config-admin-password-confirm'
1180 $this->parent
->getHelpBox( 'config-admin-help' ) .
1181 $this->parent
->getTextBox( array(
1182 'var' => '_AdminEmail',
1183 'label' => 'config-admin-email'
1185 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1186 $this->parent
->getCheckBox( array(
1187 'var' => '_Subscribe',
1188 'label' => 'config-subscribe'
1190 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1191 $this->parent
->getFieldsetEnd() .
1192 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1193 $this->parent
->getRadioSet( array(
1194 'var' => '_SkipOptional',
1195 'itemLabelPrefix' => 'config-optional-',
1196 'values' => array( 'continue', 'skip' )
1200 // Restore the default value
1201 $this->setVar( 'wgMetaNamespace', $metaNS );
1209 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1210 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1211 '_Subscribe', '_SkipOptional' ) );
1213 // Validate site name
1214 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1215 $this->parent
->showError( 'config-site-name-blank' );
1220 $nsType = $this->getVar( '_NamespaceType' );
1221 if ( $nsType == 'site-name' ) {
1222 $name = $this->getVar( 'wgSitename' );
1223 // Sanitize for namespace
1224 // This algorithm should match the JS one in WebInstallerOutput.php
1225 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1226 $name = str_replace( '&', '&', $name );
1227 $name = preg_replace( '/__+/', '_', $name );
1228 $name = ucfirst( trim( $name, '_' ) );
1229 } elseif ( $nsType == 'generic' ) {
1230 $name = wfMsg( 'config-ns-generic' );
1232 $name = $this->getVar( 'wgMetaNamespace' );
1235 // Validate namespace
1236 if ( strpos( $name, ':' ) !== false ) {
1239 // Title-style validation
1240 $title = Title
::newFromText( $name );
1242 $good = $nsType == 'site-name' ?
true : false;
1244 $name = $title->getDBkey();
1249 $this->parent
->showError( 'config-ns-invalid', $name );
1252 $this->setVar( 'wgMetaNamespace', $name );
1254 // Validate username for creation
1255 $name = $this->getVar( '_AdminName' );
1256 if ( strval( $name ) === '' ) {
1257 $this->parent
->showError( 'config-admin-name-blank' );
1261 $cname = User
::getCanonicalName( $name, 'creatable' );
1262 if ( $cname === false ) {
1263 $this->parent
->showError( 'config-admin-name-invalid', $name );
1266 $this->setVar( '_AdminName', $cname );
1270 // Validate password
1272 $pwd = $this->getVar( '_AdminPassword' );
1273 $user = User
::newFromName( $cname );
1274 $valid = $user->getPasswordValidity( $pwd );
1275 if ( strval( $pwd ) === '' ) {
1276 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1277 # This message is more specific and helpful.
1278 $msg = 'config-admin-password-blank';
1279 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1280 $msg = 'config-admin-password-mismatch';
1281 } elseif ( $valid !== true ) {
1282 # As of writing this will only catch the username being e.g. 'FOO' and
1283 # the password 'foo'
1286 if ( $msg !== false ) {
1287 $this->parent
->showError( $msg );
1288 $this->setVar( '_AdminPassword', '' );
1289 $this->setVar( '_AdminPassword2', '' );
1296 class WebInstaller_Options
extends WebInstallerPage
{
1297 function execute() {
1298 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1301 if ( $this->parent
->request
->wasPosted() ) {
1302 if ( $this->submit() ) {
1310 $this->parent
->getRadioSet( array(
1311 'var' => '_RightsProfile',
1312 'label' => 'config-profile',
1313 'itemLabelPrefix' => 'config-profile-',
1314 'values' => array_keys( $this->parent
->rightsProfiles
),
1316 $this->parent
->getHelpBox( 'config-profile-help' ) .
1319 $this->parent
->getRadioSet( array(
1320 'var' => '_LicenseCode',
1321 'label' => 'config-license',
1322 'itemLabelPrefix' => 'config-license-',
1323 'values' => array_keys( $this->parent
->licenses
),
1324 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1326 $this->getCCChooser() .
1327 $this->parent
->getHelpBox( 'config-license-help' ) .
1330 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1331 $this->parent
->getCheckBox( array(
1332 'var' => 'wgEnableEmail',
1333 'label' => 'config-enable-email',
1334 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1336 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1337 "<div id=\"emailwrapper\">" .
1338 $this->parent
->getTextBox( array(
1339 'var' => 'wgPasswordSender',
1340 'label' => 'config-email-sender'
1342 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1343 $this->parent
->getCheckBox( array(
1344 'var' => 'wgEnableUserEmail',
1345 'label' => 'config-email-user',
1347 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1348 $this->parent
->getCheckBox( array(
1349 'var' => 'wgEnotifUserTalk',
1350 'label' => 'config-email-usertalk',
1352 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1353 $this->parent
->getCheckBox( array(
1354 'var' => 'wgEnotifWatchlist',
1355 'label' => 'config-email-watchlist',
1357 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1358 $this->parent
->getCheckBox( array(
1359 'var' => 'wgEmailAuthentication',
1360 'label' => 'config-email-auth',
1362 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1364 $this->parent
->getFieldsetEnd()
1367 $extensions = $this->parent
->findExtensions();
1369 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1370 foreach( $extensions as $ext ) {
1371 $extHtml .= $this->parent
->getCheckBox( array(
1372 'var' => "ext-$ext",
1376 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1377 $this->parent
->getFieldsetEnd();
1378 $this->addHTML( $extHtml );
1383 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1384 $this->parent
->getCheckBox( array(
1385 'var' => 'wgEnableUploads',
1386 'label' => 'config-upload-enable',
1387 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1389 $this->parent
->getHelpBox( 'config-upload-help' ) .
1390 '<div id="uploadwrapper" style="display: none;">' .
1391 $this->parent
->getTextBox( array(
1392 'var' => 'wgDeletedDirectory',
1393 'label' => 'config-upload-deleted',
1395 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1396 $this->parent
->getTextBox( array(
1398 'label' => 'config-logo'
1400 $this->parent
->getHelpBox( 'config-logo-help' ) .
1402 $this->parent
->getFieldsetEnd()
1405 $caches = array( 'none', 'anything', 'db' );
1407 if( count( $this->getVar( '_Caches' ) ) ) {
1408 $caches[] = 'accel';
1409 $selected = 'accel';
1411 $caches[] = 'memcached';
1415 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1416 # Object cache settings
1417 $this->parent
->getRadioSet( array(
1418 'var' => 'wgMainCacheType',
1419 'label' => 'config-cache-options',
1420 'itemLabelPrefix' => 'config-cache-',
1421 'values' => $caches,
1422 'value' => $selected,
1424 $this->parent
->getHelpBox( 'config-cache-help' ) .
1425 $this->parent
->getTextBox( array(
1426 'var' => '_MemCachedServers',
1427 'label' => 'config-memcached-servers',
1429 $this->parent
->getHelpBox( 'config-memcached-help' ) .
1430 $this->parent
->getFieldsetEnd()
1435 function getCCPartnerUrl() {
1437 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1438 'page' => 'Options',
1439 'SubmitCC' => 'indeed',
1440 'config__LicenseCode' => 'cc',
1441 'config_wgRightsUrl' => '[license_url]',
1442 'config_wgRightsText' => '[license_name]',
1443 'config_wgRightsIcon' => '[license_button]',
1445 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1446 '/skins/common/config-cc.css';
1447 $iframeUrl = 'http://creativecommons.org/license/?' .
1448 wfArrayToCGI( array(
1449 'partner' => 'MediaWiki',
1450 'exit_url' => $exitUrl,
1451 'lang' => $this->getVar( '_UserLang' ),
1452 'stylesheet' => $styleUrl,
1457 function getCCChooser() {
1458 $iframeAttribs = array(
1459 'class' => 'config-cc-iframe',
1460 'name' => 'config-cc-iframe',
1461 'id' => 'config-cc-iframe',
1466 if ( $this->getVar( '_CCDone' ) ) {
1467 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1469 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1473 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1474 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1478 function getCCDoneBox() {
1479 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1480 // If you change this height, also change it in config.css
1481 $expandJs = str_replace( '$1', '54em', $js );
1482 $reduceJs = str_replace( '$1', '70px', $js );
1485 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1487 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1489 "<p style=\"text-align: center\">" .
1492 'href' => $this->getCCPartnerUrl(),
1493 'onclick' => $expandJs,
1495 wfMsg( 'config-cc-again' )
1498 "<script type=\"text/javascript\">\n" .
1499 # Reduce the wrapper div height
1500 htmlspecialchars( $reduceJs ) .
1506 function submitCC() {
1507 $newValues = $this->parent
->setVarsFromRequest(
1508 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1509 if ( count( $newValues ) != 3 ) {
1510 $this->parent
->showError( 'config-cc-error' );
1513 $this->setVar( '_CCDone', true );
1514 $this->addHTML( $this->getCCDoneBox() );
1518 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1519 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1520 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1521 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers' ) );
1523 if ( !in_array( $this->getVar( '_RightsProfile' ),
1524 array_keys( $this->parent
->rightsProfiles
) ) )
1526 reset( $this->parent
->rightsProfiles
);
1527 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1530 $code = $this->getVar( '_LicenseCode' );
1531 if ( $code == 'cc-choose' ) {
1532 if ( !$this->getVar( '_CCDone' ) ) {
1533 $this->parent
->showError( 'config-cc-not-chosen' );
1536 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1537 $entry = $this->parent
->licenses
[$code];
1538 if ( isset( $entry['text'] ) ) {
1539 $this->setVar( 'wgRightsText', $entry['text'] );
1541 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1543 $this->setVar( 'wgRightsUrl', $entry['url'] );
1544 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1546 $this->setVar( 'wgRightsText', '' );
1547 $this->setVar( 'wgRightsUrl', '' );
1548 $this->setVar( 'wgRightsIcon', '' );
1551 $exts = $this->parent
->getVar( '_Extensions' );
1552 foreach( $exts as $key => $ext ) {
1553 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1554 unset( $exts[$key] );
1557 $this->parent
->setVar( '_Extensions', $exts );
1562 class WebInstaller_Install
extends WebInstallerPage
{
1564 function execute() {
1565 if( $this->parent
->request
->wasPosted() ) {
1569 $this->addHTML("<ul>");
1570 foreach( $this->parent
->getInstallSteps() as $step ) {
1571 $this->startStage( "config-install-$step" );
1572 $func = 'install' . ucfirst( $step );
1573 $status = $this->parent
->{$func}();
1574 $ok = $status->isGood();
1576 $this->parent
->showStatusErrorBox( $status );
1578 $this->endStage( $ok );
1580 $this->addHTML("</ul>");
1586 private function startStage( $msg ) {
1587 $this->addHTML( "<li>" . wfMsgHtml( $msg ) . wfMsg( 'ellipsis') );
1590 private function endStage( $success = true ) {
1591 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1592 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1594 $html = "<span class=\"error\">$html</span>";
1596 $this->addHTML( $html . "</li>\n" );
1600 class WebInstaller_Complete
extends WebInstallerPage
{
1601 public function execute() {
1604 $msg = file_exists( "$IP/LocalSettings.php" ) ?
'config-install-done-moved' : 'config-install-done';
1606 $this->parent
->getInfoBox(
1608 $GLOBALS['wgServer'] .
1609 $this->getVar( 'wgScriptPath' ) . '/index' .
1610 $this->getVar( 'wgScriptExtension' )
1614 $this->endForm( false );
1618 class WebInstaller_Restart
extends WebInstallerPage
{
1619 function execute() {
1620 $r = $this->parent
->request
;
1621 if ( $r->wasPosted() ) {
1622 $really = $r->getVal( 'submit-restart' );
1624 $this->parent
->session
= array();
1625 $this->parent
->happyPages
= array();
1626 $this->parent
->settings
= array();
1632 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1633 $this->addHTML( $s );
1634 $this->endForm( 'restart' );
1638 abstract class WebInstaller_Document
extends WebInstallerPage
{
1639 abstract function getFileName();
1641 function execute() {
1642 $text = $this->getFileContents();
1643 $this->parent
->output
->addWikiText( $text );
1645 $this->endForm( false );
1648 function getFileContents() {
1649 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1652 protected function formatTextFile( $text ) {
1653 // replace numbering with [1], [2], etc with MW-style numbering
1654 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1655 // join word-wrapped lines into one
1658 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1659 } while ( $text != $prev );
1660 // turn (bug nnnn) into links
1661 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1662 // add links to manual to every global variable mentioned
1663 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1664 // special case for <pre> - formatted links
1667 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1668 } while ( $text != $prev );
1672 private function replaceBugLinks( $matches ) {
1673 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1674 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1677 private function replaceConfigLinks( $matches ) {
1678 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1679 $matches[1] . ' ' . $matches[1] . ']</span>';
1683 class WebInstaller_Readme
extends WebInstaller_Document
{
1684 function getFileName() { return 'README'; }
1686 function getFileContents() {
1687 return $this->formatTextFile( parent
::getFileContents() );
1691 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1692 function getFileName() { return 'RELEASE-NOTES'; }
1694 function getFileContents() {
1695 return $this->formatTextFile( parent
::getFileContents() );
1699 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1700 function getFileName() { return 'UPGRADE'; }
1702 function getFileContents() {
1703 return $this->formatTextFile( parent
::getFileContents() );
1707 class WebInstaller_Copying
extends WebInstaller_Document
{
1708 function getFileName() { return 'COPYING'; }
1710 function getFileContents() {
1711 $text = parent
::getFileContents();
1712 $text = str_replace( "\x0C", '', $text );
1713 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1714 $text = '<tt>' . nl2br( $text ) . '</tt>';
1718 private static function replaceLeadingSpaces( $matches ) {
1719 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );