/**
  * Hook handler for CreateDefaultQuestionPageFilter hook
  * @see extensions/wikia/Answers/PrefilledDefaultQuestion.php#L15
  * @see extensions/wikia/Answers/DefaultQuestion.php#L50
  *
  * @static
  *
  * @param Title $title -- instance of Title class
  *
  * @return Bool -- is word bad or not
  */
 public static function badWordsTest($title)
 {
     wfProfileIn(__METHOD__);
     $language = RequestContext::getMain()->getLanguage();
     $phalanxModel = new PhalanxContentModel($title, $language->getCode());
     $ret = $phalanxModel->match_question_title();
     wfProfileOut(__METHOD__);
     return $ret;
 }
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * @group Slow
  * @slowExecutionTime 0.04322 ms
  * @dataProvider phalanxTitleDataProvider
  */
 public function testPhalanxContentModelTitle($title, $block, $language, $result)
 {
     $titleMock = $this->setUpTitle($title);
     $this->setUpTest($block);
     $model = new PhalanxContentModel($titleMock);
     $ret = (int) $model->match_title();
     $this->assertEquals($result, $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;
 }