<?php
declare(strict_types=1);
/**
* Íconos SVG reutilizables para navegación, redes y acciones.
* Se usa una caché estática para no reconstruir el arreglo en cada llamada.
*/
function icon(string $name): string
{
static $icons = null;
if ($icons === null) {
$icons = [
'home' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M3 10.5 12 3l9 7.5"></path><path d="M5 10v10h14V10"></path></svg>',
'book' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M4 19a2 2 0 0 0 2 2h14"></path><path d="M6 3h14v18H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"></path></svg>',
'microscope' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M6 18h8"></path><path d="M3 22h18"></path><path d="M14 7l3 3"></path><path d="M10 11l3 3"></path><path d="M7 14a6 6 0 1 0 10 4"></path><path d="M11 3l3 3"></path></svg>',
'file' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><path d="M14 2v6h6"></path><path d="M8 13h8"></path><path d="M8 17h8"></path></svg>',
'play' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10"></circle><path d="M10 8l6 4-6 4V8z"></path></svg>',
'users' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2"></path><path d="M7 7a4 4 0 1 0 8 0 4 4 0 0 0-8 0z"></path><path d="M21 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>',
'repository' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M4 7.5 12 3l8 4.5-8 4.5L4 7.5Z"></path><path d="M4 12.5 12 17l8-4.5"></path><path d="M4 17l8 4 8-4"></path></svg>',
'campus' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><rect x="3" y="4" width="18" height="12" rx="2"></rect><path d="M8 20h8"></path><path d="M12 16v4"></path><path d="m9 9 3-2 3 2"></path><path d="M10 10h4"></path></svg>',
'route-rose' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M12 21s-7-4.3-7-10V5l7-3 7 3v6c0 5.7-7 10-7 10Z"></path><path d="M12 16.2s-2.8-1.8-2.8-4a1.9 1.9 0 0 1 3.2-1.4 1.9 1.9 0 0 1 3.2 1.4c0 2.2-2.8 4-2.8 4Z"></path></svg>',
'search' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-3.5-3.5"></path></svg>',
'x' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" focusable="false"><path d="M18.9 2H22l-6.77 7.74L23.2 22h-6.24l-4.88-6.77L6.16 22H3.05l7.24-8.27L.8 2h6.39l4.41 6.2L18.9 2Zm-1.09 18h1.72L6.26 3.9H4.42L17.81 20Z"/></svg>',
'youtube' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" focusable="false"><path d="M23 12c0 2.1-.24 3.86-.52 4.92a3.2 3.2 0 0 1-2.26 2.26C19.16 19.46 17.41 19.7 12 19.7s-7.16-.24-8.22-.52a3.2 3.2 0 0 1-2.26-2.26C1.24 15.86 1 14.1 1 12c0-2.1.24-3.86.52-4.92a3.2 3.2 0 0 1 2.26-2.26C4.84 4.54 6.59 4.3 12 4.3s7.16.24 8.22.52a3.2 3.2 0 0 1 2.26 2.26C22.76 8.14 23 9.9 23 12Zm-14.5 3.95L16 12 8.5 8.05v7.9Z"/></svg>',
'facebook' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" focusable="false"><path d="M13.12 21v-7.17h2.4l.36-2.8h-2.76V9.24c0-.81.22-1.36 1.39-1.36H16V5.36c-.65-.07-1.31-.1-1.97-.1-1.95 0-3.29 1.19-3.29 3.38v1.89H8.5v2.8h2.24V21h2.38Z"/></svg>',
'instagram' => '<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" focusable="false"><path d="M7.5 2h9A5.5 5.5 0 0 1 22 7.5v9A5.5 5.5 0 0 1 16.5 22h-9A5.5 5.5 0 0 1 2 16.5v-9A5.5 5.5 0 0 1 7.5 2Zm0 2A3.5 3.5 0 0 0 4 7.5v9A3.5 3.5 0 0 0 7.5 20h9a3.5 3.5 0 0 0 3.5-3.5v-9A3.5 3.5 0 0 0 16.5 4h-9Zm10.75 1.5a1.25 1.25 0 1 0 .001 2.501A1.25 1.25 0 0 0 18.25 5.5ZM12 7a5 5 0 1 0 0 10 5 5 0 0 0 0-10Zm0 2a3 3 0 1 1 0 6 3 3 0 0 1 0-6Z"/></svg>',
'arrow-up-right' => '<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.9" aria-hidden="true" focusable="false"><path d="M7 17 17 7"></path><path d="M9 7h8v8"></path></svg>',
];
}
return $icons[$name] ?? '';
}
/**
* Detecta el archivo actual para marcar el menú activo.
*/
function currentPath(): string
{
$path = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
$base = basename($path);
return $base !== '' ? $base : 'index.php';
}
/**
* Atributos HTML seguros para enlaces externos.
*/
function navTargetAttributes(bool $external): string
{
return $external ? ' target="_blank" rel="noopener noreferrer"' : '';
}
$NAV_ITEMS = [
['href' => 'index.php', 'text' => 'Inicio', 'icon' => 'home'],
['href' => 'RecursosBibliograficos.php', 'text' => 'Recursos bibliográficos', 'icon' => 'book'],
['href' => 'https://investigaciones.unillanos.edu.co/', 'text' => 'Investigaciones', 'icon' => 'microscope', 'external' => true],
['href' => 'https://editorial.unillanos.edu.co/', 'text' => 'Editorial', 'icon' => 'file', 'external' => true],
['href' => 'tutoriales.php', 'text' => 'Tutoriales', 'icon' => 'play'],
['href' => 'quienes-somos.php', 'text' => 'Equipo Biblioteca', 'icon' => 'users'],
];
$UTILITY_ITEMS = [
['href' => 'https://repositorio.unillanos.edu.co/home', 'text' => 'Repositorio Institucional', 'icon' => 'repository', 'external' => true],
['href' => 'https://unillanos.metacatalogo.org/', 'text' => 'Catálogo público', 'icon' => 'book', 'external' => true],
['href' => 'https://campusvirtualunillanos.co/', 'text' => 'Campus virtual', 'icon' => 'campus', 'external' => true],
['href' => 'https://view.genially.com/65242de3583ad90011755b99', 'text' => 'Ruta rosa', 'icon' => 'route-rose', 'external' => true],
];
$SOCIAL_LINKS = [
['label' => 'X', 'href' => 'https://x.com/unillanos_', 'icon' => 'x', 'network' => 'x'],
['label' => 'YouTube', 'href' => 'https://www.youtube.com/@bibliotecajorgeboshellmanr4592', 'icon' => 'youtube', 'network' => 'youtube'],
['label' => 'Facebook', 'href' => 'https://www.facebook.com/UnillanosOficial/', 'icon' => 'facebook', 'network' => 'facebook'],
['label' => 'Instagram', 'href' => 'https://instagram.com/unillanos_/', 'icon' => 'instagram', 'network' => 'instagram'],
];