Files
spl-tools/pledge-update/pledge-page.php
2024-09-17 22:19:24 +10:00

33 lines
785 B
PHP

<?php
require_once("parse_pledge_data.php");
require_once("page_renderer.php");
$options = getopt("", ["candidates-files:"]);
if (isset($options['candidates-files'])) {
$candidates_files = $options['candidates-files'];
} else {
error_log("Error: Missing required option '--candidates-files'.");
exit(1);
}
$candidate_data = parse_pledge_data(explode(" ", $candidates_files));
/* Select people who have taken the pledge */
$pledgeCandidates = array_filter($candidate_data, function ($candidate) {
return $candidate['Pledge'] === 'y';
});
$renderer = new SPLPageRenderer();
//print_r($pledgeCandidates);
$pageContent = $renderer->renderPledgePage($councilData, $candidateData, $mediaData);
if ($pageContent === null) {
exit(2);
}
echo $pageContent;
exit(0);