summaryrefslogtreecommitdiff
path: root/Vote.php
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-10-08 09:00:20 +0200
committerMartin Fischer <martin@push-f.com>2022-10-08 09:14:25 +0200
commitddc0fd1c8399c225f9a198614d6f1dfc98bdcbdc (patch)
tree3789bc2362786369fef905036dc59ffe073880c1 /Vote.php
parent3cd1539ad81868242b17b4d163d105483dc84983 (diff)
gray out superseded votes
Thanks to waldyrious for the suggestion!
Diffstat (limited to 'Vote.php')
-rw-r--r--Vote.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/Vote.php b/Vote.php
index 63d8fde..e72fb07 100644
--- a/Vote.php
+++ b/Vote.php
@@ -94,7 +94,7 @@ class VoteHooks {
$voteText = '';
$votes = [];
- foreach ($lines as $line) {
+ foreach ($lines as $idx => $line) {
if (array_key_exists('raw', $line)) {
$voteText .= $line['raw'];
} elseif (array_key_exists('error', $line)) {
@@ -105,6 +105,13 @@ class VoteHooks {
$vote = $line['vote'];
$voteText .= '* ';
+ $class = '';
+ for ($i = $idx + 1; $i < count($lines); $i++) {
+ if (($lines[$i]['user'] ?? null) == $user) {
+ $class = 'uncounted-vote';
+ }
+ }
+ $voteText .= "<span class=$class>";
if (array_key_exists($user, $votes)) {
if ($votes[$user] == $vote) {
$voteText .= "(" . $msg('vote-repeated') . ') ';
@@ -119,7 +126,8 @@ class VoteHooks {
}
$userLink = $parser->getLinkRenderer()->makeLink($line['userTitle'], $user);
- $voteText .= " --$userLink ". $line['date']->format('H:i, j F Y') . "\n";
+ $voteText .= " --$userLink ". $line['date']->format('H:i, j F Y');
+ $voteText .= "</span>\n";
}
}
@@ -152,6 +160,8 @@ class VoteHooks {
$parser->addTrackingCategory('pages-with-open-votes-category', $parser->getTitle());
}
+ $parser->getOutput()->addModules(['ext.vote-css']);
+
return $text;
}