[FileBackend] Added getScopedLocksForOps() function.
[lhc/web/wiklou.git] / includes / installer / InstallDocFormatter.php
1 <?php
2
3 class InstallDocFormatter {
4 static function format( $text ) {
5 $obj = new self( $text );
6 return $obj->execute();
7 }
8
9 protected function __construct( $text ) {
10 $this->text = $text;
11 }
12
13 protected function execute() {
14 $text = $this->text;
15 // Use Unix line endings, escape some wikitext stuff
16 $text = str_replace( array( '<', '{{', '[[', "\r" ),
17 array( '&lt;', '&#123;&#123;', '&#91;&#91;', '' ), $text );
18 // join word-wrapped lines into one
19 do {
20 $prev = $text;
21 $text = preg_replace( "/\n([\\*#\t])([^\n]*?)\n([^\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
22 } while ( $text != $prev );
23 // Replace tab indents with colons
24 $text = preg_replace( '/^\t\t/m', '::', $text );
25 $text = preg_replace( '/^\t/m', ':', $text );
26 // turn (bug nnnn) into links
27 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
28 // add links to manual to every global variable mentioned
29 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
30 return $text;
31 }
32
33 protected function replaceBugLinks( $matches ) {
34 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
35 $matches[1] . ' bug ' . $matches[1] . ']</span>';
36 }
37
38 protected function replaceConfigLinks( $matches ) {
39 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
40 $matches[1] . ' ' . $matches[1] . ']</span>';
41 }
42 }