praiadeseselle/site/templates/atopar.php

73 lines
2.6 KiB
PHP
Raw Normal View History

<?php namespace ProcessWire;
2023-03-11 12:53:47 +01:00
/** @var Page $page API variable */
$atopar = $sanitizer->text($input->get('q'));
$menu = '';
$contido = '';
2023-03-11 12:53:47 +01:00
if($configuracion['mantemento']['activo'] && !$user->isLoggedin())
{
$session->redirect($inicio->url);
}
else
{
2023-03-11 12:53:47 +01:00
$menu = renderMenu($inicio->children);
}
2023-03-11 12:53:47 +01:00
$contido .= renderMigasPan($page) . "\n";
$contido .= '<article id="' . $page->name .'" class="container">' . "\n";
$contido .= '<h2 class="visually-hidden">' . ucfirst($page->title) . '</h2>' . "\n";
2023-03-11 12:53:47 +01:00
if($atopar)
{
$input->whitelist('q', $atopar);
$atopar = $sanitizer->selectorValue($atopar);
2023-03-11 12:53:47 +01:00
$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);
2023-03-11 12:53:47 +01:00
$cnt = $matches->count;
2023-03-11 12:53:47 +01:00
if($cnt)
{
$contido .= '<h3>Resultados para: ' . $atopar . '</h3>' . "\n";
$contido .= '<p>' . sprintf(_n(_x('Atopouse %d páxina', 'Found 1 page'),
_x('Atopáronse %d páxinas', 'Found multiple pages'), $cnt), $cnt) . '</p>' . "\n";
$contido .= '<section>' . "\n";
$contido .= '<h4 class="accesibilidade-oculto">' . _x("Resultados", "Search results") . '</h4>' . "\n";
$contido .= '<ul class="lista">'."\n";
foreach($matches as $paxina)
{
2023-03-11 12:53:47 +01:00
$contido .= '<li class="info">' . "\n";
$contido .= '<a href="' . $paxina->url . '"><i class="icon-play"></i> ' . $paxina->title . '</a>' . "\n";
$contido .= '</li>' . "\n";
}
2023-03-11 12:53:47 +01:00
$contido .= '</ul>'."\n";
$contido .= '</section>';
}
else
{
$contido .= '<h3>' . _x('Mapa do sitio', 'Sitemap') . '</h3>' . "\n";
$contido .= '<p>' . _x('Sentímolo, non se atoparon resultados', 'Sorry, no results were found.') . '</p>' . "\n";
$contido .= '<section>' . "\n";
$contido .= '<h4 class="accesibilidade-oculto">' . _x('Mapa do sitio', 'Sitemap') . '</h4>' . "\n";
$contido .= renderMapaDoSitio($inicio, 3, 'mapa-sitio');
$contido .= '</section>';
}
2023-03-11 12:53:47 +01:00
}
else
{
$contido .= '<h3>' . _x('Mapa do sitio', 'Sitemap') . '</h3>' . "\n";
$contido .= '<p>' . _x('Sentímolo, non se atoparon resultados', 'Sorry, no results were found.') . '</p>' . "\n";
$contido .= '<section>' . "\n";
$contido .= '<h4 class="accesibilidade-oculto">' . _x('Mapa do sitio', 'Sitemap') . '</h4>' . "\n";
$contido .= renderMapaDoSitio($inicio, 3, 'mapa-sitio');
$contido .= '</section>';
}
$contido .= '</article>' . "\n";