update menu root app - refs #2681

pull/2818/head
Alex Aragón 6 years ago
parent 439e4154f3
commit 49384c072d
  1. 11
      main/inc/lib/display.lib.php
  2. 216
      main/inc/lib/social.lib.php
  3. 61
      src/CoreBundle/Menu/NavBuilder.php
  4. 91
      src/ThemeBundle/Resources/views/Layout/menu.html.twig
  5. 26
      src/ThemeBundle/Resources/views/Layout/sidebar.html.twig

@ -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;
}
}

@ -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 = '<ul class="nav navbar-nav">';
// My own profile
if ($show_full_profile && $user_id == intval(api_get_user_id())) {
$links .= '
<li class="home-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">
'.$homeIcon.' '.get_lang('Home').'
</a>
</li>
<li class="messages-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">
'.$messagesIcon.' '.get_lang('Messages').$count_unread_message.'
</a>
</li>';
$active = $show == 'invitations' ? 'active' : null;
$links .= '
<li class="invitations-icon'.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">
'.$invitationsIcon.' '.get_lang('Invitations').$total_invitations.'
</a>
</li>';
$links .= '
<li class="shared-profile-icon active">
<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php">
'.$sharedProfileIcon.' '.get_lang('ViewMySharedProfile').'
</a>
</li>
<li class="friends-icon">
<a href="'.api_get_path(WEB_CODE_PATH).'social/friends.php">
'.$friendsIcon.' '.get_lang('Friends').'
</a>
</li>
<li class="browse-groups-icon">
<a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php">
'.$groupsIcon.' '.get_lang('SocialGroups').'
</a>
</li>';
$active = $show == 'search' ? 'active' : null;
$links .= '
<li class="search-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/search.php">
'.$searchIcon.' '.get_lang('Search').'
</a>
</li>';
$active = $show == 'myfiles' ? 'active' : null;
$myFiles = '
<li class="myfiles-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/myfiles.php">
'.$filesIcon.' '.get_lang('MyFiles').'
</a>
</li>';
$itemMenu [0]= [
'item' => get_lang('Home'),
'url' => api_get_path(WEB_CODE_PATH) . 'social/home.php',
'icon' => $homeIcon,
'active' => ($show == 'home' ? 'active' : null)
];
$itemMenu [1]= [
'item' => get_lang('Messages') . $count_unread_message,
'url' => api_get_path(WEB_CODE_PATH) . 'social/inbox.php',
'icon' => $messagesIcon,
'active' => ($show == 'messages' ? 'active' : null)
];
$itemMenu [2]= [
'item' => get_lang('Invitations') .$total_invitations,
'url' => api_get_path(WEB_CODE_PATH) . 'social/invitations.php',
'icon' => $invitationsIcon,
'active' => ($show == 'invitations' ? 'active' : null)
];
$itemMenu [3]= [
'item' => get_lang('ViewMySharedProfile'),
'url' => api_get_path(WEB_CODE_PATH) . 'social/profile.php',
'icon' => $sharedProfileIcon,
'active' => ($show == 'shared_profile' ? 'active' : null)
];
$itemMenu [4]= [
'item' => get_lang('Friends'),
'url' => api_get_path(WEB_CODE_PATH) . 'social/friends.php',
'icon' => $friendsIcon,
'active' => ($show == 'friends' ? 'active' : null)
];
$itemMenu [5]= [
'item' => get_lang('SocialGroups'),
'url' => api_get_path(WEB_CODE_PATH) . 'social/groups.php',
'icon' => $groupsIcon,
'active' => ($show == 'browse_groups' ? 'active' : null)
];
$itemMenu [6]= [
'item' => get_lang('Search'),
'url' => api_get_path(WEB_CODE_PATH) . 'social/search.php',
'icon' => $searchIcon,
'active' => ($show == 'search' ? 'active' : null)
];
if (api_get_setting('allow_my_files') === 'false') {
$myFiles = '';
$itemMenu [7]= [
'item' => get_lang('MyFiles'),
'url' => api_get_path(WEB_CODE_PATH) . 'social/myfiles.php',
'icon' => $filesIcon,
'active' => ($show == 'myfiles' ? 'active' : null)
];
}
$links .= $myFiles;
if (api_get_configuration_value('allow_portfolio_tool')) {
$links .= '
<li class="portoflio-icon '.($show == 'portfolio' ? 'active' : '').'">
<a href="'.api_get_path(WEB_CODE_PATH).'portfolio/index.php">
'.$portfolioIcon.' '.get_lang('Portfolio').'
</a>
</li>
';
$itemMenu [8]= [
'item' => get_lang('Portfolio'),
'url' => api_get_path(WEB_CODE_PATH) . 'portfolio/index.php',
'icon' => $portfolioIcon,
'active' => ($show == 'portfolio' ? 'active' : null)
];
}
}
// My friend profile.
if ($user_id != api_get_user_id()) {
$sendMessageText = get_lang('SendMessage');
$sendMessageIcon = Display::return_icon(
'new-message.png',
$sendMessageText
get_lang('SendMessage')
);
$sendMessageUrl = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?'.http_build_query([
'a' => 'get_user_popup',
'user_id' => $user_id,
]);
$links .= '<li>';
$links .= Display::url(
"$sendMessageIcon $sendMessageText",
$sendMessageUrl,
[
'class' => 'ajax',
'title' => $sendMessageText,
'data-title' => $sendMessageText,
]
);
$links .= '</li>';
$itemMenu [1]= [
'item' => get_lang('SendMessage') ,
'url' => $sendMessageUrl,
'icon' => $sendMessageIcon,
'class' => 'ajax',
];
if (api_get_configuration_value('allow_portfolio_tool')) {
$links .= '
<li class="portoflio-icon '.($show == 'portfolio' ? 'active' : '').'">
<a href="'.api_get_path(WEB_CODE_PATH).'portfolio/index.php?user='.$user_id.'">
'.$portfolioIcon.' '.get_lang('Portfolio').'
</a>
</li>
';
$itemMenu [8]= [
'item' => get_lang('Portfolio'),
'url' => api_get_path(WEB_CODE_PATH) . 'portfolio/index.php?user='.$user_id,
'icon' => $portfolioIcon,
'active' => ($show == 'portfolio' ? 'active' : null)
];
}
}
// Check if I already sent an invitation message
$invitation_sent_list = self::get_list_invitation_sent_by_user_id(
/*$invitation_sent_list = self::get_list_invitation_sent_by_user_id(
api_get_user_id()
);
@ -1161,19 +1151,11 @@ class SocialManager extends UserManager
Display::return_icon('invitation.png', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').
'</a></li>';
}
}
}*/
$links .= '</ul>';
$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 .= '</ul>';
$html .= '</div>';
}
}
}*/
}
if ($show_delete_account_button) {
$html .= '<div class="panel panel-default"><div class="panel-body">';
$html .= '<ul class="nav nav-pills nav-stacked"><li>';
$url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php';
$html .= Display::url(
Display::return_icon(
'delete.png',
get_lang('Unsubscribe'),
[],
ICON_SIZE_TINY
).get_lang('Unsubscribe'),
$url
// if ($show_delete_account_button) {
$deleteIcon = Display::return_icon(
'delete.png',
get_lang('Unsubscribe'),
[],
ICON_SIZE_TINY
);
$html .= '</li></ul>';
$html .= '</div></div>';
}
$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);
}
/**

@ -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' => [

@ -1,91 +0,0 @@
{% autoescape false %}
<nav id="menubar" class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="{{ _p.web }}">{{ _s.site_name }}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menuone"
aria-controls="menuone" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="menuone">
{{ mopa_bootstrap_menu('ChamiloCoreBundle:NavBuilder:leftMenu', {'automenu': 'navbar', 'stacked' : false}) }}
{% if app.user is not null and is_granted('IS_AUTHENTICATED_FULLY') %}
<ul class="navbar-nav ml-0 mr-0 ml-md-auto">
<li id="count_message_li" class="nav-item">
<script>
$(document).ready(function () {
$.get(
'{{ url('legacy_main', { name : 'inc/ajax/message.ajax.php'}) }}',
{'a': 'get_count_message'},
function (data) {
if (data === '0') {
$("#count_message_li").addClass('hidden');
} else {
$("#count_message_li").removeClass('hidden');
$("#count_message").append(data);
}
}
);
});
</script>
<a href="{{ message_url }}">
<span id="count_message" class="badge badge-warning"></span>
</a>
</li>
{% if language_form %}
<li class="nav-item dropdown language">
{{ language_form }}
</li>
{% endif %}
<li class="nav-item dropdown user user-menu">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button"
id="navar-user" aria-expanded="false" aria-haspopup="true">
<img class="img-circle" src="{{ asset(app.user.avatarOrAnonymous(32)) }}"
alt="{{ app.user.completeName }}"/>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navar-user">
<div class="user-header text-center">
<p class="mb-0 pt-0 pr-2 pb-0 pl-2">
<img class="img-circle" src="{{ asset(app.user.avatarOrAnonymous(64)) }}"
alt="{{ app.user.completeName }}"/>
</p>
<p class="mb-0 pt-0 pr-2 pb-0 pl-2">
<a href="{{ url('legacy_main', { 'name' : 'social/home.php' }) }}">
{{ app.user.completeName }}
</a>
</p>
<p class="mb-0 pt-0 pr-2 pb-0 pl-2">
{#<span class="fa fa-envelope" aria-hidden="true"></span>#}
{{ app.user.email }}
</p>
</div>
<div class="dropdown-divider"></div>
<a title="{{ "Inbox"|trans }}" class="dropdown-item"
href="{{ url('legacy_main', { 'name' : 'messages/inbox.php' }) }}">
<em class="fa fa-envelope" aria-hidden="true"></em> {{ "Inbox"|get_lang }}
</a>
<a href="{{ url('legacy_main', { 'name' : 'survey/pending.php' }) }}" class="dropdown-item">
<em class="fa fa-chart-pie"></em> {{ 'PendingSurveys'|get_lang }}
</a>
<a title="{{ "MyCertificates"|trans }}" class="dropdown-item"
href="{{ url('legacy_main', { 'name' : 'gradebook/my_certificates.php' }) }}">
<em class="fa fa-graduation-cap"
aria-hidden="true"></em> {{ "MyCertificates"|get_lang }}
</a>
<a id="logout_button" title="{{ "Logout"|trans }}" class="dropdown-item"
href="{{ path('legacy_main', { 'name' : '../public/logout'}) }}">
<em class="fa fa-sign-out-alt"></em> {{ "Logout"|trans }}
</a>
</div>
</li>
</ul>
{% endif %}
</div>
</div>
</nav>
{% endautoescape %}

@ -1,7 +1,31 @@
{% autoescape false %}
<ul class="sidebar-menu scrollable pos-r">
{{ mopa_bootstrap_menu('ChamiloCoreBundle:NavBuilder:leftMenu', {'automenu': 'navbar', 'stacked' : true}) }}
{% set menu = knp_menu_get('ChamiloCoreBundle:NavBuilder:menuApp') %}
<ul class="navbar-nav">
{% for item in menu.children %}
{% set children = item.children|length %}
<li class="nav-item {{ children > 0 ? 'dropdown' : '' }}">
<a class='sidebar-link' href="{{ item.uri }}">
<i class="fa fa-{{ item.extras.icon }}"></i>
{{ item.label }}
</a>
{% if children > 0 %}
<ul class="dropdown-menu">
{% for item in item.children %}
<li>
<a href="{{ item.uri }}" class="sidebar-link">
{{ item.label }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
<li class="sidebar-divider"></li>

Loading…
Cancel
Save