Paxina de procura.

This commit is contained in:
Laegnur 2023-03-11 12:53:47 +01:00
parent 03414732d1
commit d4f77bb8da
4 changed files with 1904 additions and 48 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,29 +1,34 @@
<?php namespace ProcessWire;
/** @var Page $page API variable */
$atopar = $sanitizer->text($input->get('q'));
$menu = '';
$contido = '';
$mantemento = $inicio->mantemento;
if($mantemento && !$user->isLoggedin())
if($configuracion['mantemento']['activo'] && !$user->isLoggedin())
{
$session->redirect($inicio->url);
}
else
{
$atopar = $sanitizer->text($input->get('q'));
$menu = renderMenu($inicio->children);
}
$contido .= '<article id="' . $page->name . '">' . "\n";
$contido .= '<h2 class="bloque"><i class="icon-search"></i> ';
$contido .= $atopar ? $page->title . ': ' . $atopar : $page->title;
$contido .= '</h2>' . "\n";
$contido .= renderMigasPan($page) . "\n";
$contido .= '<article id="' . $page->name .'" class="container">' . "\n";
$contido .= '<h2 class="visually-hidden">' . ucfirst($page->title) . '</h2>' . "\n";
if($atopar)
{
$input->whitelist('q', $atopar);
$atopar = $sanitizer->selectorValue($atopar);
$selector = "title|seccions.artigo~=$atopar, limit=50";
$selector = "";
$selector .= "(title|seccions.titular|seccions.artigo~=$atopar)";
$selector .= ",(seccions.destacados.titular~=$atopar)";
$selector .= ",(seccions.destacados.artigo~=$atopar), limit=50";
if($user->isLoggedin()) $selector .= ", has_parent!=2";
$matches = $pages->find($selector);
@ -66,4 +71,3 @@ else
$contido .= '</section>';
}
$contido .= '</article>' . "\n";
}

View file

@ -223,6 +223,39 @@ function renderMigasPan($paxina, $separador = '<i class="icon-chevrons-right"></
return $saida;
}
/**
* @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' : '') . '">' . "\n";
$saida .= "<a href='$paxina->url'>$paxina->title</a>";
if($paxina->hasChildren() && $profundidade)
{
if($class == 'nav') $class = 'nav nav-tree';
$saida .= renderMapaDoSitio($paxina->children, $profundidade-1, $clase);
}
$saida .= "</li>";
}
if($saida) $saida = '<ul class="' . $class . '">' . $saida . '</ul>' ."\n";
return $saida;
}
/**
* @param string $titulo
* @param string $texto