Skip to content
Merged

Dev #3566

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions app/GrassrootsGrantsHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,38 @@ public function statusLabel(): ?string

public function statusBodyHtml(): string
{
$message = trim(strip_tags((string) ($this->status_message ?? ''), '<p><br><strong><em><a><ul><ol><li>'));
$message = trim((string) ($this->status_message ?? ''));
if ($message !== '') {
if (str_contains((string) $this->status_message, '<')) {
return (string) $this->status_message;
}
return $this->stripEmbeddedStatusLine($message);
}

return $this->stripEmbeddedStatusLine(trim((string) ($this->overview ?? '')));
}

private function stripEmbeddedStatusLine(string $html): string
{
if ($html === '') {
return '';
}

$cleaned = preg_replace(
'/<p>\s*<strong>\s*Status:\s*<\/strong>[^<]*<\/p>\s*/iu',
'',
$html
) ?? $html;

return '<p>'.e($message).'</p>';
$plain = trim(strip_tags($cleaned));
$plain = preg_replace('/^Status:\s*.+?(?:\n|$)/iu', '', $plain) ?? $plain;
$plain = trim($plain);

if ($plain === '') {
return '';
}

$overview = trim((string) ($this->overview ?? ''));
if (str_contains($cleaned, '<')) {
return trim($cleaned);
}

return $overview;
return '<p>'.e($plain).'</p>';
}
}
3 changes: 0 additions & 3 deletions resources/views/static/grassroots-grants.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ class="absolute top-0 right-0 w-full md:w-[60vw] h-[50%] md:h-full object-cover
<div class="overflow-hidden max-h-0 transition-all duration-300">
<div class="pb-6 pt-2 text-[#333E48] text-lg md:text-xl font-normal grants-content">
@if($hub->isStatusOnly())
@if($statusLabel = $hub->statusLabel())
<p class="mb-4"><strong>Status:</strong> {{ $statusLabel }}</p>
@endif
@if($statusBody = $hub->statusBodyHtml())
<div>{!! $statusBody !!}</div>
@endif
Expand Down
Loading