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 box using a Status object
736 function showStatusErrorBox( $status ) {
737 $text = $status->getWikiText();
738 $this->output
->addHTML( $this->getErrorBox( $text ) );
741 function showStatusMessage( $status ) {
742 $text = $status->getWikiText();
743 $this->output
->addWikiText(
744 "<div class=\"config-message\">\n" .
751 * Convenience function to set variables based on form data.
752 * Assumes that variables containing "password" in the name are (potentially
755 * @param $varNames Array
756 * @param $prefix String: the prefix added to variables to obtain form names
758 function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
759 $newValues = array();
760 foreach ( $varNames as $name ) {
761 $value = trim( $this->request
->getVal( $prefix . $name ) );
762 $newValues[$name] = $value;
763 if ( $value === null ) {
765 $this->setVar( $name, false );
767 if ( stripos( $name, 'password' ) !== false ) {
768 $this->setPassword( $name, $value );
770 $this->setVar( $name, $value );
778 * Get the starting tags of a fieldset
780 * @param $legend String: message name
782 function getFieldsetStart( $legend ) {
783 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
787 * Get the end tag of a fieldset
789 function getFieldsetEnd() {
790 return "</fieldset>\n";
794 * Helper for Installer::docLink()
796 function getDocUrl( $page ) {
797 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
798 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
799 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
805 abstract class WebInstallerPage
{
806 function __construct( $parent ) {
807 $this->parent
= $parent;
810 function addHTML( $html ) {
811 $this->parent
->output
->addHTML( $html );
814 function startForm() {
816 "<div class=\"config-section\">\n" .
821 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
827 function endForm( $continue = 'continue' ) {
828 $this->parent
->output
->outputWarnings();
829 $s = "<div class=\"config-submit\">\n";
830 $id = $this->getId();
831 if ( $id === false ) {
832 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
835 // Fake submit button for enter keypress
836 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
837 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
840 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
842 'name' => 'submit-back',
843 'tabindex' => $this->parent
->nextTabIndex()
847 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
849 'name' => "submit-$continue",
850 'tabindex' => $this->parent
->nextTabIndex(),
853 $s .= "</div></form></div>\n";
854 $this->addHTML( $s );
858 return str_replace( 'WebInstaller_', '', get_class( $this ) );
862 return array_search( $this->getName(), $this->parent
->pageSequence
);
865 abstract function execute();
867 function getVar( $var ) {
868 return $this->parent
->getVar( $var );
871 function setVar( $name, $value ) {
872 $this->parent
->setVar( $name, $value );
876 class WebInstaller_Language
extends WebInstallerPage
{
879 $r = $this->parent
->request
;
880 $userLang = $r->getVal( 'UserLang' );
881 $contLang = $r->getVal( 'ContLang' );
883 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
885 $lifetime = 1440; // PHP default
888 if ( $r->wasPosted() ) {
890 if ( $this->parent
->getSession( 'test' ) === null ) {
891 $requestTime = $r->getVal( 'LanguageRequestTime' );
892 if ( !$requestTime ) {
893 // The most likely explanation is that the user was knocked back
894 // from another page on POST due to session expiry
895 $msg = 'config-session-expired';
896 } elseif ( time() - $requestTime > $lifetime ) {
897 $msg = 'config-session-expired';
899 $msg = 'config-no-session';
901 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
903 $languages = Language
::getLanguageNames();
904 if ( isset( $languages[$userLang] ) ) {
905 $this->setVar( '_UserLang', $userLang );
907 if ( isset( $languages[$contLang] ) ) {
908 $this->setVar( 'wgLanguageCode', $contLang );
909 if ( $this->getVar( '_AdminName' ) === null ) {
910 // Load localised sysop username in *content* language
911 $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) );
916 } elseif ( $this->parent
->showSessionWarning
) {
917 # The user was knocked back from another page to the start
918 # This probably indicates a session expiry
919 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
922 $this->parent
->setSession( 'test', true );
924 if ( !isset( $languages[$userLang] ) ) {
925 $userLang = $this->getVar( '_UserLang', 'en' );
927 if ( !isset( $languages[$contLang] ) ) {
928 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
932 Xml
::hidden( 'LanguageRequestTime', time() ) .
933 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
934 $this->parent
->getHelpBox( 'config-your-language-help' ) .
935 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
936 $this->parent
->getHelpBox( 'config-wiki-language-help' );
939 $this->addHTML( $s );
944 * Get a <select> for selecting languages
946 function getLanguageSelector( $name, $label, $selectedCode ) {
947 global $wgDummyLanguageCodes;
948 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
950 $languages = Language
::getLanguageNames();
952 $dummies = array_flip( $wgDummyLanguageCodes );
953 foreach ( $languages as $code => $lang ) {
954 if ( isset( $dummies[$code] ) ) continue;
955 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
957 $s .= "\n</select>\n";
958 return $this->parent
->label( $label, $name, $s );
962 class WebInstaller_Welcome
extends WebInstallerPage
{
964 if ( $this->parent
->request
->wasPosted() ) {
965 if ( $this->getVar( '_Environment' ) ) {
969 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
970 $status = $this->parent
->doEnvironmentChecks();
972 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
979 class WebInstaller_DBConnect
extends WebInstallerPage
{
981 $r = $this->parent
->request
;
982 if ( $r->wasPosted() ) {
983 $status = $this->submit();
984 if ( $status->isGood() ) {
985 $this->setVar( '_UpgradeDone', false );
988 $this->parent
->showStatusErrorBox( $status );
995 $types = "<ul class=\"config-settings-block\">\n";
997 $defaultType = $this->getVar( 'wgDBtype' );
998 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
999 $installer = $this->parent
->getDBInstaller( $type );
1003 $installer->getReadableName(),
1007 $type == $defaultType,
1008 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1013 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1014 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1015 $installer->getConnectForm() .
1018 $types .= "</ul><br clear=\"left\"/>\n";
1021 $this->parent
->label( 'config-db-type', false, $types ) .
1029 $r = $this->parent
->request
;
1030 $type = $r->getVal( 'DBType' );
1031 $this->setVar( 'wgDBtype', $type );
1032 $installer = $this->parent
->getDBInstaller( $type );
1033 if ( !$installer ) {
1034 return Status
::newFatal( 'config-invalid-db-type' );
1036 return $installer->submitConnectForm();
1040 class WebInstaller_Upgrade
extends WebInstallerPage
{
1041 function execute() {
1042 if ( $this->getVar( '_UpgradeDone' ) ) {
1043 if ( $this->parent
->request
->wasPosted() ) {
1044 // Done message acknowledged
1047 // Back button click
1048 // Show the done message again
1049 // Make them click back again if they want to do the upgrade again
1050 $this->showDoneMessage();
1055 // wgDBtype is generally valid here because otherwise the previous page
1056 // (connect) wouldn't have declared its happiness
1057 $type = $this->getVar( 'wgDBtype' );
1058 $installer = $this->parent
->getDBInstaller( $type );
1060 if ( !$installer->needsUpgrade() ) {
1064 if ( $this->parent
->request
->wasPosted() ) {
1066 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1067 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1068 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1070 $this->parent
->output
->flush();
1071 $result = $installer->doUpgrade();
1072 $this->addHTML( '</textarea>
1073 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1074 $this->parent
->output
->flush();
1076 $this->setVar( '_UpgradeDone', true );
1077 $this->showDoneMessage();
1083 $this->addHTML( $this->parent
->getInfoBox(
1084 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1088 function showDoneMessage() {
1091 $this->parent
->getInfoBox(
1092 wfMsgNoTrans( 'config-upgrade-done',
1093 $GLOBALS['wgServer'] .
1094 $this->getVar( 'wgScriptPath' ) . '/index' .
1095 $this->getVar( 'wgScriptExtension' )
1099 $this->endForm( 'regenerate' );
1103 class WebInstaller_DBSettings
extends WebInstallerPage
{
1104 function execute() {
1105 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1107 $r = $this->parent
->request
;
1108 if ( $r->wasPosted() ) {
1109 $status = $installer->submitSettingsForm();
1110 if ( $status === false ) {
1112 } elseif ( $status->isGood() ) {
1115 $this->parent
->showStatusErrorBox( $status );
1119 $form = $installer->getSettingsForm();
1120 if ( $form === false ) {
1125 $this->addHTML( $form );
1131 class WebInstaller_Name
extends WebInstallerPage
{
1132 function execute() {
1133 $r = $this->parent
->request
;
1134 if ( $r->wasPosted() ) {
1135 if ( $this->submit() ) {
1142 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1143 $this->setVar( 'wgSitename', '' );
1146 // Set wgMetaNamespace to something valid before we show the form.
1147 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1148 $metaNS = $this->getVar( 'wgMetaNamespace' );
1149 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1152 $this->parent
->getTextBox( array(
1153 'var' => 'wgSitename',
1154 'label' => 'config-site-name',
1156 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1157 $this->parent
->getRadioSet( array(
1158 'var' => '_NamespaceType',
1159 'label' => 'config-project-namespace',
1160 'itemLabelPrefix' => 'config-ns-',
1161 'values' => array( 'site-name', 'generic', 'other' ),
1162 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1164 $this->parent
->getTextBox( array(
1165 'var' => 'wgMetaNamespace',
1167 'attribs' => array( 'disabled' => '' ),
1169 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1170 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1171 $this->parent
->getTextBox( array(
1172 'var' => '_AdminName',
1173 'label' => 'config-admin-name'
1175 $this->parent
->getPasswordBox( array(
1176 'var' => '_AdminPassword',
1177 'label' => 'config-admin-password',
1179 $this->parent
->getPasswordBox( array(
1180 'var' => '_AdminPassword2',
1181 'label' => 'config-admin-password-confirm'
1183 $this->parent
->getHelpBox( 'config-admin-help' ) .
1184 $this->parent
->getTextBox( array(
1185 'var' => '_AdminEmail',
1186 'label' => 'config-admin-email'
1188 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1189 $this->parent
->getCheckBox( array(
1190 'var' => '_Subscribe',
1191 'label' => 'config-subscribe'
1193 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1194 $this->parent
->getFieldsetEnd() .
1195 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1196 $this->parent
->getRadioSet( array(
1197 'var' => '_SkipOptional',
1198 'itemLabelPrefix' => 'config-optional-',
1199 'values' => array( 'continue', 'skip' )
1203 // Restore the default value
1204 $this->setVar( 'wgMetaNamespace', $metaNS );
1212 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1213 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1214 '_Subscribe', '_SkipOptional' ) );
1216 // Validate site name
1217 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1218 $this->parent
->showError( 'config-site-name-blank' );
1223 $nsType = $this->getVar( '_NamespaceType' );
1224 if ( $nsType == 'site-name' ) {
1225 $name = $this->getVar( 'wgSitename' );
1226 // Sanitize for namespace
1227 // This algorithm should match the JS one in WebInstallerOutput.php
1228 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1229 $name = str_replace( '&', '&', $name );
1230 $name = preg_replace( '/__+/', '_', $name );
1231 $name = ucfirst( trim( $name, '_' ) );
1232 } elseif ( $nsType == 'generic' ) {
1233 $name = wfMsg( 'config-ns-generic' );
1235 $name = $this->getVar( 'wgMetaNamespace' );
1238 // Validate namespace
1239 if ( strpos( $name, ':' ) !== false ) {
1242 // Title-style validation
1243 $title = Title
::newFromText( $name );
1245 $good = $nsType == 'site-name' ?
true : false;
1247 $name = $title->getDBkey();
1252 $this->parent
->showError( 'config-ns-invalid', $name );
1255 $this->setVar( 'wgMetaNamespace', $name );
1257 // Validate username for creation
1258 $name = $this->getVar( '_AdminName' );
1259 if ( strval( $name ) === '' ) {
1260 $this->parent
->showError( 'config-admin-name-blank' );
1264 $cname = User
::getCanonicalName( $name, 'creatable' );
1265 if ( $cname === false ) {
1266 $this->parent
->showError( 'config-admin-name-invalid', $name );
1269 $this->setVar( '_AdminName', $cname );
1273 // Validate password
1275 $pwd = $this->getVar( '_AdminPassword' );
1276 $user = User
::newFromName( $cname );
1277 $valid = $user->getPasswordValidity( $pwd );
1278 if ( strval( $pwd ) === '' ) {
1279 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1280 # This message is more specific and helpful.
1281 $msg = 'config-admin-password-blank';
1282 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1283 $msg = 'config-admin-password-mismatch';
1284 } elseif ( $valid !== true ) {
1285 # As of writing this will only catch the username being e.g. 'FOO' and
1286 # the password 'foo'
1289 if ( $msg !== false ) {
1290 $this->parent
->showError( $msg );
1291 $this->setVar( '_AdminPassword', '' );
1292 $this->setVar( '_AdminPassword2', '' );
1299 class WebInstaller_Options
extends WebInstallerPage
{
1300 function execute() {
1301 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1304 if ( $this->parent
->request
->wasPosted() ) {
1305 if ( $this->submit() ) {
1313 $this->parent
->getRadioSet( array(
1314 'var' => '_RightsProfile',
1315 'label' => 'config-profile',
1316 'itemLabelPrefix' => 'config-profile-',
1317 'values' => array_keys( $this->parent
->rightsProfiles
),
1319 $this->parent
->getHelpBox( 'config-profile-help' ) .
1322 $this->parent
->getRadioSet( array(
1323 'var' => '_LicenseCode',
1324 'label' => 'config-license',
1325 'itemLabelPrefix' => 'config-license-',
1326 'values' => array_keys( $this->parent
->licenses
),
1327 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1329 $this->getCCChooser() .
1330 $this->parent
->getHelpBox( 'config-license-help' ) .
1333 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1334 $this->parent
->getCheckBox( array(
1335 'var' => 'wgEnableEmail',
1336 'label' => 'config-enable-email',
1337 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1339 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1340 "<div id=\"emailwrapper\">" .
1341 $this->parent
->getTextBox( array(
1342 'var' => 'wgPasswordSender',
1343 'label' => 'config-email-sender'
1345 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1346 $this->parent
->getCheckBox( array(
1347 'var' => 'wgEnableUserEmail',
1348 'label' => 'config-email-user',
1350 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1351 $this->parent
->getCheckBox( array(
1352 'var' => 'wgEnotifUserTalk',
1353 'label' => 'config-email-usertalk',
1355 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1356 $this->parent
->getCheckBox( array(
1357 'var' => 'wgEnotifWatchlist',
1358 'label' => 'config-email-watchlist',
1360 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1361 $this->parent
->getCheckBox( array(
1362 'var' => 'wgEmailAuthentication',
1363 'label' => 'config-email-auth',
1365 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1367 $this->parent
->getFieldsetEnd()
1370 $extensions = $this->parent
->findExtensions();
1372 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1373 foreach( $extensions as $ext ) {
1374 $extHtml .= $this->parent
->getCheckBox( array(
1375 'var' => "ext-$ext",
1379 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1380 $this->parent
->getFieldsetEnd();
1381 $this->addHTML( $extHtml );
1386 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1387 $this->parent
->getCheckBox( array(
1388 'var' => 'wgEnableUploads',
1389 'label' => 'config-upload-enable',
1390 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1392 $this->parent
->getHelpBox( 'config-upload-help' ) .
1393 '<div id="uploadwrapper" style="display: none;">' .
1394 $this->parent
->getTextBox( array(
1395 'var' => 'wgDeletedDirectory',
1396 'label' => 'config-upload-deleted',
1398 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1400 $this->parent
->getTextBox( array(
1402 'label' => 'config-logo'
1404 $this->parent
->getHelpBox( 'config-logo-help' ) .
1405 $this->parent
->getFieldsetEnd()
1408 $caches = array( 'none' );
1409 if( count( $this->getVar( '_Caches' ) ) ) {
1410 $caches[] = 'accel';
1411 $selected = 'accel';
1413 $caches[] = 'memcached';
1417 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1418 # Object cache settings
1419 $this->parent
->getRadioSet( array(
1420 'var' => 'wgMainCacheType',
1421 'label' => 'config-cache-options',
1422 'itemLabelPrefix' => 'config-cache-',
1423 'values' => $caches,
1424 'value' => $selected,
1426 $this->parent
->getHelpBox( 'config-cache-help' ) .
1427 '<div id="config-memcachewrapper">' .
1428 $this->parent
->getTextBox( array(
1429 'var' => '_MemCachedServers',
1430 'label' => 'config-memcached-servers',
1432 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
1433 $this->parent
->getFieldsetEnd()
1438 function getCCPartnerUrl() {
1440 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1441 'page' => 'Options',
1442 'SubmitCC' => 'indeed',
1443 'config__LicenseCode' => 'cc',
1444 'config_wgRightsUrl' => '[license_url]',
1445 'config_wgRightsText' => '[license_name]',
1446 'config_wgRightsIcon' => '[license_button]',
1448 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1449 '/skins/common/config-cc.css';
1450 $iframeUrl = 'http://creativecommons.org/license/?' .
1451 wfArrayToCGI( array(
1452 'partner' => 'MediaWiki',
1453 'exit_url' => $exitUrl,
1454 'lang' => $this->getVar( '_UserLang' ),
1455 'stylesheet' => $styleUrl,
1460 function getCCChooser() {
1461 $iframeAttribs = array(
1462 'class' => 'config-cc-iframe',
1463 'name' => 'config-cc-iframe',
1464 'id' => 'config-cc-iframe',
1469 if ( $this->getVar( '_CCDone' ) ) {
1470 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1472 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1476 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1477 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1481 function getCCDoneBox() {
1482 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1483 // If you change this height, also change it in config.css
1484 $expandJs = str_replace( '$1', '54em', $js );
1485 $reduceJs = str_replace( '$1', '70px', $js );
1488 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1490 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1492 "<p style=\"text-align: center\">" .
1495 'href' => $this->getCCPartnerUrl(),
1496 'onclick' => $expandJs,
1498 wfMsg( 'config-cc-again' )
1501 "<script type=\"text/javascript\">\n" .
1502 # Reduce the wrapper div height
1503 htmlspecialchars( $reduceJs ) .
1509 function submitCC() {
1510 $newValues = $this->parent
->setVarsFromRequest(
1511 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1512 if ( count( $newValues ) != 3 ) {
1513 $this->parent
->showError( 'config-cc-error' );
1516 $this->setVar( '_CCDone', true );
1517 $this->addHTML( $this->getCCDoneBox() );
1521 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1522 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1523 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1524 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers' ) );
1526 if ( !in_array( $this->getVar( '_RightsProfile' ),
1527 array_keys( $this->parent
->rightsProfiles
) ) )
1529 reset( $this->parent
->rightsProfiles
);
1530 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1533 $code = $this->getVar( '_LicenseCode' );
1534 if ( $code == 'cc-choose' ) {
1535 if ( !$this->getVar( '_CCDone' ) ) {
1536 $this->parent
->showError( 'config-cc-not-chosen' );
1539 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1540 $entry = $this->parent
->licenses
[$code];
1541 if ( isset( $entry['text'] ) ) {
1542 $this->setVar( 'wgRightsText', $entry['text'] );
1544 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1546 $this->setVar( 'wgRightsUrl', $entry['url'] );
1547 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1549 $this->setVar( 'wgRightsText', '' );
1550 $this->setVar( 'wgRightsUrl', '' );
1551 $this->setVar( 'wgRightsIcon', '' );
1554 $exts = $this->parent
->getVar( '_Extensions' );
1555 foreach( $exts as $key => $ext ) {
1556 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1557 unset( $exts[$key] );
1560 $this->parent
->setVar( '_Extensions', $exts );
1565 class WebInstaller_Install
extends WebInstallerPage
{
1567 function execute() {
1568 if( $this->parent
->request
->wasPosted() ) {
1572 $this->addHTML("<ul>");
1573 foreach( $this->parent
->getInstallSteps() as $stepObj ) {
1574 $step = is_array( $stepObj ) ?
$stepObj['name'] : $stepObj;
1575 $this->startStage( "config-install-$step" );
1578 # Call our working function
1579 if ( is_array( $step ) ) {
1580 # A custom callaback
1581 $callback = $stepObj['callback'];
1582 $status = call_user_func_array( $callback, array() );
1584 # Boring implicitly named callback
1585 $func = 'install' . ucfirst( $step );
1586 $status = $this->parent
->{$func}();
1589 $ok = $status->isGood();
1591 $this->parent
->showStatusErrorBox( $status );
1593 $this->endStage( $ok );
1595 $this->addHTML("</ul>");
1601 private function startStage( $msg ) {
1602 $this->addHTML( "<li>" . wfMsgHtml( $msg ) . wfMsg( 'ellipsis') );
1605 private function endStage( $success = true ) {
1606 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1607 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1609 $html = "<span class=\"error\">$html</span>";
1611 $this->addHTML( $html . "</li>\n" );
1615 class WebInstaller_Complete
extends WebInstallerPage
{
1616 public function execute() {
1619 $msg = file_exists( "$IP/LocalSettings.php" ) ?
'config-install-done-moved' : 'config-install-done';
1621 $this->parent
->getInfoBox(
1623 $GLOBALS['wgServer'] .
1624 $this->getVar( 'wgScriptPath' ) . '/index' .
1625 $this->getVar( 'wgScriptExtension' )
1629 $this->endForm( false );
1633 class WebInstaller_Restart
extends WebInstallerPage
{
1634 function execute() {
1635 $r = $this->parent
->request
;
1636 if ( $r->wasPosted() ) {
1637 $really = $r->getVal( 'submit-restart' );
1639 $this->parent
->session
= array();
1640 $this->parent
->happyPages
= array();
1641 $this->parent
->settings
= array();
1647 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1648 $this->addHTML( $s );
1649 $this->endForm( 'restart' );
1653 abstract class WebInstaller_Document
extends WebInstallerPage
{
1654 abstract function getFileName();
1656 function execute() {
1657 $text = $this->getFileContents();
1658 $this->parent
->output
->addWikiText( $text );
1660 $this->endForm( false );
1663 function getFileContents() {
1664 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1667 protected function formatTextFile( $text ) {
1668 $text = str_replace( array( '<', '{{', '[[' ),
1669 array( '<', '{{', '[[' ), $text );
1670 // replace numbering with [1], [2], etc with MW-style numbering
1671 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1672 // join word-wrapped lines into one
1675 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1676 } while ( $text != $prev );
1677 // turn (bug nnnn) into links
1678 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1679 // add links to manual to every global variable mentioned
1680 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1681 // special case for <pre> - formatted links
1684 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1685 } while ( $text != $prev );
1689 private function replaceBugLinks( $matches ) {
1690 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1691 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1694 private function replaceConfigLinks( $matches ) {
1695 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1696 $matches[1] . ' ' . $matches[1] . ']</span>';
1700 class WebInstaller_Readme
extends WebInstaller_Document
{
1701 function getFileName() { return 'README'; }
1703 function getFileContents() {
1704 return $this->formatTextFile( parent
::getFileContents() );
1708 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1709 function getFileName() { return 'RELEASE-NOTES'; }
1711 function getFileContents() {
1712 return $this->formatTextFile( parent
::getFileContents() );
1716 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1717 function getFileName() { return 'UPGRADE'; }
1719 function getFileContents() {
1720 return $this->formatTextFile( parent
::getFileContents() );
1724 class WebInstaller_Copying
extends WebInstaller_Document
{
1725 function getFileName() { return 'COPYING'; }
1727 function getFileContents() {
1728 $text = parent
::getFileContents();
1729 $text = str_replace( "\x0C", '', $text );
1730 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1731 $text = '<tt>' . nl2br( $text ) . '</tt>';
1735 private static function replaceLeadingSpaces( $matches ) {
1736 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );