diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index b502d20176..8ca72c93f1 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -2948,18 +2948,13 @@ class CourseManager public static function getListCategory() { $table_categories = Database::get_main_table(TABLE_MAIN_CATEGORY); - $sql = "SELECT * FROM $table_categories "; - $result = Database::query($sql); - $count = 0; - $list = array(); + $sql = "SELECT * FROM $table_categories"; + $result = Database::query($sql); $category = array(); - while($row = Database::fetch_array($result, 'ASSOC')){ - $category['code'] = $row['code']; - $category['name'] = $row['name']; - $count++; - $list[$count] = $category; + while ($row = Database::fetch_array($result, 'ASSOC')) { + $category[$row['code']] = $row['name']; } - return $list; + return $category; } /** diff --git a/main/template/default/auth/courses_categories.php b/main/template/default/auth/courses_categories.php index c7cffed90e..1ebf086eb9 100755 --- a/main/template/default/auth/courses_categories.php +++ b/main/template/default/auth/courses_categories.php @@ -222,7 +222,7 @@ if ($showCourses && $action != 'display_sessions') { $html .= '
'; // display thumbnail - $html .= return_thumbnail($course, $icon_title, $listCategory); + $html .= returnThumbnail($course, $listCategory[$course['category']]); // display course title and button bloc $html .= '
'; @@ -288,10 +288,11 @@ echo $cataloguePagination; /** * Display the course catalog image of a course - * @param $course - * @param $icon_title + * @param array $course + * @param string $categoryTitle + * @return string HTML string */ -function return_thumbnail($course, $icon_title, $list = array()) +function returnThumbnail($course, $categoryTitle=null) { $html = ''; $title = cut($course['title'], 70); @@ -307,11 +308,9 @@ function return_thumbnail($course, $icon_title, $list = array()) $html .= '
'; $html .= ''.api_htmlentities($title).''; - foreach ($list as $cat) { - if($course['category'] == $cat['code']){ - $html .= ''. $cat['name'].''; - $html .= '
'; - } + if (!empty($categoryTitle)) { + $html .= ''. $categoryTitle.''; + $html .= '
'; } $teachers = CourseManager::getTeacheCourseCode($course['code']); $html .= '
';