diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 1adff25a60..5a9c721c16 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1045,6 +1045,7 @@ class IndexManager $sessionCount = 0; $courseCount = 0; + $items = []; // If we're not in the history view... if (!isset($_GET['history'])) { // Display special courses. @@ -1059,6 +1060,7 @@ class IndexManager $this->load_directories_preview ); $courses_html .= $courses['html']; + $items = $courses['items']; $courseCount = $specialCourses['course_count'] + $courses['course_count']; } @@ -1203,10 +1205,12 @@ class IndexManager $this->tpl->assign('session', $params); $this->tpl->assign('gamification_mode', $gamificationModeIsActive); - $sessions_with_no_category .= $this->tpl->fetch( + $item = $this->tpl->fetch( $this->tpl->get_template('/user_portal/session.tpl') ); + $sessions_with_no_category .= $item; + $items[] = $item; $sessionCount++; } } @@ -1288,9 +1292,7 @@ class IndexManager $sessionParams['id'] = $session_id; $sessionParams['show_link_to_session'] = !api_is_drh() && $sessionTitleLink; $sessionParams['title'] = $session_box['title']; - $sessionParams['subtitle'] = (!empty($session_box['coach']) - ? $session_box['coach'] . ' | ' - : '') . $session_box['dates']; + $sessionParams['subtitle'] = (!empty($session_box['coach']) ? $session_box['coach'] . ' | ': '') . $session_box['dates']; $sessionParams['show_actions'] = api_is_platform_admin(); $sessionParams['courses'] = $html_courses_session; $sessionParams['show_simple_session_info'] = false; @@ -1303,10 +1305,14 @@ class IndexManager } $this->tpl->assign('session', $sessionParams); - $html_sessions .= $this->tpl->fetch( + $item = $this->tpl->fetch( $this->tpl->get_template('user_portal/session.tpl') ); + $html_sessions .= $item; + + $items[] = $item; + $sessionCount++; } } @@ -1352,16 +1358,19 @@ class IndexManager } $this->tpl->assign('session_category', $categoryParams); - $sessions_with_category .= $this->tpl->fetch( - "{$this->tpl->templateFolder}/user_portal/session_category.tpl" - ); + $item = $this->tpl->fetch("{$this->tpl->templateFolder}/user_portal/session_category.tpl"); + $sessions_with_category .= $item; + $items[] = $item; } } } } + $items = array_reverse($items); + return [ 'html' => $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses, + 'items' => $items, 'session_count' => $sessionCount, 'course_count' => $courseCount ]; @@ -1421,7 +1430,7 @@ class IndexManager if ($load_history) { $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); if (empty($session_categories)) { - $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); + $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); } } @@ -1473,7 +1482,7 @@ class IndexManager $listUserCategories[0] = ''; $html = '
'; - + $items = []; foreach ($listUserCategories as $userCategoryId => $userCatTitle) { // add user category $userCategoryHtml = ''; @@ -1529,7 +1538,7 @@ class IndexManager } $htmlSessionCategory .= '
'; // end session cat block $htmlCategory .= $htmlSessionCategory .'' ; - $htmlCategory .= ''; // end course block + $items[] = $htmlSessionCategory; } $userCategoryHtml .= $htmlCategory; } @@ -1538,32 +1547,35 @@ class IndexManager // if course not already added $htmlCategory = ''; foreach ($listCoursesInfo as $i => $listCourse) { + $item = ''; if ($listCourse['userCatId'] == $userCategoryId && !isset($listCoursesAlreadyDisplayed[$listCourse['id']])) { if ($userCategoryId != 0) { - $htmlCategory .= '
'; + $item .= '
'; } else { - $htmlCategory .= '
'; + $item .= '
'; } - $htmlCategory .= self::getHtmlForCourse( + $item .= self::getHtmlForCourse( $listCourse['course'], $userCategoryId, 0, $loadDirs ); - $htmlCategory .= '
'; + $item .= '
'; + $htmlCategory .= $item; + $items[] = $item; } } - $htmlCategory .= ''; $userCategoryHtml .= $htmlCategory; // end user cat block if ($userCategoryId != 0) { $userCategoryHtml .= '
'; } - $html .= $userCategoryHtml; // + $html .= $userCategoryHtml; } $html .= '
'; return [ 'html' => $html.$specialCourses, + 'items' => $items, 'session_count' => $sessionCount, 'course_count' => $courseCount ]; diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 4bf6bd3384..c155bc007e 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -238,3 +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'] = ''; +// Userportal template located in main/template/default/layout/user_portal +//$_configuration['user_portal_tpl'] = 'index_grid.tpl'; \ No newline at end of file diff --git a/main/template/default/user_portal/index.tpl b/main/template/default/user_portal/index.tpl new file mode 100644 index 0000000000..cadec8248a --- /dev/null +++ b/main/template/default/user_portal/index.tpl @@ -0,0 +1,3 @@ +{% for item in items %} + {{ item }} +{% endfor %} diff --git a/main/template/default/user_portal/index_grid.tpl b/main/template/default/user_portal/index_grid.tpl new file mode 100644 index 0000000000..a06823ec05 --- /dev/null +++ b/main/template/default/user_portal/index_grid.tpl @@ -0,0 +1,5 @@ +{% for item in items %} +
+ {{ item }} +
+{% endfor %} diff --git a/main/template/default/user_portal/session.tpl b/main/template/default/user_portal/session.tpl index cb744544a9..9cfbcb3fa1 100644 --- a/main/template/default/user_portal/session.tpl +++ b/main/template/default/user_portal/session.tpl @@ -21,83 +21,83 @@ {% endif %}
- {% if session.show_simple_session_info %} -
-
-

- {{ session.title ~ session.notifications }} -

+ {% if session.show_simple_session_info %} +
+
+

+ {{ session.title ~ session.notifications }} +

- {% if session.show_description %} -
- {{ session.description }} -
- {% endif %} + {% if session.show_description %} +
+ {{ session.description }} +
+ {% endif %} - {% if session.subtitle %} - {{ session.subtitle }} - {% endif %} + {% if session.subtitle %} + {{ session.subtitle }} + {% endif %} - {% if session.teachers %} -
{{ "teacher.png"|icon(16) ~ session.teachers }}
- {% endif %} + {% if session.teachers %} +
{{ "teacher.png"|icon(16) ~ session.teachers }}
+ {% endif %} - {% if session.coaches %} -
{{ "teacher.png"|icon(16) ~ session.coaches }}
- {% endif %} -
+ {% if session.coaches %} +
{{ "teacher.png"|icon(16) ~ session.coaches }}
+ {% endif %} +
- {% if session.show_actions %} -
- - {{ - + {% if session.show_actions %} +
+ + {{ + +
+ {% endif %} +
+ {% else %} +
+
+ {% if session.subtitle %} +
+ {{ session.subtitle }}
{% endif %} -
- {% else %} -
-
- {% if session.subtitle %} -
- {{ session.subtitle }} -
- {% endif %} - {% if session.show_description %} -
- {{ session.description }} -
- {% endif %} -
- {% for item in session.courses %} -
-
- {% if item.link %} - {{ item.icon }} - {% else %} - {{ item.icon }} - {% endif %} -
-
- {{ item.title }} + {% if session.show_description %} +
+ {{ session.description }} +
+ {% endif %} +
+ {% for item in session.courses %} +
+
+ {% if item.link %} + {{ item.icon }} + {% else %} + {{ item.icon }} + {% endif %} +
+
+ {{ item.title }} - {% if item.coaches|length > 0 %} - + {% if item.coaches|length > 0 %} + - {% for coach in item.coaches %} - {{ loop.index > 1 ? ' | ' }} + {% for coach in item.coaches %} + {{ loop.index > 1 ? ' | ' }} - - {{ coach.full_name }} - - {% endfor %} - {% endif %} -
+ + {{ coach.full_name }} + + {% endfor %} + {% endif %}
- {% endfor %} -
+
+ {% endfor %}
- {% endif %} +
+ {% endif %}
diff --git a/user_portal.php b/user_portal.php index 796d565c1a..f53fe5c1dd 100755 --- a/user_portal.php +++ b/user_portal.php @@ -185,13 +185,21 @@ if (api_get_setting('go_to_course_after_login') == 'true') { } } - -//Show the chamilo mascot +// Show the chamilo mascot if (empty($courseAndSessions['html']) && !isset($_GET['history'])) { $controller->tpl->assign('welcome_to_course_block', $controller->return_welcome_to_course_block()); } -$controller->tpl->assign('content', $courseAndSessions['html']); +$template = api_get_configuration_value('user_portal_tpl'); +if (empty($template)) { + $controller->tpl->assign('content', $courseAndSessions['html']); +} else { + $controller->tpl->assign('items', $courseAndSessions['items']); + $userPortalTemplate = $controller->tpl->get_template('user_portal/'.$template); + $content = $controller->tpl->fetch($userPortalTemplate); +} + +$controller->tpl->assign('content', $content); if (api_get_setting('allow_browser_sniffer') == 'true') { if (isset($_SESSION['sniff_navigator']) && $_SESSION['sniff_navigator'] != "checked") {