Got a basic calendar editing page going.
This commit is contained in:
31
lib.php
Executable file
31
lib.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
ini_set('memory_limit', '512M');
|
||||
|
||||
function getEvents() {
|
||||
$content = file_get_contents("dat/events.json");
|
||||
$entries = json_decode($content, $associative = true);
|
||||
for ( $i = 0; $i < count($entries); $i++ ) {
|
||||
$entry = $entries[$i];
|
||||
$dt = new DateTime( $entry["start"] );
|
||||
$ctl = $dt -> format("YmdHi");
|
||||
$entries[$i]["ctl"] = $ctl;
|
||||
$datestamp = $dt -> format("Ymd");
|
||||
$files = array( "agenda" => sprintf("agenda/%d.md", $datestamp)
|
||||
, "minutes" => sprintf("minutes/%d.md", $datestamp)
|
||||
);
|
||||
foreach ( $files as $key => $file ) {
|
||||
if ( file_exists( $file ) ) {
|
||||
$entries[$i][$key] = file_get_contents($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
usort($entries, function ($a, $b) {
|
||||
$dateA = new DateTime($a['start']);
|
||||
$dateB = new DateTime($b['start']);
|
||||
return $dateA < $dateB ? 1 : -1;
|
||||
});
|
||||
return($entries);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user