当前位置: 首页>>代码示例>>PHP>>正文


PHP EditPage::matchSummarySpamRegex方法代码示例

本文整理汇总了PHP中EditPage::matchSummarySpamRegex方法的典型用法代码示例。如果您正苦于以下问题:PHP EditPage::matchSummarySpamRegex方法的具体用法?PHP EditPage::matchSummarySpamRegex怎么用?PHP EditPage::matchSummarySpamRegex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EditPage的用法示例。


在下文中一共展示了EditPage::matchSummarySpamRegex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkPermissions

 public function checkPermissions(User $user, $reason)
 {
     $status = new Status();
     $errors = wfMergeErrorArrays($this->oldTitle->getUserPermissionsErrors('move', $user), $this->oldTitle->getUserPermissionsErrors('edit', $user), $this->newTitle->getUserPermissionsErrors('move-target', $user), $this->newTitle->getUserPermissionsErrors('edit', $user));
     // Convert into a Status object
     if ($errors) {
         foreach ($errors as $error) {
             call_user_func_array(array($status, 'fatal'), $error);
         }
     }
     if (EditPage::matchSummarySpamRegex($reason) !== false) {
         // This is kind of lame, won't display nice
         $status->fatal('spamprotectiontext');
     }
     # The move is allowed only if (1) the target doesn't exist, or
     # (2) the target is a redirect to the source, and has no history
     # (so we can undo bad moves right after they're done).
     if ($this->newTitle->getArticleID()) {
         # Target exists; check for validity
         if (!$this->isValidMoveTarget()) {
             $status->fatal('articleexists');
         }
     } else {
         $tp = $this->newTitle->getTitleProtection();
         if ($tp !== false) {
             if (!$user->isAllowed($tp['permission'])) {
                 $status->fatal('cantmove-titleprotected');
             }
         }
     }
     Hooks::run('MovePageCheckPermissions', array($this->oldTitle, $this->newTitle, $user, $reason, $status));
     return $status;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:33,代码来源:MovePage.php

示例2: getFormFields

 protected function getFormFields()
 {
     $that = $this;
     $fields = array('pagetitle' => array('type' => 'text', 'name' => 'pagetitle', 'default' => $this->par, 'label-message' => 'changecontentmodel-title-label', 'validation-callback' => array($this, 'validateTitle')));
     if ($this->title) {
         $fields['pagetitle']['readonly'] = true;
         $fields += array('model' => array('type' => 'select', 'name' => 'model', 'options' => $this->getOptionsForTitle($this->title), 'label-message' => 'changecontentmodel-model-label'), 'reason' => array('type' => 'text', 'name' => 'reason', 'validation-callback' => function ($reason) use($that) {
             $match = EditPage::matchSummarySpamRegex($reason);
             if ($match) {
                 return $that->msg('spamprotectionmatch', $match)->parse();
             }
             return true;
         }, 'label-message' => 'changecontentmodel-reason-label'));
     }
     return $fields;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:16,代码来源:SpecialChangeContentModel.php

示例3: getFormFields

 protected function getFormFields()
 {
     $fields = ['pagetitle' => ['type' => 'title', 'creatable' => true, 'name' => 'pagetitle', 'default' => $this->par, 'label-message' => 'changecontentmodel-title-label', 'validation-callback' => [$this, 'validateTitle']]];
     if ($this->title) {
         $options = $this->getOptionsForTitle($this->title);
         if (empty($options)) {
             throw new ErrorPageError('changecontentmodel-emptymodels-title', 'changecontentmodel-emptymodels-text', $this->title->getPrefixedText());
         }
         $fields['pagetitle']['readonly'] = true;
         $fields += ['model' => ['type' => 'select', 'name' => 'model', 'options' => $options, 'label-message' => 'changecontentmodel-model-label'], 'reason' => ['type' => 'text', 'name' => 'reason', 'validation-callback' => function ($reason) {
             $match = EditPage::matchSummarySpamRegex($reason);
             if ($match) {
                 return $this->msg('spamprotectionmatch', $match)->parse();
             }
             return true;
         }, 'label-message' => 'changecontentmodel-reason-label']];
     }
     return $fields;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:19,代码来源:SpecialChangeContentModel.php

示例4: checkPermissions

 public function checkPermissions(User $user, $reason)
 {
     $status = new Status();
     $errors = wfMergeErrorArrays($this->oldTitle->getUserPermissionsErrors('move', $user), $this->oldTitle->getUserPermissionsErrors('edit', $user), $this->newTitle->getUserPermissionsErrors('move-target', $user), $this->newTitle->getUserPermissionsErrors('edit', $user));
     // Convert into a Status object
     if ($errors) {
         foreach ($errors as $error) {
             call_user_func_array(array($status, 'fatal'), $error);
         }
     }
     if (EditPage::matchSummarySpamRegex($reason) !== false) {
         // This is kind of lame, won't display nice
         $status->fatal('spamprotectiontext');
     }
     $tp = $this->newTitle->getTitleProtection();
     if ($tp !== false && !$user->isAllowed($tp['permission'])) {
         $status->fatal('cantmove-titleprotected');
     }
     Hooks::run('MovePageCheckPermissions', array($this->oldTitle, $this->newTitle, $user, $reason, $status));
     return $status;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:21,代码来源:MovePage.php

示例5: isValidMoveOperation

 /**
  * Check whether a given move operation would be valid.
  * Returns true if ok, or a getUserPermissionsErrors()-like array otherwise
  *
  * @param $nt Title the new title
  * @param $auth Bool indicates whether $wgUser's permissions
  *  should be checked
  * @param $reason String is the log summary of the move, used for spam checking
  * @return Mixed True on success, getUserPermissionsErrors()-like array on failure
  */
 public function isValidMoveOperation(&$nt, $auth = true, $reason = '')
 {
     global $wgUser;
     $errors = array();
     if (!$nt) {
         // Normally we'd add this to $errors, but we'll get
         // lots of syntax errors if $nt is not an object
         return array(array('badtitletext'));
     }
     if ($this->equals($nt)) {
         $errors[] = array('selfmove');
     }
     if (!$this->isMovable()) {
         $errors[] = array('immobile-source-namespace', $this->getNsText());
     }
     if ($nt->getInterwiki() != '') {
         $errors[] = array('immobile-target-namespace-iw');
     }
     if (!$nt->isMovable()) {
         $errors[] = array('immobile-target-namespace', $nt->getNsText());
     }
     $oldid = $this->getArticleID();
     $newid = $nt->getArticleID();
     if (strlen($nt->getDBkey()) < 1) {
         $errors[] = array('articleexists');
     }
     if ($this->getDBkey() == '' || !$oldid || $nt->getDBkey() == '') {
         $errors[] = array('badarticleerror');
     }
     // Image-specific checks
     if ($this->getNamespace() == NS_FILE) {
         $errors = array_merge($errors, $this->validateFileMoveOperation($nt));
     }
     if ($nt->getNamespace() == NS_FILE && $this->getNamespace() != NS_FILE) {
         $errors[] = array('nonfile-cannot-move-to-file');
     }
     if ($auth) {
         $errors = wfMergeErrorArrays($errors, $this->getUserPermissionsErrors('move', $wgUser), $this->getUserPermissionsErrors('edit', $wgUser), $nt->getUserPermissionsErrors('move-target', $wgUser), $nt->getUserPermissionsErrors('edit', $wgUser));
     }
     $match = EditPage::matchSummarySpamRegex($reason);
     if ($match !== false) {
         // This is kind of lame, won't display nice
         $errors[] = array('spamprotectiontext');
     }
     $err = null;
     if (!wfRunHooks('AbortMove', array($this, $nt, $wgUser, &$err, $reason))) {
         $errors[] = array('hookaborted', $err);
     }
     # The move is allowed only if (1) the target doesn't exist, or
     # (2) the target is a redirect to the source, and has no history
     # (so we can undo bad moves right after they're done).
     if (0 != $newid) {
         # Target exists; check for validity
         if (!$this->isValidMoveTarget($nt)) {
             $errors[] = array('articleexists');
         }
     } else {
         $tp = $nt->getTitleProtection();
         $right = $tp['pt_create_perm'] == 'sysop' ? 'protect' : $tp['pt_create_perm'];
         if ($tp and !$wgUser->isAllowed($right)) {
             $errors[] = array('cantmove-titleprotected');
         }
     }
     if (empty($errors)) {
         return true;
     }
     return $errors;
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:78,代码来源:Title.php

示例6: checkPermissions

 /**
  * Check if the merge is possible
  * @param User $user
  * @param string $reason
  * @return Status
  */
 public function checkPermissions(User $user, $reason)
 {
     $status = new Status();
     // Check if user can edit both pages
     $errors = wfMergeErrorArrays($this->source->getUserPermissionsErrors('edit', $user), $this->dest->getUserPermissionsErrors('edit', $user));
     // Convert into a Status object
     if ($errors) {
         foreach ($errors as $error) {
             call_user_func_array(array($status, 'fatal'), $error);
         }
     }
     // Anti-spam
     if (EditPage::matchSummarySpamRegex($reason) !== false) {
         // This is kind of lame, won't display nice
         $status->fatal('spamprotectiontext');
     }
     // Check mergehistory permission
     if (!$user->isAllowed('mergehistory')) {
         // User doesn't have the right to merge histories
         $status->fatal('mergehistory-fail-permission');
     }
     return $status;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:29,代码来源:MergeHistory.php


注:本文中的EditPage::matchSummarySpamRegex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。