/**
  * 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 #2
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);
 }
 public static function abortMove($oldTitle, $newTitle, $user, &$error, $reason)
 {
     wfProfileIn(__METHOD__);
     if (self::isContentBlockingDisabled()) {
         wfProfileOut(__METHOD__);
         wfDebug(__METHOD__ . ": content blocking disabled by \$wgPhalanxDisableContent\n");
         return true;
     }
     $phalanxModel = new PhalanxContentModel($newTitle);
     $ret = $phalanxModel->match_title();
     if ($ret !== false) {
         /* compare reason with spam-whitelist - WTF? */
         if (!empty($reason) && is_null(self::$whitelist)) {
             self::$whitelist = $phalanxModel->buildWhiteList();
         }
         /* check reason - WHY? */
         if (!empty(self::$whitelist)) {
             $reason = preg_replace(self::$whitelist, '', $reason);
         }
         $ret = $phalanxModel->match_summary($reason);
     }
     if ($ret === false) {
         $error .= $phalanxModel->reasonBlock();
     }
     wfProfileOut(__METHOD__);
     return true;
 }