Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor/views/fragments/announcement-list.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Announcement fragment view
4 + *
5 + * @package Tutor\Views
6 + * @subpackage Tutor\Fragments
7 + * @author Themeum <support@themeum.com>
8 + * @link https://themeum.com
9 + * @since 2.0.0
10 + */
11 +
12 + use Tutor\Models\CourseModel;
13 +
14 + /**
15 + * Announcement modal
16 + *
17 + * @since 2.0.0
18 + *
19 + * @param string $id modal id.
20 + * @param string $title modal title.
21 + * @param array $courses courses.
22 + * @param object|null $announcement announcement.
23 + *
24 + * @return void
25 + */
26 + function tutor_announcement_modal( $id, $title, $courses, $announcement = null ) {
27 + $course_id = $announcement ? $announcement->post_parent : null;
28 + $announcment_id = $announcement ? $announcement->ID : null;
29 + $announcment_title = $announcement ? $announcement->post_title : '';
30 + $summary = $announcement ? $announcement->post_content : '';
31 + // Assign fallback course id.
32 + ( ! $course_id && count( $courses ) ) ? $course_id = $courses[0]->ID : 0;
33 + ?>
34 + <form class="tutor-modal tutor-modal-scrollable tutor-announcements-form" id="<?php echo esc_attr( $id ); ?>">
35 + <div class="tutor-modal-overlay"></div>
36 + <div class="tutor-modal-window">
37 + <div class="tutor-modal-content">
38 + <div class="tutor-modal-header">
39 + <div class="tutor-modal-title">
40 + <?php echo esc_html( $title ); ?>
41 + </div>
42 + <button class="tutor-modal-close tutor-iconic-btn" data-tutor-modal-close role="button">
43 + <span class="tutor-icon-times" area-hidden="true"></span>
44 + </button>
45 + </div>
46 +
47 + <div class="tutor-modal-body">
48 + <?php tutor_nonce_field(); ?>
49 + <input type="hidden" name="announcement_id" value="<?php echo esc_attr( $announcment_id ); ?>">
50 + <input type="hidden" name="action" value="tutor_announcement_create"/>
51 + <input type="hidden" name="action_type" value="<?php echo esc_attr( $announcement ? 'update' : 'create' ); ?>"/>
52 + <div class="tutor-mb-32">
53 + <label class="tutor-form-label">
54 + <?php esc_html_e( 'Select Course', 'tutor' ); ?>
55 + </label>
56 + <select class="tutor-form-select" name="tutor_announcement_course" required data-searchable>
57 + <?php if ( $courses ) : ?>
58 + <?php foreach ( $courses as $course ) : ?>
59 + <option value="<?php echo esc_attr( $course->ID ); ?>" <?php selected( $course_id, $course->ID ); ?>>
60 + <?php echo esc_html( $course->post_title ); ?>
61 + </option>
62 + <?php endforeach; ?>
63 + <?php else : ?>
64 + <option value=""><?php esc_html_e( 'No course found', 'tutor' ); ?></option>
65 + <?php endif; ?>
66 + </select>
67 + </div>
68 +
69 + <div class="tutor-mb-32">
70 + <label class="tutor-form-label">
71 + <?php esc_html_e( 'Announcement Title', 'tutor' ); ?>
72 + </label>
73 + <input class="tutor-form-control" type="text" name="tutor_announcement_title" value="<?php echo esc_attr( $announcment_title ); ?>" placeholder="<?php esc_html_e( 'Announcement title', 'tutor' ); ?>" maxlength="255" required>
74 + </div>
75 +
76 + <div class="tutor-mb-32">
77 + <label class="tutor-form-label" for="tutor_announcement_course">
78 + <?php esc_html_e( 'Summary', 'tutor' ); ?>
79 + </label>
80 + <textarea style="resize: unset;" class="tutor-form-control" rows="6" type="text" name="tutor_announcement_summary" placeholder="<?php esc_html_e( 'Summary...', 'tutor' ); ?>" required><?php echo esc_textarea( $summary ); ?></textarea>
81 + </div>
82 +
83 + <?php do_action( 'tutor_announcement_editor/after' ); ?>
84 + </div>
85 +
86 + <div class="tutor-modal-footer">
87 + <button data-tutor-modal-close type="button" data-action="back" class="tutor-btn tutor-btn-outline-primary">
88 + <?php esc_html_e( 'Cancel', 'tutor' ); ?>
89 + </button>
90 + <button type="submit" data-action="next" class="tutor-btn tutor-btn-primary">
91 + <?php esc_html_e( 'Publish', 'tutor' ); ?>
92 + </button>
93 + </div>
94 + </div>
95 + </div>
96 + </form>
97 + <?php
98 + }
99 +
100 + /**
101 + * Announcement modal
102 + *
103 + * @since 2.0.0
104 + *
105 + * @param string $id modal id.
106 + * @param string $update_modal_id update modal id.
107 + * @param string $delete_modal_id delete_modal_id.
108 + * @param object $announcement announcement.
109 + * @param string $course_title course title.
110 + * @param string $publish_date announcement publish date.
111 + * @param string $publish_time announcement publish time.
112 + *
113 + * @return void
114 + */
115 + function tutor_announcement_modal_details( $id, $update_modal_id, $delete_modal_id, $announcement, $course_title, $publish_date, $publish_time ) {
116 + ?>
117 + <div id="<?php echo esc_attr( $id ); ?>" class="tutor-modal">
118 + <div class="tutor-modal-overlay"></div>
119 + <div class="tutor-modal-window">
120 + <div class="tutor-modal-content tutor-modal-content-white">
121 + <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close>
122 + <span class="tutor-icon-times" area-hidden="true"></span>
123 + </button>
124 +
125 + <div class="tutor-modal-body">
126 + <div class="tutor-py-20 tutor-px-24">
127 + <span class="tutor-round-box tutor-round-box-lg tutor-mb-32">
128 + <i class="tutor-icon-bullhorn" area-hidden="true"></i>
129 + </span>
130 + <div class="tutor-fs-4 tutor-fw-medium tutor-color-black tutor-mb-24">
131 + <?php echo esc_html( $announcement->post_title ); ?>
132 + </div>
133 + <div class="tutor-fs-6 tutor-color-muted">
134 + <?php echo wp_kses_post( $announcement->post_content ); ?>
135 + </div>
136 + </div>
137 +
138 + <div class="tutor-mx-n32 tutor-my-32"><div class="tutor-hr" area-hidden="true"></div></div>
139 +
140 + <div class="tutor-py-20 tutor-px-24">
141 + <div class="tutor-row tutor-mb-60">
142 + <div class="tutor-col-lg-7 tutor-mb-16 tutor-mb-lg-0">
143 + <div class="tutor-fs-7 tutor-color-secondary">
144 + <?php esc_html_e( 'Course', 'tutor' ); ?>
145 + </div>
146 + <div class="tutor-fs-6 tutor-fw-bold tutor-color-black tutor-mt-4">
147 + <?php echo esc_html( $course_title ); ?>
148 + </div>
149 + </div>
150 +
151 + <div class="tutor-col-lg-5">
152 + <div class="tutor-fs-7 tutor-color-secondary">
153 + <?php esc_html_e( 'Published Date', 'tutor' ); ?>
154 + </div>
155 + <div class="tutor-fs-6 tutor-fw-bold tutor-color-black tutor-mt-4">
156 + <?php echo esc_html( $publish_date . ', ' . $publish_time ); ?>
157 + </div>
158 + </div>
159 + </div>
160 +
161 + <div class="tutor-row">
162 + <div class="tutor-col-6 tutor-col-lg-7">
163 + <button class="tutor-btn tutor-btn-outline-primary tutor-btn-md" data-tutor-modal-close>
164 + <?php esc_html_e( 'Cancel', 'tutor' ); ?>
165 + </button>
166 + </div>
167 +
168 + <div class="tutor-col-6 tutor-col-lg-5">
169 + <div class="tutor-d-flex tutor-justify-end">
170 + <button data-tutor-modal-target="<?php echo esc_attr( $delete_modal_id ); ?>" class="tutor-btn tutor-btn-secondary tutor-btn-md tutor-modal-btn-delete">
171 + <?php esc_html_e( 'Delete', 'tutor' ); ?>
172 + </button>
173 + <button data-tutor-modal-target="<?php echo esc_attr( $update_modal_id ); ?>" class="tutor-btn tutor-btn-primary tutor-btn-md tutor-modal-btn-edit tutor-ml-16">
174 + <?php esc_html_e( 'Edit', 'tutor' ); ?>
175 + </button>
176 + </div>
177 + </div>
178 + </div>
179 + </div>
180 + </div>
181 + </div>
182 + </div>
183 + </div>
184 + <?php
185 + }
186 +
187 + /**
188 + * Announcement delete modal
189 + *
190 + * @since 2.0.0
191 + *
192 + * @param int $id id.
193 + * @param int $announcment_id announcement id.
194 + * @param int $row_id row id.
195 + *
196 + * @return void
197 + */
198 + function tutor_announcement_modal_delete( $id, $announcment_id, $row_id ) {
199 + ?>
200 + <div id="<?php echo esc_attr( $id ); ?>" class="tutor-modal">
201 + <div class="tutor-modal-overlay"></div>
202 + <div class="tutor-modal-window">
203 + <div class="tutor-modal-content tutor-modal-content-white">
204 + <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close>
205 + <span class="tutor-icon-times" area-hidden="true"></span>
206 + </button>
207 +
208 + <div class="tutor-modal-body tutor-text-center">
209 + <div class="tutor-mt-48">
210 + <img class="tutor-d-inline-block" src="<?php echo esc_url( tutor()->url ); ?>assets/images/icon-trash.svg" />
211 + </div>
212 +
213 + <div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mb-12"><?php esc_html_e( 'Delete This Announcement?', 'tutor' ); ?></div>
214 + <div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Are you sure you want to delete this Announcement permanently from the site? Please confirm your choice.', 'tutor' ); ?></div>
215 + <div class="tutor-d-flex tutor-justify-center tutor-my-48">
216 + <button class="tutor-btn tutor-btn-outline-primary" data-tutor-modal-close>
217 + <?php esc_html_e( 'Cancel', 'tutor' ); ?>
218 + </button>
219 + <button class="tutor-btn tutor-btn-primary tutor-list-ajax-action tutor-ml-20" data-request_data='{"announcement_id":<?php echo esc_attr( $announcment_id ); ?>, "action":"tutor_announcement_delete"}' data-redirect_to="">
220 + <?php esc_html_e( 'Yes, Delete This', 'tutor' ); ?>
221 + </button>
222 + </div>
223 + </div>
224 + </div>
225 + </div>
226 + </div>
227 + <?php
228 + }
229 +
230 + extract( $data );
231 + $courses = ( current_user_can( 'administrator' ) ) ? CourseModel::get_courses() : CourseModel::get_courses_by_instructor();
232 + ?>
233 + <?php if ( is_array( $announcements ) && count( $announcements ) ) : ?>
234 + <div class="tutor-table-responsive tutor-dashboard-list-table">
235 + <table class="tutor-table">
236 + <thead>
237 + <tr>
238 + <?php if ( is_admin() ) : ?>
239 + <th width="2%">
240 + <div class="tutor-d-flex">
241 + <input type="checkbox" id="tutor-bulk-checkbox-all" class="tutor-form-check-input">
242 + </div>
243 + </th>
244 + <th width="17%">
245 + <?php esc_html_e( 'Date', 'tutor' ); ?>
246 + </th>
247 + <?php else : ?>
248 + <th width="17%">
249 + <?php esc_html_e( 'Date', 'tutor' ); ?>
250 + </th>
251 + <?php endif; ?>
252 + <th>
253 + <?php esc_html_e( 'Announcements', 'tutor' ); ?>
254 + </th>
255 + <th></th>
256 + </tr>
257 + </thead>
258 + <tbody>
259 + <?php foreach ( $announcements as $announcement ) : ?>
260 + <?php
261 + $course = get_post( $announcement->post_parent );
262 + $date_format = tutor_get_formated_date( get_option( 'date_format' ), $announcement->post_date );
263 + $time_format = tutor_get_formated_date( get_option( 'time_format' ), $announcement->post_date );
264 +
265 + $update_modal_id = 'tutor_announcement_' . $announcement->ID;
266 + $details_modal_id = $update_modal_id . '_details';
267 + $delete_modal_id = $update_modal_id . '_delete';
268 + $row_id = 'tutor-announcement-tr-' . $announcement->ID;
269 + ?>
270 + <tr id="<?php echo esc_attr( $row_id ); ?>">
271 + <?php if ( is_admin() ) : ?>
272 + <td class="v-align-top">
273 + <div class="tutor-form-check">
274 + <input
275 + id="tutor-admin-list-<?php echo esc_attr( $announcement->ID ); ?>"
276 + type="checkbox"
277 + class="tutor-form-check-input tutor-bulk-checkbox"
278 + name="tutor-bulk-checkbox-all"
279 + value="<?php echo esc_attr( $announcement->ID ); ?>"
280 + />
281 + </div>
282 + </td>
283 + <td width="17%" class="v-align-top">
284 + <div><?php echo esc_html( $date_format ); ?></div>
285 + <div class="tutor-fw-normal tutor-color-muted"><?php echo esc_html( $time_format ); ?></div>
286 + </td>
287 + <?php else : ?>
288 + <td width="17%" class="tutor-nowrap-ellipsis">
289 + <div><?php echo esc_html( $date_format ); ?></div>
290 + <div class="tutor-fw-normal tutor-color-muted"><?php echo esc_html( $time_format ); ?></div>
291 + </td>
292 + <?php endif; ?>
293 +
294 + <td>
295 + <div>
296 + <div class="td-course tutor-color-black tutor-fs-6 tutor-fw-medium">
297 + <?php echo esc_html( $announcement->post_title ); ?>
298 + </div>
299 + <div class="tutor-fs-7 tutor-fw-medium tutor-color-muted" style="margin-top: 3px;">
300 + <?php esc_html_e( 'Course', 'tutor' ); ?>: <?php echo esc_html( $course ? $course->post_title : '' ); ?>
301 + </div>
302 + </div>
303 + </td>
304 +
305 + <td>
306 + <div class="tutor-d-flex tutor-align-center tutor-justify-end">
307 + <div class="tutor-d-inline-flex tutor-align-center td-action-btns tutor-mr-4">
308 + <button class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-announcement-details" data-tutor-modal-target="<?php echo esc_attr( $details_modal_id ); ?>">
309 + <?php esc_html_e( 'Details', 'tutor' ); ?>
310 + </button>
311 + </div>
312 +
313 + <div class="tutor-dropdown-parent">
314 + <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
315 + <span class="tutor-icon-kebab-menu" area-hidden="true"></span>
316 + </button>
317 + <ul class="tutor-dropdown tutor-dropdown-dark">
318 + <li>
319 + <a href="#" class="tutor-dropdown-item" data-tutor-modal-target="<?php echo esc_attr( $update_modal_id ); ?>">
320 + <i class="tutor-icon-edit tutor-mr-8" area-hidden="true"></i>
321 + <span><?php esc_html_e( 'Edit', 'tutor' ); ?></span>
322 + </a>
323 + </li>
324 + <li>
325 + <a href="#" class="tutor-dropdown-item" data-tutor-modal-target="<?php echo esc_attr( $delete_modal_id ); ?>">
326 + <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
327 + <span><?php esc_html_e( 'Delete', 'tutor' ); ?></span>
328 + </a>
329 + </li>
330 + </ul>
331 + </div>
332 + </div>
333 +
334 + <?php
335 + $course_title = isset( $course->post_title ) ? $course->post_title : '';
336 + tutor_announcement_modal( $update_modal_id, __( 'Edit Announcement', 'tutor' ), $courses, $announcement );
337 + tutor_announcement_modal_details( $details_modal_id, $update_modal_id, $delete_modal_id, $announcement, $course_title, $date_format, $time_format );
338 + tutor_announcement_modal_delete( $delete_modal_id, $announcement->ID, $row_id );
339 + ?>
340 + </td>
341 + </tr>
342 + <?php endforeach; ?>
343 + </tbody>
344 + </table>
345 +
346 + <div class="tutor-pagination-wrapper <?php echo esc_attr( is_admin() ? 'tutor-mt-20' : 'tutor-mt-40' ); ?>">
347 + <?php
348 + $limit = tutor_utils()->get_option( 'pagination_per_page' );
349 + if ( $the_query->found_posts > $limit ) {
350 + $pagination_data = array(
351 + 'total_items' => $the_query->found_posts,
352 + 'per_page' => $limit,
353 + 'paged' => $paged,
354 + );
355 +
356 + $pagination_template = tutor()->path . 'views/elements/pagination.php';
357 + if ( is_admin() ) {
358 + tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
359 + } else {
360 + $pagination_template_frontend = tutor()->path . 'templates/dashboard/elements/pagination.php';
361 + tutor_load_template_from_custom_path( $pagination_template_frontend, $pagination_data );
362 + }
363 + }
364 + ?>
365 + </div>
366 + </div>
367 +
368 + <?php else : ?>
369 + <?php tutils()->render_list_empty_state(); ?>
370 + <?php endif; ?>
371 +
372 + <?php
373 + tutor_announcement_modal( 'tutor_announcement_new', __( 'Create Announcement', 'tutor' ), $courses );
374 + ?>
375 +