MediaWiki  1.23.2
WebInstallerOutput.php
Go to the documentation of this file.
1 <?php
36 
42  public $parent;
43 
48  private $contents = '';
49 
54  private $headerDone = false;
55 
59  public $redirectTarget;
60 
67  public $allowFrames = false;
68 
73  private $useShortHeader = false;
74 
78  public function __construct( WebInstaller $parent ) {
79  $this->parent = $parent;
80  }
81 
85  public function addHTML( $html ) {
86  $this->contents .= $html;
87  $this->flush();
88  }
89 
93  public function addWikiText( $text ) {
94  $this->addHTML( $this->parent->parse( $text ) );
95  }
96 
100  public function addHTMLNoFlush( $html ) {
101  $this->contents .= $html;
102  }
103 
109  public function redirect( $url ) {
110  if ( $this->headerDone ) {
111  throw new MWException( __METHOD__ . ' called after sending headers' );
112  }
113  $this->redirectTarget = $url;
114  }
115 
116  public function output() {
117  $this->flush();
118  $this->outputFooter();
119  }
120 
132  public function getCSS( $dir ) {
133  // All CSS files these modules reference will be concatenated in sequence
134  // and loaded as one file.
135  $moduleNames = array(
136  'mediawiki.legacy.shared',
137  'mediawiki.skinning.interface',
138  'skins.vector.styles',
139  'mediawiki.legacy.config',
140  );
141 
142  $prepend = '';
143  $css = '';
144 
146  foreach ( $moduleNames as $moduleName ) {
148  $module = $resourceLoader->getModule( $moduleName );
149  $cssFileNames = $module->getAllStyleFiles();
150 
152  foreach ( $cssFileNames as $cssFileName ) {
153  if ( !file_exists( $cssFileName ) ) {
154  $prepend .= ResourceLoader::makeComment( "Unable to find $cssFileName." );
155  continue;
156  }
157 
158  if ( !is_readable( $cssFileName ) ) {
159  $prepend .= ResourceLoader::makeComment( "Unable to read $cssFileName. " .
160  "Please check file permissions." );
161  continue;
162  }
163 
164  try {
165 
166  if ( preg_match( '/\.less$/', $cssFileName ) ) {
167  // Run the LESS compiler for *.less files (bug 55589)
168  $compiler = ResourceLoader::getLessCompiler();
169  $cssFileContents = $compiler->compileFile( $cssFileName );
170  } else {
171  // Regular CSS file
172  $cssFileContents = file_get_contents( $cssFileName );
173  }
174 
175  if ( $cssFileContents ) {
176  // Rewrite URLs, though don't bother embedding images. While static image
177  // files may be cached, CSS returned by this function is definitely not.
178  $cssDirName = dirname( $cssFileName );
179  $css .= CSSMin::remap(
180  /* source */ $cssFileContents,
181  /* local */ $cssDirName,
182  /* remote */ '..' . str_replace(
183  array( $GLOBALS['IP'], DIRECTORY_SEPARATOR ),
184  array( '', '/' ),
185  $cssDirName
186  ),
187  /* embedData */ false
188  );
189  } else {
190  $prepend .= ResourceLoader::makeComment( "Unable to read $cssFileName." );
191  }
192  } catch ( Exception $e ) {
193  $prepend .= ResourceLoader::formatException( $e );
194  }
195 
196  $css .= "\n";
197  }
199  }
200 
201  $css = $prepend . $css;
202 
203  if ( $dir == 'rtl' ) {
204  $css = CSSJanus::transform( $css, true );
205  }
206 
207  return $css;
208  }
209 
215  private function getCssUrl() {
216  return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=' . $this->getDir() );
217  }
218 
219  public function useShortHeader( $use = true ) {
220  $this->useShortHeader = $use;
221  }
222 
223  public function allowFrames( $allow = true ) {
224  $this->allowFrames = $allow;
225  }
226 
227  public function flush() {
228  if ( !$this->headerDone ) {
229  $this->outputHeader();
230  }
231  if ( !$this->redirectTarget && strlen( $this->contents ) ) {
232  echo $this->contents;
233  flush();
234  $this->contents = '';
235  }
236  }
237 
241  public function getDir() {
242  global $wgLang;
243 
244  return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr';
245  }
246 
250  public function getLanguageCode() {
251  global $wgLang;
252 
253  return is_object( $wgLang ) ? $wgLang->getCode() : 'en';
254  }
255 
259  public function getHeadAttribs() {
260  return array(
261  'dir' => $this->getDir(),
262  'lang' => $this->getLanguageCode(),
263  );
264  }
265 
271  public function headerDone() {
272  return $this->headerDone;
273  }
274 
275  public function outputHeader() {
276  $this->headerDone = true;
277  $this->parent->request->response()->header( 'Content-Type: text/html; charset=utf-8' );
278 
279  if ( !$this->allowFrames ) {
280  $this->parent->request->response()->header( 'X-Frame-Options: DENY' );
281  }
282 
283  if ( $this->redirectTarget ) {
284  $this->parent->request->response()->header( 'Location: ' . $this->redirectTarget );
285 
286  return;
287  }
288 
289  if ( $this->useShortHeader ) {
290  $this->outputShortHeader();
291 
292  return;
293  }
294 ?>
295 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
296 <head>
297  <meta name="robots" content="noindex, nofollow" />
298  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
299  <title><?php $this->outputTitle(); ?></title>
300  <?php echo $this->getCssUrl() . "\n"; ?>
301  <?php echo $this->getJQuery() . "\n"; ?>
302  <?php echo Html::linkedScript( '../skins/common/config.js' ) . "\n"; ?>
303 </head>
304 
305 <?php echo Html::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?>
306 <div id="mw-page-base"></div>
307 <div id="mw-head-base"></div>
308 <div id="content">
309 <div id="bodyContent">
310 
311 <h1><?php $this->outputTitle(); ?></h1>
312 <?php
313  }
314 
315  public function outputFooter() {
316  if ( $this->useShortHeader ) {
317  echo Html::closeElement( 'body' ) . Html::closeElement( 'html' );
318 
319  return;
320  }
321 ?>
322 
323 </div></div>
324 
325 <div id="mw-panel">
326  <div class="portal" id="p-logo">
327  <a style="background-image: url(../skins/common/images/mediawiki.png);"
328  href="https://www.mediawiki.org/"
329  title="Main Page"></a>
330  </div>
331  <div class="portal"><div class="body">
332 <?php
333  echo $this->parent->parse( wfMessage( 'config-sidebar' )->plain(), true );
334 ?>
335  </div></div>
336 </div>
337 
338 <?php
339  echo Html::closeElement( 'body' ) . Html::closeElement( 'html' );
340  }
341 
342  public function outputShortHeader() {
343 ?>
344 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
345 <head>
346  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
347  <meta name="robots" content="noindex, nofollow" />
348  <title><?php $this->outputTitle(); ?></title>
349  <?php echo $this->getCssUrl() . "\n"; ?>
350  <?php echo $this->getJQuery(); ?>
351  <?php echo Html::linkedScript( '../skins/common/config.js' ); ?>
352 </head>
353 
354 <body style="background-image: none">
355 <?php
356  }
357 
358  public function outputTitle() {
359  global $wgVersion;
360  echo wfMessage( 'config-title', $wgVersion )->escaped();
361  }
362 
366  public function getJQuery() {
367  return Html::linkedScript( "../resources/lib/jquery/jquery.js" );
368  }
369 
370 }
WebInstallerOutput\addHTMLNoFlush
addHTMLNoFlush( $html)
Definition: WebInstallerOutput.php:94
WebInstallerOutput\addWikiText
addWikiText( $text)
Definition: WebInstallerOutput.php:87
WebInstallerOutput\redirect
redirect( $url)
Definition: WebInstallerOutput.php:103
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Html\htmlHeader
static htmlHeader( $attribs=array())
Constructs the opening html-tag with necessary doctypes depending on global variables.
Definition: Html.php:801
content
per default it will return the text for text based content
Definition: contenthandler.txt:107
$html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1530
WebInstallerOutput\$useShortHeader
bool $useShortHeader
Whether to use the limited header (used during CC license callbacks)
Definition: WebInstallerOutput.php:67
WebInstallerOutput\$headerDone
bool $headerDone
Has the header (or short header) been output?
Definition: WebInstallerOutput.php:51
ResourceLoader\formatException
static formatException( $e)
Handle exception display.
Definition: ResourceLoader.php:724
CSSMin\remap
static remap( $source, $local, $remote, $embedData=true)
Remaps CSS URL paths and automatically embeds data URIs for CSS rules or url() values preceded by an ...
Definition: CSSMin.php:187
WebInstallerOutput\getCssUrl
getCssUrl()
"<link>" to index.php?css=foobar for the "<head>"
Definition: WebInstallerOutput.php:209
WebInstaller
Class for the core installer web interface.
Definition: WebInstaller.php:30
contents
Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their contents
Definition: database.txt:2
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
$resourceLoader
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success such as when responding to a resource loader request or generating HTML output & $resourceLoader
Definition: hooks.txt:1956
WebInstallerOutput\outputHeader
outputHeader()
Definition: WebInstallerOutput.php:269
WebInstallerOutput\outputFooter
outputFooter()
Definition: WebInstallerOutput.php:309
WebInstallerOutput\__construct
__construct(WebInstaller $parent)
Definition: WebInstallerOutput.php:72
WebInstallerOutput
Output class modelled on OutputPage.
Definition: WebInstallerOutput.php:35
WebInstallerOutput\getJQuery
getJQuery()
Definition: WebInstallerOutput.php:360
WebInstallerOutput\getDir
getDir()
Definition: WebInstallerOutput.php:235
Html\closeElement
static closeElement( $element)
Returns "</$element>", except if $wgWellFormedXml is off, in which case it returns the empty string w...
Definition: Html.php:235
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
WebInstallerOutput\headerDone
headerDone()
Get whether the header has been output.
Definition: WebInstallerOutput.php:265
Html\openElement
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:166
MWException
MediaWiki exception.
Definition: MWException.php:26
WebInstallerOutput\$redirectTarget
string $redirectTarget
Definition: WebInstallerOutput.php:55
$css
$css
Definition: styleTest.css.php:50
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
WebInstallerOutput\$parent
WebInstaller $parent
The WebInstaller object this WebInstallerOutput is used by.
Definition: WebInstallerOutput.php:41
Html\linkedScript
static linkedScript( $url)
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
Definition: Html.php:589
wfMessage
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ResourceLoader\makeComment
static makeComment( $text)
Generate a CSS or JS comment block.
Definition: ResourceLoader.php:713
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
WebInstallerOutput\getCSS
getCSS( $dir)
Get the raw vector CSS, flipping if needed.
Definition: WebInstallerOutput.php:126
WebInstallerOutput\allowFrames
allowFrames( $allow=true)
Definition: WebInstallerOutput.php:217
WebInstallerOutput\outputShortHeader
outputShortHeader()
Definition: WebInstallerOutput.php:336
WebInstallerOutput\useShortHeader
useShortHeader( $use=true)
Definition: WebInstallerOutput.php:213
WebInstallerOutput\getHeadAttribs
getHeadAttribs()
Definition: WebInstallerOutput.php:253
WebInstallerOutput\outputTitle
outputTitle()
Definition: WebInstallerOutput.php:352
ResourceLoader\getLessCompiler
static getLessCompiler()
Returns LESS compiler set up for use with MediaWiki.
Definition: ResourceLoader.php:1290
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
ResourceLoader
Dynamic JavaScript and CSS resource loading system.
Definition: ResourceLoader.php:31
$dir
if(count( $args)==0) $dir
Definition: importImages.php:49
Html\linkedStyle
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
Definition: Html.php:625
WebInstallerOutput\$allowFrames
bool $allowFrames
Does the current page need to allow being used as a frame? If not, X-Frame-Options will be output to ...
Definition: WebInstallerOutput.php:62
WebInstallerOutput\$contents
String $contents
Buffered contents that haven't been output yet.
Definition: WebInstallerOutput.php:46
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
WebInstallerOutput\output
output()
Definition: WebInstallerOutput.php:110
WebInstallerOutput\flush
flush()
Definition: WebInstallerOutput.php:221
WebInstallerOutput\getLanguageCode
getLanguageCode()
Definition: WebInstallerOutput.php:244
CSSJanus\transform
static transform( $css, $swapLtrRtlInURL=false, $swapLeftRightInURL=false)
Transform an LTR stylesheet to RTL.
Definition: CSSJanus.php:139
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
$e
if( $useReadline) $e
Definition: eval.php:66
WebInstallerOutput\addHTML
addHTML( $html)
Definition: WebInstallerOutput.php:79
href
shown</td >< td > a href
Definition: All_system_messages.txt:2674
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6