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;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSeccions($seccions, $mantemento = false)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
foreach($seccions as $seccion)
|
|
|
|
{
|
|
|
|
switch($seccion->template)
|
|
|
|
{
|
|
|
|
case 'repeater_seccions':
|
|
|
|
switch ($seccion->tipo_seccion->value)
|
|
|
|
{
|
|
|
|
case 'texto':
|
|
|
|
$saida .= renderTexto($seccion->artigo);
|
|
|
|
break;
|
|
|
|
case 'galeria':
|
|
|
|
$saida .= renderGaleria($seccion->galeria);
|
|
|
|
break;
|
|
|
|
case 'texto_imaxe_lateral':
|
|
|
|
$saida .= renderTextoImaxe($seccion->artigo, $seccion->imaxe, $seccion->posicion_imaxe->value);
|
|
|
|
break;
|
|
|
|
case 'texto_imaxe_superior':
|
|
|
|
$saida .= getSeccions($seccion->seccion_destacada);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'repeater_seccion_destacada':
|
|
|
|
if($mantemento)
|
|
|
|
{
|
|
|
|
$saida .= renderTextoImaxe($seccion->artigo, $seccion->imaxe, 'mantemento');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= renderTextoImaxe($seccion->artigo, $seccion->imaxe, 'superior');
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
$saida .= '<li class="activo">';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$saida .= '<li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
|
|
|
$saida .= '</li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if($saida)
|
|
|
|
{
|
|
|
|
$saida = '<ul id="' . $id . '" class="contenedor columna separado fin">' . $saida . '</ul>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
2022-03-09 18:09:44 +01:00
|
|
|
function renderTexto($artigo)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
$saida .= '<section>';
|
|
|
|
$saida .= $artigo;
|
|
|
|
$saida .= '</section>';
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderGaleria($galeria)
|
|
|
|
{
|
|
|
|
$saida = '';
|
|
|
|
|
|
|
|
$saida .= '<section>';
|
|
|
|
$saida .= '<div class="swiper-wrapper">';
|
|
|
|
foreach($galeria as $imaxen)
|
|
|
|
{
|
|
|
|
$saida .= '<img src="' . $imaxen->url . '" alt="">';
|
|
|
|
}
|
|
|
|
$saida .= '</section>';
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderTextoImaxe($texto, $imaxe, $posicion)
|
|
|
|
{
|
|
|
|
$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;
|
|
|
|
case 'mantemento':
|
2022-03-10 01:47:18 +01:00
|
|
|
$saida .= '<section id="' . $posicion .'">';
|
|
|
|
$saida .= '<img src="' . $imaxe->url . '" alt="">';
|
2022-03-09 18:09:44 +01:00
|
|
|
$saida .= '<div>' . $texto . '</div>';
|
|
|
|
$saida .= '</section>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $saida;
|
|
|
|
}
|