| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- // Start session for language preference
- if (session_status() === PHP_SESSION_NONE) {
- session_start();
- }
- require_once '../includes/config.php';
- require_once '../includes/database.php';
- require_once '../includes/auth.php';
- require_once '../includes/publication.php';
- require_once '../includes/translation.php';
- // Include LDAP class if LDAP is enabled
- if (LDAP_ENABLED) {
- require_once '../includes/ldap.php';
- }
- $auth = new Auth();
- $auth->requireAuth();
- $publication = new Publication();
- $user = $auth->getUser();
- // Translation system is auto-initialized when translation.php is included
- // Handle actions
- $action = $_GET['action'] ?? '';
- $message = '';
- if ($action === 'delete' && isset($_GET['id'])) {
- $id = (int)$_GET['id'];
- try {
- $publication->delete($id);
- $message = t('admin_publication_deleted_success');
- } catch (Exception $e) {
- $message = t('admin_publication_deleted_error') . ' ' . $e->getMessage();
- }
- }
- // Get statistics
- $stats = $publication->getStats();
- // Get recent publications
- $recentPublications = $publication->getAll('all', 10);
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title><?php echo t('admin_dashboard_title'); ?> - <?php echo SITE_TITLE; ?></title>
- <link rel="stylesheet" href="../css/style.css">
- </head>
- <body>
- <div class="admin-layout">
- <header class="admin-header">
- <div class="header-content">
- <h1><a href="/index.php"><?php echo SITE_TITLE; ?></a></h1>
- <nav class="admin-nav">
- <a href="index.php" class="nav-link active"><?php echo t('admin_nav_dashboard'); ?></a>
- <a href="publications.php" class="nav-link"><?php echo t('admin_nav_publications'); ?></a>
- <a href="categories.php" class="nav-link"><?php echo t('admin_nav_categories'); ?></a>
- <a href="comments.php" class="nav-link"><?php echo t('admin_nav_comments'); ?></a>
- <a href="users.php" class="nav-link"><?php echo t('manage_users'); ?></a>
- <a href="wordpress_import.php" class="nav-link"><?php echo t('wordpress_import'); ?></a>
- <?php if (LDAP_ENABLED): ?>
- <a href="ldap-users.php" class="nav-link"><?php echo t('admin_nav_ldap_users'); ?></a>
- <?php endif; ?>
- <a href="logout.php" class="nav-link"><?php echo t('admin_nav_logout'); ?></a>
- </nav>
- <div class="user-info">
- <?php echo t('admin_welcome'); ?>, <?php echo htmlspecialchars($user['username']); ?>
- </div>
- </div>
- </header>
- <main class="admin-main">
- <?php if ($message): ?>
- <div class="alert alert-<?php echo strpos($message, 'Error') === false ? 'success' : 'error'; ?>">
- <?php echo htmlspecialchars($message); ?>
- </div>
- <?php endif; ?>
- <section class="dashboard-stats">
- <h2><?php echo t('admin_overview'); ?></h2>
- <div class="stats-grid">
- <div class="stat-card">
- <h3><?php echo t('admin_total_publications'); ?></h3>
- <p class="stat-number"><?php echo $stats['total']; ?></p>
- </div>
- <div class="stat-card">
- <h3><?php echo t('admin_published'); ?></h3>
- <p class="stat-number"><?php echo $stats['published']; ?></p>
- </div>
- <div class="stat-card">
- <h3><?php echo t('admin_drafts'); ?></h3>
- <p class="stat-number"><?php echo $stats['draft']; ?></p>
- </div>
- <div class="stat-card">
- <h3><?php echo t('admin_archived'); ?></h3>
- <p class="stat-number"><?php echo $stats['archived']; ?></p>
- </div>
- </div>
- </section>
- <section class="recent-publications">
- <h2><?php echo t('admin_recent_publications'); ?></h2>
- <div class="table-container">
- <table class="admin-table">
- <thead>
- <tr>
- <th><?php echo t('admin_table_title'); ?></th>
- <th><?php echo t('admin_table_author'); ?></th>
- <th><?php echo t('admin_table_status'); ?></th>
- <th><?php echo t('admin_table_created'); ?></th>
- <th><?php echo t('admin_table_actions'); ?></th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($recentPublications as $pub): ?>
- <tr>
- <td>
- <a href="edit.php?id=<?php echo $pub['id']; ?>">
- <?php echo htmlspecialchars($pub['title']); ?>
- </a>
- </td>
- <td><?php echo htmlspecialchars($pub['author']); ?></td>
- <td>
- <span class="status-badge status-<?php echo $pub['status']; ?>">
- <?php echo ucfirst($pub['status']); ?>
- </span>
- </td>
- <td><?php echo date('M j, Y', strtotime($pub['created_at'])); ?></td>
- <td>
- <a href="edit.php?id=<?php echo $pub['id']; ?>" class="btn btn-sm"><?php echo t('admin_action_edit'); ?></a>
- <a href="index.php?action=delete&id=<?php echo $pub['id']; ?>"
- class="btn btn-sm btn-danger"
- onclick="return confirm('<?php echo t('admin_confirm_delete'); ?>')">
- <?php echo t('admin_action_delete'); ?>
- </a>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div>
-
- <div class="actions">
- <a href="edit.php" class="btn btn-primary"><?php echo t('admin_create_publication'); ?></a>
- </div>
- </section>
- </main>
- </div>
- </body>
- </html>
|