praiadeseselle/site/templates/atopar.php
2023-03-11 13:28:54 +01:00

73 lines
No EOL
2.6 KiB
PHP

<?php namespace ProcessWire;
/** @var Page $page API variable */
$atopar = $sanitizer->text($input->get('q'));
$menu = '';
$contido = '';
if($configuracion['mantemento']['activo'] && !$user->isLoggedin())
{
$session->redirect($inicio->url);
}
else
{
$menu = renderMenu($inicio->children);
}
$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 = "";
$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);
$cnt = $matches->count;
if($cnt)
{
$contido .= '<h3>Resultados para: ' . $atopar . '</h3>' . "\n";
$contido .= '<p>' . sprintf(_n(_x('Found %d page', 'found 1 page'),
_x('Found %d pages', 'found multiple pages'), $cnt), $cnt) . '</p>' . "\n";
$contido .= '<section>' . "\n";
$contido .= '<h4 class="accesibilidade-oculto">' . _x("Search results", "search results") . '</h4>' . "\n";
$contido .= '<ul class="lista">'."\n";
foreach($matches as $paxina)
{
$contido .= '<li class="info">' . "\n";
$contido .= '<a href="' . $paxina->url . '"><i class="icon-play"></i> ' . $paxina->title . '</a>' . "\n";
$contido .= '</li>' . "\n";
}
$contido .= '</ul>'."\n";
$contido .= '</section>';
}
else
{
$contido .= '<h3>' . _x('Sitemap', 'sitemap') . '</h3>' . "\n";
$contido .= '<p>' . _x('Sorry, no results were found', 'no results found') . '.</p>' . "\n";
$contido .= '<section>' . "\n";
$contido .= '<h4 class="accesibilidade-oculto">' . _x('Sitemap', 'sitemap') . '</h4>' . "\n";
$contido .= renderMapaDoSitio($inicio, 3, 'mapa-sitio');
$contido .= '</section>';
}
}
else
{
$contido .= '<h3>' . _x('Sitemap', 'sitemap') . '</h3>' . "\n";
$contido .= '<p>' . _x('Sorry, no results were found', 'no results found') . '.</p>' . "\n";
$contido .= '<section>' . "\n";
$contido .= '<h4 class="accesibilidade-oculto">' . _x('Sitemap', 'sitemap') . '</h4>' . "\n";
$contido .= renderMapaDoSitio($inicio, 3, 'mapa-sitio');
$contido .= '</section>';
}
$contido .= '</article>' . "\n";