2022-03-09 18:09:44 +01:00
|
|
|
<?php namespace ProcessWire;
|
|
|
|
|
|
|
|
function getConfig($paxina)
|
|
|
|
{
|
|
|
|
$configuracion = array();
|
|
|
|
|
|
|
|
foreach($paxina->configuracion as $config)
|
|
|
|
{
|
|
|
|
$configuracion[$config->nome_parametro] = $config->valor_parametro;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $configuracion;
|
|
|
|
}
|
|
|
|
|
2022-04-06 13:08:40 +02:00
|
|
|
function getSeccions($seccions)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
foreach($seccions as $seccion)
|
|
|
|
{
|
|
|
|
switch($seccion->template)
|
|
|
|
{
|
|
|
|
case 'repeater_seccions':
|
|
|
|
switch ($seccion->tipo_seccion->value)
|
|
|
|
{
|
|
|
|
case 'texto':
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= renderTexto($seccion->titular, $seccion->artigo);
|
2022-03-09 18:09:44 +01:00
|
|
|
break;
|
|
|
|
case 'galeria':
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= renderGaleria($seccion->titular, $seccion->galeria);
|
2022-03-09 18:09:44 +01:00
|
|
|
break;
|
|
|
|
case 'texto_imaxe_lateral':
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= renderTextoImaxe($seccion->titular, $seccion->artigo, $seccion->imaxe, $seccion->posicion_imaxe->value);
|
2022-03-09 18:09:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2022-04-07 13:57:02 +02:00
|
|
|
case 'repeater_mensaxe_mantemento':
|
|
|
|
$saida .= renderTextoMantemento($seccion->titular, $seccion->artigo, $seccion->imaxe);
|
|
|
|
break;
|
|
|
|
case 'imaxe_ligazon':
|
2022-03-09 18:09:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2022-03-10 01:47:18 +01:00
|
|
|
function renderMenu($paxinas, $maxDepth = 0, $id = 'nav')
|
|
|
|
{
|
|
|
|
if($paxinas instanceof Page)
|
|
|
|
{
|
|
|
|
$paxinas = array($paxinas);
|
|
|
|
}
|
|
|
|
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
foreach($paxinas as $paxina)
|
|
|
|
{
|
|
|
|
|
|
|
|
if($paxina->id == wire('page')->id)
|
|
|
|
{
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= ' <li class="activo">';
|
2022-03-10 01:47:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= ' <li>';
|
2022-03-10 01:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$saida .= '<a href="' . $paxina->url . '">' . $paxina->title . '</a>';
|
|
|
|
|
|
|
|
if($paxina->hasChildren() && $maxDepth)
|
|
|
|
{
|
|
|
|
if($id == 'nav')
|
|
|
|
{
|
|
|
|
$id = 'nav nav-tree';
|
|
|
|
}
|
|
|
|
$saida .= renderMenu($paxina->children, $maxDepth-1, $id);
|
|
|
|
}
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= '</li>' . "\n";
|
2022-03-10 01:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if($saida)
|
|
|
|
{
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida = ' <ul id="' . $id . '">' . "\n" . $saida . ' </ul>' . "\n";
|
2022-03-10 01:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2022-04-06 13:08:40 +02:00
|
|
|
function renderMigasPan($paxina, $separador = '<i class="icon-chevrons-right"></i>')
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= '<div class="contedor migas_pan" role="navigation" aria-label="' . _x('Current page', 'navigation') . ':">' . "\n";
|
|
|
|
$saida .= ' ' . $separador . ' ';
|
2022-04-06 13:08:40 +02:00
|
|
|
foreach($paxina->parents() as $pai)
|
|
|
|
{
|
|
|
|
$saida .= '<span><a href="' . $pai->url . '">' . $pai->title . '</a></span> ' . $separador . ' ';
|
|
|
|
}
|
|
|
|
$saida .= '<span>' . $paxina->title . '</span>';
|
|
|
|
if($paxina->editable()):
|
|
|
|
$saida .= ' [ <a href="' . $paxina->editURL . '"> <i class="icon-edit"></i> ' . _x('Edit', 'Edit page') . ' </a> ]';
|
|
|
|
endif;
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= "\n";
|
|
|
|
$saida .= ' </div>';
|
2022-04-06 13:08:40 +02:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
function renderTexto($titulo, $texto)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= '<section>' . "\n";
|
|
|
|
$saida .= $texto . "\n";
|
|
|
|
$saida .= '</section>' . "\n";
|
2022-03-09 18:09:44 +01:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
function renderGaleria($titulo, $galeria)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= '<section class="contedor swiper">' . "\n";
|
|
|
|
$saida .= ' <h3 class="visually-hidden">';
|
|
|
|
if($titulo)
|
|
|
|
{
|
|
|
|
$saida .= $titulo;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= 'Galeria';
|
|
|
|
}
|
|
|
|
$saida .= '</h3>' . "\n";
|
|
|
|
$saida .= ' <div class="swiper-wrapper">' . "\n";
|
2022-04-06 13:08:40 +02:00
|
|
|
foreach($galeria as $imaxe)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= ' <div class="swiper-slide">' . "\n";
|
|
|
|
$saida .= ' <figure>' . "\n";
|
|
|
|
$saida .= ' <img src="' . $imaxe->url . '" alt="' . $imaxe->description . '">' . "\n";
|
|
|
|
$saida .= ' <figcaption>' . $imaxe->description . '</figcaption>' . "\n";
|
|
|
|
$saida .= ' </figure>' . "\n";
|
|
|
|
$saida .= ' </div>' . "\n";
|
2022-03-09 18:09:44 +01:00
|
|
|
}
|
2022-04-07 13:57:02 +02:00
|
|
|
$saida .= ' </div>' . "\n";
|
|
|
|
$saida .= ' <div class="swiper-button-prev"></div>' . "\n";
|
|
|
|
$saida .= ' <div class="swiper-button-next"></div>' . "\n";
|
|
|
|
$saida .= ' <div class="swiper-paxination"></div>' . "\n";
|
|
|
|
$saida .= ' </section>';
|
2022-03-09 18:09:44 +01:00
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
function renderTextoImaxe($titulo, $texto, $imaxe, $posicion)
|
2022-03-09 18:09:44 +01:00
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
switch ($posicion)
|
|
|
|
{
|
|
|
|
case 'esquerda':
|
|
|
|
$saida .= '<section>';
|
|
|
|
$saida .= '<img class="' . $posicion .'" src="' . $imaxe->url . '" alt="">';
|
|
|
|
$saida .= '<div>' . $texto . '</div>';
|
|
|
|
$saida .= '</section>';
|
|
|
|
break;
|
|
|
|
case 'dereita':
|
|
|
|
$saida .= '<section>';
|
|
|
|
$saida .= '<div>' . $texto . '</div>';
|
|
|
|
$saida .= '<img class="' . $posicion .'" src="' . $imaxe->url . '" alt="">';
|
|
|
|
$saida .= '</section>';
|
|
|
|
break;
|
|
|
|
case 'superior':
|
|
|
|
$saida .= '<section>';
|
|
|
|
$saida .= '<img class="' . $posicion .'" src="' . $imaxe->url . '" alt="">';
|
|
|
|
$saida .= '<div>' . $texto . '</div>';
|
|
|
|
$saida .= '</section>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-04-07 13:57:02 +02:00
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderTextoMantemento($titulo, $texto, $imaxe)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
$saida .= '<section>' . "\n";
|
|
|
|
$saida .= ' <h3>' . $titulo . '</h3>' . "\n";
|
|
|
|
if($imaxe)
|
|
|
|
{
|
|
|
|
$saida .= ' <figure>' . "\n";
|
|
|
|
$saida .= ' <img src="' . $imaxe->url . '" alt="' . $imaxe->description . '">' . "\n";
|
|
|
|
$saida .= ' <figcaption>' . $texto . '</figcaption>' . "\n";
|
|
|
|
$saida .= ' </figure>' . "\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= ' ' . $texto . "\n";
|
|
|
|
}
|
|
|
|
$saida .= ' </section>';
|
|
|
|
|
2022-03-09 18:09:44 +01:00
|
|
|
return $saida;
|
|
|
|
}
|