335 lines
18 KiB
PHP
335 lines
18 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/includes/layout.php';
|
|
|
|
library_bootstrap();
|
|
|
|
$lang = library_get_language();
|
|
$query = trim((string) ($_GET['q'] ?? ''));
|
|
$language = trim((string) ($_GET['language'] ?? ''));
|
|
|
|
$pageCopy = [
|
|
'en' => [
|
|
'meta_title' => 'Digital Catalog',
|
|
'meta_description' => 'Browse the public digital catalog, switch the interface language from the top bar, and open documents in the browser.',
|
|
'hero_eyebrow' => 'Electronic library · one language per view',
|
|
'hero_title' => 'A cleaner catalog with a top-bar language switch.',
|
|
'hero_copy' => 'The public library now stays in one interface language at a time. Use the switch in the top bar to move between English and Arabic while keeping the same page.',
|
|
'browse_catalog' => 'Browse catalog',
|
|
'add_documents' => 'Add documents',
|
|
'snapshot_kicker' => 'Live shelf snapshot',
|
|
'snapshot_title' => 'What this delivery includes',
|
|
'snapshot_badge' => 'Updated UI',
|
|
'public_titles' => 'Public titles',
|
|
'private_titles' => 'Private titles',
|
|
'ai_summaries' => 'AI summaries',
|
|
'snapshot_item_1' => 'Single-language public pages with a top-bar switch',
|
|
'snapshot_item_2' => 'Catalog filters for keyword and content language',
|
|
'snapshot_item_3' => 'Document pages with localized title, summary, and description',
|
|
'discovery_kicker' => 'Public discovery',
|
|
'discovery_title' => 'Search the live collection',
|
|
'keyword' => 'Keyword',
|
|
'keyword_placeholder' => 'Title, author, tag, or excerpt',
|
|
'language_filter' => 'Content language',
|
|
'all_shelves' => 'All shelves',
|
|
'filter' => 'Filter',
|
|
'rules_kicker' => 'Visibility rules',
|
|
'rules_title' => 'Admin-controlled access',
|
|
'rules_copy' => 'Public items appear in this catalog immediately. Private items stay off the public shelf and remain available only from the admin workspace.',
|
|
'rules_link' => 'Review publishing controls',
|
|
'catalog_kicker' => 'Catalog',
|
|
'catalog_title' => 'Available public titles',
|
|
'result_singular' => 'result',
|
|
'result_plural' => 'results',
|
|
'empty_title' => 'No public documents yet',
|
|
'empty_copy' => 'Upload your first Arabic or English document from the Admin Studio to turn this into a browsable library.',
|
|
'open_admin' => 'Open Admin Studio',
|
|
'no_cover' => 'No cover',
|
|
'untitled' => 'Untitled document',
|
|
'cover_alt' => 'Cover image for',
|
|
'author' => 'Author',
|
|
'views' => 'Views',
|
|
'tags' => 'Tags',
|
|
'author_fallback' => 'Not set',
|
|
'open_reader' => 'Open reader →',
|
|
'workflow_kicker' => 'Workflow',
|
|
'workflow_title' => 'Thin slice, end to end',
|
|
'workflow_item_1' => 'Admin uploads a document and chooses public or private visibility.',
|
|
'workflow_item_2' => 'Readers discover public titles from the catalog and open the detail page.',
|
|
'workflow_item_3' => 'Summaries and descriptions follow the selected interface language.',
|
|
'recent_kicker' => 'Recently added',
|
|
'recent_title' => 'Latest public titles',
|
|
'manage_shelf' => 'Manage shelf',
|
|
'unknown_author' => 'Unknown author',
|
|
],
|
|
'ar' => [
|
|
'meta_title' => 'الفهرس الرقمي',
|
|
'meta_description' => 'تصفح الفهرس الرقمي العام، وبدّل لغة الواجهة من الشريط العلوي، وافتح المستندات داخل المتصفح.',
|
|
'hero_eyebrow' => 'مكتبة إلكترونية · لغة واحدة لكل عرض',
|
|
'hero_title' => 'فهرس أوضح مع مفتاح تبديل اللغة في الشريط العلوي.',
|
|
'hero_copy' => 'تعرض المكتبة العامة الآن لغة واجهة واحدة في كل مرة. استخدم المفتاح في الشريط العلوي للتبديل بين العربية والإنجليزية مع البقاء في الصفحة نفسها.',
|
|
'browse_catalog' => 'تصفح الفهرس',
|
|
'add_documents' => 'إضافة مستندات',
|
|
'snapshot_kicker' => 'نظرة مباشرة على الرف',
|
|
'snapshot_title' => 'ما الذي يتضمنه هذا التحديث',
|
|
'snapshot_badge' => 'واجهة محدثة',
|
|
'public_titles' => 'العناوين العامة',
|
|
'private_titles' => 'العناوين الخاصة',
|
|
'ai_summaries' => 'ملخصات الذكاء الاصطناعي',
|
|
'snapshot_item_1' => 'صفحات عامة بلغة واحدة مع مفتاح تبديل في الشريط العلوي',
|
|
'snapshot_item_2' => 'مرشحات للفهرس حسب الكلمة المفتاحية ولغة المحتوى',
|
|
'snapshot_item_3' => 'صفحات مستندات بعنوان وملخص ووصف حسب اللغة المختارة',
|
|
'discovery_kicker' => 'الاكتشاف العام',
|
|
'discovery_title' => 'ابحث في المجموعة المباشرة',
|
|
'keyword' => 'الكلمة المفتاحية',
|
|
'keyword_placeholder' => 'العنوان أو المؤلف أو الوسوم أو المقتطف',
|
|
'language_filter' => 'لغة المحتوى',
|
|
'all_shelves' => 'كل الرفوف',
|
|
'filter' => 'تصفية',
|
|
'rules_kicker' => 'قواعد الظهور',
|
|
'rules_title' => 'وصول يتحكم به المشرف',
|
|
'rules_copy' => 'تظهر العناصر العامة في هذا الفهرس فوراً، بينما تبقى العناصر الخاصة خارج الرف العام ومتاحة فقط من مساحة الإدارة.',
|
|
'rules_link' => 'مراجعة إعدادات النشر',
|
|
'catalog_kicker' => 'الفهرس',
|
|
'catalog_title' => 'العناوين العامة المتاحة',
|
|
'result_singular' => 'نتيجة',
|
|
'result_plural' => 'نتائج',
|
|
'empty_title' => 'لا توجد مستندات عامة بعد',
|
|
'empty_copy' => 'ارفع أول مستند عربي أو إنجليزي من استوديو الإدارة لتحويل هذا القسم إلى مكتبة قابلة للتصفح.',
|
|
'open_admin' => 'فتح استوديو الإدارة',
|
|
'no_cover' => 'بلا غلاف',
|
|
'untitled' => 'مستند بدون عنوان',
|
|
'cover_alt' => 'صورة غلاف لـ',
|
|
'author' => 'المؤلف',
|
|
'views' => 'المشاهدات',
|
|
'tags' => 'الوسوم',
|
|
'author_fallback' => 'غير محدد',
|
|
'open_reader' => 'فتح القارئ ←',
|
|
'workflow_kicker' => 'سير العمل',
|
|
'workflow_title' => 'مسار كامل ومختصر',
|
|
'workflow_item_1' => 'يرفع المشرف مستنداً ويحدد ما إذا كان عاماً أو خاصاً.',
|
|
'workflow_item_2' => 'يكتشف القراء العناوين العامة من الفهرس ويفتحون صفحة التفاصيل.',
|
|
'workflow_item_3' => 'تتبع الملخصات والأوصاف لغة الواجهة المختارة.',
|
|
'recent_kicker' => 'أضيف مؤخراً',
|
|
'recent_title' => 'أحدث العناوين العامة',
|
|
'manage_shelf' => 'إدارة الرف',
|
|
'unknown_author' => 'مؤلف غير معروف',
|
|
],
|
|
][$lang];
|
|
|
|
// Pagination Logic
|
|
$page = isset($_GET['page']) ? max(1, (int) $_GET['page']) : 1;
|
|
$limit = 12;
|
|
$offset = ($page - 1) * $limit;
|
|
|
|
$result = library_fetch_documents_paginated(true, ['q' => $query, 'language' => $language], $limit, $offset);
|
|
$documents = $result['data'];
|
|
$totalDocuments = $result['total'];
|
|
$totalPages = (int) ceil($totalDocuments / $limit);
|
|
|
|
$metrics = library_catalog_metrics();
|
|
$recentDocuments = library_recent_documents(3, true);
|
|
|
|
library_render_header(
|
|
$pageCopy['meta_title'],
|
|
$pageCopy['meta_description'],
|
|
'catalog'
|
|
);
|
|
?>
|
|
<section class="hero-surface mb-4 mb-lg-5">
|
|
<div class="row g-4 align-items-center">
|
|
<div class="col-lg-7">
|
|
<span class="eyebrow"><?= h($pageCopy['hero_eyebrow']) ?></span>
|
|
<h1 class="display-6 mb-3"><?= h($pageCopy['hero_title']) ?></h1>
|
|
<p class="lead text-secondary mb-4"><?= h($pageCopy['hero_copy']) ?></p>
|
|
<div class="d-flex flex-wrap gap-2">
|
|
<a class="btn btn-dark" href="#catalog-grid"><?= h($pageCopy['browse_catalog']) ?></a>
|
|
<a class="btn btn-outline-secondary" href="/admin.php"><?= h($pageCopy['add_documents']) ?></a>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-5">
|
|
<div class="panel h-100">
|
|
<div class="d-flex justify-content-between align-items-start gap-3 mb-4">
|
|
<div>
|
|
<div class="section-kicker"><?= h($pageCopy['snapshot_kicker']) ?></div>
|
|
<h2 class="h5 mb-1"><?= h($pageCopy['snapshot_title']) ?></h2>
|
|
</div>
|
|
<span class="badge text-bg-light"><?= h($pageCopy['snapshot_badge']) ?></span>
|
|
</div>
|
|
<div class="metric-grid">
|
|
<article class="metric-card">
|
|
<span class="metric-value"><?= h((string) $metrics['public_count']) ?></span>
|
|
<span class="metric-label"><?= h($pageCopy['public_titles']) ?></span>
|
|
</article>
|
|
<article class="metric-card">
|
|
<span class="metric-value"><?= h((string) $metrics['private_count']) ?></span>
|
|
<span class="metric-label"><?= h($pageCopy['private_titles']) ?></span>
|
|
</article>
|
|
<article class="metric-card">
|
|
<span class="metric-value"><?= h((string) $metrics['summarized_count']) ?></span>
|
|
<span class="metric-label"><?= h($pageCopy['ai_summaries']) ?></span>
|
|
</article>
|
|
</div>
|
|
<ul class="list-unstyled mb-0 mt-4 compact-list">
|
|
<li><?= h($pageCopy['snapshot_item_1']) ?></li>
|
|
<li><?= h($pageCopy['snapshot_item_2']) ?></li>
|
|
<li><?= h($pageCopy['snapshot_item_3']) ?></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="row g-4 mb-4 mb-lg-5">
|
|
<div class="col-lg-8">
|
|
<div class="panel h-100">
|
|
<div class="section-kicker"><?= h($pageCopy['discovery_kicker']) ?></div>
|
|
<h2 class="h4 mb-3"><?= h($pageCopy['discovery_title']) ?></h2>
|
|
<form class="row g-3 align-items-end" method="get" action="/index.php">
|
|
<div class="col-md-7">
|
|
<label class="form-label" for="q"><?= h($pageCopy['keyword']) ?></label>
|
|
<input class="form-control" id="q" name="q" type="search" value="<?= h($query) ?>" placeholder="<?= h($pageCopy['keyword_placeholder']) ?>">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label" for="language"><?= h($pageCopy['language_filter']) ?></label>
|
|
<select class="form-select" id="language" name="language">
|
|
<option value=""><?= h($pageCopy['all_shelves']) ?></option>
|
|
<option value="en" <?= $language === 'en' ? 'selected' : '' ?>><?= h(library_language_label('en')) ?></option>
|
|
<option value="ar" <?= $language === 'ar' ? 'selected' : '' ?>><?= h(library_language_label('ar')) ?></option>
|
|
<option value="bilingual" <?= $language === 'bilingual' ? 'selected' : '' ?>><?= h(library_language_label('bilingual')) ?></option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2 d-grid">
|
|
<button class="btn btn-dark" type="submit"><?= h($pageCopy['filter']) ?></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-4">
|
|
<div class="panel h-100">
|
|
<div class="section-kicker"><?= h($pageCopy['rules_kicker']) ?></div>
|
|
<h2 class="h5 mb-3"><?= h($pageCopy['rules_title']) ?></h2>
|
|
<p class="text-secondary mb-3"><?= h($pageCopy['rules_copy']) ?></p>
|
|
<a class="link-arrow" href="/admin.php"><?= h($pageCopy['rules_link']) ?></a>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="mb-5" id="catalog-grid">
|
|
<div class="d-flex justify-content-between align-items-center mb-3 gap-3 flex-wrap">
|
|
<div>
|
|
<div class="section-kicker"><?= h($pageCopy['catalog_kicker']) ?></div>
|
|
<h2 class="h3 mb-0"><?= h($pageCopy['catalog_title']) ?></h2>
|
|
</div>
|
|
<span class="text-secondary small"><?= h((string) $totalDocuments) ?> <?= h($totalDocuments === 1 ? $pageCopy['result_singular'] : $pageCopy['result_plural']) ?></span>
|
|
</div>
|
|
|
|
<?php if (!$documents): ?>
|
|
<div class="panel empty-panel text-center py-5">
|
|
<div class="empty-icon mb-3">⌘</div>
|
|
<h3 class="h5"><?= h($pageCopy['empty_title']) ?></h3>
|
|
<p class="text-secondary mb-4"><?= h($pageCopy['empty_copy']) ?></p>
|
|
<a class="btn btn-dark" href="/admin.php"><?= h($pageCopy['open_admin']) ?></a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
|
|
<?php foreach ($documents as $document): ?>
|
|
<?php
|
|
$cardTitle = library_localized_document_title($document, $lang, $pageCopy['untitled']);
|
|
$cardTitleLang = library_text_lang($cardTitle, $lang);
|
|
$cardTitleDir = library_text_dir($cardTitle, $cardTitleLang);
|
|
?>
|
|
<div class="col">
|
|
<article class="panel catalog-card h-100 position-relative">
|
|
<div class="catalog-card-media">
|
|
<?php if (!empty($document['cover_image_path'])): ?>
|
|
<img
|
|
src="/<?= h((string) $document['cover_image_path']) ?>"
|
|
alt="<?= h($pageCopy['cover_alt'] . ' ' . $cardTitle) ?>"
|
|
class="catalog-card-cover"
|
|
width="128"
|
|
height="176"
|
|
>
|
|
<?php else: ?>
|
|
<div class="catalog-card-cover catalog-card-cover-placeholder" aria-hidden="true">
|
|
<span><?= h($pageCopy['no_cover']) ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="catalog-card-body">
|
|
<div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-2">
|
|
<div class="min-w-0">
|
|
<h3 class="h5 mb-1 catalog-card-title" lang="<?= h($cardTitleLang) ?>" dir="<?= h($cardTitleDir) ?>"><?= h($cardTitle) ?></h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="catalog-card-meta small text-secondary">
|
|
<div><span class="catalog-card-label"><?= h($pageCopy['author']) ?></span><span><?= h((string) ($document['author'] ?: $pageCopy['author_fallback'])) ?></span></div>
|
|
<div><span class="catalog-card-label"><?= h($pageCopy['views']) ?></span><span><?= h((string) $document['view_count']) ?></span></div>
|
|
<div><span class="catalog-card-label"><?= h($pageCopy['tags']) ?></span><span><?= h((string) ($document['tags'] ?: '—')) ?></span></div>
|
|
</div>
|
|
|
|
<div class="mt-3">
|
|
<a class="link-arrow stretched-link" href="/document.php?id=<?= h((string) $document['id']) ?>"><?= h($pageCopy['open_reader']) ?></a>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ($totalPages > 1): ?>
|
|
<div class="mt-5">
|
|
<?php library_render_pagination($page, $totalPages, '/index.php'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
</section>
|
|
|
|
<section class="row g-4">
|
|
<div class="col-lg-4">
|
|
<div class="panel h-100">
|
|
<div class="section-kicker"><?= h($pageCopy['workflow_kicker']) ?></div>
|
|
<h2 class="h5 mb-3"><?= h($pageCopy['workflow_title']) ?></h2>
|
|
<ol class="compact-list-numbered mb-0 text-secondary">
|
|
<li><?= h($pageCopy['workflow_item_1']) ?></li>
|
|
<li><?= h($pageCopy['workflow_item_2']) ?></li>
|
|
<li><?= h($pageCopy['workflow_item_3']) ?></li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-8">
|
|
<div class="panel h-100">
|
|
<div class="d-flex justify-content-between align-items-center mb-3 gap-3 flex-wrap">
|
|
<div>
|
|
<div class="section-kicker"><?= h($pageCopy['recent_kicker']) ?></div>
|
|
<h2 class="h5 mb-0"><?= h($pageCopy['recent_title']) ?></h2>
|
|
</div>
|
|
<a class="link-arrow" href="/admin.php"><?= h($pageCopy['manage_shelf']) ?></a>
|
|
</div>
|
|
<div class="row g-3">
|
|
<?php foreach ($recentDocuments as $document): ?>
|
|
<?php
|
|
$recentTitle = library_localized_document_title($document, $lang, $pageCopy['untitled']);
|
|
$recentTitleLang = library_text_lang($recentTitle, $lang);
|
|
$recentTitleDir = library_text_dir($recentTitle, $recentTitleLang);
|
|
?>
|
|
<div class="col-md-4">
|
|
<a class="recent-card text-decoration-none" href="/document.php?id=<?= h((string) $document['id']) ?>">
|
|
<span class="small text-secondary d-block mb-2"><?= h(library_language_label((string) $document['document_language'])) ?></span>
|
|
<strong class="d-block text-dark mb-1" lang="<?= h($recentTitleLang) ?>" dir="<?= h($recentTitleDir) ?>"><?= h($recentTitle) ?></strong>
|
|
<span class="small text-secondary"><?= h((string) ($document['author'] ?: $pageCopy['unknown_author'])) ?></span>
|
|
</a>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<?php
|
|
library_render_footer();
|