4 * Output class modelled on OutputPage.
6 * I've opted to use a distinct class rather than derive from OutputPage here in
7 * the interests of separation of concerns: if we used a subclass, there would be
8 * quite a lot of things you could do in OutputPage that would break the installer,
9 * that wouldn't be immediately obvious.
14 class WebInstallerOutput
{
17 * The WebInstaller object this WebInstallerOutput is used by.
23 public $contents = '';
24 public $warnings = '';
25 public $headerDone = false;
26 public $redirectTarget;
28 public $useShortHeader = false;
33 * @param $parent WebInstaller
35 public function __construct( WebInstaller
$parent ) {
36 $this->parent
= $parent;
39 public function addHTML( $html ) {
40 $this->contents
.= $html;
44 public function addWikiText( $text ) {
45 $this->addHTML( $this->parent
->parse( $text ) );
48 public function addHTMLNoFlush( $html ) {
49 $this->contents
.= $html;
52 public function addWarning( $msg ) {
53 $this->warnings
.= "<p>$msg</p>\n";
56 public function addWarningMsg( $msg /*, ... */ ) {
57 $params = func_get_args();
58 array_shift( $params );
59 $this->addWarning( wfMsg( $msg, $params ) );
62 public function redirect( $url ) {
63 if ( $this->headerDone
) {
64 throw new MWException( __METHOD__
. ' called after sending headers' );
66 $this->redirectTarget
= $url;
69 public function output() {
71 $this->outputFooter();
74 public function useShortHeader( $use = true ) {
75 $this->useShortHeader
= $use;
78 public function flush() {
79 if ( !$this->headerDone
) {
80 $this->outputHeader();
82 if ( !$this->redirectTarget
&& strlen( $this->contents
) ) {
90 public function getDir() {
92 if( !is_object( $wgLang ) ||
!$wgLang->isRtl() )
98 public function getLanguageCode() {
100 if( !is_object( $wgLang ) )
103 return $wgLang->getCode();
106 public function getHeadAttribs() {
108 'dir' => $this->getDir(),
109 'lang' => $this->getLanguageCode(),
113 public function headerDone() {
114 return $this->headerDone
;
117 public function outputHeader() {
118 $this->headerDone
= true;
119 $dbTypes = $this->parent
->getDBTypes();
121 $this->parent
->request
->response()->header("Content-Type: text/html; charset=utf-8");
122 if ( $this->redirectTarget
) {
123 $this->parent
->request
->response()->header( 'Location: '.$this->redirectTarget
);
127 if ( $this->useShortHeader
) {
128 $this->outputShortHeader();
133 <?php
echo Html
::htmlHeader( $this->getHeadAttribs() ); ?
>
135 <meta name
="robots" content
="noindex, nofollow" />
136 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
137 <title
><?php
$this->outputTitle(); ?
></title
>
138 <?php
echo Html
::linkedStyle( '../skins/common/shared.css' ) . "\n"; ?
>
139 <?php
echo Html
::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?
>
140 <?php
echo Html
::linkedStyle( '../skins/common/config.css' ) . "\n"; ?
>
141 <?php
echo Html
::inlineScript( "var dbTypes = " . Xml
::encodeJsVar( $dbTypes ) ) . "\n"; ?
>
142 <?php
$this->outputJQuery() . "\n"; ?
>
143 <?php
echo Html
::linkedScript( '../skins/common/config.js' ) . "\n"; ?
>
146 <?php
echo Html
::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?
>
148 <style type
="text/css">
149 .config
-help
-message
{ display
: block
; }
150 .config
-show
-help
{ display
: none
; }
153 <div id
="globalWrapper">
154 <div id
="column-content">
156 <div id
="bodyContent">
158 <h1
><?php
$this->outputTitle(); ?
></h1
>
162 public function outputFooter() {
163 $this->outputWarnings();
165 if ( $this->useShortHeader
) {
176 <div id
="column-one">
177 <div
class="portlet" id
="p-logo">
178 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
179 href
="http://www.mediawiki.org/"
180 title
="Main Page"></a
>
182 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
183 <div
class='portlet'><div
class='pBody'>
185 echo $this->parent
->parse( wfMsgNoTrans( 'config-sidebar' ), true );
197 public function outputShortHeader() {
199 <?php
echo Html
::htmlHeader( $this->getHeadAttribs() ); ?
>
201 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
202 <meta name
="robots" content
="noindex, nofollow" />
203 <title
><?php
$this->outputTitle(); ?
></title
>
204 <?php
echo Html
::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?
>
205 <?php
echo Html
::linkedStyle( '../skins/common/config.css' ) . "\n"; ?
>
206 <?php
$this->outputJQuery(); ?
>
207 <?php
echo Html
::linkedScript( '../skins/common/config.js' ); ?
>
210 <body style
="background-image: none">
214 public function outputTitle() {
216 echo htmlspecialchars( wfMsg( 'config-title', $wgVersion ) );
219 public function outputJQuery() {
220 global $wgJQueryVersion;
221 echo Html
::linkedScript( "../skins/common/jquery-$wgJQueryVersion.min.js" );
224 public function outputWarnings() {
225 $this->addHTML( $this->warnings
);
226 $this->warnings
= '';