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-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;
|
|
|
|
$saida .= '<img src="' . $imaxe->url . '" alt="' . $imaxe->description . '" loading="lazy">';
|
|
|
|
$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 . '">';
|
|
|
|
$saida .= '<h3>' . $seccion->titular . '</h3>';
|
|
|
|
$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 = '';
|
|
|
|
|
|
|
|
$saida .= '<figure>' . "\n";
|
|
|
|
$saida .= '<img src="' . $seccion->imaxe->url . '" alt="' . $seccion->imaxe->description . '" loading="lazy">';
|
|
|
|
$saida .= '<figcaption>' . "\n";
|
|
|
|
$saida .= '<h2>' . $seccion->titular . '</h2>' . "\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";
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2024-09-20 14:24:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Rehacer */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array|PageArray $paxinas
|
|
|
|
* @param int $maxDepth How many levels of navigation below current should it go?
|
|
|
|
* @param string $fieldNames Any extra field names to display (separate multiple fields with a space)
|
|
|
|
* @param string $class CSS class name for containing <ul>
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function renderMapaDoSitio($paxinas, $profundidade = 0, $clase = 'nav')
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
$actual = wire('page');
|
|
|
|
|
|
|
|
if($paxinas instanceof Page) $paxinas = array($paxinas);
|
|
|
|
|
|
|
|
foreach($paxinas as $paxina)
|
|
|
|
{
|
|
|
|
$saida .= '<li class="'. (($paxina->id == $actual->id) ? ' active' : '') . '">';
|
|
|
|
$saida .= "<a href='$paxina->url'>$paxina->title</a>";
|
|
|
|
|
|
|
|
if($paxina->hasChildren() && $profundidade)
|
|
|
|
{
|
|
|
|
if($clase == 'nav') $clase = 'nav nav-tree';
|
|
|
|
$saida .= renderMapaDoSitio($paxina->children, $profundidade-1, $clase);
|
|
|
|
}
|
|
|
|
$saida .= "</li>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($saida) $saida = '<ul class="' . $clase . '">' . $saida . '</ul>';
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
|
2023-02-18 18:21:02 +01:00
|
|
|
}
|