praiadeseselle/site/templates/layout/func.php

708 lines
23 KiB
PHP
Raw Normal View History

2022-03-09 18:09:44 +01:00
<?php namespace ProcessWire;
/**
* @param Page $paxina
* @return array
*/
2022-03-09 18:09:44 +01:00
function getConfig($paxina)
{
$configuracion = array();
foreach($paxina->configuracion as $config)
{
2022-10-06 10:54:15 +02:00
switch ($config->parametro_tipo->value)
2022-05-03 12:18:01 +02:00
{
case 'texto':
2022-10-06 10:54:15 +02:00
$configuracion[$config->parametro_nome] = $config->parametro_valor;
2022-05-03 12:18:01 +02:00
break;
case 'cor':
2022-10-06 10:54:15 +02:00
list($r, $g, $b) = sscanf($config->parametro_cor, "%02x%02x%02x");
$configuracion[$config->parametro_nome] = $r . ', ' . $g . ', ' . $b;
2022-05-03 12:18:01 +02:00
break;
case 'mantemento':
if($config->parametro_mantemento==1)
{
$configuracion['mantemento'] = array(
'activo' => true,
'titular' => $config->titular,
'artigo' => $config->artigo,
'imaxe' => $config->imaxe
);
}
else
{
$configuracion['mantemento'] = array('activo' => false);
}
break;
case 'logo':
foreach($config->imaxes as $logo)
{
$configuracion['logo'][$logo->tags] = array(
'url' => $logo->url,
'alt' => $logo->description
);
}
break;
2022-05-03 12:18:01 +02:00
}
2022-03-09 18:09:44 +01:00
}
return $configuracion;
}
/**
* @param array|PageArray $seccions
* @return string
*/
2022-10-25 14:47:38 +02:00
function getSeccions($seccions)
2022-03-09 18:09:44 +01:00
{
$saida = '';
$posicion = 0;
2022-03-09 18:09:44 +01:00
foreach($seccions as $seccion)
{
$posicion++;
2022-03-09 18:09:44 +01:00
switch($seccion->template)
{
case 'repeater_seccions':
2022-10-06 10:54:15 +02:00
switch ($seccion->seccion_tipo->value)
2022-03-09 18:09:44 +01:00
{
case 'deslizante':
$saida .= renderDeslizante($seccion);
break;
case 'destacados':
$saida .= renderDestacado($seccion);
break;
case 'columnas':
$saida .= renderColumna($seccion);
break;
case 'imaxe_texto_lateral':
$saida .= renderImaxeTexto($seccion);
break;
case 'opinions':
$saida .= renderOpinions($seccion);
break;
2022-03-09 18:09:44 +01:00
case 'texto':
2023-03-11 11:41:24 +01:00
$saida .= renderTexto($seccion, true);
2022-03-09 18:09:44 +01:00
break;
case 'galeria':
$saida .= renderGaleria($seccion);
2022-03-09 18:09:44 +01:00
break;
2022-04-08 12:32:49 +02:00
case 'reixa':
$saida .= renderReixa($seccion);
2022-05-03 12:18:01 +02:00
break;
2022-03-09 18:09:44 +01:00
}
break;
case 'repeater_deslizante':
$saida .= renderDiapositiva($seccion, $posicion);
break;
case 'repeater_botons':
$saida .= renderBoton($seccion);
break;
case 'repeater_ligazon_imaxe':
$saida .= renderLigazonImaxe($seccion);
break;
case 'repeater_destacados':
case 'repeater_columnas':
$saida .= renderElemento($seccion, $posicion);
break;
case 'repeater_opinions':
$saida .= renderCita($seccion);
2022-03-09 18:09:44 +01:00
break;
}
}
return $saida;
}
2023-02-21 14:48:37 +01:00
/**
* @param string $texto
* @return string
*/
function getTextoLimpo($texto)
{
$texto = preg_replace ('/<[^>]*>/', ' ', $texto);
$texto = str_replace("\r", '', $texto);
$texto = str_replace("\n", ' ', $texto);
$texto = str_replace("\t", ' ', $texto);
$texto = trim(preg_replace('/ {2,}/', ' ', $texto));
return $texto;
}
/**
* @param PageArray $paxinas
* @param string $clase
* @return string
*/
function renderMenu($paxinas, $clase = 'navbar-nav')
2022-03-10 01:47:18 +01:00
{
$saida = '';
$inicio = wire('pages')->get('/');
$actual = wire('page');
2022-03-10 01:47:18 +01:00
if($paxinas instanceof Page)
{
$paxinas = array($paxinas);
}
$saida .= '<ul class="' . $clase . '">' . "\n";
2023-02-22 18:57:39 +01:00
$saida .= '<li class="nav-item px-3 px-md-0 ' . (($inicio->id == $actual->id) ? ' active' : '') . '">';
$saida .= '<a class="nav-link text-uppercase link-dark px-2' . (($inicio->id == $actual->id) ? ' active" aria-current="page' : '') . '" href="' . $inicio->url . '">' . mb_strtoupper($inicio->title) . '</a>';
$saida .= '</li>' . "\n";
2022-03-10 01:47:18 +01:00
foreach($paxinas as $paxina)
{
2023-02-22 18:57:39 +01:00
$saida .= '<li class="nav-item px-3 px-md-0 ' . (($paxina->id == $actual->id) ? ' active' : '') . '">';
$saida .= '<a class="nav-link text-uppercase link-dark px-2' . (($paxina->id == $actual->id) ? ' active" aria-current="page' : '') . '" href="' . $paxina->url . '">' . mb_strtoupper($paxina->title) . '</a>';
$saida .= '</li>' . "\n";
2022-03-10 01:47:18 +01:00
}
$saida .= '</ul>' . "\n";
2022-03-10 01:47:18 +01:00
return $saida;
}
/**
* @param array|PageArray $paxina
* @param string $separador
* @return string
*/
2022-03-10 01:47:18 +01:00
function renderMigasPan($paxina, $separador = '<i class="icon-chevrons-right"></i>')
{
$saida = '';
2022-10-27 14:10:14 +02:00
$icono = '';
switch ($paxina->template)
{
case 'inicio':
2022-10-27 14:10:14 +02:00
$icono = 'home';
break;
case 'paxina':
case 'habitacions':
2023-02-21 14:48:37 +01:00
case 'habitacion':
2022-10-27 14:10:14 +02:00
$icono = 'play';
break;
case 'blogue':
$icono = 'book';
break;
case 'categoria':
$icono = 'folder';
break;
case 'etiqueta':
$icono = 'tag';
break;
case 'publicacion':
$icono = 'book-open';
break;
case 'contacto':
$icono = 'user';
break;
}
$saida .= '<div id="migas_pan" class="container">' . "\n";
$saida .= '<nav style="--bs-breadcrumb-divider: '. "''" . ';" aria-label="breadcrumb">' . "\n";
$saida .= '<ol class="breadcrumb">' . "\n";
foreach($paxina->parents() as $pai)
{
2023-02-21 14:48:37 +01:00
$saida .= '<li class="breadcrumb-item">' . $separador . '<a href="' . $pai->url . '">' . $pai->title . '</a></li>';
}
$saida .= '<li class="breadcrumb-item active" aria-current="page">' . $separador . ' ' . (($icono != '')? '<i class="icon-' . $icono . '"></i> ' : '') . '<span>' . $paxina->title . '</span>';
if($paxina->editable()):
2023-02-21 14:48:37 +01:00
$saida .= ' [ <a href="' . $paxina->editURL . '"><i class="icon-edit"></i> ' . _x('Edit', 'Edit page') . ' </a> ]';
endif;
$saida .= '</li>' . "\n";
$saida .= '</ol>' . "\n";
$saida .= '</nav>' . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '</div>';
return $saida;
}
/**
* @param string $titulo
* @param string $texto
* @param array|PageArray $imaxe
* @return string
*/
2022-10-25 14:47:38 +02:00
function renderTextoMantemento($titulo, $texto, $imaxe)
2022-03-09 18:09:44 +01:00
{
$saida = '';
2023-02-27 17:10:20 +01:00
$saida .= '<div class="container px-lg-4 pb-5 text-center">' . "\n";
$saida .= '<h2>' . $titulo . '</h2>' . "\n";
$saida .= '<div class="col-lg-6 mx-auto">' . "\n";
$saida .= $texto . "\n";
$saida .= '</div>' . "\n";
$saida .= '<div>' . "\n";
2023-02-27 17:10:20 +01:00
$saida .= '<div class="container px-lg-5">' . "\n";
$saida .= '<img src="' . $imaxe->url . '" class="img-fluid border rounded-3 shadow-lg p-3 p-lg-5 mb-4" alt="' . $imaxe->description . '" loading="lazy" width="700" height="500">' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
2022-03-09 18:09:44 +01:00
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderGaleria($seccion)
2022-03-09 18:09:44 +01:00
{
$saida = '';
2023-03-11 11:41:24 +01:00
$saida .= '<section id="galeria" class="swiper d-none d-md-block mb-5">' . "\n";
$saida .= '<h3 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Galeria') . '</h3>' . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '<div class="swiper-wrapper">' . "\n";
foreach($seccion->imaxes as $imaxe)
2022-03-09 18:09:44 +01:00
{
2022-10-06 10:54:15 +02:00
$saida .= '<div class="swiper-slide">' . "\n";
$saida .= '<figure>' . "\n";
$saida .= '<img src="' . $imaxe->url . '" alt="' . $imaxe->description . '" loading="lazy">' . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '<figcaption>' . $imaxe->description . '</figcaption>' . "\n";
$saida .= '</figure>' . "\n";
$saida .= '<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>' . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '</div>' . "\n";
2022-03-09 18:09:44 +01:00
}
2022-10-06 10:54:15 +02:00
$saida .= '</div>' . "\n";
2023-02-19 16:09:41 +01:00
$saida .= '<div class="swiper-button-prev"><span class="visually-hidden">Previous</span></div>' . "\n";
$saida .= '<div class="swiper-button-next"><span class="visually-hidden">Next</span></div>' . "\n";
$saida .= '<div class="swiper-pagination"></div>' . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '</section>';
2022-03-09 18:09:44 +01:00
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderReixa($seccion)
2022-04-08 12:32:49 +02:00
{
$saida = '';
2023-02-19 16:09:41 +01:00
$saida .= '<section class="container">' . "\n";
$saida .= '<h3 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Reixa') . '</h3>' . "\n";
2023-02-21 14:48:37 +01:00
$saida .= '<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">' . "\n";
foreach($seccion->imaxes as $imaxe)
2022-04-08 12:32:49 +02:00
{
2023-02-21 14:48:37 +01:00
$saida .= '<figure class="col py-3">' . "\n";
$saida .= '<img class="reixa-item" src="' . $imaxe->url . '" alt="' . $imaxe->description . '">' . "\n";
2023-02-19 16:09:41 +01:00
$saida .= '</figure>' . "\n";
2022-04-08 12:32:49 +02:00
}
2023-02-19 16:09:41 +01:00
$saida .= '</div>' . "\n";
2023-02-21 14:48:37 +01:00
$saida .= '<div class="modal fade" id="reixa-modal" tabindex="-1" aria-labelledby="reixa-modal-label" aria-hidden="true">' . "\n";
$saida .= '<div class="modal-dialog modal-dialog-centered modal-lg">' . "\n";
$saida .= '<div class="modal-content">' . "\n";
$saida .= '<div class="modal-header">' . "\n";
$saida .= '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '<div class="modal-body">' . "\n";
$saida .= '<figure class="col">' . "\n";
$saida .= '<img class="modal-img" src="' . $imaxe->url . '" alt="' . $imaxe->description . '">' . "\n";
$saida .= '<figcaption class="modal-label">' . $imaxe->description . '</figcaption>' . "\n";
$saida .= '</figure>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '</section>';
2022-04-08 12:32:49 +02:00
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderImaxeTexto($seccion)
2022-03-09 18:09:44 +01:00
{
$saida = '';
$imaxe = '';
$texto = '';
$botons = '';
2022-03-09 18:09:44 +01:00
if($seccion->imaxe)
2022-04-08 12:32:49 +02:00
{
$imaxe .= renderImaxe($seccion);
2022-04-08 12:32:49 +02:00
}
$texto .= renderTexto($seccion);
if($seccion->botons->isEmpty())
2022-04-08 12:32:49 +02:00
{
$botons .= '<div class="row text-center">' . "\n";
$botons .= getSeccions($seccion->botons) . "\n";
$botons .= '</div>' . "\n";
2022-03-09 18:09:44 +01:00
}
switch ($seccion->imaxe_posicion->value)
{
case 'superior':
$saida .= '<section class="container mb-5 text-center">' . "\n";
$saida .= '<div class="row mb-5">' . "\n";
$saida .= $imaxe . "\n";
$saida .= '</div>' . "\n";
$saida .= '<div class="row text-start mb-5">' . "\n";
$saida .= $texto . "\n";
$saida .= '</div>' . "\n";
$saida .= $botons . "\n";
break;
case 'esquerda':
2023-03-11 11:41:24 +01:00
case 'dereita':
$saida .= '<section class="container mb-5">' . "\n";
2023-03-11 11:41:24 +01:00
$saida .= '<div class="row row-cols-1 row-cols-md-2 align-items-center">' . "\n";
$saida .= '<div class="col col-lg-6 ' . (($seccion->imaxe_posicion->value == 'esquerda') ? 'order-md-first ' : 'order-md-last ') . 'text-center">' . "\n";
$saida .= $imaxe . "\n";
$saida .= '</div>' . "\n";
2023-03-11 11:41:24 +01:00
$saida .= '<div class="col col-lg-6 ' . (($seccion->imaxe_posicion->value == 'esquerda') ? 'order-md-last ' : 'order-md-first ') . 'text-center">' . "\n";
$saida .= $texto . "\n";
$saida .= $botons . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
break;
}
$saida .= '</section>' . "\n";
2022-03-09 18:09:44 +01:00
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderImaxe($seccion)
{
$saida = '';
2023-02-21 14:48:37 +01:00
$saida .= '<figure>' . "\n";
$saida .= '<img src="' . $seccion->imaxe->url . '" alt="' . $seccion->maxe->description . '" loading="lazy">' . "\n";
$saida .= '<figcaption>' . $seccion->imaxe->description . '</figcaption>' . "\n";
$saida .= '</figure>' . "\n";
2022-05-03 12:18:01 +02:00
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
2023-03-11 11:41:24 +01:00
function renderTexto($seccion, $centrado = false)
2022-05-03 12:18:01 +02:00
{
$saida = '';
if($seccion->titular)
{
2023-03-11 11:41:24 +01:00
$saida .= '<div class="row text-start ' . (($centrado) ? 'text-md-center' : '') . '">' . "\n";
$saida .= '<h3 class="fw-semibold">' . $seccion->titular . '</h3>' . "\n";
$saida .= '</div>' . "\n";
}
2023-03-11 11:41:24 +01:00
$saida .= '<div class="row text-start ' . (($centrado) ? 'text-md-center ' : '') . 'mb-5">' . "\n";
$saida .= $seccion->artigo . "\n";
2022-10-06 10:54:15 +02:00
$saida .= '</div>' . "\n";
2022-05-03 12:18:01 +02:00
2022-03-09 18:09:44 +01:00
return $saida;
2022-10-25 14:47:38 +02:00
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderBoton($seccion)
2022-10-27 14:10:14 +02:00
{
$saida = '';
$clases = '';
$sufijo = '';
2022-10-27 14:10:14 +02:00
switch ($seccion->botons_estilo->value)
2022-10-27 14:10:14 +02:00
{
case 'activo':
$clases = 'btn btn-lg btn-primary';
2022-10-27 14:10:14 +02:00
break;
case 'secundario':
$clases = 'btn btn-lg btn-secundary';
2022-10-27 14:10:14 +02:00
break;
case 'inactivo':
$clases = 'btn btn-lg btn-primary disabled';
break;
case 'aviso':
$clases = 'btn btn-lg text-black btn-outline-warning';
break;
case 'ligazon':
$clases = 'd-inline-flex align-items-center link-primary text-decoration-none text-uppercase';
$sufijo = ' <i class="icon-chevrons-right"></i>';
2022-10-27 14:10:14 +02:00
break;
}
$saida .= '<div class="col mx-auto"><a href="' . (($seccion->ligazon_interna) ? $seccion->ligazon_interna->url : '#') . '" class="' . $clases . '">' . (($seccion->parametro_valor)? $seccion->parametro_valor : $seccion->ligazon_interna->title) . $sufijo . '</a></div>';
2022-10-27 14:10:14 +02:00
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
2022-10-27 14:10:14 +02:00
function renderLigazonImaxe($seccion)
2022-10-27 14:10:14 +02:00
{
$saida = '';
$saida .= '<figure class="col effect-ming">' . "\n";
$saida .= '<img src="' . $seccion->imaxe->url . '" alt="' . $seccion->imaxe->description . '">' . "\n";
$saida .= '<figcaption>' . "\n";
$saida .= '<h3>' . $seccion->titular . '</h3>' . "\n";
$saida .= '<p>' . _x('See details', 'see details') . '</p>' . "\n";
$saida .= '<a href=' . $seccion->ligazon_interna->url . '></a>' . "\n";
$saida .= '</figcaption>' . "\n";
$saida .= '</figure>' . "\n";
2022-10-27 14:10:14 +02:00
return $saida;
2023-02-21 14:48:37 +01:00
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderDestacado($seccion)
{
$saida = '';
$icona = '';
$saida .= '<section class="container mb-5 text-center">' . "\n";
$saida .= '<h2 class="border-bottom my-3">' . $seccion->titular . '</h2>' . "\n";
$saida .= '<div class="row row-cols-1 row-cols-lg-3 g-4">' . "\n";
$saida .= getSeccions($seccion->destacados);
$saida .= '</div>' . "\n";
$saida .= '</section>' . "\n";
return $saida;
}
/**
* @param array|PageArray $seccion
* @param int $posicion
* @return string
*/
function renderElemento($seccion, $posicion = 0)
{
$saida = '';
$saida .= '<div class="col flex-grow-1 d-flex align-items-start">' . "\n";
switch($seccion->destacado_icona_tipo->value)
{
case 'icona':
$saida .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center flex-shrink-0 text-bg-primary bg-gradient fs-4 rounded-3 me-3"><i class="' . $seccion->parametro_valor .' bi"></i></div>';
break;
case 'imaxe':
$saida .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center flex-shrink-0 text-bg-primary bg-gradient fs-4 rounded-3 me-3"><img src="' . $seccion->imaxe->url . '" alt="' . $seccion->imaxe->description . '"></div>';
break;
case 'posicion':
$saida .= '<div class="d-inline-flex align-items-center justify-content-center fs-4 flex-shrink-0 me-3"><span class="display-2 fw-bold text-secondary">' . $posicion . '</span></div>';
break;
default:
$saida .= '';
break;
}
2023-03-11 11:41:24 +01:00
$saida .= '<div class="row mb-lg-5">' . "\n";
2023-02-21 14:48:37 +01:00
$saida .= '<div class="col mx-auto text-start">' . "\n";
$saida .= renderTexto($seccion);
if($seccion->botons && $seccion->botons->isEmpty())
{
$saida .= '<div class="row text-center">' . "\n";
$saida .= getSeccions($seccion->botons) . "\n";
$saida .= '</div>' . "\n";
}
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
return $saida;
}
/**
* @param array|PageArray $seccion
* @return string
*/
function renderCategoriasEtiquetas($seccion)
{
$saida = '';
switch ($seccion->first()->template->name)
{
case 'categoria':
$icono = 'folder';
$nome = 'categorias';
break;
case 'etiqueta':
$icono = 'tag';
$nome = 'etiquetas';
break;
default:
$icono = 'sn';
$nome = 'sin';
break;
}
2023-02-27 17:10:20 +01:00
$saida .= '<div id="' . $nome . '" class="col p-3">' . "\n";
2023-02-21 14:48:37 +01:00
$saida .= '<a class="collapse-head" data-bs-toggle="collapse" href="#collapse-' . $nome . '" role="button" aria-expanded="false" aria-controls="collapse-' . $nome . '">' . "\n";
$saida .= '<h3>' . pages()->get('/noticias/' . $nome)->title . '</h3>' . "\n";
$saida .= '</a>' . "\n";
$saida .= '<div class="collapse" id="collapse-' . $nome . '">' . "\n";
$saida .= '<ul class="list-group">' . "\n";
foreach($seccion as $item)
{
$numPosts = pages()->count('template=publicacion, ' . $nome . '=' . $item->name);
$saida .= '<li class="list-group-item d-flex justify-content-between align-items-start">' . "\n";
$saida .= '<a class="ms-2 me-auto" href="' . $item->url . '"><i class="icon-' . $icono . '"></i> ' . $item->title . '</a>' . "\n";
$saida .= '<span class="badge bg-primary rounded-pill">(' . sprintf(_n('%d post', '%d posts', $numPosts), $numPosts) . ')</span>' . "\n";
$saida .= '</li>' . "\n";
}
$saida .= '</ul>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</div>' . "\n";
return $saida;
}
/**
* @param array|PageArray $artigos
* @param int $posicion
* @return string
*/
function renderPaxinacion($artigos, $posicion)
{
$paxinacion = $artigos->renderPager(
array(
'listMarkup' => '<nav id="paxinacion-' . $posicion . '" class="paxinacion"><ul>{out}</ul></nav>',
'itemMarkup' => '<li class="{class}">{out}</li>',
'linkMarkup' => '<a href="{url}"><span>{out}</span></a>',
'nextItemLabel' => '<i class="icon-skip-forward"></i>',
'previousItemLabel' => '<i class="icon-skip-back"></i>',
'separatorItemClass' => 'separador',
'nextItemClass' => 'seguinte',
'previousItemClass' => 'anterior',
'lastItemClass' => 'derradeiro',
'currentItemClass' => 'actual'
)
);
return $paxinacion;
}
/**
* @param array|PageArray $publicacion
* @param string $locale
* @param boolean $resumen
* @return string
*/
function renderArtigos($publicacion, $locale, $resumen = true)
{
$saida = '';
$data = strtotime($publicacion->fecha_publicacion);
$dateFormatter = \IntlDateFormatter::create(
$locale,
\IntlDateFormatter::NONE,
\IntlDateFormatter::NONE,
\date_default_timezone_get(),
\IntlDateFormatter::GREGORIAN
);
$saida .= '<article id="' . $publicacion->name .'" class="container">' . "\n";
$saida .= '<header class="d-flex gap-3 mb-3">' . "\n";
$saida .= '<time datetime="' . $publicacion->fecha_publicacion . '">' ."\n";
$dateFormatter->setPattern('EEEE');
$saida .= '<em>' . ucfirst(datefmt_format($dateFormatter, $data)) . '</em>' . "\n";
$dateFormatter->setPattern('MMMM');
$saida .= '<strong>' . ucfirst(datefmt_format($dateFormatter, $data)) . '</strong>' . "\n";
$dateFormatter->setPattern('dd');
$saida .= '<span>' . datefmt_format($dateFormatter, $data) . '</span>' . "\n";
$saida .= '</time>' . "\n";
$saida .= '<div>' . "\n";
$saida .= '<h3 class="publicacion-titulo">' . "\n";
$saida .= '<a href="' . $publicacion->url . '"><i class="icon-' . (($resumen) ? 'book' : 'book-open') . '"></i> ' . $publicacion->title . '</a>' . "\n";
$saida .= '</h3>' . "\n";
$saida .= '<dl>' . "\n";
$saida .= '<dt title="' . pages()->get('/noticias/categorias/')->title . '"><i class="icon-folder"></i><span class="d-none d-lg-inline"> ' . pages()->get('/noticias/categorias/')->title . '</span></dt>' . "\n";
$saida .= '<dd><a href="' . $publicacion->categorias->url . '">' . $publicacion->categorias->title . '</a></dd>' . "\n";
$saida .= '<dt title="' . pages()->get('/noticias/etiquetas/')->title . '"><i class="icon-tag"></i><span class="d-none d-lg-inline"> ' . pages()->get('/noticias/etiquetas/')->title . '</span></dt>' . "\n";
$saida .= '<dd>' . $publicacion->etiquetas->each("<a href='{url}'>{title}</a>") . '</dd>' . "\n";
$saida .= '</dl>' . "\n";
$saida .= '</div>' . "\n";
$saida .= '</header>' . "\n";
if($resumen)
{
if($publicacion->imaxe)
{
$thumb = $publicacion->imaxe->size(466, 260);
2023-02-27 17:10:20 +01:00
$saida .= '<img class="mw-100" src="' . $thumb->url . '" alt="' . $publicacion->imaxe->description . '">' . "\n";
2023-02-21 14:48:37 +01:00
}
2023-02-27 17:10:20 +01:00
$saida .= '<div class="resumo mb-5">' . "\n";
2023-02-21 14:48:37 +01:00
$saida .= '<p>' . renderResumen(getTextoLimpo(getSeccions($publicacion->seccions))) . '</p>' . "\n";
$saida .= '<p><a href="' . $publicacion->url . '"><i class="icon-arrow-right"></i>' . _x("Read more", "Read more") . '</a></p>' ."\n";
$saida .= '</div>' . "\n";
}
else
{
if($publicacion->imaxe)
{
$thumb = $publicacion->imaxe->size(466, 260);
2023-02-27 17:10:20 +01:00
$saida .= '<a href="' . $publicacion->imaxe->url . '"><img class="mw-100" src="' . $thumb->url . '" alt="' . $publicacion->imaxe->description . '"></a>' . "\n";
2023-02-21 14:48:37 +01:00
}
2023-02-27 17:10:20 +01:00
$saida .= '<div class="secciones mb-5">' . "\n";
2023-02-21 14:48:37 +01:00
$saida .= getSeccions($publicacion->seccions) . "\n";
$saida .= '</div>' . "\n";
}
$saida .= '</article>' . "\n";
return $saida;
}
/**
* @param string $texto
* @param int $limite
* @param string $fin
* @return string
*/
function renderResumen($texto = '', $limite = 120, $fin = '...')
{
$saida = '';
if($texto == '') return '';
if(strlen($texto) <= $limite) return $texto;
$saida = substr($texto, 0, $limite);
$pos = strrpos($saida, " ");
if($pos>0)
{
$saida = substr($saida, 0, $pos);
}
$saida .= $fin;
return $saida;
}