本文整理汇总了PHP中EditPage::matchSpamRegex方法的典型用法代码示例。如果您正苦于以下问题:PHP EditPage::matchSpamRegex方法的具体用法?PHP EditPage::matchSpamRegex怎么用?PHP EditPage::matchSpamRegex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditPage
的用法示例。
在下文中一共展示了EditPage::matchSpamRegex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValidMoveOperation
/**
* Check whether a given move operation would be valid.
* Returns true if ok, or a getUserPermissionsErrors()-like array otherwise
* @param &$nt \type{Title} the new title
* @param $auth \type{\bool} indicates whether $wgUser's permissions
* should be checked
* @param $reason \type{\string} is the log summary of the move, used for spam checking
* @return \type{\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) {
$file = wfLocalFile($this);
if ($file->exists()) {
if ($nt->getNamespace() != NS_FILE) {
$errors[] = array('imagenocrossnamespace');
}
if ($nt->getText() != wfStripIllegalFilenameChars($nt->getText())) {
$errors[] = array('imageinvalidfilename');
}
if (!File::checkExtensionCompatibility($file, $nt->getDBKey())) {
$errors[] = array('imagetypemismatch');
}
}
}
if ($auth) {
$errors = wfMergeErrorArrays($errors, $this->getUserPermissionsErrors('move', $wgUser), $this->getUserPermissionsErrors('edit', $wgUser), $nt->getUserPermissionsErrors('move-target', $wgUser), $nt->getUserPermissionsErrors('edit', $wgUser));
}
$match = EditPage::matchSpamRegex($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;
}