summaryrefslogtreecommitdiff
path: root/views/mods/mod_reviews/admin_index.phtml
blob: 74f6fc5e3de91629bc7544ebee3af1b708f0b6dc (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
	/**
	 * Backend: Bewertungen prüfen, freigeben, ablehnen, beantworten; Zeilen- und Mehrfachaktionen wie unter Kommentare
	 * @version 4.6.1
	 */
	defined('ABSPATH') || exit;

	$admin = $this->view['wpsg_mod_reviews']['admin'];
	$arTabs = [
		wpsg_review::STATUS_PENDING => __('Zu prüfen', 'wpsg'),
		wpsg_review::STATUS_APPROVED => __('Veröffentlicht', 'wpsg'),
		wpsg_review::STATUS_REJECTED => __('Abgelehnt', 'wpsg')
	];
	$base = admin_url('admin.php?page=wpsg-Reviews');
	$current_url = add_query_arg(['status' => $admin['status'], 'paged' => $admin['paged']], $base);

	// Freigeben nicht bei veröffentlichten, Ablehnen nicht bei abgelehnten
	$arActions = [];
	if ($admin['status'] !== wpsg_review::STATUS_APPROVED) $arActions['approve'] = __('Freigeben', 'wpsg');
	if ($admin['status'] !== wpsg_review::STATUS_REJECTED) $arActions['reject'] = __('Ablehnen', 'wpsg');
	$arActions['delete'] = __('Löschen', 'wpsg');

	// Oben und unten wie im Kern; schmal blendet der Kern die obere Auswahl aus
	$bulkactions = function(string $position) use ($arActions) {

		$id = 'wpsg-reviews-bulk-'.$position;

		?>
		<div class="alignleft actions bulkactions">
			<label for="<?php echo esc_attr($id); ?>" class="screen-reader-text"><?php echo esc_html__('Mehrfachaktion wählen', 'wpsg'); ?></label>
			<select name="wpsg_bulk_action[<?php echo esc_attr($position); ?>]" id="<?php echo esc_attr($id); ?>">
				<option value=""><?php echo esc_html__('Mehrfachaktionen', 'wpsg'); ?></option>
				<?php foreach ($arActions as $action => $label) { ?>
				<option value="<?php echo esc_attr($action); ?>"><?php echo esc_html($label); ?></option>
				<?php } ?>
			</select>
			<button type="submit" name="wpsg_review_bulk" value="<?php echo esc_attr($position); ?>" class="button action"><?php echo esc_html__('Übernehmen', 'wpsg'); ?></button>
		</div>
		<?php

	};

	$pagination = function() use ($admin, $current_url) {

		$total = intval($admin['count'][$admin['status']]??0);

		?>
		<div class="tablenav-pages<?php echo (($admin['pages'] <= 1)?' one-page':''); ?>">
			<span class="displaying-num"><?php echo esc_html(sprintf(_n('%s Eintrag', '%s Einträge', $total, 'wpsg'), number_format_i18n($total))); ?></span>
			<?php if ($admin['pages'] > 1) { ?>
			<span class="pagination-links">
				<?php if ($admin['paged'] > 1) { ?>
				<a class="prev-page button" href="<?php echo esc_url(add_query_arg('paged', $admin['paged'] - 1, $current_url)); ?>"><span class="screen-reader-text"><?php echo esc_html__('Vorherige Seite', 'wpsg'); ?></span><span aria-hidden="true">‹</span></a>
				<?php } else { ?>
				<span class="tablenav-pages-navspan button disabled" aria-hidden="true">‹</span>
				<?php } ?>
				<span class="paging-input"><span class="tablenav-paging-text"><?php echo esc_html(sprintf(__('Seite %1$s von %2$s', 'wpsg'), number_format_i18n($admin['paged']), number_format_i18n($admin['pages']))); ?></span></span>
				<?php if ($admin['paged'] < $admin['pages']) { ?>
				<a class="next-page button" href="<?php echo esc_url(add_query_arg('paged', $admin['paged'] + 1, $current_url)); ?>"><span class="screen-reader-text"><?php echo esc_html__('Nächste Seite', 'wpsg'); ?></span><span aria-hidden="true">›</span></a>
				<?php } else { ?>
				<span class="tablenav-pages-navspan button disabled" aria-hidden="true">›</span>
				<?php } ?>
			</span>
			<?php } ?>
		</div>
		<?php

	};
?>
<div class="wrap wpsg-reviews-admin">

	<h1><?php echo esc_html__('Bewertungen', 'wpsg'); ?></h1>

	<?php echo $this->writeBackendMessage(); ?>

	<?php echo $this->callMod('wpsg_mod_reviews', 'privacyNotice'); /* schon escaped */ ?>
	<?php echo $this->callMod('wpsg_mod_reviews', 'importNotice'); /* schon escaped */ ?>

	<nav class="nav-tab-wrapper" aria-label="<?php echo esc_attr__('Bewertungen nach Status', 'wpsg'); ?>">
		<?php foreach ($arTabs as $status => $label) { ?>
		<a href="<?php echo esc_url(add_query_arg('status', $status, $base)); ?>" class="nav-tab<?php echo (($admin['status'] === $status)?' nav-tab-active':''); ?>"<?php if ($admin['status'] === $status) { ?> aria-current="page"<?php } ?>><?php echo esc_html($label); ?> (<?php echo intval($admin['count'][$status]??0); ?>)</a>
		<?php } ?>
	</nav>

	<?php if (sizeof($admin['reviews']) === 0) { ?>

		<p><?php echo esc_html__('Keine Bewertungen.', 'wpsg'); ?></p>

	<?php } else { ?>

	<form method="post" action="<?php echo esc_url(add_query_arg('noheader', '1', $current_url)); ?>" class="wpsg-reviews-admin__form" data-confirm-bulk="<?php echo esc_attr__('Die ausgewählten Bewertungen endgültig löschen?', 'wpsg'); ?>">

		<?php wp_nonce_field('wpsg_reviews_moderate'); ?>

		<div class="tablenav top">
			<?php $bulkactions('top'); ?>
			<?php $pagination(); ?>
			<br class="clear" />
		</div>

		<table class="wp-list-table widefat fixed striped table-view-list wpsg-reviews-admin__table">
			<thead>
				<tr>
					<td class="manage-column column-cb check-column"><input id="wpsg-reviews-select-all" type="checkbox" /><label for="wpsg-reviews-select-all"><span class="screen-reader-text"><?php echo esc_html__('Alle auswählen', 'wpsg'); ?></span></label></td>
					<th scope="col" class="manage-column column-review column-primary"><?php echo esc_html__('Bewertung', 'wpsg'); ?></th>
					<th scope="col" class="manage-column column-product"><?php echo esc_html__('Produkt', 'wpsg'); ?></th>
					<th scope="col" class="manage-column column-author"><?php echo esc_html__('Name', 'wpsg'); ?></th>
					<th scope="col" class="manage-column column-date"><?php echo esc_html__('Abgegeben', 'wpsg'); ?></th>
				</tr>
			</thead>
			<tbody>
				<?php foreach ($admin['reviews'] as $review) { $review_id = intval($review['id']); $bReply = ((string)$review['reply'] !== ''); ?>
				<tr id="wpsg-review-<?php echo $review_id; ?>">
					<th scope="row" class="check-column"><input type="checkbox" id="wpsg-review-cb-<?php echo $review_id; ?>" name="review_ids[]" value="<?php echo $review_id; ?>" /><label for="wpsg-review-cb-<?php echo $review_id; ?>"><span class="screen-reader-text"><?php echo esc_html(wpsg_translate(__('Bewertung von #1# auswählen', 'wpsg'), $review['display_name'])); ?></span></label></th>
					<?php /* Ohne data-colname: schmal stünde die Spaltenbeschriftung über den Sternen (in 7.1 ist die Hauptspalte im Kern ein th) */ ?>
					<td class="column-review column-primary has-row-actions">
						<div class="wpsg-reviews-admin__stars"><span aria-hidden="true"><?php echo str_repeat('★', intval($review['stars'])).str_repeat('☆', 5 - intval($review['stars'])); ?></span><span class="screen-reader-text"><?php echo esc_html(wpsg_translate(__('#1# von 5 Sternen', 'wpsg'), intval($review['stars']))); ?></span></div>
						<?php if ((string)$review['title'] !== '') { ?><strong class="wpsg-reviews-admin__title"><?php echo esc_html($review['title']); ?></strong><?php } ?>
						<div class="wpsg-reviews-admin__text"><?php echo nl2br(esc_html((string)$review['text'])); ?></div>
						<div class="wpsg-reviews-admin__meta"><?php echo esc_html($review['product']); ?> · <?php echo esc_html($review['display_name']); ?><?php if (intval($review['anonymous']??0) === 1) { ?> (<?php echo esc_html__('angezeigt als „Anonym“', 'wpsg'); ?>)<?php } ?></div>
						<?php if ($bReply) { ?><div class="wpsg-reviews-admin__reply-text"><strong><?php echo esc_html__('Ihre Antwort:', 'wpsg'); ?></strong> <?php echo nl2br(esc_html((string)$review['reply'])); ?></div><?php } ?>
						<div class="row-actions">
							<?php if (isset($arActions['approve'])) { ?><span class="wpsg-approve"><button type="submit" name="wpsg_review_action" value="approve:<?php echo $review_id; ?>" class="button-link"><?php echo esc_html($arActions['approve']); ?></button> | </span><?php } ?>
							<?php if (isset($arActions['reject'])) { ?><span class="wpsg-reject"><button type="submit" name="wpsg_review_action" value="reject:<?php echo $review_id; ?>" class="button-link"><?php echo esc_html($arActions['reject']); ?></button> | </span><?php } ?>
							<span class="wpsg-reply"><button type="button" class="button-link wpsg-reviews-admin__reply-toggle" aria-expanded="false" aria-controls="wpsg-review-reply-<?php echo $review_id; ?>"><?php echo esc_html(($bReply)?__('Antwort bearbeiten', 'wpsg'):__('Antworten', 'wpsg')); ?></button> | </span>
							<span class="wpsg-delete"><button type="submit" name="wpsg_review_action" value="delete:<?php echo $review_id; ?>" class="button-link button-link-delete" data-confirm="<?php echo esc_attr__('Bewertung endgültig löschen?', 'wpsg'); ?>"><?php echo esc_html($arActions['delete']); ?></button></span>
						</div>
						<button type="button" class="toggle-row"><span class="screen-reader-text"><?php echo esc_html__('Mehr Details anzeigen', 'wpsg'); ?></span></button>
					</td>
					<td class="column-product" data-colname="<?php echo esc_attr__('Produkt', 'wpsg'); ?>"><?php echo esc_html($review['product']); ?><br />
						<small><?php echo ((intval($review['verified']) === 1)?esc_html__('Verifizierter Kauf', 'wpsg'):esc_html__('Ohne Kaufnachweis (übernommen)', 'wpsg')); ?></small>
						<?php if (!$review['allowed']) { ?><br /><small><?php echo esc_html__('Bewertungen für dieses Produkt aus', 'wpsg'); ?></small><?php } ?></td>
					<td class="column-author" data-colname="<?php echo esc_attr__('Name', 'wpsg'); ?>"><?php echo esc_html($review['display_name']); ?><?php if (intval($review['anonymous']??0) === 1) { ?><br /><?php echo esc_html__('angezeigt als „Anonym“', 'wpsg'); ?><?php } ?></td>
					<td class="column-date" data-colname="<?php echo esc_attr__('Abgegeben', 'wpsg'); ?>"><?php echo esc_html((string)wp_date(get_option('date_format').' '.get_option('time_format'), (int)strtotime((string)$review['submitted'].' UTC'))); ?></td>
				</tr>
				<?php /* Leere Zeile hält die Streifen im Wechsel, wie die Schnellbearbeitung im Kern */ ?>
				<tr class="hidden"></tr>
				<tr id="wpsg-review-reply-<?php echo $review_id; ?>" class="inline-edit-row wpsg-reviews-admin__reply-row" hidden>
					<td colspan="5">
						<label for="wpsg_review_reply_<?php echo $review_id; ?>"><?php echo esc_html__('Öffentliche Antwort', 'wpsg'); ?></label>
						<textarea id="wpsg_review_reply_<?php echo $review_id; ?>" name="reply[<?php echo $review_id; ?>]" rows="3" class="large-text"><?php echo esc_textarea((string)$review['reply']); ?></textarea>
						<p class="wpsg-reviews-admin__reply-buttons">
							<button type="submit" name="wpsg_review_action" value="reply:<?php echo $review_id; ?>" class="button button-primary"><?php echo esc_html__('Antwort speichern', 'wpsg'); ?></button>
							<button type="button" class="button wpsg-reviews-admin__reply-cancel"><?php echo esc_html__('Abbrechen', 'wpsg'); ?></button>
						</p>
					</td>
				</tr>
				<?php } ?>
			</tbody>
		</table>

		<div class="tablenav bottom">
			<?php $bulkactions('bottom'); ?>
			<?php $pagination(); ?>
			<br class="clear" />
		</div>

	</form>

	<?php } ?>

</div>