3 * Output handler for the web installer.
10 * Output class modelled on OutputPage.
12 * I've opted to use a distinct class rather than derive from OutputPage here in
13 * the interests of separation of concerns: if we used a subclass, there would be
14 * quite a lot of things you could do in OutputPage that would break the installer,
15 * that wouldn't be immediately obvious.
20 class WebInstallerOutput
{
23 * The WebInstaller object this WebInstallerOutput is used by.
29 public $contents = '';
30 public $warnings = '';
31 public $headerDone = false;
32 public $redirectTarget;
34 public $useShortHeader = false;
39 * @param $parent WebInstaller
41 public function __construct( WebInstaller
$parent ) {
42 $this->parent
= $parent;
45 public function addHTML( $html ) {
46 $this->contents
.= $html;
50 public function addWikiText( $text ) {
51 $this->addHTML( $this->parent
->parse( $text ) );
54 public function addHTMLNoFlush( $html ) {
55 $this->contents
.= $html;
58 public function addWarning( $msg ) {
59 $this->warnings
.= "<p>$msg</p>\n";
62 public function addWarningMsg( $msg /*, ... */ ) {
63 $params = func_get_args();
64 array_shift( $params );
65 $this->addWarning( wfMsg( $msg, $params ) );
68 public function redirect( $url ) {
69 if ( $this->headerDone
) {
70 throw new MWException( __METHOD__
. ' called after sending headers' );
72 $this->redirectTarget
= $url;
75 public function output() {
77 $this->outputFooter();
80 public function useShortHeader( $use = true ) {
81 $this->useShortHeader
= $use;
84 public function flush() {
85 if ( !$this->headerDone
) {
86 $this->outputHeader();
88 if ( !$this->redirectTarget
&& strlen( $this->contents
) ) {
96 public function getDir() {
98 if( !is_object( $wgLang ) ||
!$wgLang->isRtl() )
104 public function getLanguageCode() {
106 if( !is_object( $wgLang ) )
109 return $wgLang->getCode();
112 public function getHeadAttribs() {
114 'dir' => $this->getDir(),
115 'lang' => $this->getLanguageCode(),
119 public function headerDone() {
120 return $this->headerDone
;
123 public function outputHeader() {
124 $this->headerDone
= true;
125 $dbTypes = $this->parent
->getDBTypes();
127 $this->parent
->request
->response()->header("Content-Type: text/html; charset=utf-8");
128 if ( $this->redirectTarget
) {
129 $this->parent
->request
->response()->header( 'Location: '.$this->redirectTarget
);
133 if ( $this->useShortHeader
) {
134 $this->outputShortHeader();
139 <?php
echo Html
::htmlHeader( $this->getHeadAttribs() ); ?
>
141 <meta name
="robots" content
="noindex, nofollow" />
142 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
143 <title
><?php
$this->outputTitle(); ?
></title
>
144 <?php
echo Html
::linkedStyle( '../skins/common/shared.css' ) . "\n"; ?
>
145 <?php
echo Html
::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?
>
146 <?php
echo Html
::linkedStyle( '../skins/common/config.css' ) . "\n"; ?
>
147 <?php
echo Html
::inlineScript( "var dbTypes = " . Xml
::encodeJsVar( $dbTypes ) ) . "\n"; ?
>
148 <?php
echo $this->getJQuery() . "\n"; ?
>
149 <?php
echo Html
::linkedScript( '../skins/common/config.js' ) . "\n"; ?
>
152 <?php
echo Html
::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?
>
154 <style type
="text/css">
155 .config
-help
-message
{ display
: block
; }
156 .config
-show
-help
{ display
: none
; }
159 <div id
="globalWrapper">
160 <div id
="column-content">
162 <div id
="bodyContent">
164 <h1
><?php
$this->outputTitle(); ?
></h1
>
168 public function outputFooter() {
169 $this->outputWarnings();
171 if ( $this->useShortHeader
) {
182 <div id
="column-one">
183 <div
class="portlet" id
="p-logo">
184 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
185 href
="http://www.mediawiki.org/"
186 title
="Main Page"></a
>
188 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
189 <div
class='portlet'><div
class='pBody'>
191 echo $this->parent
->parse( wfMsgNoTrans( 'config-sidebar' ), true );
203 public function outputShortHeader() {
205 <?php
echo Html
::htmlHeader( $this->getHeadAttribs() ); ?
>
207 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
208 <meta name
="robots" content
="noindex, nofollow" />
209 <title
><?php
$this->outputTitle(); ?
></title
>
210 <?php
echo Html
::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?
>
211 <?php
echo Html
::linkedStyle( '../skins/common/config.css' ) . "\n"; ?
>
212 <?php
echo $this->getJQuery(); ?
>
213 <?php
echo Html
::linkedScript( '../skins/common/config.js' ); ?
>
216 <body style
="background-image: none">
220 public function outputTitle() {
222 echo htmlspecialchars( wfMsg( 'config-title', $wgVersion ) );
225 public function getJQuery() {
226 return Html
::linkedScript( "../resources/jquery/jquery.js" );
229 public function outputWarnings() {
230 $this->addHTML( $this->warnings
);
231 $this->warnings
= '';