Browse Source

Minor - moving blue menu in a new template file called menu.tpl

Julio Montoya 12 years ago
parent
commit
899cd9a099

+ 7 - 52
main/inc/lib/banner.lib.php

@@ -371,8 +371,7 @@ function return_menu() {
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
 
     $lis = '';
-    $show_bar = false;
-
+    
     if (!empty($open)) {
         if (strpos($open, 'show_menu') === false) {
             if (api_is_anonymous()) {
@@ -380,8 +379,7 @@ function return_menu() {
             }
         } else {
             $lis .= Display::tag('li', $open);
-        }
-        $show_bar = true;
+        }        
     }
 
     if (count($navigation) > 0 || !empty($lis)) {
@@ -396,56 +394,13 @@ function return_menu() {
                 $pre_lis .= '<li'.$current.'><a  href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a></li>';
             }
         }
-        $lis = $pre_lis.$lis;
-        $show_bar = true;
+        $lis = $pre_lis.$lis;        
     }
 
-    $menu = null;
-
-    // Logout
-    if ($show_bar) {
-        if (api_get_user_id() && !api_is_anonymous()) {
-            $login = '';
-            if (api_is_anonymous()) {
-                $login = get_lang('Anonymous');
-            } else {
-                $user_info = api_get_user_info(api_get_user_id());
-            }
-            $logout_link = api_get_path(WEB_PATH).'index.php?logout=logout&amp;uid='.api_get_user_id();
-
-            $message_link  = null;
-
-            if (api_get_setting('allow_message_tool') == 'true') {
-                $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>';
-            }
-
-            if (api_get_setting('allow_social_tool')=='true') {
-                $profile_url = '<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>';
-            } else {
-                $profile_url = '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('Profile').'</a>';
-            }
-            //start user section line with name, my course, my profile, scorm info, etc
-            $menu .= '<ul class="nav nav-pills pull-right">';
-                //echo '<li><span>'.get_lang('LoggedInAsX').' '.$login.'</span></li>';
-                $menu .= '<li class="dropdown">';
-                $menu .= '<a class="dropdown-toggle" data-toggle="dropdown" href="#"><img src="'.$user_info['avatar_small'].'"/> '.$user_info['complete_name'].'<b class="caret"></b></a>
-                                <ul class="dropdown-menu">
-                                    <li>
-                                        '.$profile_url.'
-                                        '.$message_link.'
-                                    </li>
-                                </ul>';
-                $menu .= '</li>';
-                $menu .= '<li><a class="logout" title="'.get_lang('Logout').'" href="'.$logout_link.'">'.Display::return_icon('exit.png', get_lang('Logout'), array(), ICON_SIZE_SMALL).'</a></li>';
-            $menu .= '</ul>';
-        }
-
-        if (!empty($lis)) {
-            $menu .= '<ul class="nav nav-pills">';
-            $menu .= $lis;
-            $menu .= '</ul>';
-        }
-    }
+    $menu = null;        
+    if (!empty($lis)) {            
+         $menu .= $lis;            
+    }    
     return $menu;
 }
 

+ 25 - 1
main/inc/lib/template.lib.php

@@ -589,18 +589,42 @@ class Template {
         $notification = return_notification_menu();
         $this->assign('notification_menu', $notification);
         
+        
+        //Preparing values for the menu
+        
+        //Logout link
+        $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&&uid='.api_get_user_id());        
+        
+        //Profile link
+        if (api_get_setting('allow_social_tool')=='true') {
+            $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>';
+        } else {
+            $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('Profile').'</a>';
+        }
+        $this->assign('profile_link', $profile_link);
+        
+        //Message link
+        $message_link = null;
+        if (api_get_setting('allow_message_tool') == 'true') {
+            $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>';
+        }
+        $this->assign('message_link', $message_link);
+        
+        //Menu
         $menu = return_menu();
         $this->assign('menu', $menu);
         
+        //Breadcrumb        
         $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools);
         $this->assign('breadcrumb', $breadcrumb);
 
+        //Extra content
         $extra_header = null;
         if (!api_is_platform_admin()) {
             $extra_header = trim(api_get_setting('header_extra_content'));
         }
         $this->assign('header_extra_content', $extra_header);
-
+        
         if ($this->show_header == 1) {
             header('Content-Type: text/html; charset=' . api_get_system_encoding());
             header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1));

+ 6 - 9
main/template/default/layout/main_header.tpl

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<!--[if lt IE 7]> <html lang="{{ document_language  }}" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
+<!--[if lt IE 7]> <html lang="{{ document_language }}" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
 <!--[if IE 7]>    <html lang="{{ document_language }}" class="no-js lt-ie9 lt-ie8"> <![endif]-->
 <!--[if IE 8]>    <html lang="{{ document_language }}" class="no-js lt-ie9"> <![endif]-->
 <!--[if gt IE 8]><!--><html lang="{{ document_language }}" class="no-js"> <!--<![endif]-->
@@ -7,13 +7,13 @@
 {% include "default/layout/head.tpl" %}
 </head>
 <body dir="{{ text_direction }}" class="{{ section_name }}">
-<noscript>{{"NoJavascript"|get_lang}}</noscript>
+<noscript>{{ "NoJavascript" | get_lang }}</noscript>
 
 {% if show_header == true %}
     <div class="skip">
         <ul>
-            <li><a href="#menu">{{"WCAGGoMenu"|get_lang}}</a></li>
-            <li><a href="#content" accesskey="2">{{"WCAGGoContent"|get_lang}}</a></li>
+            <li><a href="#menu">{{ "WCAGGoMenu" | get_lang }}</a></li>
+            <li><a href="#content" accesskey="2">{{ "WCAGGoContent" | get_lang }}</a></li>
         </ul>
     </div>
     <div id="wrapper">
@@ -22,6 +22,7 @@
             {{ help_content }}
             {{ bug_notification_link }}
         </ul>
+            
         {# topbar #}
         {% include "default/layout/topbar.tpl" %}
 
@@ -74,11 +75,7 @@
                 {% endif %}
 
                 {# menu #}
-                {% if menu is not null %}
-                    <div class="subnav">
-                        {{ menu }}
-                    </div>
-                {% endif %}
+                {% include "default/layout/menu.tpl" %}                
 
                 {# breadcrumb #}
                 {{ breadcrumb }}

+ 31 - 0
main/template/default/layout/menu.tpl

@@ -0,0 +1,31 @@
+{% if menu is not null %}
+    <div class="subnav">
+        {% if _u.logged == 1 %}
+        <ul class="nav nav-pills pull-right">
+            <li class="dropdown">
+                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
+                    <img src="{{ _u.avatar_small }}"/>
+                    {{ _u.complete_name }}
+
+                    <b class="caret"></b>
+                </a>
+                <ul class="dropdown-menu">
+                    <li>
+                        {{ profile_link }}
+                        {{ message_link }}
+                    </li>
+                </ul>
+            
+            <li>
+                <a class="logout" title="{{ "Logout" | get_lang }}" href="{{ logout_link }}" >
+                    <img src="{{ "exit.png" | icon(22) }}">
+                </a>
+            </li>            
+        </ul>
+        {% endif %}
+         
+        <ul class="nav nav-pills">
+            {{ menu }}
+        </ul>
+    </div>
+{% endif %}