2013-11-17 14:39:50 +01:00
|
|
|
<?php
|
|
|
|
class LogController
|
|
|
|
{
|
2014-05-03 10:54:40 +02:00
|
|
|
public function listView()
|
2013-11-17 14:39:50 +01:00
|
|
|
{
|
2014-05-03 10:54:40 +02:00
|
|
|
$ret = Api::run(new ListLogsJob(), []);
|
|
|
|
getContext()->transport->logs = $ret;
|
2013-11-17 14:39:50 +01:00
|
|
|
}
|
|
|
|
|
2014-05-03 10:54:40 +02:00
|
|
|
public function logView($name, $page = 1, $filter = '')
|
2013-11-17 14:39:50 +01:00
|
|
|
{
|
2014-04-29 21:35:29 +02:00
|
|
|
$context = getContext();
|
2014-05-03 10:54:40 +02:00
|
|
|
$context->viewName = 'log-view';
|
|
|
|
|
2014-01-27 09:17:36 +01:00
|
|
|
//redirect requests in form of ?query=... to canonical address
|
|
|
|
$formQuery = InputHelper::get('query');
|
|
|
|
if ($formQuery !== null)
|
|
|
|
{
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Util\Url::forward(
|
|
|
|
\Chibi\Router::linkTo(
|
2014-05-03 10:54:40 +02:00
|
|
|
['LogController', 'logView'],
|
2014-01-27 09:17:36 +01:00
|
|
|
[
|
|
|
|
'name' => $name,
|
|
|
|
'filter' => $formQuery,
|
|
|
|
'page' => 1
|
|
|
|
]));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-03 10:54:40 +02:00
|
|
|
$ret = Api::run(
|
|
|
|
new GetLogJob(),
|
|
|
|
[
|
|
|
|
JobArgs::PAGE_NUMBER => $page,
|
|
|
|
JobArgs::LOG_ID => $name,
|
|
|
|
JobArgs::QUERY => $filter,
|
|
|
|
]);
|
2014-01-27 09:17:36 +01:00
|
|
|
|
2013-11-17 23:29:59 +01:00
|
|
|
//stylize important lines
|
2014-05-03 10:54:40 +02:00
|
|
|
foreach ($ret->lines as &$line)
|
2013-11-17 23:29:59 +01:00
|
|
|
if (strpos($line, 'flag') !== false)
|
|
|
|
$line = '**' . $line . '**';
|
|
|
|
unset($line);
|
|
|
|
|
2014-05-03 10:54:40 +02:00
|
|
|
$ret->lines = join(PHP_EOL, $ret->lines);
|
|
|
|
$ret->lines = TextHelper::parseMarkdown($ret->lines, true);
|
|
|
|
$ret->lines = trim($ret->lines);
|
2013-11-17 14:39:50 +01:00
|
|
|
|
2014-04-29 21:35:29 +02:00
|
|
|
$context->transport->paginator = new StdClass;
|
2014-05-03 10:54:40 +02:00
|
|
|
$context->transport->paginator->page = $ret->page;
|
|
|
|
$context->transport->paginator->pageCount = $ret->pageCount;
|
|
|
|
$context->transport->paginator->entityCount = $ret->lineCount;
|
|
|
|
$context->transport->paginator->entities = $ret->lines;
|
|
|
|
$context->transport->lines = $ret->lines;
|
2014-04-29 21:35:29 +02:00
|
|
|
$context->transport->filter = $filter;
|
|
|
|
$context->transport->name = $name;
|
2013-11-17 14:39:50 +01:00
|
|
|
}
|
|
|
|
}
|