* @ingroup Deployment
* @since 1.17
*/
-class WebInstaller extends CoreInstaller {
+class WebInstaller extends Installer {
/**
* @var WebInstallerOutput
*
* @var array
*/
- public $session;
+ protected $session;
/**
* Captured PHP error text. Temporary.
+ * @var array
*/
- public $phpErrors;
+ protected $phpErrors;
/**
* The main sequence of page names. These will be displayed in turn.
* * Add it here
* * Add a config-page-<name> message
* * Add a WebInstaller_<name> class
+ * @var array
*/
public $pageSequence = array(
'Language',
+ 'ExistingWiki',
'Welcome',
'DBConnect',
'Upgrade',
/**
* Out of sequence pages, selectable by the user at any time.
+ * @var array
*/
- public $otherPages = array(
+ protected $otherPages = array(
'Restart',
'Readme',
'ReleaseNotes',
/**
* Array of pages which have declared that they have been submitted, have validated
* their input, and need no further processing.
+ * @var array
*/
- public $happyPages;
+ protected $happyPages;
/**
* List of "skipped" pages. These are pages that will automatically continue
* to the next page on any GET request. To avoid breaking the "back" button,
* they need to be skipped during a back operation.
+ * @var array
*/
- public $skippedPages;
+ protected $skippedPages;
/**
* Flag indicating that session data may have been lost.
+ * @var bool
*/
public $showSessionWarning = false;
- public $tabIndex = 1;
+ /**
+ * Numeric index of the page we're on
+ * @var int
+ */
+ protected $tabIndex = 1;
- public $currentPageName;
+ /**
+ * Name of the page we're on
+ * @var string
+ */
+ protected $currentPageName;
/**
* Constructor.
parent::__construct();
$this->output = new WebInstallerOutput( $this );
$this->request = $request;
+
+ // Add parser hooks
+ global $wgParser;
+ $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
+ $wgParser->setHook( 'doclink', array( $this, 'docLink' ) );
}
/**
if ( $this->request->getVal( 'SubmitCC' ) ) {
$page = $this->getPageByName( 'Options' );
$this->output->useShortHeader();
+ $this->output->allowFrames();
$page->submitCC();
return $this->finish();
}
if ( $this->request->getVal( 'ShowCC' ) ) {
$page = $this->getPageByName( 'Options' );
$this->output->useShortHeader();
+ $this->output->allowFrames();
$this->output->addHTML( $page->getCCDoneBox() );
return $this->finish();
}
# Get the page name.
$pageName = $this->request->getVal( 'page' );
- # Check LocalSettings status
- $localSettings = $this->getLocalSettingsStatus();
-
- if( !$localSettings->isGood() && $this->getVar( '_LocalSettingsLocked' ) ) {
- $pageName = 'Locked';
- $pageId = false;
- $page = $this->getPageByName( $pageName );
- $page->setLocalSettingsStatus( $localSettings );
- } elseif ( in_array( $pageName, $this->otherPages ) ) {
+ if ( in_array( $pageName, $this->otherPages ) ) {
# Out of sequence
$pageId = false;
$page = $this->getPageByName( $pageName );
return $this->finish();
}
+ /**
+ * Find the next page in sequence that hasn't been completed
+ * @return int
+ */
public function getLowestUnhappy() {
if ( count( $this->happyPages ) == 0 ) {
return 0;
* Start the PHP session. This may be called before execute() to start the PHP session.
*/
public function startSession() {
- $sessPath = $this->getSessionSavePath();
-
- if( $sessPath != '' ) {
- if( strval( ini_get( 'open_basedir' ) ) != '' ) {
- // we need to skip the following check when open_basedir is on.
- // The session path probably *wont* be writable by the current
- // user, and telling them to change it is bad. Bug 23021.
- } elseif( !is_dir( $sessPath ) || !is_writeable( $sessPath ) ) {
- $this->showError( 'config-session-path-bad', $sessPath );
- return false;
- }
- } else {
- // If the path is unset it'll default to some system bit, which *probably* is ok...
- // not sure how to actually get what will be used.
- }
-
if( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
// Done already
return true;
return true;
}
- /**
- * Get the value of session.save_path
- *
- * Per http://www.php.net/manual/en/session.configuration.php#ini.session.save-path,
- * this may have an initial integer value to indicate the depth of session
- * storage (eg /tmp/a/b/c). Explode on ; and check and see if this part is
- * there or not. Should also allow paths with semicolons in them (if you
- * really wanted your session files stored in /tmp/some;dir) which PHP
- * supposedly supports.
- *
- * @return String
- */
- private function getSessionSavePath() {
- $parts = explode( ';', ini_get( 'session.save_path' ), 2 );
- return count( $parts ) == 1 ? $parts[0] : $parts[1];
- }
-
/**
* Get a hash of data identifying this MW installation.
*
- * This is used by config/index.php to prevent multiple installations of MW
+ * This is used by mw-config/index.php to prevent multiple installations of MW
* on the same cookie domain from interfering with each other.
*/
public function getFingerprint() {
// Get the base URL of the installation
$url = $this->request->getFullRequestURL();
+ if ( preg_match( '!^(.*\?)!', $url, $m) ) {
+ // Trim query string
+ $url = $m[1];
+ }
if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
+ // This... seems to try to get the base path from
+ // the /mw-config/index.php. Kinda scary though?
$url = $m[1];
}
return md5( serialize( array(
return $this->session;
}
+ /**
+ * We're restarting the installation, reset the session, happyPages, etc
+ */
+ public function reset() {
+ $this->session = array();
+ $this->happyPages = array();
+ $this->settings = array();
+ }
+
/**
* Get a URL for submission back to the same script.
*
* @param $query: Array
+ * @return string
*/
public function getUrl( $query = array() ) {
$url = $this->request->getRequestURL();
* Get a WebInstallerPage by name.
*
* @param $pageName String
- *
* @return WebInstallerPage
*/
public function getPageByName( $pageName ) {
- // Totally lame way to force autoload of WebInstallerPage.php
- class_exists( 'WebInstallerPage' );
-
$pageClass = 'WebInstaller_' . $pageName;
return new $pageClass( $this );
/**
* Set a session variable.
+ * @param $name String key for the variable
+ * @param $value Mixed
*/
public function setSession( $name, $value ) {
$this->session[$name] = $value;
/**
* Get the next tabindex attribute value.
+ * @return int
*/
public function nextTabIndex() {
return $this->tabIndex++;
}
$s .= "</ul><br/><ul>\n";
-
- foreach ( $this->otherPages as $pageName ) {
- $s .= $this->getPageListItem( $pageName, true, $currentPageName );
- }
-
+ $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
$s .= "</ul></div>\n"; // end list pane
$s .= Html::element( 'h2', array(),
wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
*/
private function endPageWrapper() {
$this->output->addHTMLNoFlush(
- "</div>\n" .
- "<br style=\"clear:both\"/>\n" .
+ "<div class=\"visualClear\"></div>\n" .
+ "</div>\n" .
+ "<div class=\"visualClear\"></div>\n" .
"</div>" );
}
) . "\n" .
"</div>\n" .
"<div class=\"config-info-right\">\n" .
- $this->parse( $text ) . "\n" .
+ $this->parse( $text, true ) . "\n" .
"</div>\n" .
"<div style=\"clear: left;\"></div>\n" .
"</div>\n";
$text = wfMsgReal( $msg, $args, false, false, false );
$html = htmlspecialchars( $text );
$html = $this->parse( $text, true );
-
-
+
return "<div class=\"mw-help-field-container\">\n" .
- "<span class=\"mw-help-field-hint\">" . wfMsgHtml( 'config-help' ) . "</span>\n" .
- "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
- "</div>\n";
+ "<span class=\"mw-help-field-hint\">" . wfMsgHtml( 'config-help' ) . "</span>\n" .
+ "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
+ "</div>\n";
}
/**
* Output a help box.
+ * @param $msg String key for wfMsg()
*/
public function showHelpBox( $msg /*, ... */ ) {
$args = func_get_args();
return
"<div class=\"config-block\">\n" .
- " <div class=\"config-block-label\">\n" .
+ " <div class=\"config-block-label\">\n" .
Xml::tags( 'label',
$attributes,
$labelText ) . "\n" .
- $helpData .
+ $helpData .
" </div>\n" .
- " <div class=\"config-block-elements\">\n" .
- $contents .
+ " <div class=\"config-block-elements\">\n" .
+ $contents .
" </div>\n" .
"</div>\n";
}
);
}
+ /**
+ * Get a labelled textarea to configure a variable
+ *
+ * @param $params Array
+ * Parameters are:
+ * var: The variable to be configured (required)
+ * label: The message name for the label (required)
+ * attribs: Additional attributes for the input element (optional)
+ * controlName: The name for the input element (optional)
+ * value: The current value of the variable (optional)
+ * help: The html for the help text (optional)
+ */
+ public function getTextArea( $params ) {
+ if ( !isset( $params['controlName'] ) ) {
+ $params['controlName'] = 'config_' . $params['var'];
+ }
+
+ if ( !isset( $params['value'] ) ) {
+ $params['value'] = $this->getVar( $params['var'] );
+ }
+
+ if ( !isset( $params['attribs'] ) ) {
+ $params['attribs'] = array();
+ }
+ if ( !isset( $params['help'] ) ) {
+ $params['help'] = "";
+ }
+ return
+ $this->label(
+ $params['label'],
+ $params['controlName'],
+ Xml::textarea(
+ $params['controlName'],
+ $params['value'],
+ 30,
+ 5,
+ $params['attribs'] + array(
+ 'id' => $params['controlName'],
+ 'class' => 'config-input-text',
+ 'tabindex' => $this->nextTabIndex()
+ )
+ ),
+ $params['help']
+ );
+ }
+
/**
* Get a labelled password box to configure a variable.
*
return $url;
}
+ /**
+ * Extension tag hook for a documentation link.
+ */
+ public function docLink( $linkText, $attribs, $parser ) {
+ $url = $this->getDocUrl( $attribs['href'] );
+ return '<a href="' . htmlspecialchars( $url ) . '">' .
+ htmlspecialchars( $linkText ) .
+ '</a>';
+ }
+
+ /**
+ * Helper for "Download LocalSettings" link on WebInstall_Complete
+ * @return String Html for download link
+ */
+ public function downloadLinkHook( $text, $attribs, $parser ) {
+ $img = Html::element( 'img', array(
+ 'src' => '../skins/common/images/download-32.png',
+ 'width' => '32',
+ 'height' => '32',
+ ) );
+ $anchor = Html::rawElement( 'a',
+ array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
+ $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) );
+ return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
+ }
}