announcements: Transform markdown markup
This commit is contained in:
parent
3a955ae19b
commit
bd2060739e
|
@ -8,7 +8,7 @@ use Icinga\Data\Filter\Filter;
|
|||
use Icinga\Forms\Announcement\AcknowledgeAnnouncementForm;
|
||||
use Icinga\Web\Announcement\AnnouncementCookie;
|
||||
use Icinga\Web\Announcement\AnnouncementIniRepository;
|
||||
use Icinga\Web\Helper\HtmlPurifier;
|
||||
use Icinga\Web\Helper\Markdown;
|
||||
|
||||
/**
|
||||
* Render announcements
|
||||
|
@ -36,13 +36,12 @@ class Announcements extends AbstractWidget
|
|||
$announcements = $repo->findActive();
|
||||
$announcements->applyFilter($acked);
|
||||
if ($announcements->hasResult()) {
|
||||
$purifier = new HtmlPurifier(array('HTML.Allowed' => 'b,a[href|target],i,*[class]'));
|
||||
$html = '<ul role="alert" id="announcements">';
|
||||
foreach ($announcements as $announcement) {
|
||||
$ackForm = new AcknowledgeAnnouncementForm();
|
||||
$ackForm->populate(array('hash' => $announcement->hash));
|
||||
$html .= '<li><div>'
|
||||
. $purifier->purify($announcement->message)
|
||||
. Markdown::text($announcement->message)
|
||||
. '</div>'
|
||||
. $ackForm
|
||||
. '</li>';
|
||||
|
|
|
@ -8,7 +8,7 @@ use Icinga\Application\Hook\ApplicationStateHook;
|
|||
use Icinga\Authentication\Auth;
|
||||
use Icinga\Forms\AcknowledgeApplicationStateMessageForm;
|
||||
use Icinga\Web\ApplicationStateCookie;
|
||||
use Icinga\Web\Helper\HtmlPurifier;
|
||||
use Icinga\Web\Helper\Markdown;
|
||||
|
||||
/**
|
||||
* Render application state messages
|
||||
|
@ -27,12 +27,6 @@ class ApplicationStateMessages extends AbstractWidget
|
|||
return $active;
|
||||
}
|
||||
|
||||
|
||||
protected function getPurifier()
|
||||
{
|
||||
return new HtmlPurifier(['HTML.Allowed' => 'b,a[href|target],i,*[class]']);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$enabled = Auth::getInstance()
|
||||
|
@ -55,8 +49,6 @@ class ApplicationStateMessages extends AbstractWidget
|
|||
return '<div style="display: none;"></div>';
|
||||
}
|
||||
|
||||
$purifier = $this->getPurifier();
|
||||
|
||||
$html = '<div>';
|
||||
|
||||
reset($active);
|
||||
|
@ -69,7 +61,7 @@ class ApplicationStateMessages extends AbstractWidget
|
|||
$ackForm = new AcknowledgeApplicationStateMessageForm();
|
||||
$ackForm->populate(['id' => $id]);
|
||||
|
||||
$html .= $purifier->purify($message) . $ackForm;
|
||||
$html .= Markdown::text($message) . $ackForm;
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
|
|
Loading…
Reference in New Issue