mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
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\Forms\Announcement\AcknowledgeAnnouncementForm;
|
||||||
use Icinga\Web\Announcement\AnnouncementCookie;
|
use Icinga\Web\Announcement\AnnouncementCookie;
|
||||||
use Icinga\Web\Announcement\AnnouncementIniRepository;
|
use Icinga\Web\Announcement\AnnouncementIniRepository;
|
||||||
use Icinga\Web\Helper\HtmlPurifier;
|
use Icinga\Web\Helper\Markdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render announcements
|
* Render announcements
|
||||||
@ -36,13 +36,12 @@ class Announcements extends AbstractWidget
|
|||||||
$announcements = $repo->findActive();
|
$announcements = $repo->findActive();
|
||||||
$announcements->applyFilter($acked);
|
$announcements->applyFilter($acked);
|
||||||
if ($announcements->hasResult()) {
|
if ($announcements->hasResult()) {
|
||||||
$purifier = new HtmlPurifier(array('HTML.Allowed' => 'b,a[href|target],i,*[class]'));
|
|
||||||
$html = '<ul role="alert" id="announcements">';
|
$html = '<ul role="alert" id="announcements">';
|
||||||
foreach ($announcements as $announcement) {
|
foreach ($announcements as $announcement) {
|
||||||
$ackForm = new AcknowledgeAnnouncementForm();
|
$ackForm = new AcknowledgeAnnouncementForm();
|
||||||
$ackForm->populate(array('hash' => $announcement->hash));
|
$ackForm->populate(array('hash' => $announcement->hash));
|
||||||
$html .= '<li><div>'
|
$html .= '<li><div>'
|
||||||
. $purifier->purify($announcement->message)
|
. Markdown::text($announcement->message)
|
||||||
. '</div>'
|
. '</div>'
|
||||||
. $ackForm
|
. $ackForm
|
||||||
. '</li>';
|
. '</li>';
|
||||||
|
@ -8,7 +8,7 @@ use Icinga\Application\Hook\ApplicationStateHook;
|
|||||||
use Icinga\Authentication\Auth;
|
use Icinga\Authentication\Auth;
|
||||||
use Icinga\Forms\AcknowledgeApplicationStateMessageForm;
|
use Icinga\Forms\AcknowledgeApplicationStateMessageForm;
|
||||||
use Icinga\Web\ApplicationStateCookie;
|
use Icinga\Web\ApplicationStateCookie;
|
||||||
use Icinga\Web\Helper\HtmlPurifier;
|
use Icinga\Web\Helper\Markdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render application state messages
|
* Render application state messages
|
||||||
@ -27,12 +27,6 @@ class ApplicationStateMessages extends AbstractWidget
|
|||||||
return $active;
|
return $active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getPurifier()
|
|
||||||
{
|
|
||||||
return new HtmlPurifier(['HTML.Allowed' => 'b,a[href|target],i,*[class]']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$enabled = Auth::getInstance()
|
$enabled = Auth::getInstance()
|
||||||
@ -55,8 +49,6 @@ class ApplicationStateMessages extends AbstractWidget
|
|||||||
return '<div style="display: none;"></div>';
|
return '<div style="display: none;"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$purifier = $this->getPurifier();
|
|
||||||
|
|
||||||
$html = '<div>';
|
$html = '<div>';
|
||||||
|
|
||||||
reset($active);
|
reset($active);
|
||||||
@ -69,7 +61,7 @@ class ApplicationStateMessages extends AbstractWidget
|
|||||||
$ackForm = new AcknowledgeApplicationStateMessageForm();
|
$ackForm = new AcknowledgeApplicationStateMessageForm();
|
||||||
$ackForm->populate(['id' => $id]);
|
$ackForm->populate(['id' => $id]);
|
||||||
|
|
||||||
$html .= $purifier->purify($message) . $ackForm;
|
$html .= Markdown::text($message) . $ackForm;
|
||||||
|
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user