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 $session Array: 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( strval( ini_get( 'open_basedir' ) ) != '' ) {
211 // we need to skip the following check when open_basedir is on.
212 // The session path probably *wont* be writable by the current
213 // user, and telling them to change it is bad. Bug 23021.
214 } elseif( !is_dir( $sessPath ) ||
!is_writeable( $sessPath ) ) {
215 $this->showError( 'config-session-path-bad', $sessPath );
219 // If the path is unset it'll default to some system bit, which *probably* is ok...
220 // not sure how to actually get what will be used.
222 if( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
227 $this->phpErrors
= array();
228 set_error_handler( array( $this, 'errorHandler' ) );
230 restore_error_handler();
231 if ( $this->phpErrors
) {
232 $this->showError( 'config-session-error', $this->phpErrors
[0] );
239 * Get the value of session.save_path
241 * Per http://www.php.net/manual/en/session.configuration.php#ini.session.save-path,
242 * this might have some additional preceding parts which need to be
247 private function getSessionSavePath() {
248 $path = ini_get( 'session.save_path' );
249 $path = ltrim( substr( $path, strrpos( $path, ';' ) ), ';');
255 * Show an error message in a box. Parameters are like wfMsg().
257 function showError( $msg /*...*/ ) {
258 $args = func_get_args();
259 array_shift( $args );
260 $args = array_map( 'htmlspecialchars', $args );
261 $msg = wfMsgReal( $msg, $args, false, false, false );
262 $this->output
->addHTML( $this->getErrorBox( $msg ) );
266 * Temporary error handler for session start debugging
268 function errorHandler( $errno, $errstr ) {
269 $this->phpErrors
[] = $errstr;
273 * Clean up from execute()
275 private function finish() {
276 $this->output
->output();
277 $this->session
['happyPages'] = $this->happyPages
;
278 $this->session
['skippedPages'] = $this->skippedPages
;
279 $this->session
['settings'] = $this->settings
;
280 return $this->session
;
284 * Get a URL for submission back to the same script
286 function getUrl( $query = array() ) {
287 $url = $this->request
->getRequestURL();
288 # Remove existing query
289 $url = preg_replace( '/\?.*$/', '', $url );
291 $url .= '?' . wfArrayToCGI( $query );
297 * Get a WebInstallerPage from the main sequence, by ID
299 function getPageById( $id ) {
300 $pageName = $this->pageSequence
[$id];
301 $pageClass = 'WebInstaller_' . $pageName;
302 return new $pageClass( $this );
306 * Get a WebInstallerPage by name
308 function getPageByName( $pageName ) {
309 $pageClass = 'WebInstaller_' . $pageName;
310 return new $pageClass( $this );
314 * Get a session variable
316 function getSession( $name, $default = null ) {
317 if ( !isset( $this->session
[$name] ) ) {
320 return $this->session
[$name];
325 * Set a session variable
327 function setSession( $name, $value ) {
328 $this->session
[$name] = $value;
332 * Get the next tabindex attribute value
334 function nextTabIndex() {
335 return $this->tabIndex++
;
339 * Initializes language-related variables
341 function setupLanguage() {
342 global $wgLang, $wgContLang, $wgLanguageCode;
343 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
344 $wgLanguageCode = $this->getAcceptLanguage();
345 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
346 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
347 $this->setVar( '_UserLang', $wgLanguageCode );
349 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
350 $wgLang = Language
::factory( $this->getVar( '_UserLang' ) );
351 $wgContLang = Language
::factory( $wgLanguageCode );
356 * Retrieves MediaWiki language from Accept-Language HTTP header
358 function getAcceptLanguage() {
359 global $wgLanguageCode;
361 $mwLanguages = Language
::getLanguageNames();
362 $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
363 foreach ( explode( ';', $langs ) as $splitted ) {
364 foreach ( explode( ',', $splitted ) as $lang ) {
365 $lang = trim( strtolower( $lang ) );
366 if ( $lang == '' ||
$lang[0] == 'q' ) {
369 if ( isset( $mwLanguages[$lang] ) ) {
372 $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang );
373 if ( $lang != '' && isset( $mwLanguages[$lang] ) ) {
378 return $wgLanguageCode;
382 * Called by execute() before page output starts, to show a page list
384 function startPageWrapper( $currentPageName ) {
385 $s = "<div class=\"config-page-wrapper\">\n" .
386 "<div class=\"config-page-list\"><ul>\n";
388 foreach ( $this->pageSequence
as $id => $pageName ) {
389 $happy = !empty( $this->happyPages
[$id] );
390 $s .= $this->getPageListItem( $pageName,
391 $happy ||
$lastHappy == $id - 1, $currentPageName );
396 $s .= "</ul><br/><ul>\n";
397 foreach ( $this->otherPages
as $pageName ) {
398 $s .= $this->getPageListItem( $pageName, true, $currentPageName );
400 $s .= "</ul></div>\n". // end list pane
401 "<div class=\"config-page\">\n" .
402 Xml
::element( 'h2', array(),
403 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
405 $this->output
->addHTMLNoFlush( $s );
409 * Get a list item for the page list
411 function getPageListItem( $pageName, $enabled, $currentPageName ) {
412 $s = "<li class=\"config-page-list-item\">";
413 $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
415 $query = array( 'page' => $pageName );
416 if ( !in_array( $pageName, $this->pageSequence
) ) {
417 if ( in_array( $currentPageName, $this->pageSequence
) ) {
418 $query['lastPage'] = $currentPageName;
420 $link = Xml
::element( 'a',
422 'href' => $this->getUrl( $query )
427 $link = htmlspecialchars( $name );
429 if ( $pageName == $currentPageName ) {
430 $s .= "<span class=\"config-page-current\">$link</span>";
435 $s .= Xml
::element( 'span',
437 'class' => 'config-page-disabled'
447 * Output some stuff after a page is finished
449 function endPageWrapper() {
450 $this->output
->addHTMLNoFlush(
452 "<br style=\"clear:both\"/>\n" .
457 * Get HTML for an error box with an icon
459 * @param $text String: wikitext, get this with wfMsgNoTrans()
461 function getErrorBox( $text ) {
462 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
466 * Get HTML for a warning box with an icon
468 * @param $text String: wikitext, get this with wfMsgNoTrans()
470 function getWarningBox( $text ) {
471 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
475 * Get HTML for an info box with an icon
477 * @param $text String: wikitext, get this with wfMsgNoTrans()
478 * @param $icon String: icon name, file in skins/common/images
479 * @param $class String: additional class name to add to the wrapper div
481 function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
483 "<div class=\"config-info $class\">\n" .
484 "<div class=\"config-info-left\">\n" .
487 'src' => '../skins/common/images/' . $icon,
488 'alt' => wfMsg( 'config-information' ),
492 "<div class=\"config-info-right\">\n" .
493 $this->parse( $text ) . "\n" .
495 "<div style=\"clear: left;\"></div>\n" .
501 * Get small text indented help for a preceding form field.
502 * Parameters like wfMsg().
504 function getHelpBox( $msg /*, ... */ ) {
505 $args = func_get_args();
506 array_shift( $args );
507 $args = array_map( 'htmlspecialchars', $args );
508 $text = wfMsgReal( $msg, $args, false, false, false );
509 $html = $this->parse( $text, true );
510 $id = $this->helpId++
;
511 $alt = wfMsg( 'help' );
514 "<div class=\"config-help-wrapper\">\n" .
515 "<div class=\"config-help-message\">\n" .
518 "<div class=\"config-show-help\">\n" .
520 wfMsgHtml( 'config-show-help' ) .
522 "<div class=\"config-hide-help\">\n" .
524 wfMsgHtml( 'config-hide-help' ) .
525 "</a></div>\n</div>\n";
531 function showHelpBox( $msg /*, ... */ ) {
532 $args = func_get_args();
533 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
534 $this->output
->addHTML( $html );
538 * Show a short informational message
539 * Output looks like a list.
541 function showMessage( $msg /*, ... */ ) {
542 $args = func_get_args();
543 array_shift( $args );
544 $html = '<div class="config-message">' .
545 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
547 $this->output
->addHTML( $html );
551 * Label a control by wrapping a config-input div around it and putting a
554 function label( $msg, $forId, $contents ) {
555 if ( strval( $msg ) == '' ) {
556 $labelText = ' ';
558 $labelText = wfMsgHtml( $msg );
560 $attributes = array( 'class' => 'config-label' );
562 $attributes['for'] = $forId;
565 "<div class=\"config-input\">\n" .
568 $labelText ) . "\n" .
574 * Get a labelled text box to configure a variable
576 * @param $params Array
578 * var: The variable to be configured (required)
579 * label: The message name for the label (required)
580 * attribs: Additional attributes for the input element (optional)
581 * controlName: The name for the input element (optional)
582 * value: The current value of the variable (optional)
584 function getTextBox( $params ) {
585 if ( !isset( $params['controlName'] ) ) {
586 $params['controlName'] = 'config_' . $params['var'];
588 if ( !isset( $params['value'] ) ) {
589 $params['value'] = $this->getVar( $params['var'] );
591 if ( !isset( $params['attribs'] ) ) {
592 $params['attribs'] = array();
597 $params['controlName'],
599 $params['controlName'],
600 30, // intended to be overridden by CSS
602 $params['attribs'] +
array(
603 'id' => $params['controlName'],
604 'class' => 'config-input-text',
605 'tabindex' => $this->nextTabIndex()
612 * Get a labelled password box to configure a variable
614 * Implements password hiding
615 * @param $params Array
617 * var: The variable to be configured (required)
618 * label: The message name for the label (required)
619 * attribs: Additional attributes for the input element (optional)
620 * controlName: The name for the input element (optional)
621 * value: The current value of the variable (optional)
623 function getPasswordBox( $params ) {
624 if ( !isset( $params['value'] ) ) {
625 $params['value'] = $this->getVar( $params['var'] );
627 if ( !isset( $params['attribs'] ) ) {
628 $params['attribs'] = array();
630 $params['value'] = $this->getFakePassword( $params['value'] );
631 $params['attribs']['type'] = 'password';
632 return $this->getTextBox( $params );
636 * Get a labelled checkbox to configure a boolean variable
638 * @param $params Array
640 * var: The variable to be configured (required)
641 * label: The message name for the label (required)
642 * attribs: Additional attributes for the input element (optional)
643 * controlName: The name for the input element (optional)
644 * value: The current value of the variable (optional)
646 function getCheckBox( $params ) {
647 if ( !isset( $params['controlName'] ) ) {
648 $params['controlName'] = 'config_' . $params['var'];
650 if ( !isset( $params['value'] ) ) {
651 $params['value'] = $this->getVar( $params['var'] );
653 if ( !isset( $params['attribs'] ) ) {
654 $params['attribs'] = array();
656 if( isset( $params['rawtext'] ) ) {
657 $labelText = $params['rawtext'];
659 $labelText = $this->parse( wfMsg( $params['label'] ) );
662 "<div class=\"config-input-check\">\n" .
665 $params['controlName'],
667 $params['attribs'] +
array(
668 'id' => $params['controlName'],
669 'class' => 'config-input-text',
670 'tabindex' => $this->nextTabIndex(),
679 * Get a set of labelled radio buttons
681 * @param $params Array
683 * var: The variable to be configured (required)
684 * label: The message name for the label (required)
685 * itemLabelPrefix: The message name prefix for the item labels (required)
686 * values: List of allowed values (required)
687 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
688 * commonAttribs Attribute array applied to all items
689 * controlName: The name for the input element (optional)
690 * value: The current value of the variable (optional)
692 function getRadioSet( $params ) {
693 if ( !isset( $params['controlName'] ) ) {
694 $params['controlName'] = 'config_' . $params['var'];
696 if ( !isset( $params['value'] ) ) {
697 $params['value'] = $this->getVar( $params['var'] );
699 if ( !isset( $params['label'] ) ) {
702 $label = $this->parse( wfMsgNoTrans( $params['label'] ) );
704 $s = "<label class=\"config-label\">\n" .
707 "<ul class=\"config-settings-block\">\n";
708 foreach ( $params['values'] as $value ) {
709 $itemAttribs = array();
710 if ( isset( $params['commonAttribs'] ) ) {
711 $itemAttribs = $params['commonAttribs'];
713 if ( isset( $params['itemAttribs'][$value] ) ) {
714 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
716 $checked = $value == $params['value'];
717 $id = $params['controlName'] . '_' . $value;
718 $itemAttribs['id'] = $id;
719 $itemAttribs['tabindex'] = $this->nextTabIndex();
722 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
724 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
725 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
734 * Output an error or warning box using a Status object
736 function showStatusBox( $status ) {
737 if( !$status->isGood() ) {
738 $text = $status->getWikiText();
739 if( $status->isOk() ) {
740 $box = $this->getWarningBox( $text );
742 $box = $this->getErrorBox( $text );
744 $this->output
->addHTML( $box );
748 function showStatusMessage( $status ) {
749 $text = $status->getWikiText();
750 $this->output
->addWikiText(
751 "<div class=\"config-message\">\n" .
758 * Convenience function to set variables based on form data.
759 * Assumes that variables containing "password" in the name are (potentially
762 * @param $varNames Array
763 * @param $prefix String: the prefix added to variables to obtain form names
765 function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
766 $newValues = array();
767 foreach ( $varNames as $name ) {
768 $value = trim( $this->request
->getVal( $prefix . $name ) );
769 $newValues[$name] = $value;
770 if ( $value === null ) {
772 $this->setVar( $name, false );
774 if ( stripos( $name, 'password' ) !== false ) {
775 $this->setPassword( $name, $value );
777 $this->setVar( $name, $value );
785 * Get the starting tags of a fieldset
787 * @param $legend String: message name
789 function getFieldsetStart( $legend ) {
790 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
794 * Get the end tag of a fieldset
796 function getFieldsetEnd() {
797 return "</fieldset>\n";
801 * Helper for Installer::docLink()
803 function getDocUrl( $page ) {
804 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
805 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
806 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
812 abstract class WebInstallerPage
{
813 function __construct( $parent ) {
814 $this->parent
= $parent;
817 function addHTML( $html ) {
818 $this->parent
->output
->addHTML( $html );
821 function startForm() {
823 "<div class=\"config-section\">\n" .
828 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
834 function endForm( $continue = 'continue' ) {
835 $this->parent
->output
->outputWarnings();
836 $s = "<div class=\"config-submit\">\n";
837 $id = $this->getId();
838 if ( $id === false ) {
839 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
842 // Fake submit button for enter keypress
843 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
844 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
847 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
849 'name' => 'submit-back',
850 'tabindex' => $this->parent
->nextTabIndex()
854 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
856 'name' => "submit-$continue",
857 'tabindex' => $this->parent
->nextTabIndex(),
860 $s .= "</div></form></div>\n";
861 $this->addHTML( $s );
865 return str_replace( 'WebInstaller_', '', get_class( $this ) );
869 return array_search( $this->getName(), $this->parent
->pageSequence
);
872 abstract function execute();
874 function getVar( $var ) {
875 return $this->parent
->getVar( $var );
878 function setVar( $name, $value ) {
879 $this->parent
->setVar( $name, $value );
883 class WebInstaller_Language
extends WebInstallerPage
{
886 $r = $this->parent
->request
;
887 $userLang = $r->getVal( 'UserLang' );
888 $contLang = $r->getVal( 'ContLang' );
890 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
892 $lifetime = 1440; // PHP default
895 if ( $r->wasPosted() ) {
897 if ( $this->parent
->getSession( 'test' ) === null ) {
898 $requestTime = $r->getVal( 'LanguageRequestTime' );
899 if ( !$requestTime ) {
900 // The most likely explanation is that the user was knocked back
901 // from another page on POST due to session expiry
902 $msg = 'config-session-expired';
903 } elseif ( time() - $requestTime > $lifetime ) {
904 $msg = 'config-session-expired';
906 $msg = 'config-no-session';
908 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
910 $languages = Language
::getLanguageNames();
911 if ( isset( $languages[$userLang] ) ) {
912 $this->setVar( '_UserLang', $userLang );
914 if ( isset( $languages[$contLang] ) ) {
915 $this->setVar( 'wgLanguageCode', $contLang );
916 if ( $this->getVar( '_AdminName' ) === null ) {
917 // Load localised sysop username in *content* language
918 $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) );
923 } elseif ( $this->parent
->showSessionWarning
) {
924 # The user was knocked back from another page to the start
925 # This probably indicates a session expiry
926 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
929 $this->parent
->setSession( 'test', true );
931 if ( !isset( $languages[$userLang] ) ) {
932 $userLang = $this->getVar( '_UserLang', 'en' );
934 if ( !isset( $languages[$contLang] ) ) {
935 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
939 Xml
::hidden( 'LanguageRequestTime', time() ) .
940 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
941 $this->parent
->getHelpBox( 'config-your-language-help' ) .
942 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
943 $this->parent
->getHelpBox( 'config-wiki-language-help' );
946 $this->addHTML( $s );
951 * Get a <select> for selecting languages
953 function getLanguageSelector( $name, $label, $selectedCode ) {
954 global $wgDummyLanguageCodes;
955 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
957 $languages = Language
::getLanguageNames();
959 $dummies = array_flip( $wgDummyLanguageCodes );
960 foreach ( $languages as $code => $lang ) {
961 if ( isset( $dummies[$code] ) ) continue;
962 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
964 $s .= "\n</select>\n";
965 return $this->parent
->label( $label, $name, $s );
969 class WebInstaller_Welcome
extends WebInstallerPage
{
971 if ( $this->parent
->request
->wasPosted() ) {
972 if ( $this->getVar( '_Environment' ) ) {
976 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
977 $status = $this->parent
->doEnvironmentChecks();
979 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
986 class WebInstaller_DBConnect
extends WebInstallerPage
{
988 $r = $this->parent
->request
;
989 if ( $r->wasPosted() ) {
990 $status = $this->submit();
991 if ( $status->isGood() ) {
992 $this->setVar( '_UpgradeDone', false );
995 $this->parent
->showStatusBox( $status );
1002 $types = "<ul class=\"config-settings-block\">\n";
1004 $defaultType = $this->getVar( 'wgDBtype' );
1005 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
1006 $installer = $this->parent
->getDBInstaller( $type );
1010 $installer->getReadableName(),
1014 $type == $defaultType,
1015 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1020 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1021 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1022 $installer->getConnectForm() .
1025 $types .= "</ul><br clear=\"left\"/>\n";
1028 $this->parent
->label( 'config-db-type', false, $types ) .
1036 $r = $this->parent
->request
;
1037 $type = $r->getVal( 'DBType' );
1038 $this->setVar( 'wgDBtype', $type );
1039 $installer = $this->parent
->getDBInstaller( $type );
1040 if ( !$installer ) {
1041 return Status
::newFatal( 'config-invalid-db-type' );
1043 return $installer->submitConnectForm();
1047 class WebInstaller_Upgrade
extends WebInstallerPage
{
1048 function execute() {
1049 if ( $this->getVar( '_UpgradeDone' ) ) {
1050 if ( $this->parent
->request
->wasPosted() ) {
1051 // Done message acknowledged
1054 // Back button click
1055 // Show the done message again
1056 // Make them click back again if they want to do the upgrade again
1057 $this->showDoneMessage();
1062 // wgDBtype is generally valid here because otherwise the previous page
1063 // (connect) wouldn't have declared its happiness
1064 $type = $this->getVar( 'wgDBtype' );
1065 $installer = $this->parent
->getDBInstaller( $type );
1067 if ( !$installer->needsUpgrade() ) {
1071 if ( $this->parent
->request
->wasPosted() ) {
1073 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1074 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1075 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1077 $this->parent
->output
->flush();
1078 $result = $installer->doUpgrade();
1079 $this->addHTML( '</textarea>
1080 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1081 $this->parent
->output
->flush();
1083 $this->setVar( '_UpgradeDone', true );
1084 $this->showDoneMessage();
1090 $this->addHTML( $this->parent
->getInfoBox(
1091 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1095 function showDoneMessage() {
1098 $this->parent
->getInfoBox(
1099 wfMsgNoTrans( 'config-upgrade-done',
1100 $GLOBALS['wgServer'] .
1101 $this->getVar( 'wgScriptPath' ) . '/index' .
1102 $this->getVar( 'wgScriptExtension' )
1106 $this->endForm( 'regenerate' );
1110 class WebInstaller_DBSettings
extends WebInstallerPage
{
1111 function execute() {
1112 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1114 $r = $this->parent
->request
;
1115 if ( $r->wasPosted() ) {
1116 $status = $installer->submitSettingsForm();
1117 if ( $status === false ) {
1119 } elseif ( $status->isGood() ) {
1122 $this->parent
->showStatusBox( $status );
1126 $form = $installer->getSettingsForm();
1127 if ( $form === false ) {
1132 $this->addHTML( $form );
1138 class WebInstaller_Name
extends WebInstallerPage
{
1139 function execute() {
1140 $r = $this->parent
->request
;
1141 if ( $r->wasPosted() ) {
1142 if ( $this->submit() ) {
1149 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1150 $this->setVar( 'wgSitename', '' );
1153 // Set wgMetaNamespace to something valid before we show the form.
1154 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1155 $metaNS = $this->getVar( 'wgMetaNamespace' );
1156 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1159 $this->parent
->getTextBox( array(
1160 'var' => 'wgSitename',
1161 'label' => 'config-site-name',
1163 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1164 $this->parent
->getRadioSet( array(
1165 'var' => '_NamespaceType',
1166 'label' => 'config-project-namespace',
1167 'itemLabelPrefix' => 'config-ns-',
1168 'values' => array( 'site-name', 'generic', 'other' ),
1169 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1171 $this->parent
->getTextBox( array(
1172 'var' => 'wgMetaNamespace',
1174 'attribs' => array( 'disabled' => '' ),
1176 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1177 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1178 $this->parent
->getTextBox( array(
1179 'var' => '_AdminName',
1180 'label' => 'config-admin-name'
1182 $this->parent
->getPasswordBox( array(
1183 'var' => '_AdminPassword',
1184 'label' => 'config-admin-password',
1186 $this->parent
->getPasswordBox( array(
1187 'var' => '_AdminPassword2',
1188 'label' => 'config-admin-password-confirm'
1190 $this->parent
->getHelpBox( 'config-admin-help' ) .
1191 $this->parent
->getTextBox( array(
1192 'var' => '_AdminEmail',
1193 'label' => 'config-admin-email'
1195 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1196 $this->parent
->getCheckBox( array(
1197 'var' => '_Subscribe',
1198 'label' => 'config-subscribe'
1200 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1201 $this->parent
->getFieldsetEnd() .
1202 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1203 $this->parent
->getRadioSet( array(
1204 'var' => '_SkipOptional',
1205 'itemLabelPrefix' => 'config-optional-',
1206 'values' => array( 'continue', 'skip' )
1210 // Restore the default value
1211 $this->setVar( 'wgMetaNamespace', $metaNS );
1219 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1220 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1221 '_Subscribe', '_SkipOptional' ) );
1223 // Validate site name
1224 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1225 $this->parent
->showError( 'config-site-name-blank' );
1230 $nsType = $this->getVar( '_NamespaceType' );
1231 if ( $nsType == 'site-name' ) {
1232 $name = $this->getVar( 'wgSitename' );
1233 // Sanitize for namespace
1234 // This algorithm should match the JS one in WebInstallerOutput.php
1235 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1236 $name = str_replace( '&', '&', $name );
1237 $name = preg_replace( '/__+/', '_', $name );
1238 $name = ucfirst( trim( $name, '_' ) );
1239 } elseif ( $nsType == 'generic' ) {
1240 $name = wfMsg( 'config-ns-generic' );
1242 $name = $this->getVar( 'wgMetaNamespace' );
1245 // Validate namespace
1246 if ( strpos( $name, ':' ) !== false ) {
1249 // Title-style validation
1250 $title = Title
::newFromText( $name );
1252 $good = $nsType == 'site-name' ?
true : false;
1254 $name = $title->getDBkey();
1259 $this->parent
->showError( 'config-ns-invalid', $name );
1262 $this->setVar( 'wgMetaNamespace', $name );
1264 // Validate username for creation
1265 $name = $this->getVar( '_AdminName' );
1266 if ( strval( $name ) === '' ) {
1267 $this->parent
->showError( 'config-admin-name-blank' );
1271 $cname = User
::getCanonicalName( $name, 'creatable' );
1272 if ( $cname === false ) {
1273 $this->parent
->showError( 'config-admin-name-invalid', $name );
1276 $this->setVar( '_AdminName', $cname );
1280 // Validate password
1282 $pwd = $this->getVar( '_AdminPassword' );
1283 $user = User
::newFromName( $cname );
1284 $valid = $user->getPasswordValidity( $pwd );
1285 if ( strval( $pwd ) === '' ) {
1286 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1287 # This message is more specific and helpful.
1288 $msg = 'config-admin-password-blank';
1289 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1290 $msg = 'config-admin-password-mismatch';
1291 } elseif ( $valid !== true ) {
1292 # As of writing this will only catch the username being e.g. 'FOO' and
1293 # the password 'foo'
1296 if ( $msg !== false ) {
1297 $this->parent
->showError( $msg );
1298 $this->setVar( '_AdminPassword', '' );
1299 $this->setVar( '_AdminPassword2', '' );
1306 class WebInstaller_Options
extends WebInstallerPage
{
1307 function execute() {
1308 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1311 if ( $this->parent
->request
->wasPosted() ) {
1312 if ( $this->submit() ) {
1320 $this->parent
->getRadioSet( array(
1321 'var' => '_RightsProfile',
1322 'label' => 'config-profile',
1323 'itemLabelPrefix' => 'config-profile-',
1324 'values' => array_keys( $this->parent
->rightsProfiles
),
1326 $this->parent
->getHelpBox( 'config-profile-help' ) .
1329 $this->parent
->getRadioSet( array(
1330 'var' => '_LicenseCode',
1331 'label' => 'config-license',
1332 'itemLabelPrefix' => 'config-license-',
1333 'values' => array_keys( $this->parent
->licenses
),
1334 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1336 $this->getCCChooser() .
1337 $this->parent
->getHelpBox( 'config-license-help' ) .
1340 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1341 $this->parent
->getCheckBox( array(
1342 'var' => 'wgEnableEmail',
1343 'label' => 'config-enable-email',
1344 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1346 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1347 "<div id=\"emailwrapper\">" .
1348 $this->parent
->getTextBox( array(
1349 'var' => 'wgPasswordSender',
1350 'label' => 'config-email-sender'
1352 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1353 $this->parent
->getCheckBox( array(
1354 'var' => 'wgEnableUserEmail',
1355 'label' => 'config-email-user',
1357 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1358 $this->parent
->getCheckBox( array(
1359 'var' => 'wgEnotifUserTalk',
1360 'label' => 'config-email-usertalk',
1362 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1363 $this->parent
->getCheckBox( array(
1364 'var' => 'wgEnotifWatchlist',
1365 'label' => 'config-email-watchlist',
1367 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1368 $this->parent
->getCheckBox( array(
1369 'var' => 'wgEmailAuthentication',
1370 'label' => 'config-email-auth',
1372 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1374 $this->parent
->getFieldsetEnd()
1377 $extensions = $this->parent
->findExtensions();
1379 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1380 foreach( $extensions as $ext ) {
1381 $extHtml .= $this->parent
->getCheckBox( array(
1382 'var' => "ext-$ext",
1386 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1387 $this->parent
->getFieldsetEnd();
1388 $this->addHTML( $extHtml );
1393 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1394 $this->parent
->getCheckBox( array(
1395 'var' => 'wgEnableUploads',
1396 'label' => 'config-upload-enable',
1397 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1399 $this->parent
->getHelpBox( 'config-upload-help' ) .
1400 '<div id="uploadwrapper" style="display: none;">' .
1401 $this->parent
->getTextBox( array(
1402 'var' => 'wgDeletedDirectory',
1403 'label' => 'config-upload-deleted',
1405 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1407 $this->parent
->getTextBox( array(
1409 'label' => 'config-logo'
1411 $this->parent
->getHelpBox( 'config-logo-help' ) .
1412 $this->parent
->getFieldsetEnd()
1415 $caches = array( 'none' );
1416 if( count( $this->getVar( '_Caches' ) ) ) {
1417 $caches[] = 'accel';
1418 $selected = 'accel';
1420 $caches[] = 'memcached';
1424 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1425 # Object cache settings
1426 $this->parent
->getRadioSet( array(
1427 'var' => 'wgMainCacheType',
1428 'label' => 'config-cache-options',
1429 'itemLabelPrefix' => 'config-cache-',
1430 'values' => $caches,
1431 'value' => $selected,
1433 $this->parent
->getHelpBox( 'config-cache-help' ) .
1434 '<div id="config-memcachewrapper">' .
1435 $this->parent
->getTextBox( array(
1436 'var' => '_MemCachedServers',
1437 'label' => 'config-memcached-servers',
1439 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
1440 $this->parent
->getFieldsetEnd()
1445 function getCCPartnerUrl() {
1447 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1448 'page' => 'Options',
1449 'SubmitCC' => 'indeed',
1450 'config__LicenseCode' => 'cc',
1451 'config_wgRightsUrl' => '[license_url]',
1452 'config_wgRightsText' => '[license_name]',
1453 'config_wgRightsIcon' => '[license_button]',
1455 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1456 '/skins/common/config-cc.css';
1457 $iframeUrl = 'http://creativecommons.org/license/?' .
1458 wfArrayToCGI( array(
1459 'partner' => 'MediaWiki',
1460 'exit_url' => $exitUrl,
1461 'lang' => $this->getVar( '_UserLang' ),
1462 'stylesheet' => $styleUrl,
1467 function getCCChooser() {
1468 $iframeAttribs = array(
1469 'class' => 'config-cc-iframe',
1470 'name' => 'config-cc-iframe',
1471 'id' => 'config-cc-iframe',
1476 if ( $this->getVar( '_CCDone' ) ) {
1477 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1479 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1483 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1484 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1488 function getCCDoneBox() {
1489 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1490 // If you change this height, also change it in config.css
1491 $expandJs = str_replace( '$1', '54em', $js );
1492 $reduceJs = str_replace( '$1', '70px', $js );
1495 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1497 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1499 "<p style=\"text-align: center\">" .
1502 'href' => $this->getCCPartnerUrl(),
1503 'onclick' => $expandJs,
1505 wfMsg( 'config-cc-again' )
1508 "<script type=\"text/javascript\">\n" .
1509 # Reduce the wrapper div height
1510 htmlspecialchars( $reduceJs ) .
1516 function submitCC() {
1517 $newValues = $this->parent
->setVarsFromRequest(
1518 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1519 if ( count( $newValues ) != 3 ) {
1520 $this->parent
->showError( 'config-cc-error' );
1523 $this->setVar( '_CCDone', true );
1524 $this->addHTML( $this->getCCDoneBox() );
1528 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1529 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1530 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1531 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers' ) );
1533 if ( !in_array( $this->getVar( '_RightsProfile' ),
1534 array_keys( $this->parent
->rightsProfiles
) ) )
1536 reset( $this->parent
->rightsProfiles
);
1537 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1540 $code = $this->getVar( '_LicenseCode' );
1541 if ( $code == 'cc-choose' ) {
1542 if ( !$this->getVar( '_CCDone' ) ) {
1543 $this->parent
->showError( 'config-cc-not-chosen' );
1546 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1547 $entry = $this->parent
->licenses
[$code];
1548 if ( isset( $entry['text'] ) ) {
1549 $this->setVar( 'wgRightsText', $entry['text'] );
1551 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1553 $this->setVar( 'wgRightsUrl', $entry['url'] );
1554 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1556 $this->setVar( 'wgRightsText', '' );
1557 $this->setVar( 'wgRightsUrl', '' );
1558 $this->setVar( 'wgRightsIcon', '' );
1561 $exts = $this->parent
->getVar( '_Extensions' );
1562 foreach( $exts as $key => $ext ) {
1563 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1564 unset( $exts[$key] );
1567 $this->parent
->setVar( '_Extensions', $exts );
1572 class WebInstaller_Install
extends WebInstallerPage
{
1574 function execute() {
1575 if( $this->parent
->request
->wasPosted() ) {
1579 $this->addHTML("<ul>");
1580 $this->parent
->performInstallation(
1581 array( $this, 'startStage'),
1582 array( $this, 'endStage' )
1584 $this->addHTML("</ul>");
1590 public function startStage( $step ) {
1591 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
1594 public function endStage( $step, $status ) {
1595 $success = $status->isGood();
1596 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1597 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1599 $this->parent
->showStatusBox( $status );
1600 $html = "<span class=\"error\">$html</span>";
1602 $this->addHTML( $html . "</li>\n" );
1606 class WebInstaller_Complete
extends WebInstallerPage
{
1607 public function execute() {
1610 $msg = file_exists( "$IP/LocalSettings.php" ) ?
'config-install-done-moved' : 'config-install-done';
1612 $this->parent
->getInfoBox(
1614 $GLOBALS['wgServer'] .
1615 $this->getVar( 'wgScriptPath' ) . '/index' .
1616 $this->getVar( 'wgScriptExtension' )
1620 $this->endForm( false );
1624 class WebInstaller_Restart
extends WebInstallerPage
{
1625 function execute() {
1626 $r = $this->parent
->request
;
1627 if ( $r->wasPosted() ) {
1628 $really = $r->getVal( 'submit-restart' );
1630 $this->parent
->session
= array();
1631 $this->parent
->happyPages
= array();
1632 $this->parent
->settings
= array();
1638 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1639 $this->addHTML( $s );
1640 $this->endForm( 'restart' );
1644 abstract class WebInstaller_Document
extends WebInstallerPage
{
1645 abstract function getFileName();
1647 function execute() {
1648 $text = $this->getFileContents();
1649 $this->parent
->output
->addWikiText( $text );
1651 $this->endForm( false );
1654 function getFileContents() {
1655 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1658 protected function formatTextFile( $text ) {
1659 $text = str_replace( array( '<', '{{', '[[' ),
1660 array( '<', '{{', '[[' ), $text );
1661 // replace numbering with [1], [2], etc with MW-style numbering
1662 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1663 // join word-wrapped lines into one
1666 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1667 } while ( $text != $prev );
1668 // turn (bug nnnn) into links
1669 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1670 // add links to manual to every global variable mentioned
1671 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1672 // special case for <pre> - formatted links
1675 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1676 } while ( $text != $prev );
1680 private function replaceBugLinks( $matches ) {
1681 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1682 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1685 private function replaceConfigLinks( $matches ) {
1686 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1687 $matches[1] . ' ' . $matches[1] . ']</span>';
1691 class WebInstaller_Readme
extends WebInstaller_Document
{
1692 function getFileName() { return 'README'; }
1694 function getFileContents() {
1695 return $this->formatTextFile( parent
::getFileContents() );
1699 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1700 function getFileName() { return 'RELEASE-NOTES'; }
1702 function getFileContents() {
1703 return $this->formatTextFile( parent
::getFileContents() );
1707 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1708 function getFileName() { return 'UPGRADE'; }
1710 function getFileContents() {
1711 return $this->formatTextFile( parent
::getFileContents() );
1715 class WebInstaller_Copying
extends WebInstaller_Document
{
1716 function getFileName() { return 'COPYING'; }
1718 function getFileContents() {
1719 $text = parent
::getFileContents();
1720 $text = str_replace( "\x0C", '', $text );
1721 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1722 $text = '<tt>' . nl2br( $text ) . '</tt>';
1726 private static function replaceLeadingSpaces( $matches ) {
1727 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );