Fix message/signature text in capital letters only
This commit is contained in:
parent
b3a94ef06f
commit
f58f8c15fa
2 changed files with 40 additions and 16 deletions
app/Models/Pages
|
@ -44,26 +44,38 @@ trait PostValidatorTrait
|
|||
*/
|
||||
public function vCheckMessage(Validator $v, $message, $attr, $executive)
|
||||
{
|
||||
$prepare = null;
|
||||
|
||||
// после цензуры текст сообщения пустой
|
||||
if ('' == $this->c->censorship->censor($message)) {
|
||||
$v->addError('No message after censoring');
|
||||
// текст сообщения только заглавными буквами
|
||||
} elseif (
|
||||
! $executive
|
||||
&& '0' == $this->c->config->p_message_all_caps
|
||||
&& \preg_match('%\p{Lu}%u', $message)
|
||||
&& ! \preg_match('%\p{Ll}%u', $message)
|
||||
) {
|
||||
$v->addError('All caps message');
|
||||
// проверка парсером
|
||||
} else {
|
||||
$prepare = true;
|
||||
$message = $this->c->Parser->prepare($message); //????
|
||||
|
||||
foreach($this->c->Parser->getErrors() as $error) {
|
||||
$prepare = false;
|
||||
$v->addError($error);
|
||||
}
|
||||
}
|
||||
|
||||
// текст сообщения только заглавными буквами
|
||||
if (
|
||||
true === $prepare
|
||||
&& ! $executive
|
||||
&& '0' == $this->c->config->p_message_all_caps
|
||||
) {
|
||||
$text = $this->c->Parser->getText();
|
||||
|
||||
if (
|
||||
\preg_match('%\p{Lu}%u', $text)
|
||||
&& ! \preg_match('%\p{Ll}%u', $text)
|
||||
) {
|
||||
$v->addError('All caps message');
|
||||
}
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,28 +165,40 @@ class Edit extends Profile
|
|||
public function vCheckSignature(Validator $v, $signature)
|
||||
{
|
||||
if ('' != $signature) {
|
||||
$prepare = null;
|
||||
|
||||
// после цензуры текст сообщения пустой
|
||||
if ('' == $this->c->censorship->censor($signature)) {
|
||||
$v->addError('No signature after censoring');
|
||||
// количество строк
|
||||
} elseif (\substr_count($signature, "\n") >= $this->curUser->g_sig_lines) {
|
||||
$v->addError('Signature has too many lines');
|
||||
// текст сообщения только заглавными буквами
|
||||
} elseif (
|
||||
! $this->user->isAdmin
|
||||
&& '0' == $this->c->config->p_sig_all_caps
|
||||
&& \preg_match('%\p{Lu}%u', $signature)
|
||||
&& ! \preg_match('%\p{Ll}%u', $signature)
|
||||
) {
|
||||
$v->addError('All caps signature');
|
||||
// проверка парсером
|
||||
} else {
|
||||
$prepare = true;
|
||||
$signature = $this->c->Parser->prepare($signature, true); //????
|
||||
|
||||
foreach($this->c->Parser->getErrors() as $error) {
|
||||
$prepare = false;
|
||||
$v->addError($error);
|
||||
}
|
||||
}
|
||||
|
||||
// текст сообщения только заглавными буквами
|
||||
if (
|
||||
true === $prepare
|
||||
&& ! $this->user->isAdmin
|
||||
&& '0' == $this->c->config->p_sig_all_caps
|
||||
) {
|
||||
$text = $this->c->Parser->getText();
|
||||
|
||||
if (
|
||||
\preg_match('%\p{Lu}%u', $text)
|
||||
&& ! \preg_match('%\p{Ll}%u', $text)
|
||||
) {
|
||||
$v->addError('All caps signature');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $signature;
|
||||
|
|
Loading…
Add table
Reference in a new issue