diff --git a/main/auth/courses.php b/main/auth/courses.php index ff69515acc..5707bc1d7c 100755 --- a/main/auth/courses.php +++ b/main/auth/courses.php @@ -249,14 +249,7 @@ switch ($action) { $courses = CoursesAndSessionsCatalog::searchCourses($categoryCode, $searchTerm, $limit, false, $conditions); $countCoursesInCategory = CourseCategory::countCoursesInCategory($categoryCode, $searchTerm, true, $conditions); - } /*else { - if (empty($categoryCode)) { - $categoryCode = $listCategories['ALL']['code']; // by default first category - } - $courses = CoursesAndSessionsCatalog::getCoursesInCategory($categoryCode, null, $limit); - $countCoursesInCategory = CourseCategory::countCoursesInCategory($categoryCode, $searchTerm); - }*/ - + } $showCourses = CoursesAndSessionsCatalog::showCourses(); $showSessions = CoursesAndSessionsCatalog::showSessions(); $pageCurrent = isset($_GET['pageCurrent']) ? (int) $_GET['pageCurrent'] : 1; @@ -393,6 +386,18 @@ switch ($action) { $courseUrl = api_get_path(WEB_COURSE_PATH); $hideRating = api_get_configuration_value('hide_course_rating'); + + $courseCatalogSettings = [ + 'info_url' => 'course_description_popup', + 'title_url' => 'course_home', + 'image_url' => 'course_about', + ]; + + $settings = api_get_configuration_value('course_catalog_settings'); + if (!empty($settings) && isset($settings['link_settings'])) { + $courseCatalogSettings = $settings['link_settings']; + } + if (!empty($courses)) { foreach ($courses as &$course) { $courseId = $course['real_id']; @@ -404,6 +409,18 @@ switch ($action) { $courseTags = $fieldTagsRepo->getTags($tagField, $courseId); } + $aboutPage = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about'; + + $settingsUrl = [ + 'course_description_popup' => api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'], + 'course_about' => $aboutPage, + 'course_home' => $courseUrl.$course['directory'].'/index.php?id_session=0', + ]; + + $infoUrl = $settingsUrl[$courseCatalogSettings['info_url']]; + $course['title_url'] = $settingsUrl[$courseCatalogSettings['title_url']]; + $course['image_url'] = $settingsUrl[$courseCatalogSettings['image_url']]; + $userRegisteredInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']); $userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']); $userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher; @@ -426,7 +443,7 @@ switch ($action) { // Display thumbnail $course['thumbnail'] = CoursesAndSessionsCatalog::returnThumbnail($course); - $course['description_button'] = CourseManager::returnDescriptionButton($course); + $course['description_button'] = CourseManager::returnDescriptionButton($course, $infoUrl); $subscribeButton = CoursesAndSessionsCatalog::return_register_button( $course, $stok, @@ -456,7 +473,7 @@ switch ($action) { } // end buy course validation - $course['title_formatted'] = CoursesAndSessionsCatalog::return_title($course, $userRegisteredInCourse); + $course['rating'] = ''; if ($hideRating === false) { $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; diff --git a/main/inc/lib/CoursesAndSessionsCatalog.class.php b/main/inc/lib/CoursesAndSessionsCatalog.class.php index 2aa638afae..db47f167e5 100644 --- a/main/inc/lib/CoursesAndSessionsCatalog.class.php +++ b/main/inc/lib/CoursesAndSessionsCatalog.class.php @@ -954,23 +954,6 @@ class CoursesAndSessionsCatalog return $html; } - /** - * Display the title of a course in course catalog. - * - * @param array $course - * - * @return string HTML string - */ - public static function return_title($course) - { - $linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about'; - $html = '

'; - $html .= ''.$course['title'].''; - $html .= '

'; - - return $html; - } - /** * Display the already registerd text in a course in the course catalog. * diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 13f04a4db7..1068a3f793 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -6544,31 +6544,35 @@ class CourseManager * Display the description button of a course in the course catalog. * * @param array $course + * @param string $url * * @return string HTML string */ - public static function returnDescriptionButton($course) + public static function returnDescriptionButton($course, $url = '') { if (empty($course)) { return ''; } - if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { + $class = ''; + if (api_get_setting('show_courses_descriptions_in_catalog') === 'true') { $title = $course['title']; - $url = api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code']; - $html = Display::url( + if (empty($url)) { + $class = 'ajax'; + $url = api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code']; + } + + return Display::url( Display::returnFontAwesomeIcon('info-circle', 'lg'), $url, [ - 'class' => 'ajax btn btn-default btn-sm', + 'class' => "$class btn btn-default btn-sm", 'data-title' => $title, 'title' => get_lang('Description'), 'aria-label' => get_lang('Description'), 'data-size' => 'lg', ] ); - - return $html; } return ''; diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 061e080f9b..bacd2b6f16 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1428,6 +1428,15 @@ ALTER TABLE notification_event ADD COLUMN event_id INT NULL; // Course catalog show extra fields (visible and filtered) //$_configuration['allow_course_extra_field_in_catalog'] = false; +// Course catalog links behaviour. +/*$_configuration['course_catalog_settings'] = [ + 'link_settings' => [ + 'info_url' => 'course_description_popup', // course description popup page + 'title_url' => 'course_home', // Course home URL + 'image_url' => 'course_about', // Course about URL + ], +];*/ + // KEEP THIS AT THE END // -------- Custom DB changes // Add user activation by confirmation email diff --git a/main/template/default/catalog/course_item_catalog.tpl b/main/template/default/catalog/course_item_catalog.tpl index 927d964bdb..ca213ae0ec 100644 --- a/main/template/default/catalog/course_item_catalog.tpl +++ b/main/template/default/catalog/course_item_catalog.tpl @@ -2,7 +2,11 @@ {% block course_image %}
{% block course_thumbnail %} - + {% set class= '' %} + {% if 'ajax' in course.image_url %} + {% set class= 'ajax' %} + {% endif %} + {{ course.title }} {% endblock %} @@ -27,7 +31,18 @@ {% block course_description %}
{% block course_title %} - {{ course.title_formatted }} +
+

+ {% set class= '' %} + {% if 'ajax' in course.title_url %} + {% set class= 'ajax' %} + {% endif %} + + + {{ course.title }} + +

+
{% endblock %} {% block course_rating %}