* consolidate some installer functionals into the Installer class
[lhc/web/wiklou.git] / includes / installer / CliInstallerOutput.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 class CliInstallerOutput {
12
13 function __construct( $parent ) {
14 $this->parent = $parent;
15 }
16
17 function addHTML( $html ) {
18 $this->contents .= $html;
19 }
20
21 function addWikiText( $text ) {
22 $this->addHTML( $this->parent->parse( $text ) );
23 }
24
25 function addHTMLNoFlush( $html ) {
26 $this->contents .= $html;
27 }
28
29 function addWarning( $msg ) {
30 $this->warnings .= "<p>$msg</p>\n";
31 }
32
33 function addWarningMsg( $msg /*, ... */ ) {
34 $params = func_get_args();
35 array_shift( $params );
36 $this->addWarning( wfMsg( $msg, $params ) );
37 }
38
39 function redirect( $url ) {
40 if ( $this->headerDone ) {
41 throw new MWException( __METHOD__ . ' called after sending headers' );
42 }
43 $this->redirectTarget = $url;
44 }
45
46 function output() {
47 $this->flush();
48 $this->outputFooter();
49 }
50
51 function useShortHeader( $use = true ) {
52 }
53
54 function flush() {
55 echo $this->contents;
56 flush();
57 $this->contents = '';
58 }
59
60 function getDir() {
61 global $wgLang;
62 if( !is_object( $wgLang ) || !$wgLang->isRtl() )
63 return 'ltr';
64 else
65 return 'rtl';
66 }
67
68 function getLanguageCode() {
69 global $wgLang;
70 if( !is_object( $wgLang ) )
71 return 'en';
72 else
73 return $wgLang->getCode();
74 }
75
76 function outputWarnings() {
77 $this->addHTML( $this->warnings );
78 $this->warnings = '';
79 }
80
81 function outputFooter() {}
82
83 }