27 $this->escaper = $escaper;
38 $title = $this->escaper->escapeHtml(
$page[
'mainContent'][
'title']);
39 $imageUrl = $this->escaper->escapeUrl(
$page[
'mainContent'][
'imageUrl']);
43 $content .=
"<div class='release-notification-title-with-image' style='background-image: url(\"" .
$imageUrl 75 private function buildMainContent(array $mainContent)
77 $content = $this->buildContentTextAreas($mainContent[
'content']);
78 $content .= $this->buildLists($mainContent[
'lists']);
80 return $this->formatContentWithLinks(
$content);
89 private function buildContentTextAreas(array $contentAreas)
92 $lastContentArea = end($contentAreas);
94 foreach ($contentAreas as $contentArea) {
96 $content .= $this->escaper->escapeHtml($contentArea[
'text']);
98 if ($contentArea != $lastContentArea) {
112 private function buildLists(array $lists)
116 foreach ($lists as $listItem) {
118 $content .= $this->escaper->escapeHtml($listItem[
'text']);
133 private function buildSubHeadings(array $subHeadings)
137 foreach ($subHeadings as $subHeading) {
138 if (!empty($subHeading[
'imageUrl'])) {
139 $content .=
"<div class='highlight-item' style='background-image: url(\"" 140 . $this->escaper->escapeUrl($subHeading[
'imageUrl']) .
"\")'>";
142 $content .=
"<div class='highlight-item-no-image'>";
146 $content .= $this->escaper->escapeHtml($subHeading[
'title']);
149 $content .= $this->formatContentWithLinks($subHeading[
'content']);
163 private function buildFooter(array $footer)
166 $content .= $this->escaper->escapeHtml($footer[
'content']);
169 return $this->formatContentWithLinks(
$content);
179 private function formatContentWithLinks(
$content)
181 $urlRegex =
'#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#';
182 $urlTextRegex =
'/\[(.*?)\]/';
184 preg_match_all($urlRegex,
$content, $urlMatches);
185 preg_match_all($urlTextRegex,
$content, $urlTextMatches);
187 foreach ($urlMatches[0] as $key => $urlMatch) {
188 if (!empty($urlTextMatches[0])) {
189 $linkMatch = $urlMatch .
" " . $urlTextMatches[0][$key];
192 "<a target='_blank' href='{$this->escaper->escapeUrl($urlMatch)}'> 193 {$this->escaper->escapeHtml($urlTextMatches[1][$key])}</a>",
199 "<a target='_blank' href='{$this->escaper->escapeUrl($urlMatch)}'> 200 {$this->escaper->escapeUrl($urlMatch)}</a>",
getNotificationTitle(array $page)
if($_imageTitle=$block->escapeHtml($block->getCurrentImage() ->getLabel())) $imageUrl
getNotificationContent(array $page)
__construct(Escaper $escaper)