<?php
declare(strict_types=1);
require_once __DIR__ . '/../includes/nav.php';
$tutorials = require __DIR__ . '/tutoriales.php';
$services = require __DIR__ . '/mas_servicios.php';
$supportDocuments = require __DIR__ . '/documentos_apoyo.php';
$team = require __DIR__ . '/equipo_biblioteca.php';
$homeContent = require __DIR__ . '/home_sliders.php';
$resources = require __DIR__ . '/recursos_digitales.php';
$searchItems = [];
$seenItems = [];
$addItem = static function (array $item) use (&$searchItems, &$seenItems): void {
$title = trim((string) ($item['title'] ?? ''));
$url = trim((string) ($item['url'] ?? ''));
if ($title === '' || $url === '') {
return;
}
$key = strtolower($title . '|' . $url);
if (isset($seenItems[$key])) {
return;
}
$keywords = [];
foreach ((array) ($item['keywords'] ?? []) as $keyword) {
$keyword = trim((string) $keyword);
if ($keyword !== '') {
$keywords[] = $keyword;
}
}
$searchItems[] = [
'title' => $title,
'description' => trim((string) ($item['description'] ?? '')),
'url' => $url,
'section' => trim((string) ($item['section'] ?? 'General')),
'external' => !empty($item['external']),
'keywords' => array_values(array_unique($keywords)),
];
$seenItems[$key] = true;
};
$isExternalUrl = static function (string $url): bool {
return str_starts_with($url, 'http://') || str_starts_with($url, 'https://');
};
$pageDescriptions = [
'Inicio' => 'Página principal del Sistema de Bibliotecas con buscador, servicios destacados, eventos y capacitaciones.',
'Recursos bibliográficos' => 'Consulta bases de datos, plataformas de libros electrónicos y recursos institucionales de la biblioteca.',
'Investigaciones' => 'Portal de investigación institucional de la Universidad de los Llanos.',
'Editorial' => 'Sitio editorial institucional con publicaciones y producción académica.',
'Tutoriales' => 'Videotutoriales y guías para servicios y recursos bibliográficos.',
'Equipo Biblioteca' => 'Conoce al equipo de biblioteca, sus sedes y funciones.',
];
foreach ($NAV_ITEMS as $item) {
$title = (string) $item['text'];
$addItem([
'title' => $title,
'description' => $pageDescriptions[$title] ?? 'Acceso principal del sitio Biblioteca Unillanos.',
'url' => (string) $item['href'],
'section' => 'Menú principal',
'external' => !empty($item['external']),
'keywords' => ['biblioteca', 'unillanos', 'menú principal', $title],
]);
}
$addItem([
'title' => 'Más servicios',
'description' => 'Panel lateral de accesos complementarios del sitio principal de biblioteca.',
'url' => 'index.php#inicio-mas-servicios',
'section' => 'Inicio',
'keywords' => ['servicios', 'accesos directos', 'biblioteca'],
]);
$addItem([
'title' => 'Documentos de apoyo a la academia',
'description' => 'Panel lateral derecho con reglamentos, instructivos y formatos de apoyo bibliotecario.',
'url' => 'index.php#inicio-documentos-apoyo',
'section' => 'Inicio',
'keywords' => ['documentos', 'formatos', 'pdf', 'apoyo a la academia'],
]);
$addItem([
'title' => 'Capacitaciones',
'description' => 'Calendario y registro de capacitaciones visibles en la página de inicio.',
'url' => 'index.php#inicio-capacitaciones',
'section' => 'Inicio',
'keywords' => ['talleres', 'agenda', 'formación de usuarios'],
]);
$addItem([
'title' => 'Eventos y noticias',
'description' => 'Eventos institucionales y noticias destacadas del sistema de bibliotecas.',
'url' => 'index.php#inicio-eventos',
'section' => 'Inicio',
'keywords' => ['eventos', 'noticias', 'biblioteca unillanos'],
]);
$utilityDescriptions = [
'Repositorio Institucional' => 'Consulta tesis, trabajos de grado y producción científica de la Universidad de los Llanos.',
'Catálogo público' => 'Acceso al catálogo público en línea para consultar y reservar recursos bibliográficos físicos.',
'Campus virtual' => 'Acceso a la plataforma institucional de campus virtual.',
'Ruta rosa' => 'Material de orientación institucional disponible en formato interactivo.',
];
foreach ($UTILITY_ITEMS as $item) {
$title = (string) $item['text'];
$addItem([
'title' => $title,
'description' => $utilityDescriptions[$title] ?? 'Acceso rápido del encabezado superior.',
'url' => (string) $item['href'],
'section' => 'Accesos rápidos',
'external' => !empty($item['external']),
'keywords' => ['encabezado', 'acceso rápido', 'menú superior', $title],
]);
}
foreach ($SOCIAL_LINKS as $item) {
$addItem([
'title' => (string) $item['label'],
'description' => 'Canal oficial institucional en redes sociales.',
'url' => (string) $item['href'],
'section' => 'Redes sociales',
'external' => true,
'keywords' => ['redes sociales', 'unillanos', (string) $item['network']],
]);
}
foreach ($resources as $resource) {
$addItem([
'title' => (string) ($resource['titulo'] ?? ''),
'description' => (string) ($resource['descripcion'] ?? ''),
'url' => 'RecursosBibliograficos.php#' . (string) ($resource['id'] ?? ''),
'section' => 'Recursos digitales',
'keywords' => array_merge(['recursos bibliográficos', 'recursos digitales'], (array) ($resource['keywords'] ?? [])),
]);
}
foreach ($tutorials as $tutorial) {
$id = (string) ($tutorial['id'] ?? '');
$name = (string) ($tutorial['name'] ?? '');
if ($id === '' || $name === '') {
continue;
}
$category = (string) ($tutorial['category'] ?? 'resources');
$categoryLabel = $category === 'services' ? 'Tutoriales de servicios' : 'Tutoriales de recursos bibliográficos';
$addItem([
'title' => $name,
'description' => (string) ($tutorial['description'] ?? ''),
'url' => 'tutoriales.php?tutorial=' . rawurlencode($id) . '#tutorialStage',
'section' => 'Tutoriales',
'keywords' => [
$categoryLabel,
(string) ($tutorial['provider'] ?? ''),
'video tutorial',
'biblioteca unillanos',
],
]);
}
foreach ($services as $service) {
$title = (string) ($service['titulo'] ?? '');
$url = (string) ($service['url'] ?? '');
if ($title === '' || $url === '') {
continue;
}
$addItem([
'title' => $title,
'description' => (string) ($service['descripcion'] ?? ''),
'url' => $url,
'section' => 'Más servicios',
'external' => $isExternalUrl($url),
'keywords' => ['servicios de biblioteca', 'inicio', 'panel lateral'],
]);
}
foreach ($supportDocuments as $document) {
$title = (string) ($document['titulo'] ?? '');
$url = (string) ($document['url'] ?? '');
if ($title === '' || $url === '') {
continue;
}
$addItem([
'title' => $title,
'description' => (string) ($document['descripcion'] ?? ''),
'url' => $url,
'section' => 'Documentos de apoyo',
'external' => $isExternalUrl($url),
'keywords' => ['documentos', 'formatos', 'reglamento', 'multas', 'autor'],
]);
}
foreach ((array) ($team['branches'] ?? []) as $branch) {
$branchId = (string) ($branch['id'] ?? '');
$branchName = (string) ($branch['name'] ?? '');
if ($branchId === '' || $branchName === '') {
continue;
}
$addItem([
'title' => $branchName,
'description' => (string) ($branch['description'] ?? ''),
'url' => 'quienes-somos.php#branch-' . rawurlencode($branchId),
'section' => 'Sedes',
'keywords' => [
(string) ($branch['address'] ?? ''),
(string) ($branch['phone'] ?? ''),
'sede biblioteca',
'equipo biblioteca',
],
]);
}
foreach ((array) ($homeContent['capacitaciones'] ?? []) as $item) {
$title = trim((string) ($item['titulo'] ?? ''));
if ($title === '') {
continue;
}
$addItem([
'title' => $title,
'description' => 'Capacitación visible en la página de inicio. Modalidad: ' . trim((string) ($item['modalidad'] ?? '')),
'url' => 'index.php#inicio-capacitaciones',
'section' => 'Capacitaciones',
'keywords' => [(string) ($item['hora'] ?? ''), (string) ($item['modalidad'] ?? ''), 'agenda biblioteca'],
]);
}
foreach ((array) ($homeContent['eventos'] ?? []) as $item) {
$title = trim((string) ($item['titulo'] ?? ''));
if ($title === '') {
continue;
}
$eventUrl = trim((string) ($item['enlace'] ?? ''));
if ($eventUrl === '') {
$eventUrl = 'index.php#inicio-eventos';
}
$addItem([
'title' => $title,
'description' => trim((string) ($item['extracto'] ?? $item['detalle'] ?? 'Evento institucional destacado de biblioteca.')),
'url' => $eventUrl,
'section' => 'Eventos',
'external' => $isExternalUrl($eventUrl),
'keywords' => [
'evento',
'noticia',
'biblioteca unillanos',
(string) ($item['tipo'] ?? ''),
(string) ($item['canal'] ?? ''),
],
]);
}
return $searchItems;