| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- require_once '../includes/config.php';
- require_once '../includes/database.php';
- require_once '../includes/publication.php';
- $publication = new Publication();
- $id = (int)($_GET['id'] ?? 0);
- $pub = $publication->getById($id);
- if (!$pub || $pub['status'] !== 'published') {
- http_response_code(404);
- echo '<h1>Publication Not Found</h1>';
- echo '<p>The requested publication could not be found.</p>';
- exit;
- }
- // Get related publications
- $relatedPublications = [];
- if ($pub['categories_array']) {
- $firstCategory = $pub['categories_array'][0];
- $relatedPublications = $publication->getByCategory($firstCategory, 'published');
- // Remove current publication from related list
- $relatedPublications = array_filter($relatedPublications, function($p) use ($id) {
- return $p['id'] != $id;
- });
- // Limit to 3 related publications
- $relatedPublications = array_slice($relatedPublications, 0, 3);
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title><?php echo htmlspecialchars($pub['title']); ?> - <?php echo SITE_TITLE; ?></title>
- <link rel="stylesheet" href="../css/style.css">
- </head>
- <body>
- <header class="site-header">
- <div class="container">
- <h1><a href="index.php"><?php echo SITE_TITLE; ?></a></h1>
- <nav class="main-nav">
- <a href="index.php">Home</a>
- <a href="categories.php">Categories</a>
- <a href="search.php">Search</a>
- </nav>
- </div>
- </header>
- <div class="container">
- <article class="publication-full">
- <header class="publication-header">
- <h1><?php echo htmlspecialchars($pub['title']); ?></h1>
-
- <div class="publication-meta">
- <span class="author">By <?php echo htmlspecialchars($pub['author']); ?></span>
- <span class="date"><?php echo date('F j, Y', strtotime($pub['created_at'])); ?></span>
- <?php if ($pub['published_at']): ?>
- <span class="published-date">Published <?php echo date('F j, Y', strtotime($pub['published_at'])); ?></span>
- <?php endif; ?>
- </div>
- <?php if ($pub['categories_array']): ?>
- <div class="publication-categories">
- <?php foreach ($pub['categories_array'] as $category): ?>
- <a href="index.php?category=<?php echo urlencode(trim($category)); ?>" class="category-tag">
- <?php echo htmlspecialchars(trim($category)); ?>
- </a>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
- </header>
- <div class="publication-content">
- <?php if ($pub['summary']): ?>
- <div class="publication-summary">
- <p><?php echo htmlspecialchars($pub['summary']); ?></p>
- </div>
- <?php endif; ?>
- <div class="publication-body">
- <?php echo $pub['content']; ?>
- </div>
- </div>
- </article>
- <?php if (!empty($relatedPublications)): ?>
- <section class="related-publications">
- <h2>Related Publications</h2>
- <div class="publication-grid">
- <?php foreach ($relatedPublications as $related): ?>
- <article class="publication-card">
- <h3>
- <a href="publication.php?id=<?php echo $related['id']; ?>">
- <?php echo htmlspecialchars($related['title']); ?>
- </a>
- </h3>
-
- <?php if ($related['summary']): ?>
- <p class="summary"><?php echo htmlspecialchars($related['summary']); ?></p>
- <?php endif; ?>
-
- <div class="meta">
- <span class="author"><?php echo htmlspecialchars($related['author']); ?></span>
- <span class="date"><?php echo date('M j, Y', strtotime($related['created_at'])); ?></span>
- </div>
- </article>
- <?php endforeach; ?>
- </div>
- </section>
- <?php endif; ?>
- <div class="publication-actions">
- <a href="index.php" class="btn">Back to Publications</a>
- </div>
- </div>
- <footer class="site-footer">
- <div class="container">
- <p>© <?php echo date('Y'); ?> <?php echo SITE_TITLE; ?>. All rights reserved.</p>
- </div>
- </footer>
- </body>
- </html>
|