account
1 day ago
components
1 day ago
courses
1 day ago
discussions
1 day ago
elements
1 day ago
instructor
1 day ago
my-courses
1 year ago
my-quiz-attempts
1 day ago
quiz-attempts
1 day ago
student
1 day ago
wishlist
1 day ago
announcements.php
1 day ago
courses.php
1 day ago
create-course.php
1 day ago
dashboard.php
1 day ago
discussions.php
1 day ago
index.php
3 years ago
logged-in.php
3 years ago
my-courses.php
1 day ago
my-quiz-attempts.php
1 day ago
quiz-attempts.php
1 day ago
registration.php
1 day ago
wishlist.php
1 day ago
discussions.php
99 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Discussions Page |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 4.0.0 |
| 10 | */ |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | use Tutor\Components\Constants\Size; |
| 15 | use Tutor\Components\Nav; |
| 16 | use Tutor\Helpers\QueryHelper; |
| 17 | use Tutor\Helpers\UrlHelper; |
| 18 | use TUTOR\Icon; |
| 19 | use TUTOR\Input; |
| 20 | use TUTOR\Lesson; |
| 21 | use TUTOR\Q_And_A; |
| 22 | |
| 23 | if ( ! Q_And_A::is_enabled() && ! Lesson::is_comment_enabled() ) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | $current_tab = Input::get( 'tab' ); |
| 28 | $discussion_id = Input::get( 'id', 0, Input::TYPE_INT ); |
| 29 | $order_filter = QueryHelper::get_valid_sort_order( Input::get( 'order', 'DESC' ) ); |
| 30 | $current_page = max( 1, Input::get( 'current_page', 1, Input::TYPE_INT ) ); |
| 31 | $item_per_page = tutor_utils()->get_option( 'pagination_per_page', 10 ); |
| 32 | $offset = ( $current_page - 1 ) * $item_per_page; |
| 33 | |
| 34 | $discussion_url = tutor_utils()->tutor_dashboard_url( 'discussions' ); |
| 35 | $page_nav_items = array(); |
| 36 | |
| 37 | if ( Q_And_A::is_enabled() ) { |
| 38 | $page_nav_items[] = array( |
| 39 | 'type' => 'link', |
| 40 | 'label' => __( 'Q&A', 'tutor' ), |
| 41 | 'icon' => Icon::QA, |
| 42 | 'url' => esc_url( $discussion_url ), |
| 43 | 'active' => 'qna' === $current_tab || empty( $current_tab ), |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | if ( Lesson::is_comment_enabled() ) { |
| 48 | $page_nav_items[] = array( |
| 49 | 'type' => 'link', |
| 50 | 'label' => __( 'Lesson Comments', 'tutor' ), |
| 51 | 'icon' => Icon::COMMENTS, |
| 52 | 'url' => UrlHelper::add_query_params( $discussion_url, array( 'tab' => 'lesson-comments' ) ), |
| 53 | 'active' => 'lesson-comments' === $current_tab, |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | $number_of_tabs = tutor_utils()->count( $page_nav_items ); |
| 58 | if ( $number_of_tabs <= 0 ) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | if ( 1 === $number_of_tabs ) { |
| 63 | $page_nav_items[0]['active'] = true; |
| 64 | } |
| 65 | ?> |
| 66 | <div class="tutor-dashboard-discussions" x-data="tutorDiscussions()"> |
| 67 | <h4 class="tutor-h4 tutor-mb-5 tutor-hidden tutor-sm-block"> |
| 68 | <?php esc_html_e( 'Discussions', 'tutor' ); ?> |
| 69 | </h4> |
| 70 | |
| 71 | <?php |
| 72 | if ( $discussion_id ) { |
| 73 | $template = tutor()->path . 'templates/dashboard/discussions/qna-single.php'; |
| 74 | if ( 'lesson-comments' === $current_tab && Lesson::is_comment_enabled() ) { |
| 75 | $template = tutor()->path . 'templates/dashboard/discussions/comment-single.php'; |
| 76 | } |
| 77 | require_once $template; |
| 78 | } else { |
| 79 | ?> |
| 80 | <div class="tutor-dashboard-page-card"> |
| 81 | <div class="tutor-dashboard-page-card-header"> |
| 82 | <?php Nav::make()->items( $page_nav_items )->size( Size::SMALL )->render(); ?> |
| 83 | </div> |
| 84 | <div class="tutor-dashboard-page-card-body"> |
| 85 | <?php |
| 86 | $template = tutor()->path . 'templates/dashboard/discussions/qna-list.php'; |
| 87 | if ( 'lesson-comments' === $current_tab && Lesson::is_comment_enabled() ) { |
| 88 | $template = tutor()->path . 'templates/dashboard/discussions/comment-list.php'; |
| 89 | } |
| 90 | |
| 91 | require_once $template; |
| 92 | ?> |
| 93 | </div> |
| 94 | </div> |
| 95 | <?php |
| 96 | } |
| 97 | ?> |
| 98 | </div> |
| 99 |