Example #1
0
 /**
  * Performs spam check for 3rd party extension. Third parameter will be provided with matching block data
  *
  * @param $text string content to check for spam
  * @param $typeId int block type (see Phalanx::TYPE_* constants)
  * @param $blockData array array to be provided with matching block details (pass as a reference)
  * @return boolean spam check result
  *
  * @author macbre
  */
 public static function onSpamFilterCheck($text, $typeId, &$blockData)
 {
     wfProfileIn(__METHOD__);
     if ($text === '') {
         wfProfileOut(__METHOD__);
         return true;
     }
     if (!$typeId) {
         $typeId = PhalanxModel::determineTypeId($text);
     }
     $model = PhalanxModel::newFromType($typeId, $text);
     if (is_null($model)) {
         throw new WikiaException("Unsupported block type passed - #{$typeId}");
     }
     // get type ID -> type mapping
     $types = Phalanx::getAllTypeNames();
     $ret = $model->match($types[$typeId]);
     // pass matching block details
     if ($ret === false) {
         $blockData = (array) $model->getBlock();
         wfDebug(__METHOD__ . ": spam check blocked '{$text}'\n");
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
 /**
  * @param Title $title
  * @param string $lang
  * @param int $id
  */
 public function __construct($title, $lang = null, $id = 0)
 {
     parent::__construct(__CLASS__, array('title' => $title, 'lang' => $lang, 'id' => $id));
 }
Example #3
0
 public function __construct($user, $lang = '', $id = 0)
 {
     parent::__construct(__CLASS__, array('user' => $user, 'lang' => $lang, 'id' => $id));
 }
Example #4
0
 /**
  * Test models factory
  *
  * @dataProvider phalanxNewFromTypeProvider
  */
 public function testPhalanxNewFromType($type, $content, $className, $methodName)
 {
     $model = PhalanxModel::newFromType($type, $content);
     if ($className === false) {
         $this->assertNull($model);
     } else {
         $this->assertInstanceOf($className, $model);
         $this->assertEquals($content, $model->{$methodName}());
     }
 }
Example #5
0
 public function __construct($text, $lang = '', $id = 0)
 {
     parent::__construct(__CLASS__, array('text' => $text, 'lang' => $lang, 'id' => $id));
 }