From 70b74f1aaf741504371f26f8f30d9a89b84f6133 Mon Sep 17 00:00:00 2001 From: Alex Aragon Date: Thu, 26 May 2016 10:46:12 -0500 Subject: [PATCH 1/5] fix fonts url api-google editor.css deleted - refs BT#7683 --- app/Resources/public/css/editor.css | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/Resources/public/css/editor.css b/app/Resources/public/css/editor.css index 93c4353fe1..6d4340a5c2 100644 --- a/app/Resources/public/css/editor.css +++ b/app/Resources/public/css/editor.css @@ -6,9 +6,35 @@ alex.aragon@beeznest.com Version: 1.0 */ -@import url(//fonts.googleapis.com/css?family=Open+Sans:400,300,600,300italic,400italic); + @import url(../assets/fontawesome/css/font-awesome.min.css); +@font-face { + font-family: 'Open Sans'; + font-style: normal; + font-weight: 300; + src: local('Open Sans Light'), local('OpenSans-Light'), url(themes/chamilo/fonts/OpenSans-Light.woff2) format('woff2'), url(fonts/OpenSans-Light.woff) format('woff'); +} +@font-face { + font-family: 'Open Sans'; + font-style: normal; + font-weight: 400; + src: local('Open Sans'), local('OpenSans'), url(themes/chamilo/fonts/OpenSans.woff2) format('woff2'), url(fonts/OpenSans.woff) format('woff'); +} +@font-face { + font-family: 'Open Sans'; + font-style: normal; + font-weight: 600; + src: local('Open Sans Semibold'), local('OpenSans-Semibold'), url(themes/chamilo/fonts/OpenSans-Semibold.woff2) format('woff2'), url(fonts/OpenSans-Semibold.woff) format('woff'); +} +@font-face { + font-family: 'Open Sans'; + font-style: normal; + font-weight: 700; + src: local('Open Sans Bold'), local('OpenSans-Bold'), url(themes/chamilo/fonts/OpenSans-Bold.woff2) format('woff2'), url(fonts/OpenSans-Bold.woff) format('woff'); +} + + body{ color: #666; font-family: 'Open Sans', sans-serif; From 2f94b5aad2d10914be55a2fdd74005b0dc40f590 Mon Sep 17 00:00:00 2001 From: Alex Aragon Date: Thu, 26 May 2016 11:23:32 -0500 Subject: [PATCH 2/5] rename session.tpl a classic_session.tpl - refs BT#7683 --- main/inc/lib/userportal.lib.php | 4 ++-- .../{session.tpl => classic_session.tpl} | 16 ++++++++++------ .../default/user_portal/grid_session.tpl | 9 +++++++-- 3 files changed, 19 insertions(+), 10 deletions(-) rename main/template/default/user_portal/{session.tpl => classic_session.tpl} (91%) diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 0ef76de1ab..e8f939de69 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1258,7 +1258,7 @@ class IndexManager ); } else { $sessions_with_no_category = $this->tpl->fetch( - $this->tpl->get_template('/user_portal/session.tpl') + $this->tpl->get_template('/user_portal/classic_session.tpl') ); } $sessionCount++; @@ -1357,7 +1357,7 @@ class IndexManager $this->tpl->assign('session', $sessionParams); $html_sessions .= $this->tpl->fetch( - $this->tpl->get_template('user_portal/session.tpl') + $this->tpl->get_template('user_portal/classic_session.tpl') ); $sessionCount++; diff --git a/main/template/default/user_portal/session.tpl b/main/template/default/user_portal/classic_session.tpl similarity index 91% rename from main/template/default/user_portal/session.tpl rename to main/template/default/user_portal/classic_session.tpl index ee39c6e66b..ace02ddc7c 100644 --- a/main/template/default/user_portal/session.tpl +++ b/main/template/default/user_portal/classic_session.tpl @@ -40,9 +40,11 @@ {{ row.description }} {% endif %}
- - {{ row.coach_name }} - + {% if row.coach_name != '' %} + + {{ row.coach_name }} + + {% endif %} {{ row.date }} @@ -68,9 +70,11 @@ {{ row.description }} {% endif %}
- - {{ row.coach_name }} - + {% if row.coach_name != '' %} + + {{ row.coach_name }} + + {% endif %} {{ row.date }} diff --git a/main/template/default/user_portal/grid_session.tpl b/main/template/default/user_portal/grid_session.tpl index e8734049da..967f760319 100644 --- a/main/template/default/user_portal/grid_session.tpl +++ b/main/template/default/user_portal/grid_session.tpl @@ -16,8 +16,11 @@ {{ row.description }} {% endif %}
- - {{ row.coach_name }} + {% if row.coach_name != '' %} + + {{ row.coach_name }} + + {% endif %} {{ row.date }} @@ -28,7 +31,9 @@ {% for item in row.courses %}
+ {{ item.icon | var_dump }}
+ {% if item.category != '' %} {{ item.category }} From d85d8d551b698d1062062b5c63e08c5c7dc7296d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 26 May 2016 12:03:39 -0500 Subject: [PATCH 3/5] Added Course Category Name to a export/import list courses by CSV - Refs #8170 --- main/admin/course_export.php | 8 ++++++++ main/admin/course_import.php | 2 +- main/inc/lib/course.lib.php | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/main/admin/course_export.php b/main/admin/course_export.php index 781641cb3d..c4d368b4b7 100755 --- a/main/admin/course_export.php +++ b/main/admin/course_export.php @@ -54,6 +54,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) { 'Code', 'Title', 'CourseCategory', + 'CourseCategoryName', 'Teacher', 'Language', 'Users', @@ -61,10 +62,17 @@ if (isset($_POST['formSent']) && $_POST['formSent']) { ]; $dataToExport = []; + foreach ($courses as $course) { $dataToExport['code'] = str_replace(';',',',$course['code']); $dataToExport['title'] = str_replace(';',',',$course['title']); $dataToExport['category_code'] = str_replace(';',',',$course['category_code']); + $categoryInfo = CourseCategory::getCategory($course['category_code']); + if ($categoryInfo) { + $dataToExport['category_name'] = str_replace(';',',',$categoryInfo['name']); + } else { + $dataToExport['category_name'] = ''; + } $dataToExport['tutor_name'] = str_replace(';',',',$course['tutor_name']); $dataToExport['course_language'] = str_replace(';',',',$course['course_language']); diff --git a/main/admin/course_import.php b/main/admin/course_import.php index a7ed55d7e4..a8975eea88 100755 --- a/main/admin/course_import.php +++ b/main/admin/course_import.php @@ -65,7 +65,7 @@ function validate_data($courses) if (isset($course['CourseCategory']) && strlen($course['CourseCategory']) != 0) { $categoryInfo = CourseCategory::getCategory($course['CourseCategory']); if (empty($categoryInfo)) { - CourseCategory::addNode($course['CourseCategory'], $course['CourseCategory'], 'TRUE', null); + CourseCategory::addNode($course['CourseCategory'], $course['CourseCategoryName'] ? $course['CourseCategoryName'] : $course['CourseCategory'], 'TRUE', null); } } } diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 9065a4ffd6..b17de0666e 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -286,7 +286,15 @@ class CourseManager $sql .= ' OFFSET 0'; } - return Database::store_result(Database::query($sql)); + $data = []; + $res = Database::query($sql); + if (Database::num_rows($res) > 0) { + while ($row = Database::fetch_array($res, 'ASSOC')) { + $data[] = $row; + } + } + + return $data; } /** From 082422213d697cbd47dc10d00a49751e01b821c2 Mon Sep 17 00:00:00 2001 From: Alex Aragon Date: Thu, 26 May 2016 12:32:39 -0500 Subject: [PATCH 4/5] fix session item image grid_session tpl --- main/inc/lib/course.lib.php | 11 +++++++++-- main/template/default/user_portal/grid_session.tpl | 4 +--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 9065a4ffd6..e4b80c2945 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -3980,12 +3980,19 @@ class CourseManager $session_title = $course_info['name']; } + $thumbnails = null; + $image = null; $showCustomIcon = api_get_setting('course_images_in_courses_list'); $iconName = basename($course_info['course_image']); + if ($showCustomIcon === 'true' && $iconName != 'course.png') { - $params['icon'] = $course_info['course_image_large']; + $thumbnails = $course_info['course_image']; + $image = $course_info['course_image_large']; + }else{ + $image = Display::return_icon('session_default.png', null, null, null,null, true); } - + $params['thumbnails'] = $thumbnails; + $params['image'] = $image; $params['link'] = $session_url; $params['title'] = $session_title; $params['edit_actions'] = ''; diff --git a/main/template/default/user_portal/grid_session.tpl b/main/template/default/user_portal/grid_session.tpl index 967f760319..f6a41cf06d 100644 --- a/main/template/default/user_portal/grid_session.tpl +++ b/main/template/default/user_portal/grid_session.tpl @@ -31,10 +31,8 @@ {% for item in row.courses %}
- {{ item.icon | var_dump }}
- - + {% if item.category != '' %} {{ item.category }}
From 61a5bbfd412805a6ee1d6e9c78dbeddac4fe3381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 26 May 2016 15:36:03 -0500 Subject: [PATCH 5/5] Added Code validations and fixes - Refs #8170 --- main/admin/course_import.php | 27 +++++++++++++++++---------- main/inc/lib/add_course.lib.inc.php | 2 +- main/inc/lib/export.lib.inc.php | 2 ++ main/inc/lib/import.lib.php | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/main/admin/course_import.php b/main/admin/course_import.php index a8975eea88..d80ce8af58 100755 --- a/main/admin/course_import.php +++ b/main/admin/course_import.php @@ -9,6 +9,9 @@ /** * Validates imported data. + * + * @param array $courses + * @return array $errors */ function validate_data($courses) { @@ -20,14 +23,14 @@ function validate_data($courses) // 1. Check whether mandatory fields are set. $mandatory_fields = array ('Code', 'Title', 'CourseCategory'); foreach ($mandatory_fields as $field) { - if (!isset($course[$field]) || strlen($course[$field]) == 0) { + if (empty($course[$field])) { $course['error'] = get_lang($field.'Mandatory'); $errors[] = $course; } } // 2. Check current course code. - if (isset ($course['Code']) && strlen($course['Code']) != 0) { + if (!empty($course['Code'])) { // 2.1 Check whether code has been already used by this CVS-file. if (isset($coursecodes[$course['Code']])) { $course['error'] = get_lang('CodeTwiceInFile'); @@ -61,12 +64,14 @@ function validate_data($courses) } } - // 4. Check whether course category exists. - if (isset($course['CourseCategory']) && strlen($course['CourseCategory']) != 0) { + if(!empty($course['CourseCategory'])) { $categoryInfo = CourseCategory::getCategory($course['CourseCategory']); if (empty($categoryInfo)) { CourseCategory::addNode($course['CourseCategory'], $course['CourseCategoryName'] ? $course['CourseCategoryName'] : $course['CourseCategory'], 'TRUE', null); } + } else { + $course['error'] = get_lang('NoCourseCategorySupplied'); + $errors[] = $course; } } @@ -74,8 +79,9 @@ function validate_data($courses) } /** - * @param array $teachers + * Get the teacher list * + * @param array $teachers * @return array */ function getTeacherListInArray($teachers) @@ -149,7 +155,7 @@ function save_data($courses) */ function parse_csv_data($file) { - $courses = Import::csvToArray($file); + $courses = Import::csv_reader($file); return $courses; } @@ -186,6 +192,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) { Display :: display_error_message(get_lang('YouMustImportAFileAccordingToSelectedOption')); } else { $courses = parse_csv_data($_FILES['import_file']['tmp_name']); + $errors = validate_data($courses); if (count($errors) == 0) { save_data($courses); @@ -219,10 +226,10 @@ $form->display();
-Code;Title;CourseCategory;Teacher;Language
-BIO0015;Biology;BIO;teacher1;english
-BIO0016;Maths;MATH;teacher2|teacher3;english
-BIO0017;Language;LANG;;english
+Code;Title;CourseCategory;CourseCategoryName;Teacher;Language
+BIO0015;Biology;BIO;Science;teacher1;english
+BIO0016;Maths;MATH;Engineerng;teacher2|teacher3;english
+BIO0017;Language;LANG;;;english
 
diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index 5a05e3f041..64156cb0e5 100755 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -693,7 +693,7 @@ class AddCourse 'category' =>'certificates' ], 'documents_default_visibility' => ['default' =>'visible', 'category' =>'document'], - 'show_course_in_user_language' => ['default' => 2], + 'show_course_in_user_language' => ['default' => 2, 'category' => null], ]; $counter = 1; diff --git a/main/inc/lib/export.lib.inc.php b/main/inc/lib/export.lib.inc.php index 9fbb77ba3c..6fb8e3b5ad 100755 --- a/main/inc/lib/export.lib.inc.php +++ b/main/inc/lib/export.lib.inc.php @@ -37,6 +37,8 @@ class Export * Export tabular data to CSV-file * @param array $data * @param string $filename + * + * @return mixed csv file | false if no data to export */ public static function arrayToCsv($data, $filename = 'export') { diff --git a/main/inc/lib/import.lib.php b/main/inc/lib/import.lib.php index 9df3041e15..6231905773 100755 --- a/main/inc/lib/import.lib.php +++ b/main/inc/lib/import.lib.php @@ -16,6 +16,7 @@ class Import { /** * @param string $path + * @param bool $setFirstRowAsHeader * @return CsvReader */ public static function csv_reader($path, $setFirstRowAsHeader = true)