Merge pull request #1126 from aragonc/1.11.x

improving the code structure BT#11017
ofaj
Yannick Warnier 9 years ago
commit c58dcf5339
  1. 23
      main/inc/lib/course.lib.php
  2. 15
      main/inc/lib/userportal.lib.php
  3. 3
      main/install/configuration.dist.php
  4. 52
      main/template/default/auth/courses_categories.php
  5. 14
      main/template/default/auth/courses_list.php
  6. 77
      main/template/default/layout/hot_course_item.tpl

@ -3423,7 +3423,7 @@ class CourseManager
$params['title'] = $course_info['title']; $params['title'] = $course_info['title'];
$params['link'] = $course_info['course_public_url'].'?id_session=0&autoreg=1'; $params['link'] = $course_info['course_public_url'].'?id_session=0&autoreg=1';
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
$params['teachers'] = CourseManager::getTeachersFromCourseByCode($course['code']); $params['teachers'] = CourseManager::getTeachersFromCourseByCode($course['code']);
} }
@ -3460,15 +3460,12 @@ class CourseManager
if (empty($user_id)) { if (empty($user_id)) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
// Step 1: We get all the categories of the user // Step 1: We get all the categories of the user
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); $table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT id, title FROM $table $sql = "SELECT id, title FROM $table
WHERE user_id = '" . $user_id . "' WHERE user_id = '" . $user_id . "'
ORDER BY sort ASC"; ORDER BY sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
$html = null;
$courseCount = 0; $courseCount = 0;
$listItems = array(); $listItems = array();
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
@ -3477,7 +3474,7 @@ class CourseManager
$row['id'], $row['id'],
$load_dirs $load_dirs
); );
if(empty($courseInCategory)){ if (empty($courseInCategory)) {
$courseInCategory = null; $courseInCategory = null;
} }
$params = array( $params = array(
@ -3485,21 +3482,15 @@ class CourseManager
'title_category' => $row['title'], 'title_category' => $row['title'],
'courses' => $courseInCategory 'courses' => $courseInCategory
); );
//$courseCount += $courseInCategory['course_count'];
$courseCount ++; $courseCount ++;
$listItems['in_category'][$courseCount] = $params; $listItems['in_category'][$courseCount] = $params;
} }
// Step 2: We display the course without a user category. // Step 2: We display the course without a user category.
$courseInCategory = self::returnCoursesWithoutCategories(0, $load_dirs); $courseInCategory = self::returnCoursesWithoutCategories(0, $load_dirs);
$listItems['not_category'] = $courseInCategory; $listItems['not_category'] = $courseInCategory;
//$courseCount += $courseInCategory['course_count'];
return $listItems; return $listItems;
}
}
/** /**
* Display courses inside a category (without special courses) as HTML dics of * Display courses inside a category (without special courses) as HTML dics of
@ -3589,7 +3580,7 @@ class CourseManager
$courseUrl = ''; $courseUrl = '';
$courseUrl = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?id_session=0'; $courseUrl = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?id_session=0';
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
$teachers = CourseManager::getTeachersFromCourseByCode($course['code']); $teachers = CourseManager::getTeachersFromCourseByCode($course['code']);
} }
@ -3723,7 +3714,7 @@ class CourseManager
$course_title_url = ''; $course_title_url = '';
$course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?id_session=0'; $course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?id_session=0';
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
$teachers = CourseManager::getTeachersFromCourseByCode($course['code']); $teachers = CourseManager::getTeachersFromCourseByCode($course['code']);
} }
$params['status'] = $course['status']; $params['status'] = $course['status'];
@ -3985,7 +3976,7 @@ class CourseManager
$session_title .= ' (' . $course_info['visual_code'] . ') '; $session_title .= ' (' . $course_info['visual_code'] . ') ';
} }
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
$teacher_list = CourseManager::get_teacher_list_from_course_code_to_string( $teacher_list = CourseManager::get_teacher_list_from_course_code_to_string(
$course_info['code'], $course_info['code'],
@ -5801,7 +5792,7 @@ class CourseManager
$course_title .= ' ('.$course_info['visual_code'].') '; $course_title .= ' ('.$course_info['visual_code'].') ';
} }
$teachers = ''; $teachers = '';
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
$teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], self::USER_SEPARATOR, true); $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], self::USER_SEPARATOR, true);
} }
$params['link'] = $course_title_url; $params['link'] = $course_title_url;

@ -567,13 +567,13 @@ class IndexManager
$courses_list_string .= "<li>"; $courses_list_string .= "<li>";
$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />'; $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />';
$course_details = array(); $course_details = array();
if (api_get_setting('display_coursecode_in_courselist') == 'true') { if (api_get_setting('display_coursecode_in_courselist') === 'true') {
$course_details[] = $course['visual_code']; $course_details[] = $course['visual_code'];
} }
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
$course_details[] = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); $course_details[] = CourseManager::get_teacher_list_from_course_code_to_string($course['code']);
} }
if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { if (api_get_setting('show_different_course_language') === 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
$course_details[] = $course['course_language']; $course_details[] = $course['course_language'];
} }
$courses_list_string .= implode(' - ', $course_details); $courses_list_string .= implode(' - ', $course_details);
@ -614,7 +614,7 @@ class IndexManager
// if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { // if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
// $courses_list_string .= ' - '; // $courses_list_string .= ' - ';
// } // }
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
if (!empty($course['tutor_name'])) { if (!empty($course['tutor_name'])) {
$course_details[] = $course['tutor_name']; $course_details[] = $course['tutor_name'];
} }
@ -1058,17 +1058,14 @@ class IndexManager
); );
$this->tpl->assign('special_courses', $specialCourses); $this->tpl->assign('special_courses', $specialCourses);
$this->tpl->assign('courses', $courses); $this->tpl->assign('courses', $courses);
if($_configuration['view_grid_courses']==true){ if ($_configuration['view_grid_courses']==true) {
$listCourse = $this->tpl->fetch( $listCourse = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/grid_courses.tpl')); $this->tpl->get_template('/user_portal/grid_courses.tpl'));
} else { } else {
$listCourse = $this->tpl->fetch( $listCourse = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/classic_courses.tpl')); $this->tpl->get_template('/user_portal/classic_courses.tpl'));
} }
$courseCount = $specialCourses['course_count'] + $courses['course_count']; $courseCount = $specialCourses['course_count'] + $courses['course_count'];
} }
$sessions_with_category = ''; $sessions_with_category = '';

@ -238,4 +238,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['messaging_gdc_project_number'] = ''; //$_configuration['messaging_gdc_project_number'] = '';
//Api Key in the Google Developer Console //Api Key in the Google Developer Console
//$_configuration['messaging_gdc_api_key'] = ''; //$_configuration['messaging_gdc_api_key'] = '';
//$_configuration['view_grid_courses'] = true (new grid view courses); // New grid view the list of courses
//$_configuration['view_grid_courses'] = true;

@ -306,37 +306,29 @@ function returnThumbnail($course, $categoryTitle=null)
$course_medium_image = Display::returnIconPath('session_default.png'); $course_medium_image = Display::returnIconPath('session_default.png');
} }
$html .= '<div class="image">'; $html .= '<div class="image">';
$html .= '<img class="img-responsive" src="'.$course_medium_image.'" alt="'.api_htmlentities($title).'"/>'; $html .= '<img class="img-responsive" src="'.$course_medium_image.'" alt="'.api_htmlentities($title).'"/>';
if (!empty($categoryTitle)) { if (!empty($categoryTitle)) {
$html .= '<span class="category">'. $categoryTitle.'</span>'; $html .= '<span class="category">'. $categoryTitle.'</span>';
$html .= '<div class="cribbon"></div>'; $html .= '<div class="cribbon"></div>';
} }
$teachers = CourseManager::getTeachersFromCourseByCode($course['code']); $teachers = CourseManager::getTeachersFromCourseByCode($course['code']);
$html .= '<div class="black-shadow">'; $html .= '<div class="black-shadow">';
$html .= '<div class="author-card">'; $html .= '<div class="author-card">';
$count = 0; $count = 0;
foreach ($teachers as $value) { foreach ($teachers as $value) {
if($count>2){ if ($count>2) {
break; break;
}
$name = $value['firstname'].' ' . $value['lastname'];
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">';
$html .= '<img src="'.$value['avatar'].'"/>';
$html .= '</a>';
$html .= '<div class="teachers-details">';
$html .= '<h5>';
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">';
$html .= $name;
$html .= '</a>';
$html .= '</h5>';
$html .= '</div>';
$count ++;
} }
$html .= '</div>'; $name = $value['firstname'].' ' . $value['lastname'];
$html .= '</div>'; $html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">
// } <img src="'.$value['avatar'].'"/></a>';
$html .= '</div>'; $html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">'
. $name . '</a></h5></div>';
$count ++;
}
$html .= '</div></div></div>';
return $html; return $html;
} }

@ -85,17 +85,17 @@ if (!empty($user_course_categories)) {
<a name="course<?php echo $course['code']; ?>"></a> <a name="course<?php echo $course['code']; ?>"></a>
<strong><?php echo $course['title']; ?></strong><br /> <strong><?php echo $course['title']; ?></strong><br />
<?php <?php
if (api_get_setting('display_coursecode_in_courselist') == 'true') { if (api_get_setting('display_coursecode_in_courselist') === 'true') {
echo $course['visual_code']; echo $course['visual_code'];
} }
if (api_get_setting('display_coursecode_in_courselist') == 'true' && if (api_get_setting('display_coursecode_in_courselist') === 'true' &&
api_get_setting('display_teacher_in_courselist') == 'true' api_get_setting('display_teacher_in_courselist') === 'true'
) { ) {
echo " - "; echo " - ";
} }
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') === 'true') {
echo $course['tutor']; echo $course['tutor'];
} }
?> ?>
@ -192,9 +192,9 @@ if (!empty($courses_without_category)) {
<a name="course<?php echo $course['code']; ?>"></a> <a name="course<?php echo $course['code']; ?>"></a>
<strong><?php echo $course['title']; ?></strong><br /> <strong><?php echo $course['title']; ?></strong><br />
<?php <?php
if (api_get_setting('display_coursecode_in_courselist') == 'true') { echo $course['visual_code']; } if (api_get_setting('display_coursecode_in_courselist') === 'true') { echo $course['visual_code']; }
if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { echo " - "; } if (api_get_setting('display_coursecode_in_courselist') === 'true' && api_get_setting('display_teacher_in_courselist') === 'true') { echo " - "; }
if (api_get_setting('display_teacher_in_courselist') == 'true') { echo $course['tutor']; } if (api_get_setting('display_teacher_in_courselist') === 'true') { echo $course['tutor']; }
?> ?>
</td> </td>
<td valign="top"> <td valign="top">

@ -1,50 +1,49 @@
{% for item in hot_courses %} {% for item in hot_courses %}
{% if item.title %} {% if item.title %}
<div class="col-md-4 col-sm-4 col-xs-6"> <div class="col-md-4 col-sm-4 col-xs-6">
<div class="items"> <div class="items">
<div class="image"> <div class="image">
<img src="{{ item.course_image_large }}" class="img-responsive"> <img src="{{ item.course_image_large }}" class="img-responsive">
{% if item.categoryName != '' %} {% if item.categoryName != '' %}
<span class="category">{{ item.categoryName }}</span> <span class="category">{{ item.categoryName }}</span>
<div class="cribbon"></div> <div class="cribbon"></div>
{% endif %} {% endif %}
<div class="black-shadow"> <div class="black-shadow">
<div class="author-card"> <div class="author-card">
{% for teacher in item.teachers %} {% for teacher in item.teachers %}
{% set counter = counter + 1 %} {% set counter = counter + 1 %}
{% if counter <= 3 %} {% if counter <= 3 %}
<a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
<img src="{{ teacher.avatar }}"/>
</a>
<div class="teachers-details">
<h5>
<a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}"> <a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
{{ teacher.firstname }} {{ teacher.lastname }} <img src="{{ teacher.avatar }}"/>
</a> </a>
</h5> <div class="teachers-details">
<h5>
<a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
{{ teacher.firstname }} {{ teacher.lastname }}
</a>
</h5>
</div>
{% endif %}
{% endfor %}
</div> </div>
{% endif %}
{% endfor %}
</div> </div>
<div class="user-actions">{{ item.description_button }}</div>
</div> </div>
<div class="user-actions">{{ item.description_button }}</div> <div class="description">
</div> <h4 class="title">
<div class="description"> <a title="{{ item.title}}" href="{{ item.course_public_url }}">{{ item.title}}</a>
<h4 class="title"> </h4>
<a title="{{ item.title}}" href="{{ item.course_public_url }}">{{ item.title}}</a> <div class="ranking">
</h4> {{ item.rating_html }}
<div class="ranking"> </div>
{{ item.rating_html }} <div class="toolbar">
</div> <div class="btn-group" role="group">
<div class="toolbar"> {{ item.register_button }}
<div class="btn-group" role="group"> {{ item.unsubscribe_button }}
</div>
{{ item.register_button }}
{{ item.unsubscribe_button }}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> {% endif %}
{% endif %}
{% endfor %} {% endfor %}

Loading…
Cancel
Save