@@ -508,6 +508,11 @@ function return_navigation_array()
508508 ];
509509}
510510
511+ function getCourseCategoriesAsMenuItems ()
512+ {
513+
514+ }
515+
511516/**
512517 * Return the navigation menu elements as a flat array.
513518 *
@@ -527,6 +532,55 @@ function menuArray()
527532 $ lang = $ _SESSION ['_user ' ]['language ' ];
528533 }
529534
535+ if (api_get_configuration_value ('display_menu_use_course_categories ' )
536+ && 'true ' === api_get_setting ('course_catalog_published ' )
537+ ) {
538+ $ baseCategoryUrl = api_get_path (WEB_CODE_PATH ).'auth/courses.php? ' ;
539+ $ commonParams = [
540+ 'search_term ' => '' ,
541+ 'submit ' => '_qf__s ' ,
542+ ];
543+
544+ $ buildCategoryTree = function ($ parentCode = 0 , $ depth = 0 ) use ($ baseCategoryUrl , &$ buildCategoryTree , &$ commonParams ) {
545+ if ($ depth > 2 ) {
546+ return [];
547+ }
548+
549+ $ items = [];
550+
551+ foreach (CourseCategory::getChildren ($ parentCode , false ) as $ category ) {
552+ $ commonParams ['category_code ' ] = $ category ['code ' ];
553+
554+ $ categoryItem = [
555+ 'title ' => $ category ['name ' ],
556+ 'key ' => 'category_ ' .$ category ['code ' ],
557+ 'url ' => $ baseCategoryUrl .http_build_query ($ commonParams ),
558+ ];
559+
560+ $ children = $ buildCategoryTree ($ category ['code ' ], $ depth + 1 );
561+
562+ if (!empty ($ children )) {
563+ $ categoryItem ['items ' ] = $ children ;
564+ $ categoryItem ['url ' ] = '# ' ;
565+ }
566+
567+ $ items [] = $ categoryItem ;
568+ }
569+
570+ return $ items ;
571+ };
572+
573+ foreach (CourseCategory::getCategoriesToDisplayInHomePage () as $ category ) {
574+ $ key = 'category_ ' .$ category ['code ' ];
575+ $ mainNavigation ['navigation ' ][$ key ] = [
576+ 'url ' => '# ' ,
577+ 'title ' => $ category ['name ' ],
578+ 'key ' => $ key ,
579+ 'items ' => $ buildCategoryTree ($ category ['code ' ]),
580+ ];
581+ }
582+ }
583+
530584 // Preparing home folder for multiple urls
531585 if (api_get_multiple_access_url ()) {
532586 $ access_url_id = api_get_current_access_url_id ();
0 commit comments