Show photographs.

This commit is contained in:
Kim Taylor
2024-09-21 17:24:50 +10:00
parent 82f65a2050
commit cba26faf31

View File

@@ -76,38 +76,21 @@ $surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Lo
</div> </div>
<!-- /wp:columns --> <!-- /wp:columns -->
<?php exit(0); else: ?> <?php else: ?>
<!-- wp:paragraph --> <!-- wp:paragraph -->
<p></p> <p></p>
<!-- /wp:paragraph --> <!-- /wp:paragraph -->
<?php endif; ?> <?php endif; ?>
<?php <?php foreach ($councils as $key => $council): ?>
if (isset($config['groupNames'])) {
$groupNames = $config['groupNames'];
$propertyOnCandidate = 'Group';
} else {
$groupNames = $config['wardNames'];
$propertyOnCandidate = 'Ward';
}
?>
<?php foreach ($groupNames as $index => $groupName): ?>
<!-- wp:heading {"level":3,"className":"is-style-default"} --> <!-- wp:heading {"level":3,"className":"is-style-default"} -->
<?php $groupSlug = sluggify($groupName); ?> <?php $groupSlug = sluggify($council); ?>
<h3 class="wp-block-heading is-style-default" id="<?php echo $groupSlug; ?>"><a style="text-decoration: none;" href="#<?php echo $groupSlug; ?>"><?php echo htmlspecialchars($groupName); ?></a></h3> <h3 class="wp-block-heading is-style-default" id="<?php echo $groupSlug; ?>"><a style="text-decoration: none;" href="#<?php echo $groupSlug; ?>"><?php echo htmlspecialchars($council); ?></a></h3>
<!-- /wp:heading --> <!-- /wp:heading -->
<?php <?php
$groupCandidates = array_filter($candidates, function ($candidate) use ($groupName, $propertyOnCandidate) { $groupCandidates = array_filter($candidates, function ($candidate) use ($council) {
return isset($candidate[$propertyOnCandidate]) && $candidate[$propertyOnCandidate] === $groupName; return $candidate['Council'] === $council;
});
usort($groupCandidates, function($a, $b) {
if ($a == $b) {
return 0;
}
return (((int) $a['Rating']) < ((int) $b['Rating'])) ? 1 : -1;
}); });
if (count($groupCandidates) > 0): if (count($groupCandidates) > 0):
@@ -116,10 +99,10 @@ $surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Lo
<?php <?php
$columnCount = 4; $columnCount = 4;
$chunkedWardCandidates = array_chunk($groupCandidates, $columnCount); $chunkedCouncilCandidates = array_chunk($groupCandidates, $columnCount);
?> ?>
<?php foreach($chunkedWardCandidates as $chunk): ?> <?php foreach($chunkedCouncilCandidates as $chunk): ?>
<!-- wp:columns --> <!-- wp:columns -->
<div class="wp-block-columns"> <div class="wp-block-columns">
@@ -131,22 +114,13 @@ $surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Lo
<?php <?php
$candidate = $chunk[$columnIdx]; $candidate = $chunk[$columnIdx];
if (isset($candidate['Picture']) && isset($media[$candidate['Picture']])) { if (isset($candidate['Picture']) && strlen($candidate['image_url'])) {
$candidate_image = $media[$candidate['Picture']]; $candidate_image['url'] = $candidate['image_url'];
$candidate_image['id'] = $candidate['image_id'];
} else { } else {
$candidate_image = $media['default.png']; continue;
} }
$candidate_rating = str_repeat("✔️", max(0, min(5, $candidate['Rating'])));
// If string is 5 ticks, insert a zero width space entity between the 3rd and 4th ticks so that it wraps nicer
if ($candidate_rating == "✔️✔️✔️✔️✔️") {
$candidate_rating = "✔️✔️✔️&#8203;✔️✔️";
}
// If string is 4 ticks, insert a zero width space entity between the 2nd and 3rd ticks so that it wraps nicer
if ($candidate_rating == "✔️✔️✔️✔️") {
$candidate_rating = "✔️✔️&#8203;✔️✔️";
}
?> ?>
<!-- wp:image {"id":<?php echo $candidate_image['id']; ?>,"width":"200px","height":"200px","scale":"cover","align":"center","style":{"color":{}},"className":"is-resized"} --> <!-- wp:image {"id":<?php echo $candidate_image['id']; ?>,"width":"200px","height":"200px","scale":"cover","align":"center","style":{"color":{}},"className":"is-resized"} -->
@@ -157,9 +131,6 @@ $surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Lo
<h2 class="wp-block-heading has-text-align-center has-medium-font-size" style="margin-top:1rem;margin-bottom:0.5rem"><strong><?php echo htmlspecialchars($candidate['Candidate Name']); ?></strong></h2> <h2 class="wp-block-heading has-text-align-center has-medium-font-size" style="margin-top:1rem;margin-bottom:0.5rem"><strong><?php echo htmlspecialchars($candidate['Candidate Name']); ?></strong></h2>
<!-- /wp:heading --> <!-- /wp:heading -->
<!-- wp:paragraph {"align":"center","style":{"layout":{"selfStretch":"fit","flexSize":null},"typography":{"lineHeight":"1"},"spacing":{"margin":{"top":"0.5rem","bottom":"1.5rem"}}},"fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size candidate-ticks"><?php echo $candidate_rating; ?></p>
<!-- /wp:paragraph -->
<?php endif; ?> <?php endif; ?>
</div> </div>