159 lines
6.5 KiB
PHP
159 lines
6.5 KiB
PHP
<?php
|
|
|
|
function sluggify($input) {
|
|
return strtolower(str_replace(' ', '-', $input));
|
|
}
|
|
|
|
$surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Love Pledge and Survey</a>";
|
|
|
|
?>
|
|
|
|
<!-- wp:paragraph -->
|
|
<p>The Streets People Love campaign has created scorecards for candidates in the 2024 council elections. Scorecards have been generated based on a candidate's engagement with the Streets People Love campaign, their commitment to our pledge, their responses to a survey and input from campaign members located in the local government area in which they are running.</p>
|
|
<!-- /wp:paragraph -->
|
|
|
|
<!-- wp:paragraph -->
|
|
<p>Can't see a candidate you know is running? Candidates who don't take our survey won't appear on this page. Feel free to send your local candidates the <?php echo $surveyLink; ?> and let them know it's important to local residents that they do take part, so that we can vote for those who want to build the streets people love.</p>
|
|
<!-- /wp:paragraph -->
|
|
|
|
<?php if (isset($media["header.jpg"])): ?>
|
|
<!-- wp:image {"id":<?php echo $media["header.jpg"]['id']; ?>,"aspectRatio":"16/9","scale":"cover","sizeSlug":"full","linkDestination":"none"} -->
|
|
<figure class="wp-block-image size-full"><img src="<?php echo $media["header.jpg"]['url']; ?>" alt="" class="wp-image-<?php echo $media["header.jpg"]['id']; ?>" style="aspect-ratio:16/9;object-fit:cover"/></figure>
|
|
<!-- /wp:image -->
|
|
<?php endif ?>
|
|
|
|
<?php
|
|
|
|
$councilCount = count($councils);
|
|
|
|
if ($councilCount > 1) {
|
|
$wardsDescription = "Candidates from " . $councilCount . " wards have taken the pledge:";
|
|
}
|
|
|
|
?>
|
|
|
|
<!-- wp:paragraph -->
|
|
<p><?php echo $wardsDescription; ?></p>
|
|
<!-- /wp:paragraph -->
|
|
|
|
<?php if ($councilCount > 1): ?>
|
|
|
|
<?php
|
|
|
|
if ($councilCount > 8) {
|
|
$councilListChunkSize = ceil($councilCount / 2);
|
|
} else {
|
|
$councilListChunkSize = $councilCount;
|
|
}
|
|
|
|
$councilChunks = array_chunk($councils, $councilListChunkSize);
|
|
|
|
?>
|
|
<!-- wp:columns {"className":"council-list-columns"} -->
|
|
<div class="wp-block-columns council-list-columns">
|
|
|
|
<?php for ($columnIdx = 0; $columnIdx < 4; $columnIdx++): ?>
|
|
<!-- wp:column {"verticalAlignment":"top","style":{"spacing":{"padding":{"top":"0","bottom":"0"}}}} -->
|
|
<div class="wp-block-column is-vertically-aligned-top" style="padding-top:0;padding-bottom:0">
|
|
|
|
<?php if (array_key_exists($columnIdx, $councilChunks)): ?>
|
|
<!-- wp:list {"style":{"spacing":{"margin":{"top":"0","right":"0","bottom":"0","left":"0"}}}} -->
|
|
<ul style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" class="wp-block-list">
|
|
|
|
<?php foreach($councilChunks[$columnIdx] as $councilName): ?>
|
|
<!-- wp:list-item -->
|
|
<li><a href="#<?php echo sluggify($councilName); ?>"><?php echo $councilName; ?></a></li>
|
|
<!-- /wp:list-item -->
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
<!-- /wp:list -->
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
<!-- /wp:column -->
|
|
<?php endfor; ?>
|
|
|
|
</div>
|
|
<!-- /wp:columns -->
|
|
<?php else: ?>
|
|
<!-- wp:paragraph -->
|
|
<p></p>
|
|
<!-- /wp:paragraph -->
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($councils as $key => $council): ?>
|
|
<!-- wp:heading {"level":3,"className":"is-style-default"} -->
|
|
<?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($council); ?></a></h3>
|
|
<!-- /wp:heading -->
|
|
|
|
<?php
|
|
$groupCandidates = array_filter($candidates, function ($candidate) use ($council) {
|
|
return $candidate['Council'] === $council;
|
|
});
|
|
|
|
if (count($groupCandidates) > 0):
|
|
?>
|
|
|
|
<?php
|
|
$columnCount = 4;
|
|
|
|
$chunkedCouncilCandidates = array_chunk($groupCandidates, $columnCount);
|
|
?>
|
|
|
|
<?php foreach($chunkedCouncilCandidates as $chunk): ?>
|
|
<!-- wp:columns -->
|
|
<div class="wp-block-columns">
|
|
|
|
<?php for ($columnIdx = 0; $columnIdx < $columnCount; $columnIdx++): ?>
|
|
<!-- wp:column -->
|
|
<div class="wp-block-column">
|
|
|
|
<?php if (array_key_exists($columnIdx, $chunk)): ?>
|
|
<?php
|
|
$candidate = $chunk[$columnIdx];
|
|
|
|
if (isset($candidate['Picture']) && strlen($candidate['image_url'])) {
|
|
$candidate_image['url'] = $candidate['image_url'];
|
|
$candidate_image['id'] = $candidate['image_id'];
|
|
} else {
|
|
continue;
|
|
}
|
|
|
|
?>
|
|
|
|
<!-- wp:image {"id":<?php echo $candidate_image['id']; ?>,"width":"200px","height":"200px","scale":"cover","align":"center","style":{"color":{}},"className":"is-resized"} -->
|
|
<figure class="wp-block-image aligncenter is-resized"><img src="<?php echo $candidate_image['url']; ?>" alt="" class="wp-image-<?php echo $candidate_image['id']; ?>" style="object-fit:cover;width:200px;height:200px"/></figure>
|
|
<!-- /wp:image -->
|
|
|
|
<!-- wp:heading {"textAlign":"center","className":"wp-block-heading has-text-align-center has-medium-font-size","style":{"spacing":{"margin":{"top":"1rem","bottom":"0.5rem"}}}} -->
|
|
<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 -->
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
<!-- /wp:column -->
|
|
<?php endfor; ?>
|
|
|
|
</div>
|
|
<!-- /wp:columns -->
|
|
<?php endforeach; ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<!-- wp:paragraph -->
|
|
<p>No candidates in this ward have completed the survey. Send your local candidates the <?php echo $surveyLink; ?> and ask them to take part so that local residents can vote for the candidates who want to build the streets people love.</p>
|
|
<!-- /wp:paragraph -->
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
<?php if (isset($config['footer'])): ?>
|
|
<!-- wp:paragraph -->
|
|
<p><?php echo $config['footer']; ?></p>
|
|
<!-- /wp:paragraph -->
|
|
<?php endif; ?>
|