Generate pledge council index.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class SPLPageRenderer {
|
||||
public function renderPledgePage($config, $candidates, $media) {
|
||||
public function renderPledgePage($councils, $candidates) {
|
||||
ob_start();
|
||||
|
||||
$didError = false;
|
||||
|
||||
@@ -22,7 +22,16 @@ $pledgeCandidates = array_filter($candidate_data, function ($candidate) {
|
||||
$renderer = new SPLPageRenderer();
|
||||
//print_r($pledgeCandidates);
|
||||
|
||||
$pageContent = $renderer->renderPledgePage($councilData, $candidateData, $mediaData);
|
||||
$councils = [];
|
||||
foreach ($pledgeCandidates as $key => $candidate) {
|
||||
$councils[] = $candidate['Council'];
|
||||
}
|
||||
$councils = array_unique($councils);
|
||||
asort($councils);
|
||||
|
||||
//print_r($councils);
|
||||
|
||||
$pageContent = $renderer->renderPledgePage($councils, $pledgeCandidates);
|
||||
|
||||
if ($pageContent === null) {
|
||||
exit(2);
|
||||
|
||||
@@ -5,9 +5,6 @@ function sluggify($input) {
|
||||
}
|
||||
|
||||
$surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Love Pledge and Survey</a>";
|
||||
if (isset($config["survey"])) {
|
||||
$surveyLink = $config["survey"];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -27,12 +24,10 @@ if (isset($config["survey"])) {
|
||||
|
||||
<?php
|
||||
|
||||
$wardCount = count($config['wardNames']);
|
||||
$councilCount = count($councils);
|
||||
|
||||
if ($wardCount > 1) {
|
||||
$wardsDescription = $config['councilName'] . " is divided into " . $wardCount . " wards:";
|
||||
} else {
|
||||
$wardsDescription = $config['councilName'] . " is unsubdivided and does not contain any wards.";
|
||||
if ($councilCount > 1) {
|
||||
$wardsDescription = "Candidates from " . $councilCount . " wards have taken the pledge:";
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -41,39 +36,33 @@ if (isset($config["survey"])) {
|
||||
<p><?php echo $wardsDescription; ?></p>
|
||||
<!-- /wp:paragraph -->
|
||||
|
||||
<?php if (isset($media["map.jpg"])): ?>
|
||||
<!-- wp:image {"id":<?php echo $media["map.jpg"]['id']; ?>,"width":"550px","sizeSlug":"full","linkDestination":"media","className":"is-style-default"} -->
|
||||
<figure class="wp-block-image size-full is-resized is-style-default"><a href="<?php echo $media["map.jpg"]['url']; ?>" target="_blank" rel="noreferrer noopener"><img src="<?php echo $media["map.jpg"]['url']; ?>" alt="" class="wp-image-<?php echo $media["map.jpg"]['id']; ?>" style="width:550px"/></a></figure>
|
||||
<!-- /wp:image -->
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($wardCount > 1): ?>
|
||||
<?php if ($councilCount > 1): ?>
|
||||
|
||||
<?php
|
||||
|
||||
if ($wardCount > 8) {
|
||||
$wardListChunkSize = ceil($wardCount / 2);
|
||||
if ($councilCount > 8) {
|
||||
$councilListChunkSize = ceil($councilCount / 2);
|
||||
} else {
|
||||
$wardListChunkSize = $wardCount;
|
||||
$councilListChunkSize = $councilCount;
|
||||
}
|
||||
|
||||
$wardChunks = array_chunk($config['wardNames'], $wardListChunkSize);
|
||||
$councilChunks = array_chunk($councils, $councilListChunkSize);
|
||||
|
||||
?>
|
||||
<!-- wp:columns {"className":"ward-list-columns"} -->
|
||||
<div class="wp-block-columns ward-list-columns">
|
||||
<!-- 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, $wardChunks)): ?>
|
||||
<?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($wardChunks[$columnIdx] as $wardName): ?>
|
||||
<?php foreach($councilChunks[$columnIdx] as $councilName): ?>
|
||||
<!-- wp:list-item -->
|
||||
<li><a href="#<?php echo sluggify($wardName); ?>"><?php echo $wardName; ?></a></li>
|
||||
<li><a href="#<?php echo sluggify($councilName); ?>"><?php echo $councilName; ?></a></li>
|
||||
<!-- /wp:list-item -->
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -87,7 +76,7 @@ if (isset($config["survey"])) {
|
||||
|
||||
</div>
|
||||
<!-- /wp:columns -->
|
||||
<?php else: ?>
|
||||
<?php exit(0); else: ?>
|
||||
<!-- wp:paragraph -->
|
||||
<p></p>
|
||||
<!-- /wp:paragraph -->
|
||||
|
||||
Reference in New Issue
Block a user