diff --git a/main/auth/courses.php b/main/auth/courses.php index f7eb1dd83c..b86f174c9d 100755 --- a/main/auth/courses.php +++ b/main/auth/courses.php @@ -59,7 +59,6 @@ if (empty($nameTools)) { $auth = new Auth(); $userId = api_get_user_id(); $currentUrl = api_get_path(WEB_CODE_PATH).'auth/courses.php?category_code='.$categoryCode.'&search_term='.$searchTerm; -$content = ''; $toolTitle = get_lang('CourseCatalog'); $courseCatalogSettings = [ @@ -121,7 +120,6 @@ switch ($action) { header('Location: '.$currentUrl); exit; - break; case 'subscribe_course': $courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : ''; if (api_is_anonymous()) { @@ -182,6 +180,9 @@ switch ($action) { exit; } + $template = new Template($toolTitle, true, true, false, false, false); + $template->assign('content', $content); + $template->display_one_col_template(); break; case 'subscribe': if (!$userCanViewPage) { @@ -189,7 +190,6 @@ switch ($action) { } header('Location: '.api_get_self()); exit; - break; case 'display_random_courses': case 'display_courses': case 'search_course': @@ -577,7 +577,6 @@ switch ($action) { $template->display($template->get_template('catalog/course_catalog.tpl')); exit; - break; case 'display_sessions': if (!$userCanViewPage) { api_not_allowed(true); @@ -585,7 +584,6 @@ switch ($action) { CoursesAndSessionsCatalog::sessionList($limit); exit; - break; case 'subscribe_to_session': if (!$userCanViewPage) { api_not_allowed(true); @@ -666,7 +664,6 @@ switch ($action) { CoursesAndSessionsCatalog::sessionsListByCoursesTag($limit); exit; - break; case 'search_session_title': if (!$userCanViewPage) { api_not_allowed(true); @@ -674,9 +671,4 @@ switch ($action) { CoursesAndSessionsCatalog::sessionsListByName($limit); exit; - break; } - -$template = new Template($toolTitle, true, true, false, false, false); -$template->assign('content', $content); -$template->display_one_col_template(); diff --git a/main/inc/lib/CoursesAndSessionsCatalog.class.php b/main/inc/lib/CoursesAndSessionsCatalog.class.php index 4001fb638f..9f8e148ed1 100644 --- a/main/inc/lib/CoursesAndSessionsCatalog.class.php +++ b/main/inc/lib/CoursesAndSessionsCatalog.class.php @@ -18,57 +18,32 @@ class CoursesAndSessionsCatalog /** * Check the configuration for the courses and sessions catalog. - * - * @global array $_configuration Configuration - * - * @param int $value The value to check - * - * @return bool Whether the configuration is $value */ - public static function is($value = CATALOG_COURSES) + public static function is(int $value = CATALOG_COURSES): bool { $showCoursesSessions = (int) api_get_setting('catalog_show_courses_sessions'); - if ($showCoursesSessions == $value) { - return true; - } - return false; + return $showCoursesSessions == $value; } /** * Check whether to display the sessions list. - * - * @global array $_configuration Configuration - * - * @return bool whether to display */ - public static function showSessions() + public static function showSessions(): bool { $catalogShow = (int) api_get_setting('catalog_show_courses_sessions'); - if ($catalogShow == CATALOG_SESSIONS || $catalogShow == CATALOG_COURSES_SESSIONS) { - return true; - } - - return false; + return $catalogShow == CATALOG_SESSIONS || $catalogShow == CATALOG_COURSES_SESSIONS; } /** * Check whether to display the courses list. - * - * @global array $_configuration Configuration - * - * @return bool whether to display */ - public static function showCourses() + public static function showCourses(): bool { $catalogShow = (int) api_get_setting('catalog_show_courses_sessions'); - if ($catalogShow == CATALOG_COURSES || $catalogShow == CATALOG_COURSES_SESSIONS) { - return true; - } - - return false; + return $catalogShow == CATALOG_COURSES || $catalogShow == CATALOG_COURSES_SESSIONS; } /** @@ -1034,40 +1009,29 @@ class CoursesAndSessionsCatalog } /** - * Display the course catalog image of a course. - * - * @param array $course - * - * @return string HTML string + * Get the image of a course for the catalog. */ - public static function returnThumbnail($course) + public static function returnThumbnail(array $course): string { $course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; if (file_exists($course_path.'/course-pic.png')) { // redimensioned image 85x85 - $courseMediumImage = api_get_path(WEB_COURSE_PATH).$course['directory'].'/course-pic.png'; - } else { - // without picture - $courseMediumImage = Display::return_icon( - 'session_default.png', - null, - null, - null, - null, - true - ); + return api_get_path(WEB_COURSE_PATH).$course['directory'].'/course-pic.png'; } - return $courseMediumImage; + // without picture + return Display::return_icon( + 'session_default.png', + null, + null, + null, + null, + true + ); } - /** - * @param array $courseInfo - * - * @return string - */ - public static function return_teacher($courseInfo) + public static function return_teacher(array $courseInfo): string { $teachers = CourseManager::getTeachersFromCourse($courseInfo['real_id']); $length = count($teachers); @@ -1340,23 +1304,6 @@ class CoursesAndSessionsCatalog ); } - /** - * Get a icon for a session. - * - * @param string $sessionName The session name - * - * @return string The icon - */ - public static function getSessionIcon($sessionName) - { - return Display::return_icon( - 'window_list.png', - $sessionName, - null, - ICON_SIZE_MEDIUM - ); - } - public static function getSessionPagination($action, $countSessions, $limit) { $pageTotal = ceil($countSessions / $limit['length']); @@ -1382,8 +1329,8 @@ class CoursesAndSessionsCatalog */ public static function sessionList($limit = []) { - $date = isset($_POST['date']) ? $_POST['date'] : ''; - $limit = isset($limit) ? $limit : self::getLimitArray(); + $date = $_POST['date'] ?? ''; + $limit = $limit ?? self::getLimitArray(); $countSessions = self::browseSessions($date, [], false, true); $sessions = self::browseSessions($date, $limit); @@ -1425,7 +1372,7 @@ class CoursesAndSessionsCatalog */ public static function sessionsListByName(array $limit) { - $keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : null; + $keyword = $_REQUEST['keyword'] ?? null; $courseUrl = self::getCatalogUrl( 1, $limit['length'], @@ -1518,8 +1465,8 @@ class CoursesAndSessionsCatalog */ public static function sessionsListByCoursesTag(array $limit) { - $searchTag = isset($_REQUEST['search_tag']) ? $_REQUEST['search_tag'] : ''; - $searchDate = isset($_REQUEST['date']) ? $_REQUEST['date'] : date('Y-m-d'); + $searchTag = $_REQUEST['search_tag'] ?? ''; + $searchDate = $_REQUEST['date'] ?? date('Y-m-d'); $courseUrl = self::getCatalogUrl( 1, $limit['length'], @@ -1672,7 +1619,12 @@ class CoursesAndSessionsCatalog 'coach_name' => $coachName, 'coach_avatar' => UserManager::getUserPicture($coachId, USER_IMAGE_SIZE_SMALL), 'is_subscribed' => SessionManager::isUserSubscribedAsStudent($session->getId(), $userId), - 'icon' => self::getSessionIcon($session->getName()), + '' => Display::return_icon( + 'window_list.png', + $session->getName(), + [], + ICON_SIZE_MEDIUM + ), 'date' => $sessionDates['display'], 'price' => !empty($isThisSessionOnSale['html']) ? $isThisSessionOnSale['html'] : '', 'subscribe_button' => isset($isThisSessionOnSale['buy_button']) ? $isThisSessionOnSale['buy_button'] : self::getRegisteredInSessionButton( @@ -1863,7 +1815,7 @@ class CoursesAndSessionsCatalog $action = isset($action) ? Security::remove_XSS($action) : $requestAction; $searchTerm = isset($_REQUEST['search_term']) ? Security::remove_XSS($_REQUEST['search_term']) : ''; $keyword = isset($_REQUEST['keyword']) ? Security::remove_XSS($_REQUEST['keyword']) : ''; - $searchTag = isset($_REQUEST['search_tag']) ? $_REQUEST['search_tag'] : ''; + $searchTag = $_REQUEST['search_tag'] ?? ''; if ($action === 'subscribe_user_with_password') { $action = 'subscribe'; diff --git a/main/template/default/catalog/session_catalog.tpl b/main/template/default/catalog/session_catalog.tpl index 312791a86c..2e31b6f0d0 100644 --- a/main/template/default/catalog/session_catalog.tpl +++ b/main/template/default/catalog/session_catalog.tpl @@ -8,13 +8,11 @@ }); }); -
-
- {{ actions }} - -
-
- {% if catalog_settings.sessions.by_title %} + {{ actions }} + +
+
+ {% if catalog_settings.sessions.by_title %}
@@ -29,53 +27,43 @@
- {% endif %} + {% endif %} - {% if catalog_settings.sessions.by_date %} - {% if show_courses %} -
- {% else %} -
- {% endif %} -
-
- -
- - - - -
+ {% if catalog_settings.sessions.by_date %} +
+ +
+ +
+ + + +
- -
- {% endif %} +
+ +
+ {% endif %} - {% if catalog_settings.sessions.by_tag %} - {% if show_courses %} -
- {% else %} -
- {% endif %} -
- -
- - - - -
-
+ {% if catalog_settings.sessions.by_tag %} +
+
+ +
+ + + +
-
- {% endif %} -
+ +
+ {% endif %}
@@ -87,7 +75,8 @@
- + {{ item.name }} {% if item.category != '' %} {{ item.category }} @@ -116,7 +105,7 @@
- + {{ item.coach_name }}
@@ -180,8 +169,9 @@ html: true, trigger: 'click', content: function () { - var content = ''; {% if item.sequences %} + var content = ''; + {% for sequence in item.sequences %} content += '

{{ sequence.name }}

'; {% if sequence.requirements %} @@ -214,11 +204,11 @@ content += '
'; {% endif %} {% endfor %} + + return content; {% else %} - content = "{{ 'NoDependencies'|get_lang }}"; + return "{{ 'NoDependencies'|get_lang }}"; {% endif %} - - return content; } }); @@ -238,4 +228,4 @@ {{ catalog_pagination }} -{% endblock %} \ No newline at end of file +{% endblock %}