1
0
www.mikescher.com/www/internals/modules/webapps.php

49 lines
908 B
PHP
Raw Normal View History

2018-05-13 15:46:13 +02:00
<?php
2020-01-19 13:16:40 +01:00
class WebApps implements IWebsiteModule
2018-05-13 15:46:13 +02:00
{
2020-01-15 00:50:55 +01:00
/** @var array */
private $staticData;
public function __construct()
{
$this->load();
}
private function load()
2018-05-13 15:46:13 +02:00
{
2020-01-15 02:50:23 +01:00
$all = require (__DIR__ . '/../../statics/webapps/__all.php');
2018-05-13 15:46:13 +02:00
2020-01-15 00:50:55 +01:00
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
2018-05-13 15:46:13 +02:00
}
2020-01-15 00:50:55 +01:00
private static function readSingle($a)
2018-05-13 15:46:13 +02:00
{
return $a;
}
2020-01-15 00:50:55 +01:00
public function listAllNewestFirst()
2018-05-13 15:46:13 +02:00
{
2020-01-15 00:50:55 +01:00
$data = $this->staticData;
2018-05-13 15:46:13 +02:00
usort($data, function($a, $b) { return strcasecmp($b['date'], $a['date']); });
return $data;
}
2020-01-19 13:16:40 +01:00
public function checkConsistency()
{
$warn = null;
$this->load();
$ids = [];
foreach ($this->staticData as $prog)
{
if (in_array($prog['id'], $ids)) return ['result'=>'err', 'message' => 'Duplicate id ' . $prog['id']];
$ids []= $prog['id'];
}
if ($warn != null) return $warn;
return ['result'=>'ok', 'message' => ''];
}
2020-01-15 02:50:23 +01:00
}