* Installer for Oracle fixes
[mediawiki.git] / includes / installer / WebInstallerOutput.php
blobda31412473c169b1c2938412b2539a2c6be33743
1 <?php
2 /**
3 * Output handler for the web installer.
5 * @file
6 * @ingroup Deployment
7 */
9 /**
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.
17 * @ingroup Deployment
18 * @since 1.17
20 class WebInstallerOutput {
22 /**
23 * The WebInstaller object this WebInstallerOutput is used by.
25 * @var WebInstaller
26 */
27 public $parent;
29 public $contents = '';
30 public $warnings = '';
31 public $headerDone = false;
32 public $redirectTarget;
33 public $debug = true;
34 public $useShortHeader = false;
36 /**
37 * Constructor.
39 * @param $parent WebInstaller
41 public function __construct( WebInstaller $parent ) {
42 $this->parent = $parent;
45 public function addHTML( $html ) {
46 $this->contents .= $html;
47 $this->flush();
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() {
76 $this->flush();
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 ) ) {
89 echo $this->contents;
90 ob_flush();
91 flush();
92 $this->contents = '';
96 public function getDir() {
97 global $wgLang;
98 if( !is_object( $wgLang ) || !$wgLang->isRtl() )
99 return 'ltr';
100 else
101 return 'rtl';
104 public function getLanguageCode() {
105 global $wgLang;
106 if( !is_object( $wgLang ) )
107 return 'en';
108 else
109 return $wgLang->getCode();
112 public function getHeadAttribs() {
113 return array(
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 );
130 return;
133 if ( $this->useShortHeader ) {
134 $this->outputShortHeader();
135 return;
139 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
140 <head>
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"; ?>
150 </head>
152 <?php echo Html::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?>
153 <noscript>
154 <style type="text/css">
155 .config-help-message { display: block; }
156 .config-show-help { display: none; }
157 </style>
158 </noscript>
159 <div id="globalWrapper">
160 <div id="column-content">
161 <div id="content">
162 <div id="bodyContent">
164 <h1><?php $this->outputTitle(); ?></h1>
165 <?php
168 public function outputFooter() {
169 $this->outputWarnings();
171 if ( $this->useShortHeader ) {
173 </body></html>
174 <?php
175 return;
179 </div></div></div>
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>
187 </div>
188 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
189 <div class='portlet'><div class='pBody'>
190 <?php
191 echo $this->parent->parse( wfMsgNoTrans( 'config-sidebar' ), true );
193 </div></div>
194 </div>
196 </div>
198 </body>
199 </html>
200 <?php
203 public function outputShortHeader() {
205 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
206 <head>
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' ); ?>
214 </head>
216 <body style="background-image: none">
217 <?php
220 public function outputTitle() {
221 global $wgVersion;
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 = '';