Guides/Fixups

* fix urls in user menu
 * strip anchors from tooltip title
 * prevent line breaks in description
 * make only in english info popup modular
This commit is contained in:
Sarjuuk
2023-05-11 14:37:34 +02:00
parent 0e9ca3ff90
commit bc3ba23162
12 changed files with 35 additions and 14 deletions

View File

@@ -44,7 +44,7 @@ class GuidePage extends GenericPage
'submit' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkEmptySet'],
'title' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkTextLine'],
'name' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkTextLine'],
'description' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkTextBlob'],
'description' => ['filter' => FILTER_CALLBACK, 'options' => 'GuidePage::checkDescription'],
'changelog' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkTextBlob'],
'body' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkTextBlob'],
'locale' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkInt'],
@@ -521,7 +521,7 @@ class GuidePage extends GenericPage
$power = new StdClass();
if (!$this->subject->error)
{
$power->{'name_'.User::$localeString} = $this->name;
$power->{'name_'.User::$localeString} = strip_tags($this->name);
$power->{'tooltip_'.User::$localeString} = $this->subject->renderTooltip();
}
@@ -550,6 +550,16 @@ class GuidePage extends GenericPage
if ($this->subject?->getField('status') == GUIDE_STATUS_APPROVED)
DB::Aowow()->query('UPDATE ?_guides SET `views` = `views` + 1 WHERE `id` = ?d', $this->typeId);
}
protected static function checkDescription(string $str) : string
{
// run checkTextBlob and also replace \n => \s and \s+ => \s
$str = preg_replace(parent::$PATTERN_TEXT_BLOB, '', $str);
$str = strtr($str, ["\n" => ' ', "\r" => ' ']);
return preg_replace('/\s+/', ' ', trim($str));
}
}
?>