@@ -508,6 +508,38 @@ function return_navigation_array()
508
508
];
509
509
}
510
510
511
+ function buildCategoryTreeInternal ($ parentCode = 0 ): array
512
+ {
513
+ $ baseCategoryUrl = api_get_path (WEB_CODE_PATH ).'auth/courses.php? ' ;
514
+
515
+ $ commonParams = [
516
+ 'search_term ' => '' ,
517
+ 'submit ' => '_qf__s ' ,
518
+ ];
519
+
520
+ $ items = [];
521
+
522
+ foreach (CourseCategory::getChildren ($ parentCode , false ) as $ category ) {
523
+ $ commonParams ['category_code ' ] = $ category ['code ' ];
524
+
525
+ $ categoryItem = [
526
+ 'title ' => $ category ['name ' ],
527
+ 'key ' => 'category_ ' .$ category ['code ' ],
528
+ 'url ' => $ baseCategoryUrl .http_build_query ($ commonParams ),
529
+ ];
530
+
531
+ $ children = buildCategoryTreeInternal ($ category ['code ' ]);
532
+
533
+ if (!empty ($ children )) {
534
+ $ categoryItem ['items ' ] = $ children ;
535
+ }
536
+
537
+ $ items [] = $ categoryItem ;
538
+ }
539
+
540
+ return $ items ;
541
+ }
542
+
511
543
/**
512
544
* Return the navigation menu elements as a flat array.
513
545
*
@@ -527,6 +559,20 @@ function menuArray()
527
559
$ lang = $ _SESSION ['_user ' ]['language ' ];
528
560
}
529
561
562
+ if (api_get_configuration_value ('display_menu_use_course_categories ' )
563
+ && 'true ' === api_get_setting ('course_catalog_published ' )
564
+ ) {
565
+ foreach (CourseCategory::getCategoriesToDisplayInHomePage () as $ category ) {
566
+ $ key = 'category_ ' .$ category ['code ' ];
567
+ $ mainNavigation ['navigation ' ][$ key ] = [
568
+ 'url ' => '# ' ,
569
+ 'title ' => $ category ['name ' ],
570
+ 'key ' => $ key ,
571
+ 'items ' => buildCategoryTreeInternal ($ category ['code ' ]),
572
+ ];
573
+ }
574
+ }
575
+
530
576
// Preparing home folder for multiple urls
531
577
if (api_get_multiple_access_url ()) {
532
578
$ access_url_id = api_get_current_access_url_id ();
0 commit comments