36 lines
831 B
PHP
36 lines
831 B
PHP
<?php /* Copyright (c) 2024 Freya Murphy */
|
|
class Projects_model extends Model {
|
|
|
|
private $markdown;
|
|
|
|
function __construct($load) {
|
|
parent::__construct($load);
|
|
$this->markdown = new MarkdownParser();
|
|
}
|
|
|
|
private function load_projects(&$data) {
|
|
$projects = array();
|
|
$dir = $GLOBALS['assetroot'] . '/projects';
|
|
if ($handle = opendir($dir)) {
|
|
while (false !== ($entry = readdir($handle))) {
|
|
if (str_starts_with($entry, ".")) {
|
|
continue;
|
|
}
|
|
$path = $dir . '/' . $entry;
|
|
$md = $this->markdown->parse($path);
|
|
$projects[$entry] = $md;
|
|
}
|
|
}
|
|
krsort($projects);
|
|
$data['projects'] = $projects;
|
|
}
|
|
|
|
public function get_data(): ?array {
|
|
$data = parent::get_data();
|
|
$this->load_projects($data);
|
|
$data['title'] = lang('title');
|
|
$data['desc'] = lang('short_desc');
|
|
return $data;
|
|
}
|
|
}
|
|
?>
|