721 lines
No EOL
23 KiB
PHP
721 lines
No EOL
23 KiB
PHP
<?php namespace ProcessWire;
|
|
|
|
/**
|
|
* @param Page $paxina
|
|
* @return array
|
|
*/
|
|
|
|
function getConfig($paxina)
|
|
{
|
|
$configuracion = array();
|
|
|
|
foreach($paxina->configuracion as $config)
|
|
{
|
|
switch ($config->parametro_tipo->value)
|
|
{
|
|
case 'texto':
|
|
$configuracion[$config->parametro_nome] = $config->parametro_valor;
|
|
break;
|
|
case 'cor':
|
|
list($r, $g, $b) = sscanf($config->parametro_cor, "%02x%02x%02x");
|
|
$configuracion[$config->parametro_nome] = $r . ', ' . $g . ', ' . $b;
|
|
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;
|
|
}
|
|
}
|
|
|
|
return $configuracion;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccions
|
|
* @return string
|
|
*/
|
|
|
|
function getSeccions($seccions)
|
|
{
|
|
$saida = '';
|
|
$posicion = 0;
|
|
|
|
foreach($seccions as $seccion)
|
|
{
|
|
$posicion++;
|
|
switch($seccion->template)
|
|
{
|
|
case 'repeater_seccions':
|
|
switch ($seccion->seccion_tipo->value)
|
|
{
|
|
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;
|
|
case 'texto':
|
|
$saida .= renderTexto($seccion);
|
|
break;
|
|
case 'galeria':
|
|
$saida .= renderGaleria($seccion);
|
|
break;
|
|
case 'reixa':
|
|
$saida .= renderReixa($seccion);
|
|
break;
|
|
}
|
|
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);
|
|
break;
|
|
}
|
|
}
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @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')
|
|
{
|
|
$saida = '';
|
|
$inicio = wire('pages')->get('/');
|
|
$actual = wire('page');
|
|
|
|
if($paxinas instanceof Page)
|
|
{
|
|
$paxinas = array($paxinas);
|
|
}
|
|
|
|
$saida .= '<ul class="' . $clase . '">' . "\n";
|
|
$saida .= '<li class="nav-item">';
|
|
$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";
|
|
|
|
foreach($paxinas as $paxina)
|
|
{
|
|
$saida .= '<li class="nav-item">';
|
|
$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";
|
|
}
|
|
$saida .= '</ul>' . "\n";
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $paxina
|
|
* @param string $separador
|
|
* @return string
|
|
*/
|
|
|
|
function renderMigasPan($paxina, $separador = '<i class="icon-chevrons-right"></i>')
|
|
{
|
|
$saida = '';
|
|
$icono = '';
|
|
|
|
switch ($paxina->template)
|
|
{
|
|
case 'inicio':
|
|
$icono = 'home';
|
|
break;
|
|
case 'paxina':
|
|
case 'habitacions':
|
|
case 'habitacion':
|
|
$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)
|
|
{
|
|
$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()):
|
|
$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";
|
|
$saida .= '</div>';
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param string $titulo
|
|
* @param string $texto
|
|
* @param array|PageArray $imaxe
|
|
* @return string
|
|
*/
|
|
|
|
function renderTextoMantemento($titulo, $texto, $imaxe)
|
|
{
|
|
$saida = '';
|
|
|
|
$saida .= '<section class="container px-4 py-5">' . "\n";
|
|
$saida .= '<div class="row p-4 pt-lg-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";
|
|
$saida .= '<div class="container px-5">' . "\n";
|
|
$saida .= '<img src="' . $imaxe->url . '" class="img-fluid border rounded-3 shadow-lg p-5 mb-4" alt="' . $imaxe->description . '" loading="lazy" width="700" height="500">' . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
$saida .= '</section>' . "\n";
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderGaleria($seccion)
|
|
{
|
|
$saida = '';
|
|
|
|
$saida .= '<section id="galeria" class="galeria contedor columna swiper d-none d-md-block">' . "\n";
|
|
$saida .= '<h3 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Galeria') . '</h3>' . "\n";
|
|
$saida .= '<div class="swiper-wrapper">' . "\n";
|
|
foreach($seccion->imaxes as $imaxe)
|
|
{
|
|
$saida .= '<div class="swiper-slide">' . "\n";
|
|
$saida .= '<figure>' . "\n";
|
|
$saida .= '<img src="' . $imaxe->url . '" alt="' . $imaxe->description . '" loading="lazy">' . "\n";
|
|
$saida .= '<figcaption>' . $imaxe->description . '</figcaption>' . "\n";
|
|
$saida .= '</figure>' . "\n";
|
|
$saida .= '<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>' . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
}
|
|
$saida .= '</div>' . "\n";
|
|
|
|
$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";
|
|
$saida .= '</section>';
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderReixa($seccion)
|
|
{
|
|
$saida = '';
|
|
|
|
$saida .= '<section class="container">' . "\n";
|
|
$saida .= '<h3 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Reixa') . '</h3>' . "\n";
|
|
$saida .= '<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">' . "\n";
|
|
foreach($seccion->imaxes as $imaxe)
|
|
{
|
|
$saida .= '<figure class="col py-3">' . "\n";
|
|
$saida .= '<img class="reixa-item" src="' . $imaxe->url . '" alt="' . $imaxe->description . '">' . "\n";
|
|
$saida .= '</figure>' . "\n";
|
|
}
|
|
$saida .= '</div>' . "\n";
|
|
|
|
$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";
|
|
$saida .= '</section>';
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderImaxeTexto($seccion)
|
|
{
|
|
$saida = '';
|
|
$imaxe = '';
|
|
$texto = '';
|
|
$botons = '';
|
|
|
|
if($seccion->imaxe)
|
|
{
|
|
$imaxe .= renderImaxe($seccion);
|
|
}
|
|
|
|
$texto .= renderTexto($seccion);
|
|
|
|
if($seccion->botons->isEmpty())
|
|
{
|
|
$botons .= '<div class="row text-center">' . "\n";
|
|
$botons .= getSeccions($seccion->botons) . "\n";
|
|
$botons .= '</div>' . "\n";
|
|
}
|
|
|
|
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':
|
|
$saida .= '<section class="container mb-5">' . "\n";
|
|
$saida .= '<div class="row align-items-center">' . "\n";
|
|
$saida .= '<div class="col col-lg-6 text-center">' . "\n";
|
|
$saida .= $imaxe . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
$saida .= '<div class="col col-lg-6 text-center">' . "\n";
|
|
$saida .= $texto . "\n";
|
|
$saida .= $botons . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
break;
|
|
case 'dereita':
|
|
$saida .= '<section class="container mb-5">' . "\n";
|
|
$saida .= '<div class="row align-items-center">' . "\n";
|
|
$saida .= '<div class="col col-lg-6 text-center">' . "\n";
|
|
$saida .= $texto . "\n";
|
|
$saida .= $botons . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
$saida .= '<div class="col col-lg-6 text-center">' . "\n";
|
|
$saida .= $imaxe . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
break;
|
|
}
|
|
$saida .= '</section>' . "\n";
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderImaxe($seccion)
|
|
{
|
|
$saida = '';
|
|
|
|
$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";
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderTexto($seccion)
|
|
{
|
|
$saida = '';
|
|
|
|
if($seccion->titular)
|
|
{
|
|
$saida .= '<div>' . "\n";
|
|
$saida .= '<h3 class="fw-semibold">' . $seccion->titular . '</h3>' . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
}
|
|
$saida .= '<div>' . "\n";
|
|
$saida .= $seccion->artigo . "\n";
|
|
$saida .= '</div>' . "\n";
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderBoton($seccion)
|
|
{
|
|
$saida = '';
|
|
$clases = '';
|
|
$sufijo = '';
|
|
|
|
switch ($seccion->botons_estilo->value)
|
|
{
|
|
case 'activo':
|
|
$clases = 'btn btn-lg btn-primary';
|
|
break;
|
|
case 'secundario':
|
|
$clases = 'btn btn-lg btn-secundary';
|
|
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>';
|
|
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>';
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @param array|PageArray $seccion
|
|
* @return string
|
|
*/
|
|
|
|
function renderLigazonImaxe($seccion)
|
|
{
|
|
$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";
|
|
|
|
return $saida;
|
|
}
|
|
|
|
/**
|
|
* @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;
|
|
}
|
|
$saida .= '<div class="row mb-5">' . "\n";
|
|
$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;
|
|
}
|
|
|
|
$saida .= '<div id="' . $nome . '" class="col p-3 mb-4">' . "\n";
|
|
$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);
|
|
$saida .= '<img src="' . $thumb->url . '" alt="' . $publicacion->imaxe->description . '">' . "\n";
|
|
}
|
|
$saida .= '<div class="resumo">' . "\n";
|
|
$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);
|
|
$saida .= '<a href="' . $publicacion->imaxe->url . '"><img src="' . $thumb->url . '" alt="' . $publicacion->imaxe->description . '"></a>' . "\n";
|
|
}
|
|
$saida .= '<div class="secciones">' . "\n";
|
|
$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;
|
|
|
|
} |