0) ? (int)ceil(($total ?? 0) / $perPage) : 1; /** * Format bytes to human-readable size */ function formatSizeBrowse(int $bytes): string { if ($bytes >= 1073741824) { return number_format($bytes / 1073741824, 1) . ' GB'; } elseif ($bytes >= 1048576) { return number_format($bytes / 1048576, 1) . ' MB'; } elseif ($bytes >= 1024) { return number_format($bytes / 1024, 1) . ' KB'; } return $bytes . ' B'; } /** * Extract filename from full path */ function extractFilename(string $path): string { return basename($path); } /** * Build sort URL preserving current parameters */ function sortUrl(string $collection, string $field, string $currentSort): string { $dir = 'asc'; if ($field === $currentSort) { $dir = 'desc'; } return '/browse/' . urlencode($collection) . '?sort=' . urlencode($field) . '&dir=' . $dir; } /** * Sort indicator arrow */ function sortIndicator(string $field, string $currentSort): string { if ($field === $currentSort) { return ''; } return ''; } $title = htmlspecialchars($collectionName ?? 'Browse') . ' - Research Document Archive'; $content = ''; ob_start(); ?>
= number_format($total ?? 0) ?> document= ($total ?? 0) !== 1 ? 's' : '' ?> in this collection
| Document Name | Pages | Size | Processed | View |
|---|---|---|---|---|
|
= htmlspecialchars($filename) ?>
$score):
if ($score < 0.3) continue;
?>
= htmlspecialchars($topic) ?>
|
= number_format($doc['total_pages'] ?? 0) ?> | = formatSizeBrowse($doc['file_size'] ?? 0) ?> | = date('M j, Y', strtotime($doc['processed_at'])) ?> — | View |