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/ref.session.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()
277 $this->output
->output();
278 $this->session
['happyPages'] = $this->happyPages
;
279 $this->session
['skippedPages'] = $this->skippedPages
;
280 $this->session
['settings'] = $this->settings
;
281 return $this->session
;
285 * Get a URL for submission back to the same script
287 function getUrl( $query = array() ) {
288 $url = $this->request
->getRequestURL();
289 # Remove existing query
290 $url = preg_replace( '/\?.*$/', '', $url );
292 $url .= '?' . wfArrayToCGI( $query );
298 * Get a WebInstallerPage from the main sequence, by ID
300 function getPageById( $id ) {
301 $pageName = $this->pageSequence
[$id];
302 $pageClass = 'WebInstaller_' . $pageName;
303 return new $pageClass( $this );
307 * Get a WebInstallerPage by name
309 function getPageByName( $pageName ) {
310 $pageClass = 'WebInstaller_' . $pageName;
311 return new $pageClass( $this );
315 * Get a session variable
317 function getSession( $name, $default = null ) {
318 if ( !isset( $this->session
[$name] ) ) {
321 return $this->session
[$name];
326 * Set a session variable
328 function setSession( $name, $value ) {
329 $this->session
[$name] = $value;
333 * Get the next tabindex attribute value
335 function nextTabIndex() {
336 return $this->tabIndex++
;
340 * Initializes language-related variables
342 function setupLanguage() {
343 global $wgLang, $wgContLang, $wgLanguageCode;
344 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
345 $wgLanguageCode = $this->getAcceptLanguage();
346 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
347 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
348 $this->setVar( '_UserLang', $wgLanguageCode );
350 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
351 $wgLang = Language
::factory( $this->getVar( '_UserLang' ) );
352 $wgContLang = Language
::factory( $wgLanguageCode );
357 * Retrieves MediaWiki language from Accept-Language HTTP header
359 function getAcceptLanguage() {
360 global $wgLanguageCode;
362 $mwLanguages = Language
::getLanguageNames();
363 $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
364 foreach ( explode( ';', $langs ) as $splitted ) {
365 foreach ( explode( ',', $splitted ) as $lang ) {
366 $lang = trim( strtolower( $lang ) );
367 if ( $lang == '' ||
$lang[0] == 'q' ) {
370 if ( isset( $mwLanguages[$lang] ) ) {
373 $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang );
374 if ( $lang != '' && isset( $mwLanguages[$lang] ) ) {
379 return $wgLanguageCode;
383 * Called by execute() before page output starts, to show a page list
385 function startPageWrapper( $currentPageName ) {
386 $s = "<div class=\"config-page-wrapper\">\n" .
387 "<div class=\"config-page-list\"><ul>\n";
389 foreach ( $this->pageSequence
as $id => $pageName ) {
390 $happy = !empty( $this->happyPages
[$id] );
391 $s .= $this->getPageListItem( $pageName,
392 $happy ||
$lastHappy == $id - 1, $currentPageName );
397 $s .= "</ul><br/><ul>\n";
398 foreach ( $this->otherPages
as $pageName ) {
399 $s .= $this->getPageListItem( $pageName, true, $currentPageName );
401 $s .= "</ul></div>\n". // end list pane
402 "<div class=\"config-page\">\n" .
403 Xml
::element( 'h2', array(),
404 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
406 $this->output
->addHTMLNoFlush( $s );
410 * Get a list item for the page list
412 function getPageListItem( $pageName, $enabled, $currentPageName ) {
413 $s = "<li class=\"config-page-list-item\">";
414 $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
416 $query = array( 'page' => $pageName );
417 if ( !in_array( $pageName, $this->pageSequence
) ) {
418 if ( in_array( $currentPageName, $this->pageSequence
) ) {
419 $query['lastPage'] = $currentPageName;
421 $link = Xml
::element( 'a',
423 'href' => $this->getUrl( $query )
428 $link = htmlspecialchars( $name );
430 if ( $pageName == $currentPageName ) {
431 $s .= "<span class=\"config-page-current\">$link</span>";
436 $s .= Xml
::element( 'span',
438 'class' => 'config-page-disabled'
448 * Output some stuff after a page is finished
450 function endPageWrapper() {
451 $this->output
->addHTMLNoFlush(
453 "<br style=\"clear:both\"/>\n" .
458 * Get HTML for an error box with an icon
460 * @param $text String: wikitext, get this with wfMsgNoTrans()
462 function getErrorBox( $text ) {
463 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
467 * Get HTML for a warning box with an icon
469 * @param $text String: wikitext, get this with wfMsgNoTrans()
471 function getWarningBox( $text ) {
472 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
476 * Get HTML for an info box with an icon
478 * @param $text String: wikitext, get this with wfMsgNoTrans()
479 * @param $icon String: icon name, file in skins/common/images
480 * @param $class String: additional class name to add to the wrapper div
482 function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
484 "<div class=\"config-info $class\">\n" .
485 "<div class=\"config-info-left\">\n" .
488 'src' => '../skins/common/images/' . $icon,
489 'alt' => wfMsg( 'config-information' ),
493 "<div class=\"config-info-right\">\n" .
494 $this->parse( $text ) . "\n" .
496 "<div style=\"clear: left;\"></div>\n" .
502 * Get small text indented help for a preceding form field.
503 * Parameters like wfMsg().
505 function getHelpBox( $msg /*, ... */ ) {
506 $args = func_get_args();
507 array_shift( $args );
508 $args = array_map( 'htmlspecialchars', $args );
509 $text = wfMsgReal( $msg, $args, false, false, false );
510 $html = $this->parse( $text, true );
511 $id = $this->helpId++
;
512 $alt = wfMsg( 'help' );
515 "<div class=\"config-help-wrapper\">\n" .
516 "<div class=\"config-help-message\">\n" .
519 "<div class=\"config-show-help\">\n" .
521 wfMsgHtml( 'config-show-help' ) .
523 "<div class=\"config-hide-help\">\n" .
525 wfMsgHtml( 'config-hide-help' ) .
526 "</a></div>\n</div>\n";
532 function showHelpBox( $msg /*, ... */ ) {
533 $args = func_get_args();
534 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
535 $this->output
->addHTML( $html );
539 * Show a short informational message
540 * Output looks like a list.
542 function showMessage( $msg /*, ... */ ) {
543 $args = func_get_args();
544 array_shift( $args );
545 $html = '<div class="config-message">' .
546 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
548 $this->output
->addHTML( $html );
552 * Label a control by wrapping a config-input div around it and putting a
555 function label( $msg, $forId, $contents ) {
556 if ( strval( $msg ) == '' ) {
557 $labelText = ' ';
559 $labelText = wfMsgHtml( $msg );
561 $attributes = array( 'class' => 'config-label' );
563 $attributes['for'] = $forId;
566 "<div class=\"config-input\">\n" .
569 $labelText ) . "\n" .
575 * Get a labelled text box to configure a variable
577 * @param $params Array
579 * var: The variable to be configured (required)
580 * label: The message name for the label (required)
581 * attribs: Additional attributes for the input element (optional)
582 * controlName: The name for the input element (optional)
583 * value: The current value of the variable (optional)
585 function getTextBox( $params ) {
586 if ( !isset( $params['controlName'] ) ) {
587 $params['controlName'] = 'config_' . $params['var'];
589 if ( !isset( $params['value'] ) ) {
590 $params['value'] = $this->getVar( $params['var'] );
592 if ( !isset( $params['attribs'] ) ) {
593 $params['attribs'] = array();
598 $params['controlName'],
600 $params['controlName'],
601 30, // intended to be overridden by CSS
603 $params['attribs'] +
array(
604 'id' => $params['controlName'],
605 'class' => 'config-input-text',
606 'tabindex' => $this->nextTabIndex()
613 * Get a labelled password box to configure a variable
615 * Implements password hiding
616 * @param $params Array
618 * var: The variable to be configured (required)
619 * label: The message name for the label (required)
620 * attribs: Additional attributes for the input element (optional)
621 * controlName: The name for the input element (optional)
622 * value: The current value of the variable (optional)
624 function getPasswordBox( $params ) {
625 if ( !isset( $params['value'] ) ) {
626 $params['value'] = $this->getVar( $params['var'] );
628 if ( !isset( $params['attribs'] ) ) {
629 $params['attribs'] = array();
631 $params['value'] = $this->getFakePassword( $params['value'] );
632 $params['attribs']['type'] = 'password';
633 return $this->getTextBox( $params );
637 * Get a labelled checkbox to configure a boolean variable
639 * @param $params Array
641 * var: The variable to be configured (required)
642 * label: The message name for the label (required)
643 * attribs: Additional attributes for the input element (optional)
644 * controlName: The name for the input element (optional)
645 * value: The current value of the variable (optional)
647 function getCheckBox( $params ) {
648 if ( !isset( $params['controlName'] ) ) {
649 $params['controlName'] = 'config_' . $params['var'];
651 if ( !isset( $params['value'] ) ) {
652 $params['value'] = $this->getVar( $params['var'] );
654 if ( !isset( $params['attribs'] ) ) {
655 $params['attribs'] = array();
657 if( isset( $params['rawtext'] ) ) {
658 $labelText = $params['rawtext'];
660 $labelText = $this->parse( wfMsg( $params['label'] ) );
663 "<div class=\"config-input-check\">\n" .
666 $params['controlName'],
668 $params['attribs'] +
array(
669 'id' => $params['controlName'],
670 'class' => 'config-input-text',
671 'tabindex' => $this->nextTabIndex(),
680 * Get a set of labelled radio buttons
682 * @param $params Array
684 * var: The variable to be configured (required)
685 * label: The message name for the label (required)
686 * itemLabelPrefix: The message name prefix for the item labels (required)
687 * values: List of allowed values (required)
688 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
689 * commonAttribs Attribute array applied to all items
690 * controlName: The name for the input element (optional)
691 * value: The current value of the variable (optional)
693 function getRadioSet( $params ) {
694 if ( !isset( $params['controlName'] ) ) {
695 $params['controlName'] = 'config_' . $params['var'];
697 if ( !isset( $params['value'] ) ) {
698 $params['value'] = $this->getVar( $params['var'] );
700 if ( !isset( $params['label'] ) ) {
703 $label = $this->parse( wfMsgNoTrans( $params['label'] ) );
705 $s = "<label class=\"config-label\">\n" .
708 "<ul class=\"config-settings-block\">\n";
709 foreach ( $params['values'] as $value ) {
710 $itemAttribs = array();
711 if ( isset( $params['commonAttribs'] ) ) {
712 $itemAttribs = $params['commonAttribs'];
714 if ( isset( $params['itemAttribs'][$value] ) ) {
715 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
717 $checked = $value == $params['value'];
718 $id = $params['controlName'] . '_' . $value;
719 $itemAttribs['id'] = $id;
720 $itemAttribs['tabindex'] = $this->nextTabIndex();
723 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
725 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
726 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
735 * Output an error box using a Status object
737 function showStatusErrorBox( $status ) {
738 $text = $status->getWikiText();
739 $this->output
->addHTML( $this->getErrorBox( $text ) );
742 function showStatusError( $status ) {
743 $text = $status->getWikiText();
744 $this->output
->addWikiText(
745 "<div class=\"config-message\">\n" .
752 * Convenience function to set variables based on form data.
753 * Assumes that variables containing "password" in the name are (potentially
756 * @param $varNames Array
757 * @param $prefix String: the prefix added to variables to obtain form names
759 function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
760 $newValues = array();
761 foreach ( $varNames as $name ) {
762 $value = trim( $this->request
->getVal( $prefix . $name ) );
763 $newValues[$name] = $value;
764 if ( $value === null ) {
766 $this->setVar( $name, false );
768 if ( stripos( $name, 'password' ) !== false ) {
769 $this->setPassword( $name, $value );
771 $this->setVar( $name, $value );
779 * Get the starting tags of a fieldset
781 * @param $legend String: message name
783 function getFieldsetStart( $legend ) {
784 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
788 * Get the end tag of a fieldset
790 function getFieldsetEnd() {
791 return "</fieldset>\n";
795 * Helper for Installer::docLink()
797 function getDocUrl( $page ) {
798 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
799 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
800 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
806 class WebInstallerPage
{
807 function __construct( $parent ) {
808 $this->parent
= $parent;
811 function addHTML( $html ) {
812 $this->parent
->output
->addHTML( $html );
815 function startForm() {
817 "<div class=\"config-section\">\n" .
822 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
828 function endForm( $continue = 'continue' ) {
829 $this->parent
->output
->outputWarnings();
830 $s = "<div class=\"config-submit\">\n";
831 $id = $this->getId();
832 if ( $id === false ) {
833 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
836 // Fake submit button for enter keypress
837 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
838 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
841 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
843 'name' => 'submit-back',
844 'tabindex' => $this->parent
->nextTabIndex()
848 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
850 'name' => "submit-$continue",
851 'tabindex' => $this->parent
->nextTabIndex(),
854 $s .= "</div></form></div>\n";
855 $this->addHTML( $s );
859 return str_replace( 'WebInstaller_', '', get_class( $this ) );
863 return array_search( $this->getName(), $this->parent
->pageSequence
);
867 if ( $this->parent
->request
->wasPosted() ) {
871 $this->addHTML( 'Mockup' );
876 function getVar( $var ) {
877 return $this->parent
->getVar( $var );
880 function setVar( $name, $value ) {
881 $this->parent
->setVar( $name, $value );
885 class WebInstaller_Language
extends WebInstallerPage
{
888 $r = $this->parent
->request
;
889 $userLang = $r->getVal( 'UserLang' );
890 $contLang = $r->getVal( 'ContLang' );
892 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
894 $lifetime = 1440; // PHP default
897 if ( $r->wasPosted() ) {
899 if ( $this->parent
->getSession( 'test' ) === null ) {
900 $requestTime = $r->getVal( 'LanguageRequestTime' );
901 if ( !$requestTime ) {
902 // The most likely explanation is that the user was knocked back
903 // from another page on POST due to session expiry
904 $msg = 'config-session-expired';
905 } elseif ( time() - $requestTime > $lifetime ) {
906 $msg = 'config-session-expired';
908 $msg = 'config-no-session';
910 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
912 $languages = Language
::getLanguageNames();
913 if ( isset( $languages[$userLang] ) ) {
914 $this->setVar( '_UserLang', $userLang );
916 if ( isset( $languages[$contLang] ) ) {
917 $this->setVar( 'wgLanguageCode', $contLang );
918 if ( $this->getVar( '_AdminName' ) === null ) {
919 // Load localised sysop username in *content* language
920 $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) );
925 } elseif ( $this->parent
->showSessionWarning
) {
926 # The user was knocked back from another page to the start
927 # This probably indicates a session expiry
928 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
931 $this->parent
->setSession( 'test', true );
933 if ( !isset( $languages[$userLang] ) ) {
934 $userLang = $this->getVar( '_UserLang', 'en' );
936 if ( !isset( $languages[$contLang] ) ) {
937 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
941 Xml
::hidden( 'LanguageRequestTime', time() ) .
942 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
943 $this->parent
->getHelpBox( 'config-your-language-help' ) .
944 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
945 $this->parent
->getHelpBox( 'config-wiki-language-help' );
948 $this->addHTML( $s );
953 * Get a <select> for selecting languages
955 function getLanguageSelector( $name, $label, $selectedCode ) {
956 global $wgDummyLanguageCodes;
957 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
959 $languages = Language
::getLanguageNames();
961 $dummies = array_flip( $wgDummyLanguageCodes );
962 foreach ( $languages as $code => $lang ) {
963 if ( isset( $dummies[$code] ) ) continue;
964 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
966 $s .= "\n</select>\n";
967 return $this->parent
->label( $label, $name, $s );
971 class WebInstaller_Welcome
extends WebInstallerPage
{
973 if ( $this->parent
->request
->wasPosted() ) {
974 if ( $this->getVar( '_Environment' ) ) {
978 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
979 $status = $this->parent
->doEnvironmentChecks();
981 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
988 class WebInstaller_DBConnect
extends WebInstallerPage
{
990 $r = $this->parent
->request
;
991 if ( $r->wasPosted() ) {
992 $status = $this->submit();
993 if ( $status->isGood() ) {
994 $this->setVar( '_UpgradeDone', false );
997 $this->parent
->showStatusErrorBox( $status );
1004 $types = "<ul class=\"config-settings-block\">\n";
1006 $defaultType = $this->getVar( 'wgDBtype' );
1007 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
1008 $installer = $this->parent
->getDBInstaller( $type );
1012 $installer->getReadableName(),
1016 $type == $defaultType,
1017 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1022 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1023 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1024 $installer->getConnectForm() .
1027 $types .= "</ul><br clear=\"left\"/>\n";
1030 $this->parent
->label( 'config-db-type', false, $types ) .
1038 $r = $this->parent
->request
;
1039 $type = $r->getVal( 'DBType' );
1040 $this->setVar( 'wgDBtype', $type );
1041 $installer = $this->parent
->getDBInstaller( $type );
1042 if ( !$installer ) {
1043 return Status
::newFatal( 'config-invalid-db-type' );
1045 return $installer->submitConnectForm();
1049 class WebInstaller_Upgrade
extends WebInstallerPage
{
1050 function execute() {
1051 if ( $this->getVar( '_UpgradeDone' ) ) {
1052 if ( $this->parent
->request
->wasPosted() ) {
1053 // Done message acknowledged
1056 // Back button click
1057 // Show the done message again
1058 // Make them click back again if they want to do the upgrade again
1059 $this->showDoneMessage();
1064 // wgDBtype is generally valid here because otherwise the previous page
1065 // (connect) wouldn't have declared its happiness
1066 $type = $this->getVar( 'wgDBtype' );
1067 $installer = $this->parent
->getDBInstaller( $type );
1069 if ( !$installer->needsUpgrade() ) {
1073 if ( $this->parent
->request
->wasPosted() ) {
1075 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1076 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1077 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1079 $this->parent
->output
->flush();
1080 $result = $installer->doUpgrade();
1081 $this->addHTML( '</textarea>
1082 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1083 $this->parent
->output
->flush();
1085 $this->setVar( '_UpgradeDone', true );
1086 $this->showDoneMessage();
1092 $this->addHTML( $this->parent
->getInfoBox(
1093 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1097 function showDoneMessage() {
1100 $this->parent
->getInfoBox(
1101 wfMsgNoTrans( 'config-upgrade-done',
1102 $GLOBALS['wgServer'] .
1103 $this->getVar( 'wgScriptPath' ) . '/index' .
1104 $this->getVar( 'wgScriptExtension' )
1108 $this->endForm( 'regenerate' );
1112 class WebInstaller_DBSettings
extends WebInstallerPage
{
1113 function execute() {
1114 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1116 $r = $this->parent
->request
;
1117 if ( $r->wasPosted() ) {
1118 $status = $installer->submitSettingsForm();
1119 if ( $status === false ) {
1121 } elseif ( $status->isGood() ) {
1124 $this->parent
->showStatusErrorBox( $status );
1128 $form = $installer->getSettingsForm();
1129 if ( $form === false ) {
1134 $this->addHTML( $form );
1140 class WebInstaller_Name
extends WebInstallerPage
{
1141 function execute() {
1142 $r = $this->parent
->request
;
1143 if ( $r->wasPosted() ) {
1144 if ( $this->submit() ) {
1151 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1152 $this->setVar( 'wgSitename', '' );
1155 // Set wgMetaNamespace to something valid before we show the form.
1156 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1157 $metaNS = $this->getVar( 'wgMetaNamespace' );
1158 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1161 $this->parent
->getTextBox( array(
1162 'var' => 'wgSitename',
1163 'label' => 'config-site-name',
1165 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1166 $this->parent
->getRadioSet( array(
1167 'var' => '_NamespaceType',
1168 'label' => 'config-project-namespace',
1169 'itemLabelPrefix' => 'config-ns-',
1170 'values' => array( 'site-name', 'generic', 'other' ),
1171 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1173 $this->parent
->getTextBox( array(
1174 'var' => 'wgMetaNamespace',
1176 'attribs' => array( 'disabled' => '' ),
1178 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1179 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1180 $this->parent
->getTextBox( array(
1181 'var' => '_AdminName',
1182 'label' => 'config-admin-name'
1184 $this->parent
->getPasswordBox( array(
1185 'var' => '_AdminPassword',
1186 'label' => 'config-admin-password',
1188 $this->parent
->getPasswordBox( array(
1189 'var' => '_AdminPassword2',
1190 'label' => 'config-admin-password-confirm'
1192 $this->parent
->getHelpBox( 'config-admin-help' ) .
1193 $this->parent
->getTextBox( array(
1194 'var' => '_AdminEmail',
1195 'label' => 'config-admin-email'
1197 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1198 $this->parent
->getCheckBox( array(
1199 'var' => '_Subscribe',
1200 'label' => 'config-subscribe'
1202 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1203 $this->parent
->getFieldsetEnd() .
1204 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1205 $this->parent
->getRadioSet( array(
1206 'var' => '_SkipOptional',
1207 'itemLabelPrefix' => 'config-optional-',
1208 'values' => array( 'continue', 'skip' )
1212 // Restore the default value
1213 $this->setVar( 'wgMetaNamespace', $metaNS );
1221 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1222 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1223 '_Subscribe', '_SkipOptional' ) );
1225 // Validate site name
1226 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1227 $this->parent
->showError( 'config-site-name-blank' );
1232 $nsType = $this->getVar( '_NamespaceType' );
1233 if ( $nsType == 'site-name' ) {
1234 $name = $this->getVar( 'wgSitename' );
1235 // Sanitize for namespace
1236 // This algorithm should match the JS one in WebInstallerOutput.php
1237 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1238 $name = str_replace( '&', '&', $name );
1239 $name = preg_replace( '/__+/', '_', $name );
1240 $name = ucfirst( trim( $name, '_' ) );
1241 } elseif ( $nsType == 'generic' ) {
1242 $name = wfMsg( 'config-ns-generic' );
1244 $name = $this->getVar( 'wgMetaNamespace' );
1247 // Validate namespace
1248 if ( strpos( $name, ':' ) !== false ) {
1251 // Title-style validation
1252 $title = Title
::newFromText( $name );
1254 $good = $nsType == 'site-name' ?
true : false;
1256 $name = $title->getDBkey();
1261 $this->parent
->showError( 'config-ns-invalid', $name );
1264 $this->setVar( 'wgMetaNamespace', $name );
1266 // Validate username for creation
1267 $name = $this->getVar( '_AdminName' );
1268 if ( strval( $name ) === '' ) {
1269 $this->parent
->showError( 'config-admin-name-blank' );
1273 $cname = User
::getCanonicalName( $name, 'creatable' );
1274 if ( $cname === false ) {
1275 $this->parent
->showError( 'config-admin-name-invalid', $name );
1278 $this->setVar( '_AdminName', $cname );
1282 // Validate password
1284 $pwd = $this->getVar( '_AdminPassword' );
1285 $user = User
::newFromName( $cname );
1286 $valid = $user->getPasswordValidity( $pwd );
1287 if ( strval( $pwd ) === '' ) {
1288 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1289 # This message is more specific and helpful.
1290 $msg = 'config-admin-password-blank';
1291 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1292 $msg = 'config-admin-password-mismatch';
1293 } elseif ( $valid !== true ) {
1294 # As of writing this will only catch the username being e.g. 'FOO' and
1295 # the password 'foo'
1298 if ( $msg !== false ) {
1299 $this->parent
->showError( $msg );
1300 $this->setVar( '_AdminPassword', '' );
1301 $this->setVar( '_AdminPassword2', '' );
1308 class WebInstaller_Options
extends WebInstallerPage
{
1309 function execute() {
1310 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1313 if ( $this->parent
->request
->wasPosted() ) {
1314 if ( $this->submit() ) {
1322 $this->parent
->getRadioSet( array(
1323 'var' => '_RightsProfile',
1324 'label' => 'config-profile',
1325 'itemLabelPrefix' => 'config-profile-',
1326 'values' => array_keys( $this->parent
->rightsProfiles
),
1328 $this->parent
->getHelpBox( 'config-profile-help' ) .
1331 $this->parent
->getRadioSet( array(
1332 'var' => '_LicenseCode',
1333 'label' => 'config-license',
1334 'itemLabelPrefix' => 'config-license-',
1335 'values' => array_keys( $this->parent
->licenses
),
1336 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1338 $this->getCCChooser() .
1339 $this->parent
->getHelpBox( 'config-license-help' ) .
1342 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1343 $this->parent
->getCheckBox( array(
1344 'var' => 'wgEnableEmail',
1345 'label' => 'config-enable-email',
1346 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1348 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1349 "<div id=\"emailwrapper\">" .
1350 $this->parent
->getTextBox( array(
1351 'var' => 'wgPasswordSender',
1352 'label' => 'config-email-sender'
1354 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1355 $this->parent
->getCheckBox( array(
1356 'var' => 'wgEnableUserEmail',
1357 'label' => 'config-email-user',
1359 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1360 $this->parent
->getCheckBox( array(
1361 'var' => 'wgEnotifUserTalk',
1362 'label' => 'config-email-usertalk',
1364 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1365 $this->parent
->getCheckBox( array(
1366 'var' => 'wgEnotifWatchlist',
1367 'label' => 'config-email-watchlist',
1369 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1370 $this->parent
->getCheckBox( array(
1371 'var' => 'wgEmailAuthentication',
1372 'label' => 'config-email-auth',
1374 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1376 $this->parent
->getFieldsetEnd()
1379 $extensions = $this->parent
->findExtensions();
1381 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1382 foreach( $extensions as $ext ) {
1383 $extHtml .= $this->parent
->getCheckBox( array(
1384 'var' => "ext-$ext",
1388 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1389 $this->parent
->getFieldsetEnd();
1390 $this->addHTML( $extHtml );
1395 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1396 $this->parent
->getCheckBox( array(
1397 'var' => 'wgEnableUploads',
1398 'label' => 'config-upload-enable',
1399 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1401 $this->parent
->getHelpBox( 'config-upload-help' ) .
1402 '<div id="uploadwrapper" style="display: none;">' .
1403 $this->parent
->getTextBox( array(
1404 'var' => 'wgDeletedDirectory',
1405 'label' => 'config-upload-deleted',
1407 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1408 $this->parent
->getTextBox( array(
1410 'label' => 'config-logo'
1412 $this->parent
->getHelpBox( 'config-logo-help' ) .
1414 $this->parent
->getFieldsetEnd()
1417 $caches = array( 'none', 'anything', 'db' );
1419 if( count( $this->getVar( '_Caches' ) ) ) {
1420 $caches[] = 'accel';
1421 $selected = 'accel';
1423 $caches[] = 'memcached';
1427 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1428 # Object cache settings
1429 $this->parent
->getRadioSet( array(
1430 'var' => 'wgMainCacheType',
1431 'label' => 'config-cache-options',
1432 'itemLabelPrefix' => 'config-cache-',
1433 'values' => $caches,
1434 'value' => $selected,
1436 $this->parent
->getHelpBox( 'config-cache-help' ) .
1437 '<div id="config-memcachewrapper">' .
1438 $this->parent
->getTextBox( array(
1439 'var' => '_MemCachedServers',
1440 'label' => 'config-memcached-servers',
1442 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
1443 $this->parent
->getFieldsetEnd()
1448 function getCCPartnerUrl() {
1450 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1451 'page' => 'Options',
1452 'SubmitCC' => 'indeed',
1453 'config__LicenseCode' => 'cc',
1454 'config_wgRightsUrl' => '[license_url]',
1455 'config_wgRightsText' => '[license_name]',
1456 'config_wgRightsIcon' => '[license_button]',
1458 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1459 '/skins/common/config-cc.css';
1460 $iframeUrl = 'http://creativecommons.org/license/?' .
1461 wfArrayToCGI( array(
1462 'partner' => 'MediaWiki',
1463 'exit_url' => $exitUrl,
1464 'lang' => $this->getVar( '_UserLang' ),
1465 'stylesheet' => $styleUrl,
1470 function getCCChooser() {
1471 $iframeAttribs = array(
1472 'class' => 'config-cc-iframe',
1473 'name' => 'config-cc-iframe',
1474 'id' => 'config-cc-iframe',
1479 if ( $this->getVar( '_CCDone' ) ) {
1480 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1482 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1486 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1487 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1491 function getCCDoneBox() {
1492 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1493 // If you change this height, also change it in config.css
1494 $expandJs = str_replace( '$1', '54em', $js );
1495 $reduceJs = str_replace( '$1', '70px', $js );
1498 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1500 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1502 "<p style=\"text-align: center\">" .
1505 'href' => $this->getCCPartnerUrl(),
1506 'onclick' => $expandJs,
1508 wfMsg( 'config-cc-again' )
1511 "<script type=\"text/javascript\">\n" .
1512 # Reduce the wrapper div height
1513 htmlspecialchars( $reduceJs ) .
1519 function submitCC() {
1520 $newValues = $this->parent
->setVarsFromRequest(
1521 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1522 if ( count( $newValues ) != 3 ) {
1523 $this->parent
->showError( 'config-cc-error' );
1526 $this->setVar( '_CCDone', true );
1527 $this->addHTML( $this->getCCDoneBox() );
1531 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1532 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1533 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1534 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers' ) );
1536 if ( !in_array( $this->getVar( '_RightsProfile' ),
1537 array_keys( $this->parent
->rightsProfiles
) ) )
1539 reset( $this->parent
->rightsProfiles
);
1540 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1543 $code = $this->getVar( '_LicenseCode' );
1544 if ( $code == 'cc-choose' ) {
1545 if ( !$this->getVar( '_CCDone' ) ) {
1546 $this->parent
->showError( 'config-cc-not-chosen' );
1549 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1550 $entry = $this->parent
->licenses
[$code];
1551 if ( isset( $entry['text'] ) ) {
1552 $this->setVar( 'wgRightsText', $entry['text'] );
1554 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1556 $this->setVar( 'wgRightsUrl', $entry['url'] );
1557 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1559 $this->setVar( 'wgRightsText', '' );
1560 $this->setVar( 'wgRightsUrl', '' );
1561 $this->setVar( 'wgRightsIcon', '' );
1564 $exts = $this->parent
->getVar( '_Extensions' );
1565 foreach( $exts as $key => $ext ) {
1566 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1567 unset( $exts[$key] );
1570 $this->parent
->setVar( '_Extensions', $exts );
1575 class WebInstaller_Install
extends WebInstallerPage
{
1577 function execute() {
1578 if( $this->parent
->request
->wasPosted() ) {
1582 $this->addHTML("<ul>");
1583 foreach( $this->parent
->getInstallSteps() as $step ) {
1584 $this->startStage( "config-install-$step" );
1585 $func = 'install' . ucfirst( $step );
1586 $status = $this->parent
->{$func}();
1587 $ok = $status->isGood();
1589 $this->parent
->showStatusErrorBox( $status );
1591 $this->endStage( $ok );
1593 $this->addHTML("</ul>");
1599 private function startStage( $msg ) {
1600 $this->addHTML( "<li>" . wfMsgHtml( $msg ) . wfMsg( 'ellipsis') );
1603 private function endStage( $success = true ) {
1604 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1605 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1607 $html = "<span class=\"error\">$html</span>";
1609 $this->addHTML( $html . "</li>\n" );
1613 class WebInstaller_Complete
extends WebInstallerPage
{
1614 public function execute() {
1617 $msg = file_exists( "$IP/LocalSettings.php" ) ?
'config-install-done-moved' : 'config-install-done';
1619 $this->parent
->getInfoBox(
1621 $GLOBALS['wgServer'] .
1622 $this->getVar( 'wgScriptPath' ) . '/index' .
1623 $this->getVar( 'wgScriptExtension' )
1627 $this->endForm( false );
1631 class WebInstaller_Restart
extends WebInstallerPage
{
1632 function execute() {
1633 $r = $this->parent
->request
;
1634 if ( $r->wasPosted() ) {
1635 $really = $r->getVal( 'submit-restart' );
1637 $this->parent
->session
= array();
1638 $this->parent
->happyPages
= array();
1639 $this->parent
->settings
= array();
1645 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1646 $this->addHTML( $s );
1647 $this->endForm( 'restart' );
1651 abstract class WebInstaller_Document
extends WebInstallerPage
{
1652 abstract function getFileName();
1654 function execute() {
1655 $text = $this->getFileContents();
1656 $this->parent
->output
->addWikiText( $text );
1658 $this->endForm( false );
1661 function getFileContents() {
1662 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1665 protected function formatTextFile( $text ) {
1666 $text = str_replace( array( '<', '{{', '[[' ),
1667 array( '<', '{{', '[[' ), $text );
1668 // replace numbering with [1], [2], etc with MW-style numbering
1669 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1670 // join word-wrapped lines into one
1673 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1674 } while ( $text != $prev );
1675 // turn (bug nnnn) into links
1676 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1677 // add links to manual to every global variable mentioned
1678 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1679 // special case for <pre> - formatted links
1682 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1683 } while ( $text != $prev );
1687 private function replaceBugLinks( $matches ) {
1688 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1689 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1692 private function replaceConfigLinks( $matches ) {
1693 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1694 $matches[1] . ' ' . $matches[1] . ']</span>';
1698 class WebInstaller_Readme
extends WebInstaller_Document
{
1699 function getFileName() { return 'README'; }
1701 function getFileContents() {
1702 return $this->formatTextFile( parent
::getFileContents() );
1706 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1707 function getFileName() { return 'RELEASE-NOTES'; }
1709 function getFileContents() {
1710 return $this->formatTextFile( parent
::getFileContents() );
1714 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1715 function getFileName() { return 'UPGRADE'; }
1717 function getFileContents() {
1718 return $this->formatTextFile( parent
::getFileContents() );
1722 class WebInstaller_Copying
extends WebInstaller_Document
{
1723 function getFileName() { return 'COPYING'; }
1725 function getFileContents() {
1726 $text = parent
::getFileContents();
1727 $text = str_replace( "\x0C", '', $text );
1728 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1729 $text = '<tt>' . nl2br( $text ) . '</tt>';
1733 private static function replaceLeadingSpaces( $matches ) {
1734 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );