Fixed some doxygen warnings
[lhc/web/wiklou.git] / includes / installer / WebInstallerOutput.php
1 <?php
2
3 /**
4 * Output class modelled on OutputPage.
5 *
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.
10 *
11 * @ingroup Deployment
12 * @since 1.17
13 */
14 class WebInstallerOutput {
15
16 /**
17 * The WebInstaller object this WebInstallerOutput is used by.
18 *
19 * @var WebInstaller
20 */
21 public $parent;
22
23 public $contents = '';
24 public $warnings = '';
25 public $headerDone = false;
26 public $redirectTarget;
27 public $debug = true;
28 public $useShortHeader = false;
29
30 /**
31 * Constructor.
32 *
33 * @param $parent WebInstaller
34 */
35 public function __construct( WebInstaller $parent ) {
36 $this->parent = $parent;
37 }
38
39 public function addHTML( $html ) {
40 $this->contents .= $html;
41 $this->flush();
42 }
43
44 public function addWikiText( $text ) {
45 $this->addHTML( $this->parent->parse( $text ) );
46 }
47
48 public function addHTMLNoFlush( $html ) {
49 $this->contents .= $html;
50 }
51
52 public function addWarning( $msg ) {
53 $this->warnings .= "<p>$msg</p>\n";
54 }
55
56 public function addWarningMsg( $msg /*, ... */ ) {
57 $params = func_get_args();
58 array_shift( $params );
59 $this->addWarning( wfMsg( $msg, $params ) );
60 }
61
62 public function redirect( $url ) {
63 if ( $this->headerDone ) {
64 throw new MWException( __METHOD__ . ' called after sending headers' );
65 }
66 $this->redirectTarget = $url;
67 }
68
69 public function output() {
70 $this->flush();
71 $this->outputFooter();
72 }
73
74 public function useShortHeader( $use = true ) {
75 $this->useShortHeader = $use;
76 }
77
78 public function flush() {
79 if ( !$this->headerDone ) {
80 $this->outputHeader();
81 }
82 if ( !$this->redirectTarget && strlen( $this->contents ) ) {
83 echo $this->contents;
84 ob_flush();
85 flush();
86 $this->contents = '';
87 }
88 }
89
90 public function getDir() {
91 global $wgLang;
92 if( !is_object( $wgLang ) || !$wgLang->isRtl() )
93 return 'ltr';
94 else
95 return 'rtl';
96 }
97
98 public function getLanguageCode() {
99 global $wgLang;
100 if( !is_object( $wgLang ) )
101 return 'en';
102 else
103 return $wgLang->getCode();
104 }
105
106 public function getHeadAttribs() {
107 return array(
108 'dir' => $this->getDir(),
109 'lang' => $this->getLanguageCode(),
110 );
111 }
112
113 public function headerDone() {
114 return $this->headerDone;
115 }
116
117 public function outputHeader() {
118 $this->headerDone = true;
119 $dbTypes = $this->parent->getDBTypes();
120
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 );
124 return;
125 }
126
127 if ( $this->useShortHeader ) {
128 $this->outputShortHeader();
129 return;
130 }
131
132 ?>
133 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
134 <head>
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"; ?>
144 </head>
145
146 <?php echo Html::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?>
147 <noscript>
148 <style type="text/css">
149 .config-help-message { display: block; }
150 .config-show-help { display: none; }
151 </style>
152 </noscript>
153 <div id="globalWrapper">
154 <div id="column-content">
155 <div id="content">
156 <div id="bodyContent">
157
158 <h1><?php $this->outputTitle(); ?></h1>
159 <?php
160 }
161
162 public function outputFooter() {
163 $this->outputWarnings();
164
165 if ( $this->useShortHeader ) {
166 ?>
167 </body></html>
168 <?php
169 return;
170 }
171 ?>
172
173 </div></div></div>
174
175
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>
181 </div>
182 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
183 <div class='portlet'><div class='pBody'>
184 <?php
185 echo $this->parent->parse( wfMsgNoTrans( 'config-sidebar' ), true );
186 ?>
187 </div></div>
188 </div>
189
190 </div>
191
192 </body>
193 </html>
194 <?php
195 }
196
197 public function outputShortHeader() {
198 ?>
199 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
200 <head>
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' ); ?>
208 </head>
209
210 <body style="background-image: none">
211 <?php
212 }
213
214 public function outputTitle() {
215 global $wgVersion;
216 echo htmlspecialchars( wfMsg( 'config-title', $wgVersion ) );
217 }
218
219 public function outputJQuery() {
220 global $wgJQueryVersion;
221 echo Html::linkedScript( "../skins/common/jquery-$wgJQueryVersion.min.js" );
222 }
223
224 public function outputWarnings() {
225 $this->addHTML( $this->warnings );
226 $this->warnings = '';
227 }
228
229 }