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( $this->getVar( '_InstallDone' ) && $this->request
->getVal( 'localsettings' ) )
89 $ls = new LocalSettingsGenerator( $this );
90 $this->request
->response()->header('Content-type: text/plain');
91 $this->request
->response()->header(
92 'Content-Disposition: attachment; filename="LocalSettings.php"'
95 return $this->session
;
98 if ( isset( $session['happyPages'] ) ) {
99 $this->happyPages
= $session['happyPages'];
101 $this->happyPages
= array();
103 if ( isset( $session['skippedPages'] ) ) {
104 $this->skippedPages
= $session['skippedPages'];
106 $this->skippedPages
= array();
108 $lowestUnhappy = $this->getLowestUnhappy();
110 # Special case for Creative Commons partner chooser box
111 if ( $this->request
->getVal( 'SubmitCC' ) ) {
112 $page = $this->getPageByName( 'Options' );
113 $this->output
->useShortHeader();
115 return $this->finish();
117 if ( $this->request
->getVal( 'ShowCC' ) ) {
118 $page = $this->getPageByName( 'Options' );
119 $this->output
->useShortHeader();
120 $this->output
->addHTML( $page->getCCDoneBox() );
121 return $this->finish();
125 $pageName = $this->request
->getVal( 'page' );
127 if ( in_array( $pageName, $this->otherPages
) ) {
130 $page = $this->getPageByName( $pageName );
133 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
134 $pageId = $lowestUnhappy;
136 $pageId = array_search( $pageName, $this->pageSequence
);
139 # If necessary, move back to the lowest-numbered unhappy page
140 if ( $pageId > $lowestUnhappy ) {
141 $pageId = $lowestUnhappy;
142 if ( $lowestUnhappy == 0 ) {
143 # Knocked back to start, possible loss of session data
144 $this->showSessionWarning
= true;
147 $pageName = $this->pageSequence
[$pageId];
148 $page = $this->getPageByName( $pageName );
151 # If a back button was submitted, go back without submitting the form data
152 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
153 if ( $this->request
->getVal( 'lastPage' ) ) {
154 $nextPage = $this->request
->getVal( 'lastPage' );
155 } elseif ( $pageId !== false ) {
157 # Skip the skipped pages
158 $nextPageId = $pageId;
161 $nextPage = $this->pageSequence
[$nextPageId];
162 } while( isset( $this->skippedPages
[$nextPage] ) );
164 $nextPage = $this->pageSequence
[$lowestUnhappy];
166 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
167 return $this->finish();
171 $this->currentPageName
= $page->getName();
172 $this->startPageWrapper( $pageName );
173 $localSettings = $this->getLocalSettingsStatus();
174 if( !$localSettings->isGood() ) {
175 $this->showStatusBox( $localSettings );
178 $result = $page->execute();
180 $this->endPageWrapper();
182 if ( $result == 'skip' ) {
183 # Page skipped without explicit submission
184 # Skip it when we click "back" so that we don't just go forward again
185 $this->skippedPages
[$pageName] = true;
186 $result = 'continue';
188 unset( $this->skippedPages
[$pageName] );
191 # If it was posted, the page can request a continue to the next page
192 if ( $result === 'continue' && !$this->output
->headerDone() ) {
193 if ( $pageId !== false ) {
194 $this->happyPages
[$pageId] = true;
196 $lowestUnhappy = $this->getLowestUnhappy();
198 if ( $this->request
->getVal( 'lastPage' ) ) {
199 $nextPage = $this->request
->getVal( 'lastPage' );
200 } elseif ( $pageId !== false ) {
201 $nextPage = $this->pageSequence
[$pageId +
1];
203 $nextPage = $this->pageSequence
[$lowestUnhappy];
205 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
206 $nextPage = $this->pageSequence
[$lowestUnhappy];
208 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
210 return $this->finish();
213 function getLowestUnhappy() {
214 if ( count( $this->happyPages
) == 0 ) {
217 return max( array_keys( $this->happyPages
) ) +
1;
222 * Start the PHP session. This may be called before execute() to start the PHP session.
224 function startSession() {
225 $sessPath = $this->getSessionSavePath();
226 if( $sessPath != '' ) {
227 if( strval( ini_get( 'open_basedir' ) ) != '' ) {
228 // we need to skip the following check when open_basedir is on.
229 // The session path probably *wont* be writable by the current
230 // user, and telling them to change it is bad. Bug 23021.
231 } elseif( !is_dir( $sessPath ) ||
!is_writeable( $sessPath ) ) {
232 $this->showError( 'config-session-path-bad', $sessPath );
236 // If the path is unset it'll default to some system bit, which *probably* is ok...
237 // not sure how to actually get what will be used.
239 if( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
244 $this->phpErrors
= array();
245 set_error_handler( array( $this, 'errorHandler' ) );
247 restore_error_handler();
248 if ( $this->phpErrors
) {
249 $this->showError( 'config-session-error', $this->phpErrors
[0] );
256 * Get the value of session.save_path
258 * Per http://www.php.net/manual/en/session.configuration.php#ini.session.save-path,
259 * this might have some additional preceding parts which need to be
264 private function getSessionSavePath() {
265 $path = ini_get( 'session.save_path' );
266 $path = ltrim( substr( $path, strrpos( $path, ';' ) ), ';');
272 * Show an error message in a box. Parameters are like wfMsg().
274 function showError( $msg /*...*/ ) {
275 $args = func_get_args();
276 array_shift( $args );
277 $args = array_map( 'htmlspecialchars', $args );
278 $msg = wfMsgReal( $msg, $args, false, false, false );
279 $this->output
->addHTML( $this->getErrorBox( $msg ) );
283 * Temporary error handler for session start debugging
285 function errorHandler( $errno, $errstr ) {
286 $this->phpErrors
[] = $errstr;
290 * Clean up from execute()
292 public function finish() {
293 $this->output
->output();
294 $this->session
['happyPages'] = $this->happyPages
;
295 $this->session
['skippedPages'] = $this->skippedPages
;
296 $this->session
['settings'] = $this->settings
;
297 return $this->session
;
301 * Get a URL for submission back to the same script
303 function getUrl( $query = array() ) {
304 $url = $this->request
->getRequestURL();
305 # Remove existing query
306 $url = preg_replace( '/\?.*$/', '', $url );
308 $url .= '?' . wfArrayToCGI( $query );
314 * Get a WebInstallerPage from the main sequence, by ID
316 function getPageById( $id ) {
317 $pageName = $this->pageSequence
[$id];
318 $pageClass = 'WebInstaller_' . $pageName;
319 return new $pageClass( $this );
323 * Get a WebInstallerPage by name
325 function getPageByName( $pageName ) {
326 $pageClass = 'WebInstaller_' . $pageName;
327 return new $pageClass( $this );
331 * Get a session variable
333 function getSession( $name, $default = null ) {
334 if ( !isset( $this->session
[$name] ) ) {
337 return $this->session
[$name];
342 * Set a session variable
344 function setSession( $name, $value ) {
345 $this->session
[$name] = $value;
349 * Get the next tabindex attribute value
351 function nextTabIndex() {
352 return $this->tabIndex++
;
356 * Initializes language-related variables
358 function setupLanguage() {
359 global $wgLang, $wgContLang, $wgLanguageCode;
360 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
361 $wgLanguageCode = $this->getAcceptLanguage();
362 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
363 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
364 $this->setVar( '_UserLang', $wgLanguageCode );
366 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
367 $wgLang = Language
::factory( $this->getVar( '_UserLang' ) );
368 $wgContLang = Language
::factory( $wgLanguageCode );
373 * Retrieves MediaWiki language from Accept-Language HTTP header
375 function getAcceptLanguage() {
376 global $wgLanguageCode;
378 $mwLanguages = Language
::getLanguageNames();
379 $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
380 foreach ( explode( ';', $langs ) as $splitted ) {
381 foreach ( explode( ',', $splitted ) as $lang ) {
382 $lang = trim( strtolower( $lang ) );
383 if ( $lang == '' ||
$lang[0] == 'q' ) {
386 if ( isset( $mwLanguages[$lang] ) ) {
389 $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang );
390 if ( $lang != '' && isset( $mwLanguages[$lang] ) ) {
395 return $wgLanguageCode;
399 * Called by execute() before page output starts, to show a page list
401 function startPageWrapper( $currentPageName ) {
402 $s = "<div class=\"config-page-wrapper\">\n" .
403 "<div class=\"config-page-list\"><ul>\n";
405 foreach ( $this->pageSequence
as $id => $pageName ) {
406 $happy = !empty( $this->happyPages
[$id] );
407 $s .= $this->getPageListItem( $pageName,
408 $happy ||
$lastHappy == $id - 1, $currentPageName );
413 $s .= "</ul><br/><ul>\n";
414 foreach ( $this->otherPages
as $pageName ) {
415 $s .= $this->getPageListItem( $pageName, true, $currentPageName );
417 $s .= "</ul></div>\n". // end list pane
418 "<div class=\"config-page\">\n" .
419 Xml
::element( 'h2', array(),
420 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
422 $this->output
->addHTMLNoFlush( $s );
426 * Get a list item for the page list
428 function getPageListItem( $pageName, $enabled, $currentPageName ) {
429 $s = "<li class=\"config-page-list-item\">";
430 $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
432 $query = array( 'page' => $pageName );
433 if ( !in_array( $pageName, $this->pageSequence
) ) {
434 if ( in_array( $currentPageName, $this->pageSequence
) ) {
435 $query['lastPage'] = $currentPageName;
437 $link = Xml
::element( 'a',
439 'href' => $this->getUrl( $query )
444 $link = htmlspecialchars( $name );
446 if ( $pageName == $currentPageName ) {
447 $s .= "<span class=\"config-page-current\">$link</span>";
452 $s .= Xml
::element( 'span',
454 'class' => 'config-page-disabled'
464 * Output some stuff after a page is finished
466 function endPageWrapper() {
467 $this->output
->addHTMLNoFlush(
469 "<br style=\"clear:both\"/>\n" .
474 * Get HTML for an error box with an icon
476 * @param $text String: wikitext, get this with wfMsgNoTrans()
478 function getErrorBox( $text ) {
479 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
483 * Get HTML for a warning box with an icon
485 * @param $text String: wikitext, get this with wfMsgNoTrans()
487 function getWarningBox( $text ) {
488 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
492 * Get HTML for an info box with an icon
494 * @param $text String: wikitext, get this with wfMsgNoTrans()
495 * @param $icon String: icon name, file in skins/common/images
496 * @param $class String: additional class name to add to the wrapper div
498 function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
500 "<div class=\"config-info $class\">\n" .
501 "<div class=\"config-info-left\">\n" .
504 'src' => '../skins/common/images/' . $icon,
505 'alt' => wfMsg( 'config-information' ),
509 "<div class=\"config-info-right\">\n" .
510 $this->parse( $text ) . "\n" .
512 "<div style=\"clear: left;\"></div>\n" .
518 * Get small text indented help for a preceding form field.
519 * Parameters like wfMsg().
521 function getHelpBox( $msg /*, ... */ ) {
522 $args = func_get_args();
523 array_shift( $args );
524 $args = array_map( 'htmlspecialchars', $args );
525 $text = wfMsgReal( $msg, $args, false, false, false );
526 $html = $this->parse( $text, true );
527 $id = $this->helpId++
;
528 $alt = wfMsg( 'help' );
531 "<div class=\"config-help-wrapper\">\n" .
532 "<div class=\"config-help-message\">\n" .
535 "<div class=\"config-show-help\">\n" .
537 wfMsgHtml( 'config-show-help' ) .
539 "<div class=\"config-hide-help\">\n" .
541 wfMsgHtml( 'config-hide-help' ) .
542 "</a></div>\n</div>\n";
548 function showHelpBox( $msg /*, ... */ ) {
549 $args = func_get_args();
550 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
551 $this->output
->addHTML( $html );
555 * Show a short informational message
556 * Output looks like a list.
558 function showMessage( $msg /*, ... */ ) {
559 $args = func_get_args();
560 array_shift( $args );
561 $html = '<div class="config-message">' .
562 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
564 $this->output
->addHTML( $html );
568 * Label a control by wrapping a config-input div around it and putting a
571 function label( $msg, $forId, $contents ) {
572 if ( strval( $msg ) == '' ) {
573 $labelText = ' ';
575 $labelText = wfMsgHtml( $msg );
577 $attributes = array( 'class' => 'config-label' );
579 $attributes['for'] = $forId;
582 "<div class=\"config-input\">\n" .
585 $labelText ) . "\n" .
591 * Get a labelled text box to configure a variable
593 * @param $params Array
595 * var: The variable to be configured (required)
596 * label: The message name for the label (required)
597 * attribs: Additional attributes for the input element (optional)
598 * controlName: The name for the input element (optional)
599 * value: The current value of the variable (optional)
601 function getTextBox( $params ) {
602 if ( !isset( $params['controlName'] ) ) {
603 $params['controlName'] = 'config_' . $params['var'];
605 if ( !isset( $params['value'] ) ) {
606 $params['value'] = $this->getVar( $params['var'] );
608 if ( !isset( $params['attribs'] ) ) {
609 $params['attribs'] = array();
614 $params['controlName'],
616 $params['controlName'],
617 30, // intended to be overridden by CSS
619 $params['attribs'] +
array(
620 'id' => $params['controlName'],
621 'class' => 'config-input-text',
622 'tabindex' => $this->nextTabIndex()
629 * Get a labelled password box to configure a variable
631 * Implements password hiding
632 * @param $params Array
634 * var: The variable to be configured (required)
635 * label: The message name for the label (required)
636 * attribs: Additional attributes for the input element (optional)
637 * controlName: The name for the input element (optional)
638 * value: The current value of the variable (optional)
640 function getPasswordBox( $params ) {
641 if ( !isset( $params['value'] ) ) {
642 $params['value'] = $this->getVar( $params['var'] );
644 if ( !isset( $params['attribs'] ) ) {
645 $params['attribs'] = array();
647 $params['value'] = $this->getFakePassword( $params['value'] );
648 $params['attribs']['type'] = 'password';
649 return $this->getTextBox( $params );
653 * Get a labelled checkbox to configure a boolean variable
655 * @param $params Array
657 * var: The variable to be configured (required)
658 * label: The message name for the label (required)
659 * attribs: Additional attributes for the input element (optional)
660 * controlName: The name for the input element (optional)
661 * value: The current value of the variable (optional)
663 function getCheckBox( $params ) {
664 if ( !isset( $params['controlName'] ) ) {
665 $params['controlName'] = 'config_' . $params['var'];
667 if ( !isset( $params['value'] ) ) {
668 $params['value'] = $this->getVar( $params['var'] );
670 if ( !isset( $params['attribs'] ) ) {
671 $params['attribs'] = array();
673 if( isset( $params['rawtext'] ) ) {
674 $labelText = $params['rawtext'];
676 $labelText = $this->parse( wfMsg( $params['label'] ) );
679 "<div class=\"config-input-check\">\n" .
682 $params['controlName'],
684 $params['attribs'] +
array(
685 'id' => $params['controlName'],
686 'class' => 'config-input-text',
687 'tabindex' => $this->nextTabIndex(),
696 * Get a set of labelled radio buttons
698 * @param $params Array
700 * var: The variable to be configured (required)
701 * label: The message name for the label (required)
702 * itemLabelPrefix: The message name prefix for the item labels (required)
703 * values: List of allowed values (required)
704 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
705 * commonAttribs Attribute array applied to all items
706 * controlName: The name for the input element (optional)
707 * value: The current value of the variable (optional)
709 function getRadioSet( $params ) {
710 if ( !isset( $params['controlName'] ) ) {
711 $params['controlName'] = 'config_' . $params['var'];
713 if ( !isset( $params['value'] ) ) {
714 $params['value'] = $this->getVar( $params['var'] );
716 if ( !isset( $params['label'] ) ) {
719 $label = $this->parse( wfMsgNoTrans( $params['label'] ) );
721 $s = "<label class=\"config-label\">\n" .
724 "<ul class=\"config-settings-block\">\n";
725 foreach ( $params['values'] as $value ) {
726 $itemAttribs = array();
727 if ( isset( $params['commonAttribs'] ) ) {
728 $itemAttribs = $params['commonAttribs'];
730 if ( isset( $params['itemAttribs'][$value] ) ) {
731 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
733 $checked = $value == $params['value'];
734 $id = $params['controlName'] . '_' . $value;
735 $itemAttribs['id'] = $id;
736 $itemAttribs['tabindex'] = $this->nextTabIndex();
739 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
741 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
742 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
751 * Output an error or warning box using a Status object
753 function showStatusBox( $status ) {
754 if( !$status->isGood() ) {
755 $text = $status->getWikiText();
756 if( $status->isOk() ) {
757 $box = $this->getWarningBox( $text );
759 $box = $this->getErrorBox( $text );
761 $this->output
->addHTML( $box );
765 function showStatusMessage( $status ) {
766 $text = $status->getWikiText();
767 $this->output
->addWikiText(
768 "<div class=\"config-message\">\n" .
775 * Convenience function to set variables based on form data.
776 * Assumes that variables containing "password" in the name are (potentially
779 * @param $varNames Array
780 * @param $prefix String: the prefix added to variables to obtain form names
782 function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
783 $newValues = array();
784 foreach ( $varNames as $name ) {
785 $value = trim( $this->request
->getVal( $prefix . $name ) );
786 $newValues[$name] = $value;
787 if ( $value === null ) {
789 $this->setVar( $name, false );
791 if ( stripos( $name, 'password' ) !== false ) {
792 $this->setPassword( $name, $value );
794 $this->setVar( $name, $value );
802 * Get the starting tags of a fieldset
804 * @param $legend String: message name
806 function getFieldsetStart( $legend ) {
807 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
811 * Get the end tag of a fieldset
813 function getFieldsetEnd() {
814 return "</fieldset>\n";
818 * Helper for Installer::docLink()
820 function getDocUrl( $page ) {
821 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
822 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
823 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
829 abstract class WebInstallerPage
{
830 function __construct( $parent ) {
831 $this->parent
= $parent;
834 function addHTML( $html ) {
835 $this->parent
->output
->addHTML( $html );
838 function startForm() {
840 "<div class=\"config-section\">\n" .
845 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
851 function endForm( $continue = 'continue' ) {
852 $this->parent
->output
->outputWarnings();
853 $s = "<div class=\"config-submit\">\n";
854 $id = $this->getId();
855 if ( $id === false ) {
856 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
859 // Fake submit button for enter keypress
860 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
861 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
864 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
866 'name' => 'submit-back',
867 'tabindex' => $this->parent
->nextTabIndex()
871 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
873 'name' => "submit-$continue",
874 'tabindex' => $this->parent
->nextTabIndex(),
877 $s .= "</div></form></div>\n";
878 $this->addHTML( $s );
882 return str_replace( 'WebInstaller_', '', get_class( $this ) );
886 return array_search( $this->getName(), $this->parent
->pageSequence
);
889 abstract function execute();
891 function getVar( $var ) {
892 return $this->parent
->getVar( $var );
895 function setVar( $name, $value ) {
896 $this->parent
->setVar( $name, $value );
900 class WebInstaller_Language
extends WebInstallerPage
{
903 $r = $this->parent
->request
;
904 $userLang = $r->getVal( 'UserLang' );
905 $contLang = $r->getVal( 'ContLang' );
907 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
909 $lifetime = 1440; // PHP default
912 if ( $r->wasPosted() ) {
914 if ( $this->parent
->getSession( 'test' ) === null ) {
915 $requestTime = $r->getVal( 'LanguageRequestTime' );
916 if ( !$requestTime ) {
917 // The most likely explanation is that the user was knocked back
918 // from another page on POST due to session expiry
919 $msg = 'config-session-expired';
920 } elseif ( time() - $requestTime > $lifetime ) {
921 $msg = 'config-session-expired';
923 $msg = 'config-no-session';
925 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
927 $languages = Language
::getLanguageNames();
928 if ( isset( $languages[$userLang] ) ) {
929 $this->setVar( '_UserLang', $userLang );
931 if ( isset( $languages[$contLang] ) ) {
932 $this->setVar( 'wgLanguageCode', $contLang );
933 if ( $this->getVar( '_AdminName' ) === null ) {
934 // Load localised sysop username in *content* language
935 $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) );
940 } elseif ( $this->parent
->showSessionWarning
) {
941 # The user was knocked back from another page to the start
942 # This probably indicates a session expiry
943 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
946 $this->parent
->setSession( 'test', true );
948 if ( !isset( $languages[$userLang] ) ) {
949 $userLang = $this->getVar( '_UserLang', 'en' );
951 if ( !isset( $languages[$contLang] ) ) {
952 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
956 Xml
::hidden( 'LanguageRequestTime', time() ) .
957 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
958 $this->parent
->getHelpBox( 'config-your-language-help' ) .
959 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
960 $this->parent
->getHelpBox( 'config-wiki-language-help' );
963 $this->addHTML( $s );
968 * Get a <select> for selecting languages
970 function getLanguageSelector( $name, $label, $selectedCode ) {
971 global $wgDummyLanguageCodes;
972 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
974 $languages = Language
::getLanguageNames();
976 $dummies = array_flip( $wgDummyLanguageCodes );
977 foreach ( $languages as $code => $lang ) {
978 if ( isset( $dummies[$code] ) ) continue;
979 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
981 $s .= "\n</select>\n";
982 return $this->parent
->label( $label, $name, $s );
986 class WebInstaller_Welcome
extends WebInstallerPage
{
988 if ( $this->parent
->request
->wasPosted() ) {
989 if ( $this->getVar( '_Environment' ) ) {
993 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
994 $status = $this->parent
->doEnvironmentChecks();
996 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
1003 class WebInstaller_DBConnect
extends WebInstallerPage
{
1004 function execute() {
1005 $r = $this->parent
->request
;
1006 if ( $r->wasPosted() ) {
1007 $status = $this->submit();
1008 if ( $status->isGood() ) {
1009 $this->setVar( '_UpgradeDone', false );
1012 $this->parent
->showStatusBox( $status );
1019 $types = "<ul class=\"config-settings-block\">\n";
1021 $defaultType = $this->getVar( 'wgDBtype' );
1022 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
1023 $installer = $this->parent
->getDBInstaller( $type );
1027 $installer->getReadableName(),
1031 $type == $defaultType,
1032 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1037 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1038 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1039 $installer->getConnectForm() .
1042 $types .= "</ul><br clear=\"left\"/>\n";
1045 $this->parent
->label( 'config-db-type', false, $types ) .
1053 $r = $this->parent
->request
;
1054 $type = $r->getVal( 'DBType' );
1055 $this->setVar( 'wgDBtype', $type );
1056 $installer = $this->parent
->getDBInstaller( $type );
1057 if ( !$installer ) {
1058 return Status
::newFatal( 'config-invalid-db-type' );
1060 return $installer->submitConnectForm();
1064 class WebInstaller_Upgrade
extends WebInstallerPage
{
1065 function execute() {
1066 if ( $this->getVar( '_UpgradeDone' ) ) {
1067 if ( $this->parent
->request
->wasPosted() ) {
1068 // Done message acknowledged
1071 // Back button click
1072 // Show the done message again
1073 // Make them click back again if they want to do the upgrade again
1074 $this->showDoneMessage();
1079 // wgDBtype is generally valid here because otherwise the previous page
1080 // (connect) wouldn't have declared its happiness
1081 $type = $this->getVar( 'wgDBtype' );
1082 $installer = $this->parent
->getDBInstaller( $type );
1084 if ( !$installer->needsUpgrade() ) {
1088 if ( $this->parent
->request
->wasPosted() ) {
1090 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1091 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1092 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1094 $this->parent
->output
->flush();
1095 $result = $installer->doUpgrade();
1096 $this->addHTML( '</textarea>
1097 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1098 $this->parent
->output
->flush();
1100 $this->setVar( '_UpgradeDone', true );
1101 $this->showDoneMessage();
1107 $this->addHTML( $this->parent
->getInfoBox(
1108 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1112 function showDoneMessage() {
1115 $this->parent
->getInfoBox(
1116 wfMsgNoTrans( 'config-upgrade-done',
1117 $GLOBALS['wgServer'] .
1118 $this->getVar( 'wgScriptPath' ) . '/index' .
1119 $this->getVar( 'wgScriptExtension' )
1123 $this->endForm( 'regenerate' );
1127 class WebInstaller_DBSettings
extends WebInstallerPage
{
1128 function execute() {
1129 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1131 $r = $this->parent
->request
;
1132 if ( $r->wasPosted() ) {
1133 $status = $installer->submitSettingsForm();
1134 if ( $status === false ) {
1136 } elseif ( $status->isGood() ) {
1139 $this->parent
->showStatusBox( $status );
1143 $form = $installer->getSettingsForm();
1144 if ( $form === false ) {
1149 $this->addHTML( $form );
1155 class WebInstaller_Name
extends WebInstallerPage
{
1156 function execute() {
1157 $r = $this->parent
->request
;
1158 if ( $r->wasPosted() ) {
1159 if ( $this->submit() ) {
1166 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1167 $this->setVar( 'wgSitename', '' );
1170 // Set wgMetaNamespace to something valid before we show the form.
1171 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1172 $metaNS = $this->getVar( 'wgMetaNamespace' );
1173 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1176 $this->parent
->getTextBox( array(
1177 'var' => 'wgSitename',
1178 'label' => 'config-site-name',
1180 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1181 $this->parent
->getRadioSet( array(
1182 'var' => '_NamespaceType',
1183 'label' => 'config-project-namespace',
1184 'itemLabelPrefix' => 'config-ns-',
1185 'values' => array( 'site-name', 'generic', 'other' ),
1186 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1188 $this->parent
->getTextBox( array(
1189 'var' => 'wgMetaNamespace',
1191 'attribs' => array( 'disabled' => '' ),
1193 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1194 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1195 $this->parent
->getTextBox( array(
1196 'var' => '_AdminName',
1197 'label' => 'config-admin-name'
1199 $this->parent
->getPasswordBox( array(
1200 'var' => '_AdminPassword',
1201 'label' => 'config-admin-password',
1203 $this->parent
->getPasswordBox( array(
1204 'var' => '_AdminPassword2',
1205 'label' => 'config-admin-password-confirm'
1207 $this->parent
->getHelpBox( 'config-admin-help' ) .
1208 $this->parent
->getTextBox( array(
1209 'var' => '_AdminEmail',
1210 'label' => 'config-admin-email'
1212 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1213 $this->parent
->getCheckBox( array(
1214 'var' => '_Subscribe',
1215 'label' => 'config-subscribe'
1217 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1218 $this->parent
->getFieldsetEnd() .
1219 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1220 $this->parent
->getRadioSet( array(
1221 'var' => '_SkipOptional',
1222 'itemLabelPrefix' => 'config-optional-',
1223 'values' => array( 'continue', 'skip' )
1227 // Restore the default value
1228 $this->setVar( 'wgMetaNamespace', $metaNS );
1236 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1237 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1238 '_Subscribe', '_SkipOptional' ) );
1240 // Validate site name
1241 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1242 $this->parent
->showError( 'config-site-name-blank' );
1247 $nsType = $this->getVar( '_NamespaceType' );
1248 if ( $nsType == 'site-name' ) {
1249 $name = $this->getVar( 'wgSitename' );
1250 // Sanitize for namespace
1251 // This algorithm should match the JS one in WebInstallerOutput.php
1252 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1253 $name = str_replace( '&', '&', $name );
1254 $name = preg_replace( '/__+/', '_', $name );
1255 $name = ucfirst( trim( $name, '_' ) );
1256 } elseif ( $nsType == 'generic' ) {
1257 $name = wfMsg( 'config-ns-generic' );
1259 $name = $this->getVar( 'wgMetaNamespace' );
1262 // Validate namespace
1263 if ( strpos( $name, ':' ) !== false ) {
1266 // Title-style validation
1267 $title = Title
::newFromText( $name );
1269 $good = $nsType == 'site-name' ?
true : false;
1271 $name = $title->getDBkey();
1276 $this->parent
->showError( 'config-ns-invalid', $name );
1279 $this->setVar( 'wgMetaNamespace', $name );
1281 // Validate username for creation
1282 $name = $this->getVar( '_AdminName' );
1283 if ( strval( $name ) === '' ) {
1284 $this->parent
->showError( 'config-admin-name-blank' );
1288 $cname = User
::getCanonicalName( $name, 'creatable' );
1289 if ( $cname === false ) {
1290 $this->parent
->showError( 'config-admin-name-invalid', $name );
1293 $this->setVar( '_AdminName', $cname );
1297 // Validate password
1299 $pwd = $this->getVar( '_AdminPassword' );
1300 $user = User
::newFromName( $cname );
1301 $valid = $user->getPasswordValidity( $pwd );
1302 if ( strval( $pwd ) === '' ) {
1303 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1304 # This message is more specific and helpful.
1305 $msg = 'config-admin-password-blank';
1306 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1307 $msg = 'config-admin-password-mismatch';
1308 } elseif ( $valid !== true ) {
1309 # As of writing this will only catch the username being e.g. 'FOO' and
1310 # the password 'foo'
1313 if ( $msg !== false ) {
1314 $this->parent
->showError( $msg );
1315 $this->setVar( '_AdminPassword', '' );
1316 $this->setVar( '_AdminPassword2', '' );
1323 class WebInstaller_Options
extends WebInstallerPage
{
1324 function execute() {
1325 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1328 if ( $this->parent
->request
->wasPosted() ) {
1329 if ( $this->submit() ) {
1337 $this->parent
->getRadioSet( array(
1338 'var' => '_RightsProfile',
1339 'label' => 'config-profile',
1340 'itemLabelPrefix' => 'config-profile-',
1341 'values' => array_keys( $this->parent
->rightsProfiles
),
1343 $this->parent
->getHelpBox( 'config-profile-help' ) .
1346 $this->parent
->getRadioSet( array(
1347 'var' => '_LicenseCode',
1348 'label' => 'config-license',
1349 'itemLabelPrefix' => 'config-license-',
1350 'values' => array_keys( $this->parent
->licenses
),
1351 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1353 $this->getCCChooser() .
1354 $this->parent
->getHelpBox( 'config-license-help' ) .
1357 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1358 $this->parent
->getCheckBox( array(
1359 'var' => 'wgEnableEmail',
1360 'label' => 'config-enable-email',
1361 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1363 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1364 "<div id=\"emailwrapper\">" .
1365 $this->parent
->getTextBox( array(
1366 'var' => 'wgPasswordSender',
1367 'label' => 'config-email-sender'
1369 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1370 $this->parent
->getCheckBox( array(
1371 'var' => 'wgEnableUserEmail',
1372 'label' => 'config-email-user',
1374 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1375 $this->parent
->getCheckBox( array(
1376 'var' => 'wgEnotifUserTalk',
1377 'label' => 'config-email-usertalk',
1379 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1380 $this->parent
->getCheckBox( array(
1381 'var' => 'wgEnotifWatchlist',
1382 'label' => 'config-email-watchlist',
1384 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1385 $this->parent
->getCheckBox( array(
1386 'var' => 'wgEmailAuthentication',
1387 'label' => 'config-email-auth',
1389 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1391 $this->parent
->getFieldsetEnd()
1394 $extensions = $this->parent
->findExtensions();
1396 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1397 foreach( array_keys($extensions) as $ext ) {
1398 $extHtml .= $this->parent
->getCheckBox( array(
1399 'var' => "ext-$ext",
1403 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1404 $this->parent
->getFieldsetEnd();
1405 $this->addHTML( $extHtml );
1410 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1411 $this->parent
->getCheckBox( array(
1412 'var' => 'wgEnableUploads',
1413 'label' => 'config-upload-enable',
1414 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1416 $this->parent
->getHelpBox( 'config-upload-help' ) .
1417 '<div id="uploadwrapper" style="display: none;">' .
1418 $this->parent
->getTextBox( array(
1419 'var' => 'wgDeletedDirectory',
1420 'label' => 'config-upload-deleted',
1422 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1424 $this->parent
->getTextBox( array(
1426 'label' => 'config-logo'
1428 $this->parent
->getHelpBox( 'config-logo-help' )
1430 $canUse = $this->getVar( '_ExternalHTTP' ) ?
1431 'config-instantcommons-good' : 'config-instantcommons-bad';
1433 $this->parent
->getCheckBox( array(
1434 'var' => 'wgUseInstantCommons',
1435 'label' => 'config-instantcommons',
1437 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
1438 $this->parent
->getFieldsetEnd()
1441 $caches = array( 'none' );
1442 if( count( $this->getVar( '_Caches' ) ) ) {
1443 $caches[] = 'accel';
1445 $caches[] = 'memcached';
1449 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1450 # Object cache settings
1451 $this->parent
->getRadioSet( array(
1452 'var' => 'wgMainCacheType',
1453 'label' => 'config-cache-options',
1454 'itemLabelPrefix' => 'config-cache-',
1455 'values' => $caches,
1458 $this->parent
->getHelpBox( 'config-cache-help' ) .
1459 '<div id="config-memcachewrapper">' .
1460 $this->parent
->getTextBox( array(
1461 'var' => '_MemCachedServers',
1462 'label' => 'config-memcached-servers',
1464 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
1465 $this->parent
->getFieldsetEnd()
1470 function getCCPartnerUrl() {
1472 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1473 'page' => 'Options',
1474 'SubmitCC' => 'indeed',
1475 'config__LicenseCode' => 'cc',
1476 'config_wgRightsUrl' => '[license_url]',
1477 'config_wgRightsText' => '[license_name]',
1478 'config_wgRightsIcon' => '[license_button]',
1480 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1481 '/skins/common/config-cc.css';
1482 $iframeUrl = 'http://creativecommons.org/license/?' .
1483 wfArrayToCGI( array(
1484 'partner' => 'MediaWiki',
1485 'exit_url' => $exitUrl,
1486 'lang' => $this->getVar( '_UserLang' ),
1487 'stylesheet' => $styleUrl,
1492 function getCCChooser() {
1493 $iframeAttribs = array(
1494 'class' => 'config-cc-iframe',
1495 'name' => 'config-cc-iframe',
1496 'id' => 'config-cc-iframe',
1501 if ( $this->getVar( '_CCDone' ) ) {
1502 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1504 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1508 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1509 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1513 function getCCDoneBox() {
1514 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1515 // If you change this height, also change it in config.css
1516 $expandJs = str_replace( '$1', '54em', $js );
1517 $reduceJs = str_replace( '$1', '70px', $js );
1520 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1522 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1524 "<p style=\"text-align: center\">" .
1527 'href' => $this->getCCPartnerUrl(),
1528 'onclick' => $expandJs,
1530 wfMsg( 'config-cc-again' )
1533 "<script type=\"text/javascript\">\n" .
1534 # Reduce the wrapper div height
1535 htmlspecialchars( $reduceJs ) .
1541 function submitCC() {
1542 $newValues = $this->parent
->setVarsFromRequest(
1543 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1544 if ( count( $newValues ) != 3 ) {
1545 $this->parent
->showError( 'config-cc-error' );
1548 $this->setVar( '_CCDone', true );
1549 $this->addHTML( $this->getCCDoneBox() );
1553 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1554 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1555 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1556 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
1557 'wgUseInstantCommons' ) );
1559 if ( !in_array( $this->getVar( '_RightsProfile' ),
1560 array_keys( $this->parent
->rightsProfiles
) ) )
1562 reset( $this->parent
->rightsProfiles
);
1563 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1566 $code = $this->getVar( '_LicenseCode' );
1567 if ( $code == 'cc-choose' ) {
1568 if ( !$this->getVar( '_CCDone' ) ) {
1569 $this->parent
->showError( 'config-cc-not-chosen' );
1572 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1573 $entry = $this->parent
->licenses
[$code];
1574 if ( isset( $entry['text'] ) ) {
1575 $this->setVar( 'wgRightsText', $entry['text'] );
1577 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1579 $this->setVar( 'wgRightsUrl', $entry['url'] );
1580 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1582 $this->setVar( 'wgRightsText', '' );
1583 $this->setVar( 'wgRightsUrl', '' );
1584 $this->setVar( 'wgRightsIcon', '' );
1587 $exts = $this->parent
->getVar( '_Extensions' );
1588 foreach( $exts as $key => $ext ) {
1589 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1590 unset( $exts[$key] );
1593 $this->parent
->setVar( '_Extensions', $exts );
1598 class WebInstaller_Install
extends WebInstallerPage
{
1600 function execute() {
1601 if( $this->parent
->request
->wasPosted() ) {
1603 } elseif( $this->getVar( '_InstallDone' ) ) {
1605 $status = new Status();
1606 $status->warning( 'config-install-alreadydone' );
1607 $this->parent
->showStatusBox( $status );
1610 $this->addHTML("<ul>");
1611 $this->parent
->performInstallation(
1612 array( $this, 'startStage'),
1613 array( $this, 'endStage' )
1615 $this->addHTML("</ul>");
1621 public function startStage( $step ) {
1622 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
1625 public function endStage( $step, $status ) {
1626 $success = $status->isGood();
1627 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1628 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1630 $html = "<span class=\"error\">$html</span>";
1632 $this->addHTML( $html . "</li>\n" );
1634 $this->parent
->showStatusBox( $status );
1639 class WebInstaller_Complete
extends WebInstallerPage
{
1640 public function execute() {
1644 $this->parent
->getInfoBox(
1645 wfMsgNoTrans( 'config-install-done',
1646 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
1647 $GLOBALS['wgServer'] .
1648 $this->getVar( 'wgScriptPath' ) . '/index' .
1649 $this->getVar( 'wgScriptExtension' )
1653 $this->endForm( false );
1657 class WebInstaller_Restart
extends WebInstallerPage
{
1658 function execute() {
1659 $r = $this->parent
->request
;
1660 if ( $r->wasPosted() ) {
1661 $really = $r->getVal( 'submit-restart' );
1663 $this->parent
->session
= array();
1664 $this->parent
->happyPages
= array();
1665 $this->parent
->settings
= array();
1671 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1672 $this->addHTML( $s );
1673 $this->endForm( 'restart' );
1677 abstract class WebInstaller_Document
extends WebInstallerPage
{
1678 abstract function getFileName();
1680 function execute() {
1681 $text = $this->getFileContents();
1682 $this->parent
->output
->addWikiText( $text );
1684 $this->endForm( false );
1687 function getFileContents() {
1688 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1691 protected function formatTextFile( $text ) {
1692 $text = str_replace( array( '<', '{{', '[[' ),
1693 array( '<', '{{', '[[' ), $text );
1694 // replace numbering with [1], [2], etc with MW-style numbering
1695 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1696 // join word-wrapped lines into one
1699 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1700 } while ( $text != $prev );
1701 // turn (bug nnnn) into links
1702 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1703 // add links to manual to every global variable mentioned
1704 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1705 // special case for <pre> - formatted links
1708 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1709 } while ( $text != $prev );
1713 private function replaceBugLinks( $matches ) {
1714 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1715 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1718 private function replaceConfigLinks( $matches ) {
1719 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1720 $matches[1] . ' ' . $matches[1] . ']</span>';
1724 class WebInstaller_Readme
extends WebInstaller_Document
{
1725 function getFileName() { return 'README'; }
1727 function getFileContents() {
1728 return $this->formatTextFile( parent
::getFileContents() );
1732 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1733 function getFileName() { return 'RELEASE-NOTES'; }
1735 function getFileContents() {
1736 return $this->formatTextFile( parent
::getFileContents() );
1740 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1741 function getFileName() { return 'UPGRADE'; }
1743 function getFileContents() {
1744 return $this->formatTextFile( parent
::getFileContents() );
1748 class WebInstaller_Copying
extends WebInstaller_Document
{
1749 function getFileName() { return 'COPYING'; }
1751 function getFileContents() {
1752 $text = parent
::getFileContents();
1753 $text = str_replace( "\x0C", '', $text );
1754 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1755 $text = '<tt>' . nl2br( $text ) . '</tt>';
1759 private static function replaceLeadingSpaces( $matches ) {
1760 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );