contexts.php
4 years ago
qna-new.php
4 years ago
qna-single.php
4 years ago
qna-table.php
4 years ago
qna-table.php
253 lines
| 1 | <?php |
| 2 | extract($data); // $qna_list, $context, $qna_pagination, $view_as |
| 3 | |
| 4 | $page_key = 'qna-table'; |
| 5 | $table_columns = include __DIR__ . '/contexts.php'; |
| 6 | $view_as = isset($view_as) ? $view_as : (is_admin() ? 'instructor' : 'student'); |
| 7 | ?> |
| 8 | |
| 9 | <table data-qna_context="<?php echo $context; ?>" class="frontend-dashboard-qna-table-<?php echo $view_as; ?> tutor-table tutor-table-responsive qna-list-table"> |
| 10 | <?php if (is_array($qna_list) && count($qna_list)) { ?> |
| 11 | <thead> |
| 12 | <tr> |
| 13 | <?php |
| 14 | foreach ($table_columns as $key => $column) { |
| 15 | echo '<th> |
| 16 | <span class="tutor-fs-7 tutor-color-secondary" style="' . ($key == 'action' ? 'visibility:hidden' : '') . '">' . |
| 17 | $column |
| 18 | . '</span> |
| 19 | </th>'; |
| 20 | } |
| 21 | ?> |
| 22 | </tr> |
| 23 | </thead> |
| 24 | <?php } ?> |
| 25 | <tbody> |
| 26 | <?php |
| 27 | $current_user_id = get_current_user_id(); |
| 28 | |
| 29 | if (is_array($qna_list) && count($qna_list)) { |
| 30 | foreach ($qna_list as $qna) { |
| 31 | $id_string_delete = 'tutor_delete_qna_' . $qna->comment_ID; |
| 32 | $row_id = 'tutor_qna_row_' . $qna->comment_ID; |
| 33 | $menu_id = 'tutor_qna_menu_id_' . $qna->comment_ID; |
| 34 | $is_self = $current_user_id == $qna->user_id; |
| 35 | $key_slug = $context == 'frontend-dashboard-qna-table-student' ? '_' . $current_user_id : ''; |
| 36 | |
| 37 | $meta = $qna->meta; |
| 38 | $is_solved = (int)tutor_utils()->array_get('tutor_qna_solved' . $key_slug, $meta, 0); |
| 39 | $is_important = (int)tutor_utils()->array_get('tutor_qna_important' . $key_slug, $meta, 0); |
| 40 | $is_archived = (int)tutor_utils()->array_get('tutor_qna_archived' . $key_slug, $meta, 0); |
| 41 | $is_read = (int)tutor_utils()->array_get('tutor_qna_read' . $key_slug, $meta, 0); |
| 42 | |
| 43 | ?> |
| 44 | <tr id="<?php echo $row_id; ?>" data-question_id="<?php echo $qna->comment_ID; ?>" class="<?php echo $is_read ? 'is-qna-read' : ''; ?>"> |
| 45 | <?php |
| 46 | foreach ($table_columns as $key => $column) { |
| 47 | switch ($key) { |
| 48 | case 'checkbox': |
| 49 | ?> |
| 50 | <td data-th="<?php _e('Mark', 'tutor'); ?>" class="tutor-shrink"> |
| 51 | <div class="td-checkbox tutor-d-flex tutor-align-center"> |
| 52 | <input id="tutor-admin-list-<?php echo $qna->comment_ID; ?>" type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo $qna->comment_ID; ?>" style="margin-top:0" /> |
| 53 | </div> |
| 54 | </td> |
| 55 | <?php |
| 56 | break; |
| 57 | |
| 58 | case 'student': |
| 59 | ?> |
| 60 | <td data-th="<?php echo $column; ?>" > |
| 61 | <div class="td-avatar"> |
| 62 | <div class="tooltip-wrap tooltip-icon-custom tutor-qna-badges-wrapper tutor-mt-4"> |
| 63 | <span |
| 64 | data-state-class-0="tutor-icon-important-line" |
| 65 | data-state-class-1="tutor-icon-important-bold" |
| 66 | data-action="important" |
| 67 | data-state-class-selector="i" |
| 68 | > |
| 69 | <i |
| 70 | class="<?php echo $is_important ? 'tutor-icon-important-bold' : 'tutor-icon-important-line'; ?> tutor-cursor-pointer" |
| 71 | > |
| 72 | </i> |
| 73 | </span> |
| 74 | <span class="tooltip-txt tooltip-bottom"> |
| 75 | <?php $is_important ? _e('This conversation is important', 'tutor') : _e('Mark this conversation as important', 'tutor'); ?> |
| 76 | </span> |
| 77 | </div> |
| 78 | <?php echo tutor_utils()->get_tutor_avatar( $qna->user_id ); ?> |
| 79 | <div> |
| 80 | <div class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 81 | <?php echo $qna->display_name; ?> |
| 82 | </div> |
| 83 | <div class="tutor-fs-7 tutor-fw-medium tutor-color-muted" style="margin-top : -2px"> |
| 84 | <?php echo human_time_diff(strtotime($qna->comment_date)); ?> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | </td> |
| 89 | <?php |
| 90 | break; |
| 91 | |
| 92 | case 'question': |
| 93 | $content = (stripslashes($qna->comment_content)); |
| 94 | ?> |
| 95 | <td data-th="<?php echo $column; ?>"> |
| 96 | <a href="<?php echo add_query_arg(array('question_id' => $qna->comment_ID), tutor()->current_url); ?>"> |
| 97 | <div class="tutor-form-feedback tutor-qna-question-col <?php echo $is_read ? 'is-read' : ''; ?>"> |
| 98 | <i class="tutor-icon-bullet-point tutor-form-feedback-icon"></i> |
| 99 | <div class="tutor-qna-desc"> |
| 100 | <div class="tutor-qna-content tutor-fs-6 tutor-fw-bold tutor-color-black"> |
| 101 | <?php |
| 102 | $limit = 60; |
| 103 | $content = strlen($content) > $limit ? substr($content, 0, $limit) . '...' : $content; |
| 104 | echo esc_html($content); |
| 105 | ?> |
| 106 | </div> |
| 107 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 108 | <span class="tutor-fw-medium"><?php _e('Course'); ?>:</span> |
| 109 | <span><?php echo $qna->post_title; ?></span> |
| 110 | </div> |
| 111 | </div> |
| 112 | </div> |
| 113 | </a> |
| 114 | </td> |
| 115 | <?php |
| 116 | break; |
| 117 | |
| 118 | case 'reply': |
| 119 | ?> |
| 120 | <td data-th="<?php echo $column; ?>" class="v-align-top"> |
| 121 | <div class="tutor-fs-7 tutor-fw-medium tutor-color-black"> |
| 122 | <?php echo $qna->answer_count; ?> |
| 123 | </div> |
| 124 | </td> |
| 125 | <?php |
| 126 | break; |
| 127 | |
| 128 | case 'waiting_since': |
| 129 | ?> |
| 130 | <td data-th="<?php echo $column; ?>" class="v-align-top"> |
| 131 | <?php echo human_time_diff(strtotime($qna->comment_date)); ?> |
| 132 | </td> |
| 133 | <?php |
| 134 | break; |
| 135 | |
| 136 | case 'status': |
| 137 | ?> |
| 138 | <td data-th="<?php echo $column; ?>" class="v-align-top"> |
| 139 | <div class="tooltip-wrap tooltip-icon-custom" > |
| 140 | <i class="tutor-fs-4 <?php echo $is_solved ? 'tutor-icon-circle-mark tutor-color-success' : 'tutor-icon-circle-mark-line tutor-color-muted'; ?>"></i> |
| 141 | <span class="tooltip-txt tooltip-bottom"> |
| 142 | <?php $is_solved ? _e('Solved', 'tutor') : _e('Unresolved Yet', 'tutor'); ?> |
| 143 | </span> |
| 144 | </div> |
| 145 | </td> |
| 146 | <?php |
| 147 | break; |
| 148 | |
| 149 | case 'action': |
| 150 | ?> |
| 151 | <td data-th="<?php echo $column; ?>" class="tutor-text-right v-align-top"> |
| 152 | <div class="tutor-d-inline-flex tutor-align-center td-action-btns"> |
| 153 | <a href="<?php echo add_query_arg(array('question_id' => $qna->comment_ID), tutor()->current_url); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm"> |
| 154 | <?php _e('Reply', 'tutor-pro'); ?> |
| 155 | </a> |
| 156 | |
| 157 | <div class="tutor-dropdown-parent"> |
| 158 | <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle"> |
| 159 | <span class="tutor-icon-kebab-menu" area-hidden="true"></span> |
| 160 | </button> |
| 161 | <ul class="tutor-dropdown tutor-dropdown-dark tutor-text-left"> |
| 162 | <?php if ($context != 'frontend-dashboard-qna-table-student') : ?> |
| 163 | <li class="tutor-qna-badges tutor-qna-badges-wrapper"> |
| 164 | <a class="tutor-dropdown-item" href="#" data-action="archived" data-state-text-selector="[data-state-text]" data-state-class-selector="[data-state-class]" data-state-text-0="<?php _e('Archvie', 'tutor'); ?>" data-state-text-1="<?php _e('Un-archive', 'tutor'); ?>"> |
| 165 | <span class="tutor-icon-archive tutor-mr-8" data-state-class></span> |
| 166 | <span data-state-text> |
| 167 | <?php $is_archived ? _e('Un-archive', 'tutor') : _e('Archive', 'tutor'); ?> |
| 168 | </span> |
| 169 | </a> |
| 170 | </li> |
| 171 | <?php endif; ?> |
| 172 | <li class="tutor-qna-badges tutor-qna-badges-wrapper"> |
| 173 | <a class="tutor-dropdown-item" href="#" data-action="read" data-state-text-selector="[data-state-text]" data-state-class-selector="[data-state-class]" data-state-text-0="<?php _e('Mark as Read', 'tutor'); ?>" data-state-text-1="<?php _e('Mark as Unread', 'tutor'); ?>"> |
| 174 | <span class="tutor-icon-envelope tutor-mr-8" data-state-class></span> |
| 175 | <span data-state-text> |
| 176 | <?php $is_read ? _e('Mark as Unread', 'tutor') : _e('Mark as read', 'tutor'); ?> |
| 177 | </span> |
| 178 | </a> |
| 179 | </li> |
| 180 | <li> |
| 181 | <a class="tutor-dropdown-item" href="#" data-tutor-modal-target="<?php echo $id_string_delete; ?>"> |
| 182 | <span class="tutor-icon-trash-can-bold tutor-mr-8"></span> |
| 183 | <span><?php _e('Delete', 'tutor'); ?></span> |
| 184 | </a> |
| 185 | </li> |
| 186 | </ul> |
| 187 | </div> |
| 188 | |
| 189 | <!-- Delete confirmation modal --> |
| 190 | <div id="<?php echo $id_string_delete; ?>" class="tutor-modal"> |
| 191 | <div class="tutor-modal-overlay"></div> |
| 192 | <div class="tutor-modal-window"> |
| 193 | <div class="tutor-modal-content tutor-modal-content-white"> |
| 194 | <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close> |
| 195 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 196 | </button> |
| 197 | |
| 198 | <div class="tutor-modal-body tutor-text-center"> |
| 199 | <div class="tutor-mt-48"> |
| 200 | <img class="tutor-d-inline-block" src="<?php echo tutor()->url; ?>assets/images/icon-trash.svg" /> |
| 201 | </div> |
| 202 | |
| 203 | <div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mb-12"><?php esc_html_e('Delete This Question?', 'tutor'); ?></div> |
| 204 | <div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e('All the replies also will be deleted.', 'tutor'); ?></div> |
| 205 | |
| 206 | <div class="tutor-d-flex tutor-justify-center tutor-my-48"> |
| 207 | <button data-tutor-modal-close class="tutor-btn tutor-btn-outline-primary"> |
| 208 | <?php esc_html_e('Cancel', 'tutor'); ?> |
| 209 | </button> |
| 210 | <button class="tutor-btn tutor-btn-primary tutor-list-ajax-action tutor-ml-20" data-request_data='{"question_id":<?php echo $qna->comment_ID; ?>,"action":"tutor_delete_dashboard_question"}' data-delete_element_id="<?php echo $row_id; ?>"> |
| 211 | <?php esc_html_e('Yes, Delete This', 'tutor'); ?> |
| 212 | </button> |
| 213 | </div> |
| 214 | </div> |
| 215 | </div> |
| 216 | </div> |
| 217 | </div> |
| 218 | </div> |
| 219 | </td> |
| 220 | <?php |
| 221 | break; |
| 222 | } |
| 223 | } |
| 224 | ?> |
| 225 | </tr> |
| 226 | <?php |
| 227 | } |
| 228 | } else { |
| 229 | ?> |
| 230 | <tr> |
| 231 | <td colspan="100%" class="column-empty-state"> |
| 232 | <?php tutor_utils()->tutor_empty_state(tutor_utils()->not_found_text()); ?> |
| 233 | </td> |
| 234 | </tr> |
| 235 | <?php |
| 236 | } |
| 237 | ?> |
| 238 | </tbody> |
| 239 | </table> |
| 240 | <?php if ($qna_pagination['total_items'] > $qna_pagination['per_page']) : ?> |
| 241 | <div class="tutor-mt-48"> |
| 242 | <?php |
| 243 | $pagination_data = array( |
| 244 | 'base' => !empty($qna_pagination['base']) ? $qna_pagination['base'] : null, |
| 245 | 'total_items' => $qna_pagination['total_items'], |
| 246 | 'per_page' => $qna_pagination['per_page'], |
| 247 | 'paged' => $qna_pagination['paged'], |
| 248 | ); |
| 249 | $pagination_template = tutor()->path . 'views/elements/pagination.php'; |
| 250 | tutor_load_template_from_custom_path($pagination_template, $pagination_data); |
| 251 | ?> |
| 252 | </div> |
| 253 | <?php endif; ?> |