/** * handler for pageTitleFilter hook * * @static * * @param Title $title -- title for checking * @param String $error_msg -- returned message, by reference * * @return bool true -- pass hook further */ public static function pageTitleFilter($title, &$error_msg) { wfProfileIn(__METHOD__); $phalanxModel = new PhalanxContentModel($title); $ret = $phalanxModel->match_title(); if ($ret === false) { $error_msg = $phalanxModel->contentBlock(); } wfProfileOut(__METHOD__); return $ret; }
/** * @static * * hook * @param $textbox string * @param $error_msg string * @param $phalanxModel PhalanxModel * @param $errorFunctionName string */ public static function editContent($textbox, &$error_msg, $phalanxModel = null, $errorFunctionName = null) { wfProfileIn(__METHOD__); $title = RequestContext::getMain()->getTitle(); if (is_null($phalanxModel)) { $phalanxModel = new PhalanxContentModel($title); } /* compare summary with spam-whitelist */ if (!empty($textbox) && is_null(self::$whitelist)) { self::$whitelist = $phalanxModel->buildWhiteList(); } /* check content */ if (!empty(self::$whitelist)) { $textbox = preg_replace(self::$whitelist, '', $textbox); } /* check in Phalanx service */ $ret = $phalanxModel->match_content($textbox); if ($ret === false) { if ($errorFunctionName !== null) { $error_msg = call_user_func(array($phalanxModel, $errorFunctionName)); } else { $error_msg = $phalanxModel->contentBlock(); } } wfProfileOut(__METHOD__); return $ret; }