Skip to content

Commit 6ab51ae

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents ead79db + 98765b8 commit 6ab51ae

File tree

6 files changed

+121
-16
lines changed

6 files changed

+121
-16
lines changed

app/Resources/public/css/base.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9615,6 +9615,23 @@ ul.dropdown-menu.inner > li > a {
96159615
padding-bottom: 133.33%;
96169616
}
96179617

9618+
.dropdown-menu li a + .dropdown-menu {
9619+
display: block;
9620+
left: 0;
9621+
top: 0;
9622+
box-shadow: none;
9623+
margin-top: 0;
9624+
border: 0;
9625+
position: relative;
9626+
padding: 0;
9627+
}
9628+
9629+
.dropdown-menu li a + .dropdown-menu li a {
9630+
padding-top: 6px;
9631+
padding-bottom: 6px;
9632+
padding-right: 9px;
9633+
}
9634+
96189635
/* CSS Responsive */
96199636
@media (min-width: 1025px) and (max-width: 1200px) {
96209637
.sidebar-scorm {

main/inc/lib/ScheduledAnnouncement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public function returnForm($url, $action, $sessionInfo = [])
207207

208208
$useBaseProgress = api_get_configuration_value('scheduled_announcements_use_base_progress');
209209
if ($useBaseProgress) {
210-
$typeOptions['base_progress'] = get_lang('BaseProgress');
210+
$typeOptions['base_progress'] = get_lang('Progress');
211211
}
212212

213213
$form->addSelect(

main/inc/lib/banner.lib.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ function return_navigation_array()
454454
$navigation['follow_up']['icon'] = 'homepage.png';
455455
}
456456

457+
buildParentCourseCategoriesMenu($navigation);
458+
457459
// Administration
458460
if (api_is_platform_admin(true)) {
459461
if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
@@ -481,6 +483,8 @@ function return_navigation_array()
481483
}
482484
}
483485
} else {
486+
buildParentCourseCategoriesMenu($navigation);
487+
484488
// Show custom tabs that are specifically marked as public
485489
$customTabs = getCustomTabs();
486490
if (!empty($customTabs)) {
@@ -508,6 +512,56 @@ function return_navigation_array()
508512
];
509513
}
510514

515+
function buildParentCourseCategoriesMenu(array &$navigation) {
516+
if (!api_get_configuration_value('display_menu_use_course_categories')
517+
|| 'true' !== api_get_setting('course_catalog_published')
518+
) {
519+
return;
520+
}
521+
522+
foreach (CourseCategory::getCategoriesToDisplayInHomePage() as $category) {
523+
$key = 'category_'.$category['code'];
524+
$navigation[$key] = [
525+
'url' => '#',
526+
'title' => $category['name'],
527+
'key' => $key,
528+
'items' => buildChildrenCourseCategoriesMenu($category['code']),
529+
];
530+
}
531+
}
532+
533+
function buildChildrenCourseCategoriesMenu($parentCode = 0): array
534+
{
535+
$baseCategoryUrl = api_get_path(WEB_CODE_PATH).'auth/courses.php?';
536+
537+
$commonParams = [
538+
'search_term' => '',
539+
'submit' => '_qf__s',
540+
];
541+
542+
$items = [];
543+
544+
foreach (CourseCategory::getChildren($parentCode, false) as $category) {
545+
$commonParams['category_code'] = $category['code'];
546+
547+
$categoryItem = [
548+
'title' => $category['name'],
549+
'key' => 'category_'.$category['code'],
550+
'url' => $baseCategoryUrl.http_build_query($commonParams),
551+
];
552+
553+
$children = buildChildrenCourseCategoriesMenu($category['code']);
554+
555+
if (!empty($children)) {
556+
$categoryItem['items'] = $children;
557+
}
558+
559+
$items[] = $categoryItem;
560+
}
561+
562+
return $items;
563+
}
564+
511565
/**
512566
* Return the navigation menu elements as a flat array.
513567
*

main/inc/lib/course_category.lib.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,20 @@ public static function moveNodeUp($code, $tree_pos, $parent_id)
398398
return true;
399399
}
400400

401-
/**
402-
* @param string $categoryCode
403-
*
404-
* @return array
405-
*/
406-
public static function getChildren($categoryCode)
401+
public static function getChildren(string $categoryCode, bool $getChildren = true): array
407402
{
408403
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
409404
$categoryCode = Database::escape_string($categoryCode);
410-
$sql = "SELECT code, id FROM $table
405+
$sql = "SELECT name, code, id FROM $table
411406
WHERE parent_id = '$categoryCode'";
412407
$result = Database::query($sql);
413408
$children = [];
414409
while ($row = Database::fetch_array($result, 'ASSOC')) {
415410
$children[] = $row;
416-
$subChildren = self::getChildren($row['code']);
417-
$children = array_merge($children, $subChildren);
411+
if ($getChildren) {
412+
$subChildren = self::getChildren($row['code']);
413+
$children = array_merge($children, $subChildren);
414+
}
418415
}
419416

420417
return $children;
@@ -591,7 +588,7 @@ public static function listCategories($categorySource)
591588
public static function getCategoriesToDisplayInHomePage()
592589
{
593590
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
594-
$sql = "SELECT name FROM $table
591+
$sql = "SELECT name, code FROM $table
595592
WHERE parent_id IS NULL
596593
ORDER BY tree_pos";
597594

main/install/configuration.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,9 @@
25262526
// 3. Uncomment $parentId var in src/Chamilo/CoreBundle/Entity/Career.php
25272527
// $_configuration['career_hierarchy_enable'] = false;
25282528

2529+
// Use courses categories as top horizontal bar menu (#navbar) entries and submenus, to point to the catalogue with a filter on these categories
2530+
//$_configuration['display_menu_use_course_categories'] = false;
2531+
25292532
// KEEP THIS AT THE END
25302533
// -------- Custom DB changes
25312534
// Set to true to hide settings completely in a sub-URL if the setting is disabled in the

main/template/default/layout/menu.tpl

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,45 @@
121121
{% endif %}
122122

123123
{% if show_item %}
124-
<li class="{{ item.key }} {{ item.current }}">
125-
<a href="{{ item.url }}" {{ item.target ? 'target="' ~ item.target ~ '"' : '' }} title="{{ item.title }}">
126-
{{ item.title }}
127-
</a>
128-
</li>
124+
{% if item.items %}
125+
<li class="dropdown {{ item.key }} {{ item.current }}">
126+
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
127+
aria-haspopup="true" aria-expanded="false">
128+
{{ item.title }}
129+
<span class="caret"></span>
130+
</a>
131+
<ul class="dropdown-menu">
132+
{% for subitem in item.items %}
133+
<li>
134+
<a href="{{ subitem.url }}" class="{{ subitem.key }}">
135+
{{ subitem.title }}
136+
{% if subitem.items|length > 0 %}
137+
<span class="caret"></span>
138+
{% endif %}
139+
</a>
140+
141+
{% if subitem.items|length > 0 %}
142+
<ul class="dropdown-menu">
143+
{% for subsubitem in subitem.items %}
144+
<li>
145+
<a href="{{ subsubitem.url }}" class="{{ subsubitem.key }}">
146+
{{ subsubitem.title }}
147+
</a>
148+
</li>
149+
{% endfor %}
150+
</ul>
151+
{% endif %}
152+
</li>
153+
{% endfor %}
154+
</ul>
155+
</li>
156+
{% else %}
157+
<li class="{{ item.key }} {{ item.current }}">
158+
<a href="{{ item.url }}" {{ item.target ? 'target="' ~ item.target ~ '"' : '' }} title="{{ item.title }}">
159+
{{ item.title }}
160+
</a>
161+
</li>
162+
{% endif %}
129163
{% endif %}
130164
{% endfor %}
131165
</ul>

0 commit comments

Comments
 (0)