engelsystem/includes/pages/admin_log.php

46 lines
952 B
PHP
Raw Normal View History

2011-06-03 14:44:01 +02:00
<?php
2018-08-31 01:55:05 +02:00
use Engelsystem\Models\LogEntry;
2017-01-03 03:22:48 +01:00
/**
* @return string
*/
2017-01-02 03:57:23 +01:00
function admin_log_title()
{
return __('Log');
2013-11-25 21:04:58 +01:00
}
2017-01-03 03:22:48 +01:00
/**
* @return string
*/
2017-01-02 03:57:23 +01:00
function admin_log()
{
2017-01-03 14:12:17 +01:00
$filter = '';
if (request()->has('keyword')) {
2017-01-02 03:57:23 +01:00
$filter = strip_request_item('keyword');
}
2017-01-02 15:43:36 +01:00
2018-08-31 01:55:05 +02:00
$log_entries = LogEntry::filter($filter);
$entries = [];
foreach ($log_entries as $entry) {
$data = $entry->toArray();
2019-04-29 23:59:37 +02:00
$data['message'] = nl2br(htmlspecialchars($data['message']));
2018-08-31 01:55:05 +02:00
$data['created_at'] = date_format($entry->created_at, 'd.m.Y H:i');
$entries[] = $data;
2017-01-02 03:57:23 +01:00
}
2017-01-02 15:43:36 +01:00
2017-01-02 03:57:23 +01:00
return page_with_title(admin_log_title(), [
2017-01-02 15:43:36 +01:00
msg(),
form([
form_text('keyword', __('Search'), $filter),
form_submit(__('Search'), 'Go')
2017-01-02 15:43:36 +01:00
]),
table([
2018-08-31 01:55:05 +02:00
'created_at' => 'Time',
'level' => 'Type',
'message' => 'Log Entry'
], $entries)
2017-01-02 15:43:36 +01:00
]);
2011-06-03 14:44:01 +02:00
}