@@ -18,18 +18,7 @@ public function __construct($theme, $page) {
1818 protected function renderLinks () {
1919 $ webroot = $ this ->app ->request ->webRoot ;
2020 $ rc = '<link rel="stylesheet" href=" ' .$ webroot .FontAwesome::getUri ().'" rel="stylesheet" type="text/css"> ' .
21- '<link rel="stylesheet" href=" ' .$ webroot .Bootstrap::getCssUri ().'" rel="stylesheet" type="text/css"> ' .
22- '<style> ' .
23- '.dropdown-item.nav-link { ' .
24- 'padding: .25rem 1.5rem !important; ' .
25- '} ' .
26- '.navbar-dark .dropdown-item.nav-link:hover, ' .
27- '.navbar-dark .dropdown-item.nav-link:active, ' .
28- '.navbar-dark .dropdown-item.nav-link:focus { ' .
29- 'color: #333333 !important; ' .
30- 'background-color: #f8f9fa !important; ' .
31- '} ' .
32- '</style> ' ;
21+ '<link rel="stylesheet" href=" ' .$ webroot .Bootstrap::getCssUri ().'" rel="stylesheet" type="text/css"> ' ;
3322 if ($ this ->theme ->hasFeature (BootstrapTheme::DATEPICKER )) {
3423 $ rc .= '<link rel="stylesheet" href=" ' .Utils::getCssBasePath (TRUE ).'/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css"> ' ;
3524 }
@@ -109,38 +98,36 @@ protected function renderNavbarContent() {
10998 }
11099 }
111100 $ rc .= '</ul> ' ;
112- $ principal = $ this -> app -> getPrincipal ();
113- if ( $ principal != NULL ) {
114- $ rc .= ' <ul class="navbar-nav user-menu"> ' ;
115- $ userMenu = $ this -> app -> getMenu ( ' user ' );
116- if ( $ userMenu == NULL ) {
117- $ userMenu = array ();
101+
102+ $ userMenu = $ this -> app -> getMenu ( ' user ' );
103+ if ( $ userMenu == NULL ) {
104+ $ userMenu = array ( );
105+ $ principal = $ this -> app -> getPrincipal ();
106+ if ( $ principal != NULL ) {
118107 $ userItem = new \WebApp \Component \MenuItem ($ this , $ principal ->__toString (), '# ' );
119108 $ logoutLink = $ this ->app ->getPageLink ('logout ' );
120109 if ($ logoutLink != NULL ) $ logoutLink = $ this ->app ->router ->getCanonicalPath ($ logoutLink );
121110 else $ logoutLink = '' ;
122111 $ userMenu [] = new \WebApp \Component \MenuItem ($ userItem , 'logout_label ' , $ logoutLink .'?logout ' );
123112 $ userMenu = array ($ userItem );
124- }
125- if (($ userMenu != NULL ) && is_array ($ userMenu )) {
126- //$userMenu[] = new \WebApp\Component\MenuItem($this, 'logout_label', '?logout');
127- foreach ($ userMenu AS $ menuItem ) {
128- $ rc .= $ this ->theme ->renderComponent ($ menuItem );
113+ } else if ($ this ->app ->getPageLink ('login ' ) != NULL ) {
114+ $ uri = $ this ->app ->request ->uri ;
115+ $ login = $ this ->app ->router ->getCanonicalPath ($ this ->app ->getPageLink ('login ' ));
116+ if ($ this ->app ->request ->originalPath == $ login ) {
117+ $ uri = $ this ->app ->request ->originalPath ;
118+ } else {
119+ $ uri = $ login .'?return= ' .urlencode ($ this ->app ->request ->originalPath );
129120 }
130-
131- }
132- //$rc .= '<span class="navbar-text align-middle">'.$principal->__toString().'<a class="px-2" href="?logout"><i class="fas fa-sign-out-alt fa-lg"></i></a></span>';
133- $ rc .= '</ul> ' ;
134- } else if ($ this ->app ->getPageLink ('login ' ) != NULL ) {
135- $ uri = $ this ->app ->request ->uri ;
136- $ login = $ this ->app ->router ->getCanonicalPath ($ this ->app ->getPageLink ('login ' ));
137- if ($ this ->app ->request ->originalPath == $ login ) {
138- $ uri = $ this ->app ->request ->originalPath ;
139- } else {
140- $ uri = $ login .'?return= ' .urlencode ($ this ->app ->request ->originalPath );
121+ $ userMenu [] = '<span class="navbar-text align-middle"><a class="px-2" href=" ' .$ uri .'"> ' .I18N ::_ ('login_label ' ).'</a></span> ' ;
141122 }
142- $ rc .= '<span class="navbar-text align-middle"><a class="px-2" href=" ' .$ uri .'"> ' .I18N ::_ ('login_label ' ).'</a></span> ' ;
123+ }
124+
125+ if ($ userMenu != NULL ) {
126+ $ rc .= '<ul class="navbar-nav user-menu"> ' ;
127+ $ rc .= $ this ->theme ->renderComponent ($ userMenu );
128+ $ rc .= '</ul> ' ;
143129 }
130+
144131 $ rc .= '</nav> ' ;
145132 return $ rc ;
146133 }
0 commit comments