View.php
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
namespace WPML\TM\ATE\Log;
use WPML\Collect\Support\Collection;
class View {
/** @var Collection $logs */
private $logs;
public function __construct( Collection $logs ) {
$this->logs = $logs;
}
public function renderPage() {
?>
<div class="wrap">
<h1><?php esc_html_e( 'Advanced Translation Editor Error Logs', 'wpml-translation-management' ); ?></h1>
<br>
<table class="wp-list-table widefat fixed striped posts">
<thead><?php $this->renderTableHeader(); ?></thead>
<tbody id="the-list">
<?php
if ( $this->logs->isEmpty() ) {
$this->renderEmptyTable();
} else {
$this->logs->each( [ $this, 'renderTableRow' ] );
}
?>
</tbody>
<tfoot><?php $this->renderTableHeader(); ?></tfoot>
</table>
</div>
<?php
}
private function renderTableHeader() {
?>
<tr>
<th class="date">
<span><?php esc_html_e( 'Date', 'wpml-translation-management' ); ?></span>
</th>
<th class="event">
<span><?php esc_html_e( 'Event', 'wpml-translation-management' ); ?></span>
</th>
<th class="description">
<span><?php esc_html_e( 'Description', 'wpml-translation-management' ); ?></span>
</th>
<th class="wpml-job-id">
<span><?php esc_html_e( 'WPML Job ID', 'wpml-translation-management' ); ?></span>
</th>
<th class="ate-job-id">
<span><?php esc_html_e( 'ATE Job ID', 'wpml-translation-management' ); ?></span>
</th>
<th class="extra-data">
<span><?php esc_html_e( 'Extra data', 'wpml-translation-management' ); ?></span>
</th>
</tr>
<?php
}
public function renderTableRow( Entry $entry ) {
?>
<tr>
<td class="date">
<?php echo esc_html( $entry->getFormattedDate() ); ?>
</td>
<td class="event">
<?php echo esc_html( EventsTypes::getLabel( $entry->eventType ) ); ?>
</td>
<td class="description">
<?php echo esc_html( $entry->description ); ?>
</td>
<td class="wpml-job-id">
<?php echo esc_html( (string) $entry->wpmlJobId ); ?>
</td>
<td class="ate-job-id">
<?php echo esc_html( (string) $entry->ateJobId ); ?>
</td>
<td class="extra-data">
<?php echo esc_html( $entry->getExtraDataToString() ); ?>
</td>
</tr>
<?php
}
private function renderEmptyTable() {
?>
<tr>
<td colspan="6" class="title column-title has-row-actions column-primary">
<?php esc_html_e( 'No entries', 'wpml-translation-management' ); ?>
</td>
</tr>
<?php
}
}