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