From 49384c072d65b635d9997f89d347d248d71d845f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Arag=C3=B3n?= Date: Mon, 26 Nov 2018 18:24:05 -0500 Subject: [PATCH] update menu root app - refs #2681 --- main/inc/lib/display.lib.php | 11 +- main/inc/lib/social.lib.php | 216 ++++++++---------- src/CoreBundle/Menu/NavBuilder.php | 61 ++++- .../Resources/views/Layout/menu.html.twig | 91 -------- .../Resources/views/Layout/sidebar.html.twig | 26 ++- 5 files changed, 180 insertions(+), 225 deletions(-) delete mode 100644 src/ThemeBundle/Resources/views/Layout/menu.html.twig diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index a4747df4e1..33da90c33e 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -2723,13 +2723,14 @@ HTML; ); } - public static function dropdownMenu($items=[]){ - $html = null; + public static function dropdownMenu($items=[], array $attr=[]){ + $links = null; + $url = null; foreach ($items as $row){ - $icon = self::tag('img',$row['icon']); - $link = self::url($icon . $row['item'], $row['url']); - $html.= self::tag('li',$link); + $url = self::url($row['icon'] . $row['item'], $row['url'], ['class'=>'dropdown-item']); + $links .= self::tag('li',$url); } + $html = self::tag('ul',$links, $attr); return $html; } } diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 2968dea69b..f1de710ae6 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -942,14 +942,13 @@ class SocialManager extends UserManager $active = null; $links = null; + $itemMenu = []; if (!in_array( $show, ['shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends'] )) { - $itemMenu = []; - $itemMenu [0]= [ 'item' => get_lang('Home'), 'url' => api_get_path(WEB_CODE_PATH) . 'social/home.php', @@ -973,7 +972,7 @@ class SocialManager extends UserManager $itemMenu [3]= [ 'item' => get_lang('ViewMySharedProfile'), - 'url' => api_get_path(WEB_CODE_PATH) . 'social/profiles.php', + 'url' => api_get_path(WEB_CODE_PATH) . 'social/profile.php', 'icon' => $sharedProfileIcon, 'active' => ($show == 'shared_profile' ? 'active' : null) ]; @@ -1025,126 +1024,117 @@ class SocialManager extends UserManager 'active' => ($show == 'personal-data' ? 'active' : null) ]; } - - return Display::dropdownMenu($itemMenu); } + //Move group menu to another function - if (in_array($show, $show_groups) && !empty($group_id)) { + /*if (in_array($show, $show_groups) && !empty($group_id)) { $html .= $usergroup->show_group_column_information( $group_id, api_get_user_id(), $show ); - } + }*/ if ($show == 'shared_profile') { - $links = ''; - $html .= Display::panelCollapse( - get_lang('SocialNetwork'), - $links, - 'social-network-menu', - null, - 'sn-sidebar', - 'sn-sidebar-collapse' - ); + // Announcements in Courses - if ($show_full_profile && $user_id == intval(api_get_user_id())) { + /*if ($show_full_profile && $user_id == intval(api_get_user_id())) { $personal_course_list = UserManager::get_personal_session_course_list($user_id); $course_list_code = []; $i = 1; @@ -1222,28 +1204,26 @@ class SocialManager extends UserManager $html .= ''; $html .= ''; } - } + }*/ } - if ($show_delete_account_button) { - $html .= '
'; - $html .= ''; - $html .= '
'; - } - $html .= ''; + $itemMenu [9]= [ + 'item' => get_lang('Unsubscribe'), + 'url' => api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php', + 'icon' => $deleteIcon, + 'active' => null + ]; - return $html; +// } + + return Display::dropdownMenu($itemMenu); } /** diff --git a/src/CoreBundle/Menu/NavBuilder.php b/src/CoreBundle/Menu/NavBuilder.php index f01a180f81..eb5539e008 100644 --- a/src/CoreBundle/Menu/NavBuilder.php +++ b/src/CoreBundle/Menu/NavBuilder.php @@ -57,20 +57,19 @@ class NavBuilder implements ContainerAwareInterface * * @return ItemInterface */ - public function leftMenu(FactoryInterface $factory, array $options): ItemInterface + public function menuApp(FactoryInterface $factory, array $options): ItemInterface { $container = $this->container; $checker = $container->get('security.authorization_checker'); $translator = $container->get('translator'); $menu = $factory->createItem('root'); - $menu->setChildrenAttribute('class', 'navbar-nav'); $settingsManager = $container->get('chamilo.settings.manager'); $menu->addChild( - $translator->trans('Home'), - [ + 'home', + [ 'label' => $translator->trans('Home'), 'route' => 'legacy_index', 'icon' => 'home', ] @@ -78,8 +77,9 @@ class NavBuilder implements ContainerAwareInterface if ($checker && $checker->isGranted('IS_AUTHENTICATED_FULLY')) { $menu->addChild( - $translator->trans('My courses'), + 'courses', [ + 'label' => $translator->trans('My courses'), 'route' => 'legacy_main', 'icon' => 'book', 'routeParameters' => [ @@ -88,9 +88,46 @@ class NavBuilder implements ContainerAwareInterface ] ); + + $lang = $translator->trans('CreateCourse'); + if ($settingsManager->getSetting('course.course_validation') == 'true') { + $lang = $translator->trans('CreateCourseRequest'); + } + + $menu['courses']->addChild( + 'create-course', + [ + 'label' => $lang, + 'route' => 'legacy_main', + 'routeParameters' => [ + 'name' => 'create_course/add_course.php', + ], + ] + ); + + $browse = $settingsManager->getSetting('display.allow_students_to_browse_courses'); + + if ($browse == 'true') { + if ($checker->isGranted('ROLE_STUDENT') && !api_is_drh( + ) && !api_is_session_admin() + ) { + $menu['courses']->addChild( + 'catalog', + [ + 'label' => $translator->trans('CourseCatalog'), + 'route' => 'legacy_main', + 'routeParameters' => [ + 'name' => 'auth/courses.php' + ], + ] + ); + } + } + $menu->addChild( - $translator->trans('Calendar'), + 'calendar', [ + 'label' => $translator->trans('Calendar'), 'route' => 'legacy_main', 'icon' => 'calendar-alt', 'routeParameters' => [ @@ -100,8 +137,9 @@ class NavBuilder implements ContainerAwareInterface ); $menu->addChild( - $translator->trans('Reporting'), + 'reports', [ + 'label' => $translator->trans('Reporting'), 'route' => 'legacy_main', 'icon' => 'chart-bar', 'routeParameters' => [ @@ -112,8 +150,9 @@ class NavBuilder implements ContainerAwareInterface if ('true' === $settingsManager->getSetting('social.allow_social_tool')) { $menu->addChild( - $translator->trans('Social'), + 'social', [ + 'label' => $translator->trans('Social'), 'route' => 'legacy_main', 'icon' => 'heart', 'routeParameters' => [ @@ -125,8 +164,9 @@ class NavBuilder implements ContainerAwareInterface if ($checker->isGranted('ROLE_ADMIN')) { $menu->addChild( - $translator->trans('Dashboard'), + 'dashboard', [ + 'label' => $translator->trans('Dashboard'), 'route' => 'legacy_main', 'icon' => 'cube', 'routeParameters' => [ @@ -135,8 +175,9 @@ class NavBuilder implements ContainerAwareInterface ] ); $menu->addChild( - $translator->trans('Administration'), + 'administrator', [ + 'label' => $translator->trans('Administration'), 'route' => 'legacy_main', 'icon' => 'cogs', 'routeParameters' => [ diff --git a/src/ThemeBundle/Resources/views/Layout/menu.html.twig b/src/ThemeBundle/Resources/views/Layout/menu.html.twig deleted file mode 100644 index 43855caac7..0000000000 --- a/src/ThemeBundle/Resources/views/Layout/menu.html.twig +++ /dev/null @@ -1,91 +0,0 @@ -{% autoescape false %} - -{% endautoescape %} \ No newline at end of file diff --git a/src/ThemeBundle/Resources/views/Layout/sidebar.html.twig b/src/ThemeBundle/Resources/views/Layout/sidebar.html.twig index de99ab3719..0633e8db84 100644 --- a/src/ThemeBundle/Resources/views/Layout/sidebar.html.twig +++ b/src/ThemeBundle/Resources/views/Layout/sidebar.html.twig @@ -1,7 +1,31 @@ {% autoescape false %}