2022-03-09 18:09:44 +01:00
|
|
|
<?php namespace ProcessWire;
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
/** @var Page $page */
|
|
|
|
/** @var Pages $pages */
|
|
|
|
/** @var Config $config */
|
|
|
|
/** @var Sanitizer $sanitizer API variable */
|
|
|
|
/** @var WireInput $input API variable */
|
|
|
|
/** @var User $user API variable */
|
|
|
|
/** @var Languages $languages API variable */
|
|
|
|
/** @var SiteConfig $configuracion */
|
|
|
|
/** @var HomePage $inicio */
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
/**
|
|
|
|
* @param Page $paxina
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
|
2022-03-09 18:09:44 +01:00
|
|
|
function getConfig($paxina)
|
|
|
|
{
|
|
|
|
$configuracion = array();
|
2024-09-20 14:24:47 +02:00
|
|
|
$configuracion['redes'] = array();
|
2022-03-09 18:09:44 +01:00
|
|
|
|
2024-04-04 14:38:16 +02:00
|
|
|
foreach($paxina->configuracion as $cfg)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
2024-04-04 14:38:16 +02:00
|
|
|
switch ($cfg->parametro_tipo->value)
|
2022-05-03 12:18:01 +02:00
|
|
|
{
|
|
|
|
case 'texto':
|
2024-09-20 14:24:47 +02:00
|
|
|
if(strpos($cfg->parametro_nome, 'rrss') === 0)
|
|
|
|
{
|
|
|
|
$nome = substr($cfg->parametro_nome, strpos($cfg->parametro_nome, "_") + 1);
|
|
|
|
|
|
|
|
$configuracion['redes'][$nome] = $cfg->parametro_valor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$configuracion[$cfg->parametro_nome] = $cfg->parametro_valor;
|
|
|
|
}
|
2022-05-03 12:18:01 +02:00
|
|
|
break;
|
|
|
|
case 'cor':
|
2024-04-04 14:38:16 +02:00
|
|
|
$configuracion[$cfg->parametro_nome] = $cfg->parametro_cor[0] . ", " . $cfg->parametro_cor[1] . ", " . $cfg->parametro_cor[2];
|
2022-05-03 12:18:01 +02:00
|
|
|
break;
|
2022-12-06 10:05:56 +01:00
|
|
|
case 'mantemento':
|
2024-04-04 14:38:16 +02:00
|
|
|
if($cfg->parametro_mantemento==1)
|
2022-12-06 10:05:56 +01:00
|
|
|
{
|
|
|
|
$configuracion['mantemento'] = array(
|
2023-02-18 18:21:02 +01:00
|
|
|
'activo' => true,
|
2024-04-04 14:38:16 +02:00
|
|
|
'titular' => $cfg->titular,
|
|
|
|
'artigo' => $cfg->artigo,
|
|
|
|
'imaxe' => $cfg->imaxe
|
2022-12-06 10:05:56 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-02-18 18:21:02 +01:00
|
|
|
$configuracion['mantemento'] = array('activo' => false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'logo':
|
2024-04-04 14:38:16 +02:00
|
|
|
foreach($cfg->imaxes as $logo)
|
2023-02-18 18:21:02 +01:00
|
|
|
{
|
2024-09-20 14:24:47 +02:00
|
|
|
if($logo->hasTag('completo'))
|
|
|
|
{
|
|
|
|
$configuracion['logo']['completo'] = $logo;
|
|
|
|
}
|
|
|
|
if($logo->hasTag('mini'))
|
|
|
|
{
|
|
|
|
$configuracion['logo']['mini'] = $logo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'imaxe':
|
|
|
|
if(strpos($cfg->parametro_nome, 'banner') === 0)
|
|
|
|
{
|
|
|
|
$nome = substr($cfg->parametro_nome, strpos($cfg->parametro_nome, "_") + 1);
|
|
|
|
|
|
|
|
$configuracion['banners'][$nome] = $cfg->imaxes->first();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$configuracion[$cfg->parametro_nome] = $cfg->parametro_valor;
|
2022-12-06 10:05:56 +01:00
|
|
|
}
|
|
|
|
break;
|
2022-05-03 12:18:01 +02:00
|
|
|
}
|
2022-03-09 18:09:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $configuracion;
|
|
|
|
}
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccions
|
|
|
|
* @return string
|
|
|
|
*/
|
2022-10-25 14:47:38 +02:00
|
|
|
|
2022-04-06 13:08:40 +02:00
|
|
|
function getSeccions($seccions)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
2023-02-18 18:21:02 +01:00
|
|
|
$posicion = 0;
|
2022-03-09 18:09:44 +01:00
|
|
|
|
|
|
|
foreach($seccions as $seccion)
|
|
|
|
{
|
2023-02-18 18:21:02 +01:00
|
|
|
$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
|
|
|
{
|
2024-09-20 14:24:47 +02:00
|
|
|
case 'texto':
|
2024-10-07 11:18:13 +02:00
|
|
|
$saida .= renderTexto($seccion);
|
2024-09-20 14:24:47 +02:00
|
|
|
break;
|
|
|
|
case 'imaxe':
|
|
|
|
$saida .= renderImaxe($seccion);
|
|
|
|
break;
|
|
|
|
case 'galeria':
|
|
|
|
$saida .= renderGaleria($seccion);
|
|
|
|
break;
|
|
|
|
case 'reixa':
|
|
|
|
$saida .= renderReixa($seccion);
|
|
|
|
break;
|
|
|
|
case 'columnas':
|
|
|
|
$saida .= renderColumna($seccion);
|
|
|
|
break;
|
|
|
|
case 'lapelas':
|
|
|
|
$saida .= renderLapelas($seccion);
|
|
|
|
break;
|
2023-02-18 18:21:02 +01:00
|
|
|
case 'deslizante':
|
|
|
|
$saida .= renderDeslizante($seccion);
|
|
|
|
break;
|
|
|
|
case 'destacados':
|
|
|
|
$saida .= renderDestacado($seccion);
|
|
|
|
break;
|
2024-09-20 14:24:47 +02:00
|
|
|
case 'tarxetas':
|
|
|
|
$saida .= renderTarxetas($seccion);
|
2023-02-18 18:21:02 +01:00
|
|
|
break;
|
|
|
|
case 'opinions':
|
|
|
|
$saida .= renderOpinions($seccion);
|
|
|
|
break;
|
2024-09-20 14:24:47 +02:00
|
|
|
case 'empresas':
|
|
|
|
$saida .= renderEmpresas($seccion);
|
2022-05-03 12:18:01 +02:00
|
|
|
break;
|
2022-03-09 18:09:44 +01:00
|
|
|
}
|
|
|
|
break;
|
2023-02-18 18:21:02 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
/**
|
|
|
|
* @param PageArray $paxinas
|
|
|
|
* @param string $clase
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
function renderMenu($paxinas)
|
2022-03-10 01:47:18 +01:00
|
|
|
{
|
2023-02-18 18:21:02 +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);
|
|
|
|
}
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<ul>';
|
2022-03-10 01:47:18 +01:00
|
|
|
foreach($paxinas as $paxina)
|
|
|
|
{
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<li>';
|
|
|
|
$saida .= '<a class="' . (($paxina->id == $actual->id) ? ' activo" aria-current="page' : '') . '" href="' . $paxina->url . '">' . mb_strtoupper($paxina->title) . '</a>';
|
|
|
|
$saida .= '</li>';
|
2022-03-10 01:47:18 +01:00
|
|
|
}
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '</ul>';
|
2022-03-10 01:47:18 +01:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
2023-02-18 18:21:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array|PageArray $paxina
|
2023-03-11 12:53:47 +01:00
|
|
|
* @param string $separador
|
|
|
|
* @return string
|
|
|
|
*/
|
2022-03-10 01:47:18 +01:00
|
|
|
|
2022-04-06 13:08:40 +02:00
|
|
|
function renderMigasPan($paxina, $separador = '<i class="icon-chevrons-right"></i>')
|
|
|
|
{
|
|
|
|
$saida = '';
|
2022-10-27 14:10:14 +02:00
|
|
|
$icono = '';
|
|
|
|
|
|
|
|
switch ($paxina->template)
|
|
|
|
{
|
2023-02-18 18:21:02 +01:00
|
|
|
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;
|
|
|
|
}
|
2022-04-06 13:08:40 +02:00
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<ol>';
|
2022-04-06 13:08:40 +02:00
|
|
|
foreach($paxina->parents() as $pai)
|
|
|
|
{
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<li>' . $separador . '<a href="' . $pai->url . '">' . $pai->title . '</a></li>';
|
2022-04-06 13:08:40 +02:00
|
|
|
}
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<li class="activo" aria-current="page">' . $separador . '<span>' . (($icono != '')? '<i class="icon-' . $icono . '"></i>' : '') . ' ' . $paxina->title . '</span>';
|
2022-04-06 13:08:40 +02:00
|
|
|
if($paxina->editable()):
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '[<a href="' . $paxina->editURL . '"><i class="icon-edit"></i> ' . _x('Edit', 'Edit page') . '</a>]';
|
2022-04-06 13:08:40 +02:00
|
|
|
endif;
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '</li>';
|
|
|
|
$saida .= '</ol>';
|
2022-04-06 13:08:40 +02:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-10-22 19:45:48 +02:00
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
}
|
|
|
|
|
2024-11-14 18:42:06 +01:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $paxinas
|
|
|
|
* @param int $profundidade How many levels of navigation below current should it go?
|
|
|
|
* @param string $class CSS class name for containing <ul>
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderMapaDoSitio($paxinas, $profundidade = 0)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
if($paxinas instanceof Page) $paxinas = array($paxinas);
|
|
|
|
|
|
|
|
$saida .= '<ul>';
|
|
|
|
foreach($paxinas as $paxina)
|
|
|
|
{
|
|
|
|
$saida .= '<li>';
|
|
|
|
$saida .= '<a href="' . $paxina->url . '">' . ucwords($paxina->title) . '</a>';
|
|
|
|
if($paxina->hasChildren() && $profundidade)
|
|
|
|
{
|
|
|
|
$saida .= renderMapaDoSitio($paxina->children(), $profundidade-1);
|
|
|
|
}
|
|
|
|
$saida .= "</li>";
|
|
|
|
}
|
|
|
|
$saida .= '</ul>';
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
/**
|
|
|
|
* @param string $titulo
|
|
|
|
* @param string $texto
|
|
|
|
* @param array|PageArray $imaxe
|
2023-03-11 12:53:47 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2024-09-20 14:24:47 +02:00
|
|
|
|
|
|
|
function renderTextoMantemento($titulo, $texto, $imaxe)
|
2023-03-11 12:53:47 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<section id="mantemento" class="centrado">';
|
|
|
|
$saida .= '<h2>' . $titulo . '</h2>';
|
|
|
|
$saida .= $texto;
|
2024-10-22 19:45:48 +02:00
|
|
|
$saida .= '<figure>';
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<img src="' . $imaxe->url . '" alt="' . $imaxe->description . '" loading="lazy">';
|
2024-10-22 19:45:48 +02:00
|
|
|
$saida .= '<figcaption>' . $imaxe->description . '</figcaption>';
|
|
|
|
$saida .= '</figure>';
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '</section>';
|
2023-03-11 12:53:47 +01:00
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
return $saida;
|
2023-03-11 12:53:47 +01:00
|
|
|
}
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
/**
|
2024-09-20 14:24:47 +02:00
|
|
|
* @param array|PageArray $seccion
|
2023-02-18 18:21:02 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2022-10-25 14:47:38 +02:00
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
function renderGaleria($seccion)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= '<section id="galeria-' . $seccion->id . '" class="galeria swiper">';
|
|
|
|
$saida .= '<h2 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Galeria') . '</h2>';
|
|
|
|
$saida .= '<div class="swiper-wrapper">';
|
|
|
|
foreach($seccion->imaxes as $imaxe)
|
|
|
|
{
|
|
|
|
$saida .= '<figure class="swiper-slide">';
|
|
|
|
$saida .= '<img src="' . $imaxe->url . '" alt="' . $imaxe->description . '" loading="lazy">';
|
|
|
|
$saida .= '<figcaption>' . $imaxe->description . '</figcaption>';
|
|
|
|
$saida .= '</figure>';
|
|
|
|
}
|
|
|
|
$saida .= '</div>';
|
|
|
|
$saida .= '<p class="controis"><span class="swiper-button-prev"></span><span class="visually-hidden">Previous</span>';
|
|
|
|
$saida .= '<span class="swiper-pagination"></span>';
|
|
|
|
$saida .= '<span class="swiper-button-next"></span><span class="visually-hidden">Next</span></p>';
|
|
|
|
$saida .= '</section>';
|
2022-03-09 18:09:44 +01:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-10-07 11:18:13 +02:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderReixa($seccion)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
$reixa = '';
|
|
|
|
$modal = '';
|
|
|
|
|
|
|
|
foreach($seccion->imaxes as $imaxe)
|
|
|
|
{
|
|
|
|
$reixa .= '<img class="reixa-item" src="' . $imaxe->url . '" alt="' . $imaxe->description . '">';
|
|
|
|
}
|
|
|
|
|
|
|
|
$modal .= '<div class="modal" tabindex="-1" aria-labelledby="reixa-modal-label" aria-hidden="true" style="display: none;">';
|
|
|
|
$modal .= '<i class="modal-pechar icon-x"></i><span class="visually-hidden">' . _x('Close menu', 'Close the menu'). '</span>';
|
|
|
|
$modal .= '<figure>';
|
|
|
|
$modal .= '<img class="modal-imaxe">';
|
|
|
|
$modal .= '<figcaption class="modal-descripcion"></figcaption>';
|
|
|
|
$modal .= '</figure>';
|
|
|
|
$modal .= '</div>';
|
|
|
|
|
|
|
|
if($seccion->titular)
|
|
|
|
{
|
|
|
|
$saida .= '<section id="reixa-' . $seccion->id . '">';
|
|
|
|
$saida .= '<h2>' . $seccion->titular . '</h2>';
|
|
|
|
$saida .= $reixa;
|
|
|
|
$saida .= $modal;
|
|
|
|
$saida .= '</section>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= '<div id="reixa-' . $seccion->id . '">';
|
|
|
|
$saida .= $reixa;
|
|
|
|
$saida .= $modal;
|
|
|
|
$saida .= '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderTexto($seccion)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
if($seccion->titular)
|
|
|
|
{
|
|
|
|
$saida .= '<section id="texto-' . $seccion->id . '">';
|
|
|
|
$saida .= '<h2>' . $seccion->titular . '</h2>';
|
|
|
|
$saida .= $seccion->artigo;
|
|
|
|
$saida .= '</section>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= '<div id="texto-' . $seccion->id . '" class="artigo">';
|
|
|
|
$saida .= $seccion->artigo;
|
|
|
|
$saida .= '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
function renderImaxe($seccion)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
2024-09-20 14:24:47 +02:00
|
|
|
$imaxe = '';
|
|
|
|
$botons = '';
|
2022-03-09 18:09:44 +01:00
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
if($seccion->imaxe)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
2024-09-20 14:24:47 +02:00
|
|
|
$imaxe .= '<figure>';
|
|
|
|
$imaxe .= '<img src="' . $seccion->imaxe->url . '" alt="' . $seccion->imaxe->description . '" loading="lazy">';
|
|
|
|
$imaxe .= '<figcaption>' . $seccion->imaxe->description . '</figcaption>';
|
|
|
|
$imaxe .= '</figure>';
|
2022-03-09 18:09:44 +01:00
|
|
|
}
|
2023-02-18 18:21:02 +01:00
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
if($seccion->botons->isEmpty())
|
|
|
|
{
|
|
|
|
$botons .= getSeccions($seccion->botons);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($seccion->titular)
|
|
|
|
{
|
|
|
|
$saida .= '<section id="imaxe-' . $seccion->id . '" class="'. $seccion->imaxe_posicion->value . '">';
|
2024-10-08 20:55:01 +02:00
|
|
|
$saida .= '<h2>' . $seccion->titular . '</h2>';
|
2024-09-20 14:24:47 +02:00
|
|
|
$saida .= $imaxe;
|
|
|
|
$saida .= '<div class="artigo">' . $seccion->artigo . '</div>';
|
|
|
|
$saida .= $botons;
|
|
|
|
$saida .= '</section>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= '<div id="imaxe-' . $seccion->id . '" class="'. $seccion->imaxe_posicion->value . '">';
|
|
|
|
$saida .= $imaxe;
|
|
|
|
$saida .= '<div class="artigo">' . $seccion->artigo . '</div>';
|
|
|
|
$saida .= $botons;
|
|
|
|
$saida .= '</div>';
|
|
|
|
}
|
|
|
|
|
2022-03-09 18:09:44 +01:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-10-07 11:18:13 +02:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderLigazonImaxe($seccion)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
2024-10-22 19:45:48 +02:00
|
|
|
$saida .= '<figure>';
|
2024-10-07 11:18:13 +02:00
|
|
|
$saida .= '<img src="' . $seccion->imaxe->url . '" alt="' . $seccion->imaxe->description . '" loading="lazy">';
|
2024-10-22 19:45:48 +02:00
|
|
|
$saida .= '<figcaption>';
|
|
|
|
$saida .= '<h2>' . $seccion->titular . '</h2>';
|
|
|
|
$saida .= '<p>' . _x('See details', 'see details') . '</p>';
|
|
|
|
$saida .= '<a href=' . $seccion->ligazon_interna->url . '></a>';
|
|
|
|
$saida .= '</figcaption>';
|
|
|
|
$saida .= '</figure>';
|
2024-10-07 11:18:13 +02:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-10-07 13:17:36 +02:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderDestacado($seccion)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
$icona = '';
|
|
|
|
|
|
|
|
if($seccion->titular)
|
|
|
|
{
|
|
|
|
$saida .= '<section id="destacados-' . $seccion->id . '">';
|
|
|
|
$saida .= '<h2>' . $seccion->titular . '</h2>';
|
|
|
|
$saida .= getSeccions($seccion->destacados);
|
|
|
|
$saida .= '</section>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= '<div id="destacados-' . $seccion->id . '">';
|
|
|
|
$saida .= getSeccions($seccion->destacados);
|
|
|
|
$saida .= '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @param int $posicion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderElemento($seccion , $posicion)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
$saida .= '<div class="elemento">';
|
|
|
|
switch($seccion->destacado_icona_tipo->value)
|
|
|
|
{
|
|
|
|
case 'icona':
|
|
|
|
$saida .= '<i class="icona ' . $seccion->parametro_valor .'"></i>';
|
|
|
|
break;
|
|
|
|
case 'imaxe':
|
|
|
|
$saida .= '<img class="icona" src="' . $seccion->imaxe->url . '" alt="' . $seccion->imaxe->description . '">';
|
|
|
|
break;
|
|
|
|
case 'posicion':
|
|
|
|
$saida .= '<span class="icona">' . $posicion . '</span>';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$saida .= '';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$saida .= '<h3>' . $seccion->titular . '</h3>';
|
|
|
|
$saida .= $seccion->artigo;
|
|
|
|
if($seccion->botons && $seccion->botons->isEmpty())
|
|
|
|
{
|
2024-10-22 19:45:48 +02:00
|
|
|
$saida .= '<div>';
|
|
|
|
$saida .= getSeccions($seccion->botons);
|
|
|
|
$saida .= '</div>';
|
2024-10-07 13:17:36 +02:00
|
|
|
}
|
2024-10-22 19:45:48 +02:00
|
|
|
$saida .= '</div>' ;
|
2024-10-07 13:17:36 +02:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-10-22 19:45:48 +02:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderCategoriasEtiquetas($seccion, $activo = false)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
switch ($seccion->first()->template->name)
|
|
|
|
{
|
|
|
|
case 'categoria':
|
|
|
|
$icono = 'folder';
|
|
|
|
$nome = 'categorias';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'etiqueta':
|
|
|
|
$icono = 'tag';
|
|
|
|
$nome = 'etiquetas';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$saida .= '<section id="' . $nome . '" class="acordeon">';
|
|
|
|
$saida .= '<input type="radio" name="plegable" id="plegable-' . $nome . '" ' . ($activo ? 'checked':'') . '>';
|
|
|
|
$saida .= '<h2>';
|
|
|
|
$saida .= '<label for="plegable-' . $nome . '">' . pages()->get('/noticias/' . $nome)->title . '</label>';
|
|
|
|
$saida .= '</h2>';
|
|
|
|
$saida .= '<ul>';
|
|
|
|
foreach($seccion as $item)
|
|
|
|
{
|
|
|
|
$saida .= '<li>';
|
|
|
|
$saida .= '<a href="' . $item->url . '"><i class="icon-' . $icono . '"></i> ' . $item->title . '</a>';
|
|
|
|
$saida .= '</li>';
|
|
|
|
}
|
|
|
|
$saida .= '</ul>';
|
|
|
|
$saida .= '</section>';
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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="artigo">';
|
|
|
|
$saida .= '<header>';
|
|
|
|
$saida .= '<time datetime="' . $publicacion->fecha_publicacion . '" title="' . $publicacion->fecha_publicacion . '">' ."\n";
|
|
|
|
$dateFormatter->setPattern('EEEE');
|
|
|
|
$saida .= '<em>' . ucfirst(datefmt_format($dateFormatter, $data)) . '</em>';
|
|
|
|
$dateFormatter->setPattern('MMMM');
|
|
|
|
$saida .= '<strong>' . ucfirst(datefmt_format($dateFormatter, $data)) . '</strong>';
|
|
|
|
$dateFormatter->setPattern('dd');
|
|
|
|
$saida .= '<span>' . datefmt_format($dateFormatter, $data) . '</span>';
|
|
|
|
$saida .= '</time>';
|
|
|
|
$saida .= '<h3>';
|
|
|
|
$saida .= '<a href="' . $publicacion->url . '"><i class="icon-' . (($resumen) ? 'book' : 'book-open') . '"></i> ' . $publicacion->title . '</a>';
|
|
|
|
$saida .= '</h3>';
|
|
|
|
$saida .= '<dl>';
|
|
|
|
$saida .= '<dt title="' . pages()->get('/noticias/categorias/')->title . '"><i class="icon-folder"></i><span> ' . pages()->get('/noticias/categorias/')->title . '</span></dt>';
|
|
|
|
$saida .= '<dd><a href="' . $publicacion->categorias->url . '">' . $publicacion->categorias->title . '</a></dd>';
|
|
|
|
$saida .= '<dt title="' . pages()->get('/noticias/etiquetas/')->title . '"><i class="icon-tag"></i><span> ' . pages()->get('/noticias/etiquetas/')->title . '</span></dt>';
|
|
|
|
$saida .= '<dd>' . $publicacion->etiquetas->each("<a href='{url}'>{title}</a> ") . '</dd>';
|
|
|
|
$saida .= '</dl>';
|
|
|
|
$saida .= '</header>';
|
|
|
|
|
|
|
|
if($resumen)
|
|
|
|
{
|
|
|
|
if($publicacion->imaxe)
|
|
|
|
{
|
|
|
|
$thumb = $publicacion->imaxe->size(0, 260);
|
|
|
|
$saida .= '<img src="' . $thumb->url . '" alt="' . $publicacion->imaxe->description . '">';
|
|
|
|
}
|
|
|
|
$saida .= '<div class="resumo mb-5">';
|
|
|
|
$saida .= '<p>' . renderResumen(getTextoLimpo(getSeccions($publicacion->seccions))) . '</p>';
|
|
|
|
$saida .= '<p><a href="' . $publicacion->url . '"><i class="icon-arrow-right"></i>' . _x("Read more", "Read more") . '</a></p>' ."\n";
|
|
|
|
$saida .= '</div>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($publicacion->imaxe)
|
|
|
|
{
|
|
|
|
$thumb = $publicacion->imaxe->size(0, 260);
|
|
|
|
$saida .= '<a href="' . $publicacion->imaxe->url . '"><img class="mw-100" src="' . $thumb->url . '" alt="' . $publicacion->imaxe->description . '"></a>';
|
|
|
|
}
|
|
|
|
$saida .= '<div class="secciones mb-5">';
|
|
|
|
$saida .= getSeccions($publicacion->seccions);
|
|
|
|
$saida .= '</div>';
|
|
|
|
}
|
|
|
|
$saida .= '</article>';
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
2024-09-20 14:24:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Rehacer */
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
/**
|
|
|
|
* @param array|PageArray $seccion
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
function renderBoton($seccion)
|
2022-10-27 14:10:14 +02:00
|
|
|
{
|
|
|
|
$saida = '';
|
2023-02-18 18:21:02 +01:00
|
|
|
$clases = '';
|
|
|
|
$sufijo = '';
|
2022-10-27 14:10:14 +02:00
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
switch ($seccion->botons_estilo->value)
|
2022-10-27 14:10:14 +02:00
|
|
|
{
|
2023-02-18 18:21:02 +01:00
|
|
|
case 'activo':
|
|
|
|
$clases = 'btn btn-lg btn-primary';
|
2022-10-27 14:10:14 +02:00
|
|
|
break;
|
2023-02-18 18:21:02 +01:00
|
|
|
case 'secundario':
|
|
|
|
$clases = 'btn btn-lg btn-secundary';
|
2022-10-27 14:10:14 +02:00
|
|
|
break;
|
2023-02-18 18:21:02 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-21 14:48:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|