<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\AdminPages\Pages; if (!defined('ABSPATH')) exit; use MailPoet\AdminPages\PageRenderer; use MailPoet\Logging\LogRepository; use MailPoetVendor\Carbon\Carbon; class Logs { /** @var PageRenderer */ private $pageRenderer; /** @var LogRepository */ private $logRepository; public function __construct( LogRepository $logRepository, PageRenderer $pageRenderer ) { $this->pageRenderer = $pageRenderer; $this->logRepository = $logRepository; } public function render() { $search = isset($_GET['search']) ? sanitize_text_field(wp_unslash($_GET['search'])) : null; $from = isset($_GET['from']) ? sanitize_text_field(wp_unslash($_GET['from'])) : null; $to = isset($_GET['to']) ? sanitize_text_field(wp_unslash($_GET['to'])) : null; $offset = isset($_GET['offset']) ? sanitize_text_field(wp_unslash($_GET['offset'])) : null; $limit = isset($_GET['limit']) ? sanitize_text_field(wp_unslash($_GET['limit'])) : null; $dateFrom = (new Carbon())->subDays(7); $defaultFrom = $dateFrom->format('Y-m-d'); if (isset($from)) { $dateFrom = new Carbon($from); } $dateTo = null; if (isset($to)) { $dateTo = new Carbon($to); } $logs = $this->logRepository->getLogs($dateFrom, $dateTo, $search, $offset, $limit); $data = [ 'logs' => [], 'logs_default_from' => $defaultFrom, ]; foreach ($logs as $log) { $data['logs'][] = [ 'id' => $log->getId(), 'name' => $log->getName(), 'message' => $log->getMessage(), 'created_at' => ($createdAt = $log->getCreatedAt()) ? $createdAt->format('Y-m-d H:i:s') : null, ]; } $this->pageRenderer->displayPage('logs.html', $data); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Automation.php | File | 4.54 KB | 0644 |
|
AutomationAnalytics.php | File | 3.18 KB | 0644 |
|
AutomationEditor.php | File | 4.89 KB | 0644 |
|
AutomationTemplates.php | File | 3.63 KB | 0644 |
|
DynamicSegments.php | File | 9.57 KB | 0644 |
|
ExperimentalFeatures.php | File | 514 B | 0644 |
|
FormEditor.php | File | 13.8 KB | 0644 |
|
Forms.php | File | 2.08 KB | 0644 |
|
Help.php | File | 6.42 KB | 0644 |
|
Homepage.php | File | 1.23 KB | 0644 |
|
Landingpage.php | File | 1003 B | 0644 |
|
Logs.php | File | 1.8 KB | 0644 |
|
NewsletterEditor.php | File | 8.24 KB | 0644 |
|
Newsletters.php | File | 7.72 KB | 0644 |
|
Settings.php | File | 4.57 KB | 0644 |
|
StaticSegments.php | File | 804 B | 0644 |
|
Subscribers.php | File | 2.38 KB | 0644 |
|
SubscribersExport.php | File | 692 B | 0644 |
|
SubscribersImport.php | File | 1.11 KB | 0644 |
|
Upgrade.php | File | 1.21 KB | 0644 |
|
WelcomeWizard.php | File | 3.73 KB | 0644 |
|
WooCommerceSetup.php | File | 1.06 KB | 0644 |
|
index.php | File | 6 B | 0644 |
|