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()
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 showStatusMessage( $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 abstract 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
);
866 abstract function execute();
868 function getVar( $var ) {
869 return $this->parent
->getVar( $var );
872 function setVar( $name, $value ) {
873 $this->parent
->setVar( $name, $value );
877 class WebInstaller_Language
extends WebInstallerPage
{
880 $r = $this->parent
->request
;
881 $userLang = $r->getVal( 'UserLang' );
882 $contLang = $r->getVal( 'ContLang' );
884 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
886 $lifetime = 1440; // PHP default
889 if ( $r->wasPosted() ) {
891 if ( $this->parent
->getSession( 'test' ) === null ) {
892 $requestTime = $r->getVal( 'LanguageRequestTime' );
893 if ( !$requestTime ) {
894 // The most likely explanation is that the user was knocked back
895 // from another page on POST due to session expiry
896 $msg = 'config-session-expired';
897 } elseif ( time() - $requestTime > $lifetime ) {
898 $msg = 'config-session-expired';
900 $msg = 'config-no-session';
902 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
904 $languages = Language
::getLanguageNames();
905 if ( isset( $languages[$userLang] ) ) {
906 $this->setVar( '_UserLang', $userLang );
908 if ( isset( $languages[$contLang] ) ) {
909 $this->setVar( 'wgLanguageCode', $contLang );
910 if ( $this->getVar( '_AdminName' ) === null ) {
911 // Load localised sysop username in *content* language
912 $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) );
917 } elseif ( $this->parent
->showSessionWarning
) {
918 # The user was knocked back from another page to the start
919 # This probably indicates a session expiry
920 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
923 $this->parent
->setSession( 'test', true );
925 if ( !isset( $languages[$userLang] ) ) {
926 $userLang = $this->getVar( '_UserLang', 'en' );
928 if ( !isset( $languages[$contLang] ) ) {
929 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
933 Xml
::hidden( 'LanguageRequestTime', time() ) .
934 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
935 $this->parent
->getHelpBox( 'config-your-language-help' ) .
936 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
937 $this->parent
->getHelpBox( 'config-wiki-language-help' );
940 $this->addHTML( $s );
945 * Get a <select> for selecting languages
947 function getLanguageSelector( $name, $label, $selectedCode ) {
948 global $wgDummyLanguageCodes;
949 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
951 $languages = Language
::getLanguageNames();
953 $dummies = array_flip( $wgDummyLanguageCodes );
954 foreach ( $languages as $code => $lang ) {
955 if ( isset( $dummies[$code] ) ) continue;
956 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
958 $s .= "\n</select>\n";
959 return $this->parent
->label( $label, $name, $s );
963 class WebInstaller_Welcome
extends WebInstallerPage
{
965 if ( $this->parent
->request
->wasPosted() ) {
966 if ( $this->getVar( '_Environment' ) ) {
970 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
971 $status = $this->parent
->doEnvironmentChecks();
973 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
980 class WebInstaller_DBConnect
extends WebInstallerPage
{
982 $r = $this->parent
->request
;
983 if ( $r->wasPosted() ) {
984 $status = $this->submit();
985 if ( $status->isGood() ) {
986 $this->setVar( '_UpgradeDone', false );
989 $this->parent
->showStatusErrorBox( $status );
996 $types = "<ul class=\"config-settings-block\">\n";
998 $defaultType = $this->getVar( 'wgDBtype' );
999 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
1000 $installer = $this->parent
->getDBInstaller( $type );
1004 $installer->getReadableName(),
1008 $type == $defaultType,
1009 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1014 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1015 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1016 $installer->getConnectForm() .
1019 $types .= "</ul><br clear=\"left\"/>\n";
1022 $this->parent
->label( 'config-db-type', false, $types ) .
1030 $r = $this->parent
->request
;
1031 $type = $r->getVal( 'DBType' );
1032 $this->setVar( 'wgDBtype', $type );
1033 $installer = $this->parent
->getDBInstaller( $type );
1034 if ( !$installer ) {
1035 return Status
::newFatal( 'config-invalid-db-type' );
1037 return $installer->submitConnectForm();
1041 class WebInstaller_Upgrade
extends WebInstallerPage
{
1042 function execute() {
1043 if ( $this->getVar( '_UpgradeDone' ) ) {
1044 if ( $this->parent
->request
->wasPosted() ) {
1045 // Done message acknowledged
1048 // Back button click
1049 // Show the done message again
1050 // Make them click back again if they want to do the upgrade again
1051 $this->showDoneMessage();
1056 // wgDBtype is generally valid here because otherwise the previous page
1057 // (connect) wouldn't have declared its happiness
1058 $type = $this->getVar( 'wgDBtype' );
1059 $installer = $this->parent
->getDBInstaller( $type );
1061 if ( !$installer->needsUpgrade() ) {
1065 if ( $this->parent
->request
->wasPosted() ) {
1067 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1068 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1069 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1071 $this->parent
->output
->flush();
1072 $result = $installer->doUpgrade();
1073 $this->addHTML( '</textarea>
1074 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1075 $this->parent
->output
->flush();
1077 $this->setVar( '_UpgradeDone', true );
1078 $this->showDoneMessage();
1084 $this->addHTML( $this->parent
->getInfoBox(
1085 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1089 function showDoneMessage() {
1092 $this->parent
->getInfoBox(
1093 wfMsgNoTrans( 'config-upgrade-done',
1094 $GLOBALS['wgServer'] .
1095 $this->getVar( 'wgScriptPath' ) . '/index' .
1096 $this->getVar( 'wgScriptExtension' )
1100 $this->endForm( 'regenerate' );
1104 class WebInstaller_DBSettings
extends WebInstallerPage
{
1105 function execute() {
1106 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1108 $r = $this->parent
->request
;
1109 if ( $r->wasPosted() ) {
1110 $status = $installer->submitSettingsForm();
1111 if ( $status === false ) {
1113 } elseif ( $status->isGood() ) {
1116 $this->parent
->showStatusErrorBox( $status );
1120 $form = $installer->getSettingsForm();
1121 if ( $form === false ) {
1126 $this->addHTML( $form );
1132 class WebInstaller_Name
extends WebInstallerPage
{
1133 function execute() {
1134 $r = $this->parent
->request
;
1135 if ( $r->wasPosted() ) {
1136 if ( $this->submit() ) {
1143 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1144 $this->setVar( 'wgSitename', '' );
1147 // Set wgMetaNamespace to something valid before we show the form.
1148 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1149 $metaNS = $this->getVar( 'wgMetaNamespace' );
1150 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1153 $this->parent
->getTextBox( array(
1154 'var' => 'wgSitename',
1155 'label' => 'config-site-name',
1157 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1158 $this->parent
->getRadioSet( array(
1159 'var' => '_NamespaceType',
1160 'label' => 'config-project-namespace',
1161 'itemLabelPrefix' => 'config-ns-',
1162 'values' => array( 'site-name', 'generic', 'other' ),
1163 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1165 $this->parent
->getTextBox( array(
1166 'var' => 'wgMetaNamespace',
1168 'attribs' => array( 'disabled' => '' ),
1170 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1171 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1172 $this->parent
->getTextBox( array(
1173 'var' => '_AdminName',
1174 'label' => 'config-admin-name'
1176 $this->parent
->getPasswordBox( array(
1177 'var' => '_AdminPassword',
1178 'label' => 'config-admin-password',
1180 $this->parent
->getPasswordBox( array(
1181 'var' => '_AdminPassword2',
1182 'label' => 'config-admin-password-confirm'
1184 $this->parent
->getHelpBox( 'config-admin-help' ) .
1185 $this->parent
->getTextBox( array(
1186 'var' => '_AdminEmail',
1187 'label' => 'config-admin-email'
1189 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1190 $this->parent
->getCheckBox( array(
1191 'var' => '_Subscribe',
1192 'label' => 'config-subscribe'
1194 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1195 $this->parent
->getFieldsetEnd() .
1196 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1197 $this->parent
->getRadioSet( array(
1198 'var' => '_SkipOptional',
1199 'itemLabelPrefix' => 'config-optional-',
1200 'values' => array( 'continue', 'skip' )
1204 // Restore the default value
1205 $this->setVar( 'wgMetaNamespace', $metaNS );
1213 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1214 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1215 '_Subscribe', '_SkipOptional' ) );
1217 // Validate site name
1218 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1219 $this->parent
->showError( 'config-site-name-blank' );
1224 $nsType = $this->getVar( '_NamespaceType' );
1225 if ( $nsType == 'site-name' ) {
1226 $name = $this->getVar( 'wgSitename' );
1227 // Sanitize for namespace
1228 // This algorithm should match the JS one in WebInstallerOutput.php
1229 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1230 $name = str_replace( '&', '&', $name );
1231 $name = preg_replace( '/__+/', '_', $name );
1232 $name = ucfirst( trim( $name, '_' ) );
1233 } elseif ( $nsType == 'generic' ) {
1234 $name = wfMsg( 'config-ns-generic' );
1236 $name = $this->getVar( 'wgMetaNamespace' );
1239 // Validate namespace
1240 if ( strpos( $name, ':' ) !== false ) {
1243 // Title-style validation
1244 $title = Title
::newFromText( $name );
1246 $good = $nsType == 'site-name' ?
true : false;
1248 $name = $title->getDBkey();
1253 $this->parent
->showError( 'config-ns-invalid', $name );
1256 $this->setVar( 'wgMetaNamespace', $name );
1258 // Validate username for creation
1259 $name = $this->getVar( '_AdminName' );
1260 if ( strval( $name ) === '' ) {
1261 $this->parent
->showError( 'config-admin-name-blank' );
1265 $cname = User
::getCanonicalName( $name, 'creatable' );
1266 if ( $cname === false ) {
1267 $this->parent
->showError( 'config-admin-name-invalid', $name );
1270 $this->setVar( '_AdminName', $cname );
1274 // Validate password
1276 $pwd = $this->getVar( '_AdminPassword' );
1277 $user = User
::newFromName( $cname );
1278 $valid = $user->getPasswordValidity( $pwd );
1279 if ( strval( $pwd ) === '' ) {
1280 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1281 # This message is more specific and helpful.
1282 $msg = 'config-admin-password-blank';
1283 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1284 $msg = 'config-admin-password-mismatch';
1285 } elseif ( $valid !== true ) {
1286 # As of writing this will only catch the username being e.g. 'FOO' and
1287 # the password 'foo'
1290 if ( $msg !== false ) {
1291 $this->parent
->showError( $msg );
1292 $this->setVar( '_AdminPassword', '' );
1293 $this->setVar( '_AdminPassword2', '' );
1300 class WebInstaller_Options
extends WebInstallerPage
{
1301 function execute() {
1302 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1305 if ( $this->parent
->request
->wasPosted() ) {
1306 if ( $this->submit() ) {
1314 $this->parent
->getRadioSet( array(
1315 'var' => '_RightsProfile',
1316 'label' => 'config-profile',
1317 'itemLabelPrefix' => 'config-profile-',
1318 'values' => array_keys( $this->parent
->rightsProfiles
),
1320 $this->parent
->getHelpBox( 'config-profile-help' ) .
1323 $this->parent
->getRadioSet( array(
1324 'var' => '_LicenseCode',
1325 'label' => 'config-license',
1326 'itemLabelPrefix' => 'config-license-',
1327 'values' => array_keys( $this->parent
->licenses
),
1328 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1330 $this->getCCChooser() .
1331 $this->parent
->getHelpBox( 'config-license-help' ) .
1334 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1335 $this->parent
->getCheckBox( array(
1336 'var' => 'wgEnableEmail',
1337 'label' => 'config-enable-email',
1338 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1340 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1341 "<div id=\"emailwrapper\">" .
1342 $this->parent
->getTextBox( array(
1343 'var' => 'wgPasswordSender',
1344 'label' => 'config-email-sender'
1346 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1347 $this->parent
->getCheckBox( array(
1348 'var' => 'wgEnableUserEmail',
1349 'label' => 'config-email-user',
1351 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1352 $this->parent
->getCheckBox( array(
1353 'var' => 'wgEnotifUserTalk',
1354 'label' => 'config-email-usertalk',
1356 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1357 $this->parent
->getCheckBox( array(
1358 'var' => 'wgEnotifWatchlist',
1359 'label' => 'config-email-watchlist',
1361 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1362 $this->parent
->getCheckBox( array(
1363 'var' => 'wgEmailAuthentication',
1364 'label' => 'config-email-auth',
1366 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1368 $this->parent
->getFieldsetEnd()
1371 $extensions = $this->parent
->findExtensions();
1373 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1374 foreach( $extensions as $ext ) {
1375 $extHtml .= $this->parent
->getCheckBox( array(
1376 'var' => "ext-$ext",
1380 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1381 $this->parent
->getFieldsetEnd();
1382 $this->addHTML( $extHtml );
1387 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1388 $this->parent
->getCheckBox( array(
1389 'var' => 'wgEnableUploads',
1390 'label' => 'config-upload-enable',
1391 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1393 $this->parent
->getHelpBox( 'config-upload-help' ) .
1394 '<div id="uploadwrapper" style="display: none;">' .
1395 $this->parent
->getTextBox( array(
1396 'var' => 'wgDeletedDirectory',
1397 'label' => 'config-upload-deleted',
1399 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1401 $this->parent
->getTextBox( array(
1403 'label' => 'config-logo'
1405 $this->parent
->getHelpBox( 'config-logo-help' ) .
1406 $this->parent
->getFieldsetEnd()
1409 $caches = array( 'none' );
1410 if( count( $this->getVar( '_Caches' ) ) ) {
1411 $caches[] = 'accel';
1412 $selected = 'accel';
1414 $caches[] = 'memcached';
1418 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1419 # Object cache settings
1420 $this->parent
->getRadioSet( array(
1421 'var' => 'wgMainCacheType',
1422 'label' => 'config-cache-options',
1423 'itemLabelPrefix' => 'config-cache-',
1424 'values' => $caches,
1425 'value' => $selected,
1427 $this->parent
->getHelpBox( 'config-cache-help' ) .
1428 '<div id="config-memcachewrapper">' .
1429 $this->parent
->getTextBox( array(
1430 'var' => '_MemCachedServers',
1431 'label' => 'config-memcached-servers',
1433 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
1434 $this->parent
->getFieldsetEnd()
1439 function getCCPartnerUrl() {
1441 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1442 'page' => 'Options',
1443 'SubmitCC' => 'indeed',
1444 'config__LicenseCode' => 'cc',
1445 'config_wgRightsUrl' => '[license_url]',
1446 'config_wgRightsText' => '[license_name]',
1447 'config_wgRightsIcon' => '[license_button]',
1449 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1450 '/skins/common/config-cc.css';
1451 $iframeUrl = 'http://creativecommons.org/license/?' .
1452 wfArrayToCGI( array(
1453 'partner' => 'MediaWiki',
1454 'exit_url' => $exitUrl,
1455 'lang' => $this->getVar( '_UserLang' ),
1456 'stylesheet' => $styleUrl,
1461 function getCCChooser() {
1462 $iframeAttribs = array(
1463 'class' => 'config-cc-iframe',
1464 'name' => 'config-cc-iframe',
1465 'id' => 'config-cc-iframe',
1470 if ( $this->getVar( '_CCDone' ) ) {
1471 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1473 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1477 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1478 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1482 function getCCDoneBox() {
1483 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1484 // If you change this height, also change it in config.css
1485 $expandJs = str_replace( '$1', '54em', $js );
1486 $reduceJs = str_replace( '$1', '70px', $js );
1489 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1491 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1493 "<p style=\"text-align: center\">" .
1496 'href' => $this->getCCPartnerUrl(),
1497 'onclick' => $expandJs,
1499 wfMsg( 'config-cc-again' )
1502 "<script type=\"text/javascript\">\n" .
1503 # Reduce the wrapper div height
1504 htmlspecialchars( $reduceJs ) .
1510 function submitCC() {
1511 $newValues = $this->parent
->setVarsFromRequest(
1512 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1513 if ( count( $newValues ) != 3 ) {
1514 $this->parent
->showError( 'config-cc-error' );
1517 $this->setVar( '_CCDone', true );
1518 $this->addHTML( $this->getCCDoneBox() );
1522 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1523 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1524 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1525 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers' ) );
1527 if ( !in_array( $this->getVar( '_RightsProfile' ),
1528 array_keys( $this->parent
->rightsProfiles
) ) )
1530 reset( $this->parent
->rightsProfiles
);
1531 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1534 $code = $this->getVar( '_LicenseCode' );
1535 if ( $code == 'cc-choose' ) {
1536 if ( !$this->getVar( '_CCDone' ) ) {
1537 $this->parent
->showError( 'config-cc-not-chosen' );
1540 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1541 $entry = $this->parent
->licenses
[$code];
1542 if ( isset( $entry['text'] ) ) {
1543 $this->setVar( 'wgRightsText', $entry['text'] );
1545 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1547 $this->setVar( 'wgRightsUrl', $entry['url'] );
1548 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1550 $this->setVar( 'wgRightsText', '' );
1551 $this->setVar( 'wgRightsUrl', '' );
1552 $this->setVar( 'wgRightsIcon', '' );
1555 $exts = $this->parent
->getVar( '_Extensions' );
1556 foreach( $exts as $key => $ext ) {
1557 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1558 unset( $exts[$key] );
1561 $this->parent
->setVar( '_Extensions', $exts );
1566 class WebInstaller_Install
extends WebInstallerPage
{
1568 function execute() {
1569 if( $this->parent
->request
->wasPosted() ) {
1573 $this->addHTML("<ul>");
1574 foreach( $this->parent
->getInstallSteps() as $stepObj ) {
1575 $step = is_array( $stepObj ) ?
$stepObj['name'] : $stepObj;
1576 $this->startStage( "config-install-$step" );
1579 # Call our working function
1580 if ( is_array( $step ) ) {
1581 # A custom callaback
1582 $callback = $stepObj['callback'];
1583 $status = call_user_func_array( $callback, array() );
1585 # Boring implicitly named callback
1586 $func = 'install' . ucfirst( $step );
1587 $status = $this->parent
->{$func}();
1590 $ok = $status->isGood();
1592 $this->parent
->showStatusErrorBox( $status );
1594 $this->endStage( $ok );
1596 $this->addHTML("</ul>");
1602 private function startStage( $msg ) {
1603 $this->addHTML( "<li>" . wfMsgHtml( $msg ) . wfMsg( 'ellipsis') );
1606 private function endStage( $success = true ) {
1607 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1608 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1610 $html = "<span class=\"error\">$html</span>";
1612 $this->addHTML( $html . "</li>\n" );
1616 class WebInstaller_Complete
extends WebInstallerPage
{
1617 public function execute() {
1620 $msg = file_exists( "$IP/LocalSettings.php" ) ?
'config-install-done-moved' : 'config-install-done';
1622 $this->parent
->getInfoBox(
1624 $GLOBALS['wgServer'] .
1625 $this->getVar( 'wgScriptPath' ) . '/index' .
1626 $this->getVar( 'wgScriptExtension' )
1630 $this->endForm( false );
1634 class WebInstaller_Restart
extends WebInstallerPage
{
1635 function execute() {
1636 $r = $this->parent
->request
;
1637 if ( $r->wasPosted() ) {
1638 $really = $r->getVal( 'submit-restart' );
1640 $this->parent
->session
= array();
1641 $this->parent
->happyPages
= array();
1642 $this->parent
->settings
= array();
1648 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1649 $this->addHTML( $s );
1650 $this->endForm( 'restart' );
1654 abstract class WebInstaller_Document
extends WebInstallerPage
{
1655 abstract function getFileName();
1657 function execute() {
1658 $text = $this->getFileContents();
1659 $this->parent
->output
->addWikiText( $text );
1661 $this->endForm( false );
1664 function getFileContents() {
1665 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1668 protected function formatTextFile( $text ) {
1669 $text = str_replace( array( '<', '{{', '[[' ),
1670 array( '<', '{{', '[[' ), $text );
1671 // replace numbering with [1], [2], etc with MW-style numbering
1672 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1673 // join word-wrapped lines into one
1676 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1677 } while ( $text != $prev );
1678 // turn (bug nnnn) into links
1679 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1680 // add links to manual to every global variable mentioned
1681 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1682 // special case for <pre> - formatted links
1685 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1686 } while ( $text != $prev );
1690 private function replaceBugLinks( $matches ) {
1691 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1692 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1695 private function replaceConfigLinks( $matches ) {
1696 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1697 $matches[1] . ' ' . $matches[1] . ']</span>';
1701 class WebInstaller_Readme
extends WebInstaller_Document
{
1702 function getFileName() { return 'README'; }
1704 function getFileContents() {
1705 return $this->formatTextFile( parent
::getFileContents() );
1709 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1710 function getFileName() { return 'RELEASE-NOTES'; }
1712 function getFileContents() {
1713 return $this->formatTextFile( parent
::getFileContents() );
1717 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1718 function getFileName() { return 'UPGRADE'; }
1720 function getFileContents() {
1721 return $this->formatTextFile( parent
::getFileContents() );
1725 class WebInstaller_Copying
extends WebInstaller_Document
{
1726 function getFileName() { return 'COPYING'; }
1728 function getFileContents() {
1729 $text = parent
::getFileContents();
1730 $text = str_replace( "\x0C", '', $text );
1731 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1732 $text = '<tt>' . nl2br( $text ) . '</tt>';
1736 private static function replaceLeadingSpaces( $matches ) {
1737 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );