improving the code structure BT#11017

ofaj
Alex Aragon 9 years ago
parent 2367f6a5a8
commit 439adbf49e
  1. 27
      main/inc/lib/course.lib.php
  2. 17
      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. 79
      main/template/default/layout/hot_course_item.tpl

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

@ -567,13 +567,13 @@ class IndexManager
$courses_list_string .= "<li>";
$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />';
$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'];
}
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']);
}
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'];
}
$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') {
// $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'])) {
$course_details[] = $course['tutor_name'];
}
@ -1058,17 +1058,14 @@ class IndexManager
);
$this->tpl->assign('special_courses', $specialCourses);
$this->tpl->assign('courses', $courses);
if($_configuration['view_grid_courses']==true){
if ($_configuration['view_grid_courses']==true) {
$listCourse = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/grid_courses.tpl'));
} else {
} else {
$listCourse = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/classic_courses.tpl'));
}
}
$courseCount = $specialCourses['course_count'] + $courses['course_count'];
}
$sessions_with_category = '';

@ -238,4 +238,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['messaging_gdc_project_number'] = '';
//Api Key in the Google Developer Console
//$_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');
}
$html .= '<div class="image">';
$html .= '<img class="img-responsive" src="'.$course_medium_image.'" alt="'.api_htmlentities($title).'"/>';
if (!empty($categoryTitle)) {
$html .= '<span class="category">'. $categoryTitle.'</span>';
$html .= '<div class="cribbon"></div>';
}
$teachers = CourseManager::getTeachersFromCourseByCode($course['code']);
$html .= '<div class="black-shadow">';
$html .= '<div class="author-card">';
$count = 0;
foreach ($teachers as $value) {
if($count>2){
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 class="image">';
$html .= '<img class="img-responsive" src="'.$course_medium_image.'" alt="'.api_htmlentities($title).'"/>';
if (!empty($categoryTitle)) {
$html .= '<span class="category">'. $categoryTitle.'</span>';
$html .= '<div class="cribbon"></div>';
}
$teachers = CourseManager::getTeachersFromCourseByCode($course['code']);
$html .= '<div class="black-shadow">';
$html .= '<div class="author-card">';
$count = 0;
foreach ($teachers as $value) {
if ($count>2) {
break;
}
$html .= '</div>';
$html .= '</div>';
// }
$html .= '</div>';
$name = $value['firstname'].' ' . $value['lastname'];
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">
<img src="'.$value['avatar'].'"/></a>';
$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;
}

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

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

Loading…
Cancel
Save