<?php
 namespace RtmMail; use RtmMail\Helpers\EventHelper; use RtmMail\Helpers\LogHelper; class EventDetails extends AbstractPage { protected $slug = 'event_details'; private $event_logs; private $mail_log; public function __construct() { parent::__construct(); } public function handle_requests() { if ($this->page_check()) { if (isset($_GET['log_id'])) { $log_id = sanitize_key($_GET['log_id']); $this->mail_log = LogHelper::get([ 'post_per_page' => null, 'where' => [ 'id' => [ 'type' => '=', 'value' => $log_id, ] ] ]); $this->event_logs = EventHelper::get([ 'post_per_page' => null, 'search_filter' => [ 'log_id' => true, ], 's' => $log_id, ]); } } } public function display() { if ($this->page_check()) { global $events; global $log; $log = $this->mail_log; $events = $this->event_logs; require __DIR__ . '/Views/' . $this->slug . '.php'; } } public function build_dump($request) { $html = '<div class="request-dump-block">'; foreach ($request as $request_type => $request_data) { if (!empty($request_data)) { $html .= '<div class="request-dump-item">'; $html .= '<p class="request-item-label">' . $request_type . '</p>'; $html .= '<pre class="request-item-data">'; $html .= $this->build_request_data($request_data); $html .= '</pre>'; $html .= '</div>'; } } $html .= '</div>'; return $html; } private function build_request_data($data, $html = '', $level = 1) { if (empty($html)) { $html = '<p><span class="request-dump-type">' . gettype($data) . ' (' . count($data) . ')</span> '; $html .= is_array($data) ? '[</p>' : '{</p>'; } $html .= '<div class="request-dump-data" style="margin-left: calc(7px * ' . $level . ');">'; foreach ($data as $key => $value) { $html .= '<p>"<span class="request-dump-key">' . $key . '</span>" => '; if (is_array($value) || is_object($value)) { $html .= '<span class="request-dump-type">' . gettype($value) . ' (' . count($value) . ')</span> '; $html .= is_array($value) ? '[</p>' : '{</p>'; $html = $this->build_request_data($value, $html, $level + 1); } else { $value = is_string($value) ? '"<span class="request-dump-value">' . $value . '</span>"' : '<span class="request-dump-value">' . $value . '</span>'; $html .= $value . '</p>'; } } $html .= '</div>'; $html .= is_array($data) ? '<p>]</p>' : '<p>}</p>'; return $html; } } 