Admin: Add configuration setting 'course_catalog_settings'

Add course url settings in catalog page BT#16817
pull/3159/head
Julio Montoya 6 years ago
parent 7237804a6c
commit ec7a67a518
  1. 37
      main/auth/courses.php
  2. 17
      main/inc/lib/CoursesAndSessionsCatalog.class.php
  3. 18
      main/inc/lib/course.lib.php
  4. 9
      main/install/configuration.dist.php
  5. 19
      main/template/default/catalog/course_item_catalog.tpl

@ -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';

@ -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 = '<div class="block-title"><h4 class="title">';
$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
$html .= '</h4></div>';
return $html;
}
/**
* Display the already registerd text in a course in the course catalog.
*

@ -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 '';

@ -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

@ -2,7 +2,11 @@
{% block course_image %}
<div class="image">
{% block course_thumbnail %}
<a href="{{ course.course_public_url }}" title="{{ course.title }}">
{% set class= '' %}
{% if 'ajax' in course.image_url %}
{% set class= 'ajax' %}
{% endif %}
<a href="{{ course.image_url }}" title="{{ course.title }}" class="{{ class }}">
<img class="img-responsive" src="{{ course.thumbnail }}" alt="{{ course.title }}"/>
</a>
{% endblock %}
@ -27,7 +31,18 @@
{% block course_description %}
<div class="description">
{% block course_title %}
{{ course.title_formatted }}
<div class="block-title">
<h4 class="title">
{% set class= '' %}
{% if 'ajax' in course.title_url %}
{% set class= 'ajax' %}
{% endif %}
<a title="{{ course.title }}" href="{{ course.title_url }}" class="{{ class }}">
{{ course.title }}
</a>
</h4>
</div>
{% endblock %}
{% block course_rating %}

Loading…
Cancel
Save