Finished off the agenda and minutes features in the adm page. Added another six events to the calendar.
This commit is contained in:
28
lib/main.php
28
lib/main.php
@@ -33,4 +33,32 @@ function getEvents() {
|
||||
return($entries);
|
||||
}
|
||||
|
||||
function putEvents($events) {
|
||||
for ( $i = 0; $i < count($events); $i++ ) {
|
||||
$entry = $events[$i];
|
||||
$dt = new DateTime( $entry["start"] );
|
||||
$start = new DateTime($entry["start"]);
|
||||
$datestamp = $dt -> format("Ymd");
|
||||
$files = array( "agenda" => sprintf("dat/agenda/%d.md", $datestamp)
|
||||
, "minutes" => sprintf("dat/minutes/%d.md", $datestamp)
|
||||
);
|
||||
foreach ( $files as $key => $path ) {
|
||||
if ( in_array($key, array_keys($entry)) ) {
|
||||
$fout = fopen($path, "wt");
|
||||
fwrite($fout, $entry[$key]);
|
||||
fclose($fout);
|
||||
} else {
|
||||
if ( file_exists($path) ) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ( array( "ctl", "hours", "agenda", "minutes" ) as $field ) {
|
||||
unset($events[$i][$field]);
|
||||
}
|
||||
}
|
||||
$json = json_encode($events, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
||||
file_put_contents("dat/events.json", $json);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user