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";
2023-03-11 13:28:54 +01:00
$contido .= '<p>' . sprintf(_n(_x('Found %d page', 'found 1 page'),
_x('Found %d pages', 'found multiple pages'), $cnt), $cnt) . '</p>' . "\n";
2023-03-11 12:53:47 +01:00
$contido .= '<section>' . "\n";
2023-03-11 13:28:54 +01:00
$contido .= '<h4 class="accesibilidade-oculto">' . _x("Search results", "search results") . '</h4>' . "\n";
2023-03-11 12:53:47 +01:00
$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
{
2023-03-11 13:28:54 +01:00
$contido .= '<h3>' . _x('Sitemap', 'sitemap') . '</h3>' . "\n";
$contido .= '<p>' . _x('Sorry, no results were found', 'no results found') . '.</p>' . "\n";
$contido .= '<section>' . "\n";
2023-03-11 13:28:54 +01:00
$contido .= '<h4 class="accesibilidade-oculto">' . _x('Sitemap', 'sitemap') . '</h4>' . "\n";
$contido .= renderMapaDoSitio($inicio, 3, 'mapa-sitio');
$contido .= '</section>';
}
2023-03-11 12:53:47 +01:00
}
else
{
2023-03-11 13:28:54 +01:00
$contido .= '<h3>' . _x('Sitemap', 'sitemap') . '</h3>' . "\n";
$contido .= '<p>' . _x('Sorry, no results were found', 'no results found') . '.</p>' . "\n";
2023-03-11 12:53:47 +01:00
$contido .= '<section>' . "\n";
2023-03-11 13:28:54 +01:00
$contido .= '<h4 class="accesibilidade-oculto">' . _x('Sitemap', 'sitemap') . '</h4>' . "\n";
2023-03-11 12:53:47 +01:00
$contido .= renderMapaDoSitio($inicio, 3, 'mapa-sitio');
$contido .= '</section>';
}
$contido .= '</article>' . "\n";