r99750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99749‎ | r99750 | r99751 >
Date:00:45, 14 October 2011
Author:catrope
Status:ok
Tags:
Comment:
Fix comment indentation and kill orphaned replaceRelativeLinks() code
Modified paths:
  • /trunk/extensions/Contest/Contest.hooks.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.hooks.php
@@ -162,9 +162,9 @@
163163 }
164164
165165 /**
166 - * Used when generating internal and interwiki links in Linker::link(),
167 - * just before the function returns a value.
168 - * @see https://www.mediawiki.org/wiki/Manual:Hooks/LinkEnd
 166+ * Used when generating internal and interwiki links in Linker::link(),
 167+ * just before the function returns a value.
 168+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/LinkEnd
169169 *
170170 * @since 0.1
171171 *
Index: trunk/extensions/Contest/includes/ContestUtils.php
@@ -53,11 +53,6 @@
5454
5555 $article = new Article( $title, 0 );
5656
57 - // Looks like the LinkEnd hook can be used here instead of replaceRelativeLinks.
58 - // The hook could just turn relative urls into absolute ones in a nice way,
59 - // but would require setting some global such as $isContestEmailParse to true
60 - // before the parse call and to false afterwards, which also is not very nice.
61 -
6257 global $wgParser, $wgContestEmailParse;
6358
6459 $wgContestEmailParse = true;
@@ -72,36 +67,4 @@
7368
7469 return $text;
7570 }
76 -
77 - /**
78 - * Returns the provided wikitext with internal (relative) links replaced by their external equivalents.
79 - * ie turns [[Foo]] into [someurl/Foo Foo]
80 - *
81 - * This replacing is quite evil; if the parser can just do this,
82 - * we should make use of that instead of doing it here.
83 - *
84 - * @since 0.1
85 - *
86 - * @param string $wikiText
87 - *
88 - * @return string
89 - */
90 - public static function replaceRelativeLinks( $wikiText ) {
91 - $url = substr( Title::newFromText( 'a' )->getFullUrl(), 0, -1 );
92 -
93 - $wikiText = preg_replace(
94 - '/\[\[(?!(Category|Image|File|[^\s]{2,5}:))([^\|\]]*)\|([^\]]*)\]\]/e',
95 - "'[" . $url . "'.str_replace(' ', '_', '\\2').' \\3]'",
96 - $wikiText
97 - );
98 -
99 - $wikiText = preg_replace(
100 - '/\[\[((?!(Category|Image|File|[^\s]{2,5}:))[^\]]*)\]\]/e',
101 - "'[" . $url . "'.str_replace(' ', '_', '\\1').' \\1]'",
102 - $wikiText
103 - );
104 -
105 - return $wikiText;
106 - }
107 -
10871 }

Status & tagging log