@php $config = isset($config) ? $config : \App\Notificacion::configuracionVisualModulo(); $moduleLabel = isset($moduleLabel) ? $moduleLabel : (isset($config['label']) ? $config['label'] : 'General'); $dateText = isset($dateText) ? $dateText : ''; $title = isset($title) ? trim((string) $title) : ''; $summary = isset($summary) ? trim((string) $summary) : ''; $summaryHtml = isset($summaryHtml) ? $summaryHtml : null; $detailRows = isset($detailRows) ? (array) $detailRows : []; $detailHtml = isset($detailHtml) ? $detailHtml : null; $actionHref = isset($actionHref) ? $actionHref : null; $actionText = isset($actionText) ? $actionText : 'Ver detalle'; $actionClass = isset($actionClass) ? trim((string) $actionClass) : ''; $actionData = isset($actionData) ? (array) $actionData : []; $reviewHref = isset($reviewHref) ? $reviewHref : null; $reviewText = isset($reviewText) ? $reviewText : 'Marcar como revisado'; $reviewClass = isset($reviewClass) ? trim((string) $reviewClass) : ''; $reviewData = isset($reviewData) ? (array) $reviewData : []; $cardClass = isset($cardClass) ? trim((string) $cardClass) : ''; $cardId = isset($cardId) ? $cardId : null; $collapsible = isset($collapsible) ? (bool) $collapsible : true; $expanded = isset($expanded) ? (bool) $expanded : false; $orderGroup = isset($orderGroup) ? trim((string) $orderGroup) : ''; $orderDate = isset($orderDate) ? (int) $orderDate : 0; $orderSequence = isset($orderSequence) ? (int) $orderSequence : 0; $showDetail = !empty($detailRows) || !empty($detailHtml); $showAction = !empty($actionHref); $showReviewAction = !empty($reviewHref); $collapseId = $cardId ? $cardId . '-collapse' : uniqid('module-notification-card-', false); $normalizarTextoTarjeta = function ($texto) { $texto = html_entity_decode(strip_tags((string) $texto), ENT_QUOTES, 'UTF-8'); return preg_replace('/\s+/u', ' ', trim($texto)); }; // Escapa el texto y convierte únicamente URLs web en enlaces. $linkificarTextoTarjeta = function ($texto) { $texto = (string) $texto; $patronUrl = '~https?://[^\s<>"\']*[^\s<>"\'.,;:!?]~iu'; if (!preg_match_all($patronUrl, $texto, $coincidencias, PREG_OFFSET_CAPTURE)) { return e($texto); } $resultado = ''; $offset = 0; foreach ($coincidencias[0] as $coincidencia) { $url = $coincidencia[0]; $posicion = $coincidencia[1]; $urlEscapada = e($url); $resultado .= e(substr($texto, $offset, $posicion - $offset)); $resultado .= '' .$urlEscapada .''; $offset = $posicion + strlen($url); } return $resultado.e(substr($texto, $offset)); }; $mensajeDetalle = ''; foreach ($detailRows as $detailRow) { $labelDetalle = is_array($detailRow) && isset($detailRow['label']) ? trim((string) $detailRow['label']) : ''; if ($labelDetalle === 'Mensaje') { $mensajeDetalle = is_array($detailRow) && isset($detailRow['value']) ? $detailRow['value'] : ''; break; } } // Oculta solo el resumen que duplica exactamente el campo Mensaje. $textoResumen = $summaryHtml ? $normalizarTextoTarjeta($summaryHtml) : $normalizarTextoTarjeta($summary); $textoMensaje = $normalizarTextoTarjeta($mensajeDetalle); if ($textoResumen !== '' && $textoResumen === $textoMensaje) { $summary = ''; $summaryHtml = null; } if ($orderGroup === '') { $orderGroup = mb_strtolower($moduleLabel, 'UTF-8'); $orderGroup = strtr($orderGroup, [ 'á' => 'a', 'é' => 'e', 'í' => 'i', 'ó' => 'o', 'ú' => 'u', 'ñ' => 'n', ]); $orderGroup = preg_replace('/[^a-z0-9]+/', '_', $orderGroup); $orderGroup = trim($orderGroup, '_'); } if ($orderDate <= 0 && preg_match('/\b([0-9]{2}\/[0-9]{2}\/[0-9]{4})\b/', $dateText, $dateMatch)) { $fechaOrden = \DateTime::createFromFormat('d/m/Y', $dateMatch[1]); $orderDate = $fechaOrden ? $fechaOrden->getTimestamp() : 0; } @endphp
@if ($collapsible) @else
{{ $moduleLabel }} @if ($dateText !== '') {{ $dateText }} @endif
@endif
@if ($title !== '')
{{ $title }}
@endif @if ($summaryHtml)
{!! $summaryHtml !!}
@elseif ($summary !== '')
{!! nl2br($linkificarTextoTarjeta($summary)) !!}
@endif @if ($showDetail || $showAction || $showReviewAction)
@if ($showDetail)
@foreach ($detailRows as $detailRow) @php $label = is_array($detailRow) && isset($detailRow['label']) ? $detailRow['label'] : ''; $value = is_array($detailRow) && isset($detailRow['value']) ? $detailRow['value'] : ''; $href = is_array($detailRow) && isset($detailRow['href']) ? $detailRow['href'] : null; $target = is_array($detailRow) && isset($detailRow['target']) ? $detailRow['target'] : null; @endphp @if (trim((string) $value) !== '' && trim((string) $label) === '')
{!! $linkificarTextoTarjeta($value) !!}
@elseif (trim((string) $label) !== '' && trim((string) $value) !== '')
{{ $label }}: @if ($href) {{ $value }} @else {!! $linkificarTextoTarjeta($value) !!} @endif
@endif @endforeach @if ($detailHtml) {!! $detailHtml !!} @endif
@endif @if ($showAction || $showReviewAction) @endif
@endif