1
0
www.mikescher.com/www/internals/programs.php

48 lines
1.4 KiB
PHP
Raw Normal View History

2017-11-08 17:39:50 +01:00
<?php if(count(get_included_files()) ==1) exit("Direct access not permitted.");
class Programs
{
2018-01-03 22:08:56 +01:00
public static function readSingle($a)
2017-11-08 17:39:50 +01:00
{
2018-01-04 01:11:41 +01:00
$a['thumbnail_url'] = '/data/images/program_thumbnails/' . $a['internal_name'] . '.png';
2018-01-20 03:05:15 +01:00
$a['file_longdescription'] = (__DIR__ . '/../statics/programs/' . $a['internal_name'] . '_description.md');
2018-01-04 01:11:41 +01:00
$a['url'] = '/programs/view/' . $a['internal_name'];
2017-11-08 17:39:50 +01:00
return $a;
}
public static function listAll()
{
2018-01-03 22:08:56 +01:00
$all = require (__DIR__ . '/../statics/programs/__all.php');
return array_map('self::readSingle', $all);
2018-01-03 21:02:40 +01:00
}
2018-01-04 16:55:26 +01:00
public static function listAllNewestFirst($filter = '')
2018-01-03 21:02:40 +01:00
{
$data = self::listAll();
usort($data, function($a, $b) { return strcasecmp($b['add_date'], $a['add_date']); });
2018-01-04 16:55:26 +01:00
if ($filter !== '') $data = array_filter($data, function($a) use($filter) { return strtolower($a['category']) === strtolower($filter); });
2018-01-03 21:02:40 +01:00
return $data;
2017-11-08 17:39:50 +01:00
}
2017-11-20 17:15:12 +01:00
public static function listUpdateData()
{
$a = require (__DIR__ . '/../statics/updates/programupdates.php');
return $a;
}
2018-01-20 03:05:15 +01:00
public static function getProgramByInternalName($id)
{
foreach (self::listAll() as $prog) {
if (strcasecmp($prog['internal_name'], $id) === 0) return $prog;
if ($prog['internal_name_alt'] !== null && strcasecmp($prog['internal_name_alt'], $id) === 0) return $prog;
}
return null;
}
public static function getProgramDescription($prog)
{
return file_get_contents($prog['file_longdescription']);
}
2017-11-08 17:39:50 +01:00
}