X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FInstallDocFormatter.php;h=08cfd8689a76506ae7d6b06e15d10caf68b15d3e;hb=02f35caa16fa574bb36a1d22eea62c3b250de235;hp=6d3819cd42adf52ebc8260019bb82a22d51762fb;hpb=26aac7550a1454ce51c4cc988450418f74592bbe;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/InstallDocFormatter.php b/includes/installer/InstallDocFormatter.php index 6d3819cd42..08cfd8689a 100644 --- a/includes/installer/InstallDocFormatter.php +++ b/includes/installer/InstallDocFormatter.php @@ -21,7 +21,7 @@ */ class InstallDocFormatter { - static function format( $text ) { + public static function format( $text ) { $obj = new self( $text ); return $obj->execute(); @@ -34,8 +34,8 @@ class InstallDocFormatter { protected function execute() { $text = $this->text; // Use Unix line endings, escape some wikitext stuff - $text = str_replace( array( '<', '{{', '[[', '__', "\r" ), - array( '<', '{{', '[[', '__', '' ), $text ); + $text = str_replace( [ '<', '{{', '[[', '__', "\r" ], + [ '<', '{{', '[[', '__', '' ], $text ); // join word-wrapped lines into one do { $prev = $text; @@ -44,25 +44,31 @@ class InstallDocFormatter { // Replace tab indents with colons $text = preg_replace( '/^\t\t/m', '::', $text ); $text = preg_replace( '/^\t/m', ':', $text ); + + $linkStart = '['; + $linkEnd = ' $0]'; + + // turn (Tnnnn) into links + $text = preg_replace( + '/T\d+/', + "{$linkStart}https://phabricator.wikimedia.org/$0{$linkEnd}", + $text + ); + // turn (bug nnnn) into links - $text = preg_replace_callback( '/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text ); + $text = preg_replace( + '/bug (\d+)/', + "{$linkStart}https://bugzilla.wikimedia.org/$1{$linkEnd}", + $text + ); + // add links to manual to every global variable mentioned - $text = preg_replace_callback( - '/(\$wg[a-z0-9_]+)/i', - array( $this, 'replaceConfigLinks' ), + $text = preg_replace( + '/\$wg[a-z0-9_]+/i', + "{$linkStart}https://www.mediawiki.org/wiki/Manual:$0{$linkEnd}", $text ); return $text; } - - protected function replaceBugLinks( $matches ) { - return '[https://bugzilla.wikimedia.org/' . - $matches[1] . ' bug ' . $matches[1] . ']'; - } - - protected function replaceConfigLinks( $matches ) { - return '[http://www.mediawiki.org/wiki/Manual:' . - $matches[1] . ' ' . $matches[1] . ']'; - } }