## mako

<%page expression_filter="h" args="online_help_token"/>

<%namespace name='static' file='../static_content.html'/>
<%namespace file='../main.html' import="login_query"/>
<%!
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from lms.djangoapps.ccx.overrides import get_current_ccx
from openedx.core.djangolib.markup import HTML, Text

# App that handles subdomain specific branding
from branding import api as branding_api
# app that handles site status messages
from status.status import get_site_status_msg
from openedx.core.djangoapps.lang_pref.api import header_language_selector_is_enabled, released_languages
%>

## Provide a hook for themes to inject branding on top.
<%block name="navigation_top" />

## Add UI Toolkit components if using the Pattern Library
% if uses_pattern_library:
    <%block name="js_extra">
    <%static:require_module module_name="js/header_factory" class_name="HeaderFactory">
    HeaderFactory();
    </%static:require_module>
    </%block>
% endif

<%block>
<%
try:
    course_id = course.id
except:
    # can't figure out a better way to get at a possibly-defined course var
    course_id = None
site_status_msg = get_site_status_msg(course_id)
%>
% if site_status_msg:
<div class="site-status">
  <div class="inner-wrapper">
    <span class="icon fa fa-warning"></span>
    <p>${site_status_msg}</p>
  </div>
</div>
% endif
</%block>

% if uses_bootstrap:
  <header class="navigation-container header-global ${'slim' if course else ''}">
    <nav class="navbar navbar-expand-lg navbar-light">
      <%include file="bootstrap/navbar-logo-header.html" args="online_help_token=online_help_token"/>
      <button class="navbar-toggler navbar-toggler-right mt-2" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      % if user.is_authenticated():
        <%include file="bootstrap/navbar-authenticated.html" args="online_help_token=online_help_token"/>
      % else:
        <%include file="bootstrap/navbar-not-authenticated.html" args="online_help_token=online_help_token"/>
      % endif
    </nav>
  </header>
% else:
  <header id="global-navigation" class="header-global ${"slim" if course else ""}" >
    <nav class="wrapper-header" aria-label="${_('Global')}">
      <%include file="navbar-logo-header.html" args="online_help_token=online_help_token"/>
      % if user.is_authenticated():
        <%include file="navbar-authenticated.html" args="online_help_token=online_help_token"/>
      % else:
        <%include file="navbar-not-authenticated.html" args="online_help_token=online_help_token"/>
      % endif
      % if header_language_selector_is_enabled():
        <% languages = released_languages() %>
        % if len(languages) > 1:
          <ol class="user">
            <li class="primary">
              <form action="/i18n/setlang/" method="post" class="settings-language-form" id="language-settings-form">
                <input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}">
                % if user.is_authenticated():
                  <input title="preference api" type="hidden" class="url-endpoint" value="${reverse('preferences_api', kwargs={'username': user.username})}" data-user-is-authenticated="true">
                % else:
                  <input title="session update url" type="hidden" class="url-endpoint" value="${reverse('session_language')}" data-user-is-authenticated="false">
                % endif
                <label><span class="sr">${_("Choose Language")}</span>
                  <select class="input select language-selector" id="settings-language-value" name="language">
                    % for language in languages:
                      % if language[0] == LANGUAGE_CODE:
                        <option value="${language[0]}" selected="selected">${language[1]}</option>
                      % else:
                        <option value="${language[0]}" >${language[1]}</option>
                      % endif
                    % endfor
                  </select>
                </label>
              </form>
            </li>
          </ol>
        % endif
      % endif
    </nav>
  </header>
% endif
% if course:
<!--[if lte IE 9]>
<div class="ie-banner" aria-hidden="true">${Text(_('{begin_strong}Warning:{end_strong} Your browser is not fully supported. We strongly recommend using {chrome_link} or {ff_link}.')).format(
    begin_strong=HTML('<strong>'),
    end_strong=HTML('</strong>'),
    chrome_link=HTML('<a href="https://www.google.com/chrome" target="_blank">Chrome</a>'),
    ff_link=HTML('<a href="http://www.mozilla.org/firefox" target="_blank">Firefox</a>'),
)}</div>
<![endif]-->
% endif

<%include file="../help_modal.html"/>
% if settings.FEATURES.get('ENABLE_COOKIE_CONSENT', False):
  <%include file="../widgets/cookie-consent.html" />
% endif
