Beispiel #1
0
 /**
  * @group Slow
  * @slowExecutionTime 0.04324 ms
  * @dataProvider phalanxContentModelDataProvider
  */
 public function testPhalanxContentModelContent($title, $text, $summary, $block_text, $block_summary, $result_text, $result_summary)
 {
     $titleMock = $this->setUpTitle($title);
     $this->setUpTest($block_text);
     $model = new PhalanxContentModel($titleMock);
     $ret = (int) $model->match_content($text);
     $this->assertEquals($result_text, $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;
 }