| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package Logtivity |
| 5 |
* @contact logtivity.io, hello@logtivity.io |
| 6 |
* @copyright 2024-2026 Logtivity. All rights reserved |
| 7 |
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL |
| 8 |
* |
| 9 |
* This file is part of Logtivity. |
| 10 |
* |
| 11 |
* Logtivity is free software: you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License as published by |
| 13 |
* the Free Software Foundation, either version 2 of the License, or |
| 14 |
* (at your option) any later version. |
| 15 |
* |
| 16 |
* Logtivity is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with Logtivity. If not, see <https://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
|
| 25 |
/** |
| 26 |
* @var string $fileName |
| 27 |
* @var ?string $message |
| 28 |
* @var object[] $logs |
| 29 |
* @var object $meta |
| 30 |
* @var string $hasNextPage |
| 31 |
*/ |
| 32 |
|
| 33 |
?> |
| 34 |
<table class="form-table logtivity-table"> |
| 35 |
<caption class="screen-reader-text"><?php esc_html_e('Activity logs', 'logtivity'); ?></caption> |
| 36 |
<thead> |
| 37 |
<tr> |
| 38 |
<th scope="col">Action</th> |
| 39 |
<th scope="col">Context</th> |
| 40 |
<th scope="col">User</th> |
| 41 |
<th scope="col">Date</th> |
| 42 |
<th scope="col">Actions</th> |
| 43 |
</tr> |
| 44 |
</thead> |
| 45 |
<tbody> |
| 46 |
|
| 47 |
<?php if (count($logs)) : ?> |
| 48 |
<?php foreach ($logs as $key => $log) : ?> |
| 49 |
|
| 50 |
<tr> |
| 51 |
<td><?php echo sanitize_text_field($log->action) ?></td> |
| 52 |
<td><?php echo sanitize_text_field($log->context) ?></td> |
| 53 |
<td class="break-long"> |
| 54 |
<div style="margin-bottom: 5px;"><?php echo sanitize_text_field($log->action_username ?? $log->action_user_id) ?></div> |
| 55 |
<?php echo sanitize_text_field($log->ip_address) ?> |
| 56 |
</td> |
| 57 |
<td> |
| 58 |
<small> |
| 59 |
<?php echo logtivity_datetime($log->occurred_at); ?> |
| 60 |
</small> |
| 61 |
</td> |
| 62 |
<td class="text-center"> |
| 63 |
<button type="button" class="button js-logtivity-view-log" aria-haspopup="dialog" aria-controls="logtivity-log-modal" aria-label="<?php esc_attr_e('View log details', 'logtivity'); ?>">View</button> |
| 64 |
<div style="display: none;" class="js-modal-content"> |
| 65 |
<?php echo logtivity_view('_log-show', ['log' => $log,]) ?> |
| 66 |
</div> |
| 67 |
</td> |
| 68 |
</tr> |
| 69 |
|
| 70 |
<?php endforeach ?> |
| 71 |
<?php elseif (isset($message)) : ?> |
| 72 |
<tr> |
| 73 |
<td colspan="5"><?php echo sanitize_text_field($message) ?></td> |
| 74 |
</tr> |
| 75 |
<?php else : ?> |
| 76 |
<tr> |
| 77 |
<td colspan="5">No results found.</td> |
| 78 |
</tr> |
| 79 |
<?php endif ?> |
| 80 |
</tbody> |
| 81 |
</table> |
| 82 |
|
| 83 |
<?php if ($meta->current_page ?? null) : ?> |
| 84 |
<nav class="nav-pages-buttons" data-current-page="<?php echo esc_attr($meta->current_page) ?>" aria-label="<?php esc_attr_e('Log pages', 'logtivity'); ?>"> |
| 85 |
<button type="button" <?php echo $meta->current_page == 1 ? 'disabled' : ''; ?> |
| 86 |
class="js-logtivity-pagination button-primary nav-pages-prev" |
| 87 |
aria-label="<?php esc_attr_e('Previous log page', 'logtivity'); ?>" |
| 88 |
data-page="<?php echo esc_attr($meta->current_page - 1) ?>"> |
| 89 |
« Previous |
| 90 |
</button> |
| 91 |
<button type="button" <?php echo $hasNextPage ? '' : 'disabled'; ?> |
| 92 |
class="js-logtivity-pagination button-primary nav-pages-next" |
| 93 |
aria-label="<?php esc_attr_e('Next log page', 'logtivity'); ?>" |
| 94 |
data-page="<?php echo esc_attr($meta->current_page + 1) ?>">Next » |
| 95 |
</button> |
| 96 |
</nav> |
| 97 |
<?php endif ?> |
| 98 |
|
| 99 |
<div id="logtivity-log-modal" class="logtivity-modal" role="dialog" aria-modal="true" aria-hidden="true" aria-labelledby="logtivity-log-modal-title"> |
| 100 |
<div class="logtivity-modal-dialog" tabindex="-1"> |
| 101 |
<div class="logtivity-modal-content"> |
| 102 |
<!-- Populated with JS --> |
| 103 |
</div> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
|