2020-01-14 22:25:43 +01:00
|
|
|
<?php
|
2018-01-27 00:28:32 +01:00
|
|
|
|
2020-01-15 02:50:23 +01:00
|
|
|
require_once (__DIR__ . '/../../extern/egg/ExtendedGitGraph2.php');
|
2018-01-27 00:28:32 +01:00
|
|
|
|
|
|
|
class MikescherGitGraph
|
|
|
|
{
|
2020-01-15 00:57:11 +01:00
|
|
|
/** @var ExtendedGitGraph2 */
|
|
|
|
private $extgitgraph;
|
2018-01-27 00:28:32 +01:00
|
|
|
|
2020-01-15 00:57:11 +01:00
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
public function __construct(Website $site)
|
|
|
|
{
|
|
|
|
$this->extgitgraph = new ExtendedGitGraph2($site->config['extendedgitgraph']);
|
2018-01-27 00:28:32 +01:00
|
|
|
}
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2020-01-15 00:57:11 +01:00
|
|
|
public function getPathRenderedData()
|
2018-01-27 14:21:34 +01:00
|
|
|
{
|
2020-01-15 02:50:23 +01:00
|
|
|
return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html';
|
2018-01-27 14:21:34 +01:00
|
|
|
}
|
|
|
|
|
2019-12-28 14:00:11 +01:00
|
|
|
/**
|
|
|
|
* @return string|null
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2020-01-15 00:57:11 +01:00
|
|
|
public function get()
|
2018-01-27 14:21:34 +01:00
|
|
|
{
|
2020-01-15 00:57:11 +01:00
|
|
|
$d = $this->extgitgraph->loadFromCache();
|
2019-12-28 14:00:11 +01:00
|
|
|
if ($d === null) return "";
|
|
|
|
return $d;
|
2018-01-27 14:21:34 +01:00
|
|
|
}
|
|
|
|
|
2020-01-15 00:57:11 +01:00
|
|
|
public function checkConsistency()
|
2018-01-27 14:21:34 +01:00
|
|
|
{
|
2020-01-15 02:50:23 +01:00
|
|
|
$p = $this->getPathRenderedData();
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2018-02-03 14:43:41 +01:00
|
|
|
if (!file_exists($p)) return ['result'=>'err', 'message' => 'Rendered data not found'];
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2020-01-09 12:50:08 +01:00
|
|
|
if (filemtime($p) < time()-(24*60*60)) return ['result'=>'warn', 'message' => 'Rendered data is older than 1 day'];
|
2018-01-27 14:21:34 +01:00
|
|
|
|
|
|
|
return ['result'=>'ok', 'message' => ''];
|
|
|
|
}
|
2018-01-27 00:28:32 +01:00
|
|
|
}
|