feat: remplacer les étoiles par les réactions dans le hero article
This commit is contained in:
+23
-28
@@ -127,30 +127,31 @@ $hasSources = (!empty($externalLinks) || !empty($files))
|
||||
<?php if ($hasSources): ?>
|
||||
<a href="/sources/<?= rawurlencode($article['uuid']) ?>" class="hero-btn">ℹ Sources</a>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('isLoggedIn') && isLoggedIn()): ?>
|
||||
<form method="post" action="/?action=rate" class="d-flex align-items-center gap-2">
|
||||
<?php
|
||||
$_heroReactionDefs = [
|
||||
'useful' => ['👍', 'Utile'],
|
||||
'important' => ['🔥', 'Important'],
|
||||
'interesting' => ['🤔', 'À creuser'],
|
||||
];
|
||||
?>
|
||||
<div class="hero-reactions" id="reactions">
|
||||
<?php foreach ($_heroReactionDefs as $type => [$icon, $label]): ?>
|
||||
<?php $active = in_array($type, $visitorReactions ?? [], true); ?>
|
||||
<form method="post" action="/react" class="reaction-form d-inline">
|
||||
<input type="hidden" name="uuid" value="<?= htmlspecialchars($article['uuid']) ?>">
|
||||
<?php if ($ratingStats['count'] > 0): ?>
|
||||
<span class="hero-rating-score">
|
||||
<?= number_format((float)($ratingStats['avg'] ?? 0), 1) ?> <span style="opacity:.6">/ 5</span>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<div class="star-rating star-rating--hero">
|
||||
<?php for ($s = 5; $s >= 1; $s--): ?>
|
||||
<input type="radio" id="star<?= $s ?>-<?= $article['uuid'] ?>"
|
||||
name="rating" value="<?= $s ?>"
|
||||
<?= (int)($userRating ?? 0) === $s ? 'checked' : '' ?>
|
||||
onchange="this.form.submit()">
|
||||
<label for="star<?= $s ?>-<?= $article['uuid'] ?>" title="<?= $s ?>★">★</label>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<input type="hidden" name="type" value="<?= htmlspecialchars($type) ?>">
|
||||
<input type="hidden" name="_back" value="/post/<?= rawurlencode($article['slug'] ?? '') ?>#reactions">
|
||||
<button type="submit"
|
||||
class="hero-reaction-btn<?= $active ? ' hero-reaction-btn--active' : '' ?> reaction-btn"
|
||||
data-type="<?= htmlspecialchars($type) ?>"
|
||||
data-uuid="<?= htmlspecialchars($article['uuid']) ?>"
|
||||
title="<?= htmlspecialchars($label) ?>">
|
||||
<span><?= $icon ?></span>
|
||||
<span class="reaction-count" data-type="<?= htmlspecialchars($type) ?>"><?= (int)($reactionStats[$type] ?? 0) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
<?php elseif ($ratingStats['count'] > 0): ?>
|
||||
<span class="hero-rating-score">
|
||||
★ <?= number_format((float)($ratingStats['avg'] ?? 0), 1) ?>
|
||||
<span style="opacity:.6">(<?= $ratingStats['count'] ?>)</span>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,12 +164,6 @@ $hasSources = (!empty($externalLinks) || !empty($files))
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!isLoggedIn() && $ratingStats['count'] > 0): ?>
|
||||
<p class="text-muted small mt-3">
|
||||
Note : <?= number_format((float)($ratingStats['avg'] ?? 0), 1) ?>/5
|
||||
— <a href="/login">Connectez-vous</a> pour noter.
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php include __DIR__ . '/comments_section.php'; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user