r61271 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61270‎ | r61271 | r61272 >
Date:22:02, 19 January 2010
Author:ialex
Status:ok
Tags:
Comment:
* document a bit
* fixed some doxygen warnings
Modified paths:
  • /trunk/phase3/includes/LinkFilter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LinkFilter.php
@@ -3,7 +3,7 @@
44 /**
55 * Some functions to help implement an external link filter for spam control.
66 *
7 - * TODO: implement the filter. Currently these are just some functions to help
 7+ * @todo implement the filter. Currently these are just some functions to help
88 * maintenance/cleanupSpam.php remove links to a single specified domain. The
99 * next thing is to implement functions for checking a given page against a big
1010 * list of domains.
@@ -11,8 +11,13 @@
1212 * Another cool thing to do would be a web interface for fast spam removal.
1313 */
1414 class LinkFilter {
 15+
1516 /**
16 - * @static
 17+ * Check whether $text contains a link to $filterEntry
 18+ *
 19+ * @param $text String: text to check
 20+ * @param $filterEntry String: domainparts, see makeRegex() for more details
 21+ * @return Integer: 0 if no match or 1 if there's at least one match
1722 */
1823 static function matchEntry( $text, $filterEntry ) {
1924 $regex = LinkFilter::makeRegex( $filterEntry );
@@ -20,7 +25,11 @@
2126 }
2227
2328 /**
24 - * @static
 29+ * Builds a regex pattern for $filterEntry.
 30+ *
 31+ * @param $filterEntry String: URL, if it begins with "*.", it'll be
 32+ * replaced to match any subdomain
 33+ * @return String: regex pattern, for preg_match()
2534 */
2635 private static function makeRegex( $filterEntry ) {
2736 $regex = '!http://';
@@ -46,9 +55,9 @@
4756 *
4857 * Asterisks in any other location are considered invalid.
4958 *
50 - * @static
5159 * @param $filterEntry String: domainparts
5260 * @param $prot String: protocol
 61+ * @return String
5362 * @deprecated Use makeLikeArray() and pass result to Database::buildLike() instead
5463 */
5564 public static function makeLike( $filterEntry , $prot = 'http://' ) {
@@ -69,8 +78,8 @@
7079 }
7180
7281 /**
73 - * Make an array to be used for calls to Database::buildLike(), which will match the specified
74 - * string. There are several kinds of filter entry:
 82+ * Make an array to be used for calls to DatabaseBase::buildLike(), which
 83+ * will match the specified string. There are several kinds of filter entry:
7584 * *.domain.com - Produces http://com.domain.%, matches domain.com
7685 * and www.domain.com
7786 * domain.com - Produces http://com.domain./%, matches domain.com
@@ -81,10 +90,10 @@
8291 * domain.com/xy but not www.domain.com/xy
8392 *
8493 * Asterisks in any other location are considered invalid.
85 - *
86 - * @static
 94+ *
8795 * @param $filterEntry String: domainparts
8896 * @param $prot String: protocol
 97+ * @return Array to be passed to DatabaseBase::buildLike() or false on error
8998 */
9099 public static function makeLikeArray( $filterEntry , $prot = 'http://' ) {
91100 $db = wfGetDB( DB_MASTER );
@@ -145,7 +154,7 @@
146155
147156 /**
148157 * Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.
149 - * @static
 158+ *
150159 * @param $arr array: array to filter
151160 * @return filtered array
152161 */

Status & tagging log