<%namespace name='static' file='../static_content.html'/>
<%!
  from django.conf import settings
  from django.core.urlresolvers import reverse
  from django.utils.translation import ugettext as _
  from contentstore.context_processors import doc_url
%>
<%page args="online_help_token"/>

<div class="wrapper-header wrapper" id="view-top">
  <header class="primary" role="banner">

    <div class="wrapper wrapper-l">
      <h1 class="branding"><a href="/">
        <img src="${static.url("images/header-logo.png")}" alt="${settings.STUDIO_NAME}" />
      </a></h1>

      % if context_course:
      <%
            course_key = context_course.id
            index_url = reverse('contentstore.views.course_handler', kwargs={'course_key_string': unicode(course_key)})
            checklists_url = reverse('contentstore.views.checklists_handler', kwargs={'course_key_string': unicode(course_key)})
            course_team_url = reverse('contentstore.views.course_team_handler', kwargs={'course_key_string': unicode(course_key)})
            assets_url = reverse('contentstore.views.assets_handler', kwargs={'course_key_string': unicode(course_key)})
            textbooks_url = reverse('contentstore.views.textbooks_list_handler', kwargs={'course_key_string': unicode(course_key)})
            videos_url = reverse('contentstore.views.videos_handler', kwargs={'course_key_string': unicode(course_key)})
            import_url = reverse('contentstore.views.import_handler', kwargs={'course_key_string': unicode(course_key)})
            course_info_url = reverse('contentstore.views.course_info_handler', kwargs={'course_key_string': unicode(course_key)})
            export_url = reverse('contentstore.views.export_handler', kwargs={'course_key_string': unicode(course_key)})
            settings_url = reverse('contentstore.views.settings_handler', kwargs={'course_key_string': unicode(course_key)})
            grading_url = reverse('contentstore.views.grading_handler', kwargs={'course_key_string': unicode(course_key)})
            advanced_settings_url = reverse('contentstore.views.advanced_settings_handler', kwargs={'course_key_string': unicode(course_key)})
            tabs_url = reverse('contentstore.views.tabs_handler', kwargs={'course_key_string': unicode(course_key)})
            certificates_url = ''
            if settings.FEATURES.get("CERTIFICATES_HTML_VIEW") and context_course.cert_html_view_enabled:
                certificates_url = reverse('contentstore.views.certificates.certificates_list_handler', kwargs={'course_key_string': unicode(course_key)})
      %>
      <h2 class="info-course">
        <span class="sr">${_("Current Course:")}</span>
        <a class="course-link" href="${index_url}">
          <span class="course-org">${context_course.display_org_with_default | h}</span><span class="course-number">${context_course.display_number_with_default | h}</span>
          <span class="course-title" title="${context_course.display_name_with_default}">${context_course.display_name_with_default}</span>
        </a>
      </h2>

      <nav class="nav-course nav-dd ui-left" aria-label="${_('Course')}">
        <h2 class="sr">${_("Course Navigation")}</h2>
        <ol>
          <li class="nav-item nav-course-courseware">
            <h3 class="title"><span class="label"><span class="label-prefix sr">${_("Course")} </span>${_("Content")}</span> <i class="icon fa fa-caret-down ui-toggle-dd"></i></h3>

            <div class="wrapper wrapper-nav-sub">
              <div class="nav-sub">
                <ul>
                  <li class="nav-item nav-course-courseware-outline">
                    <a href="${index_url}">${_("Outline")}</a>
                  </li>
                  <li class="nav-item nav-course-courseware-updates">
                    <a href="${course_info_url}">${_("Updates")}</a>
                  </li>
                  <li class="nav-item nav-course-courseware-pages">
                    <a href="${tabs_url}">${_("Pages")}</a>
                  </li>
                  <li class="nav-item nav-course-courseware-uploads">
                    <a href="${assets_url}">${_("Files &amp; Uploads")}</a>
                  </li>
                  <li class="nav-item nav-course-courseware-textbooks">
                    <a href="${textbooks_url}">${_("Textbooks")}</a>
                  </li>
                  % if context_course.video_pipeline_configured:
                  <li class="nav-item nav-course-courseware-videos">
                    <a href="${videos_url}">${_("Video Uploads")}</a>
                  </li>
                  % endif
                </ul>
              </div>
            </div>
          </li>

          <li class="nav-item nav-course-settings">
            <h3 class="title"><span class="label"><span class="label-prefix sr">${_("Course")} </span>${_("Settings")}</span> <i class="icon fa fa-caret-down ui-toggle-dd"></i></h3>

            <div class="wrapper wrapper-nav-sub">
              <div class="nav-sub">
                <ul>
                  <li class="nav-item nav-course-settings-schedule">
                    <a href="${settings_url}">${_("Schedule &amp; Details")}</a>
                  </li>
                  <li class="nav-item nav-course-settings-grading">
                    <a href="${grading_url}">${_("Grading")}</a>
                  </li>
                  <li class="nav-item nav-course-settings-team">
                    <a href="${course_team_url}">${_("Course Team")}</a>
                  </li>
                  <li class="nav-item nav-course-settings-group-configurations">
                    <a href="${reverse('contentstore.views.group_configurations_list_handler', kwargs={'course_key_string': unicode(course_key)})}">${_("Group Configurations")}</a>
                  </li>
                  <li class="nav-item nav-course-settings-advanced">
                    <a href="${advanced_settings_url}">${_("Advanced Settings")}</a>
                  </li>
                  % if certificates_url:
                  <li class="nav-item nav-course-settings-certificates">
                    <a href="${certificates_url}">${_("Certificates")}</a>
                  </li>
                  % endif
                </ul>
              </div>
            </div>
          </li>

          <li class="nav-item nav-course-tools">
            <h3 class="title"><span class="label">${_("Tools")}</span> <i class="icon fa fa-caret-down ui-toggle-dd" aria-hidden="true"></i></h3>
            <div class="wrapper wrapper-nav-sub">
              <div class="nav-sub">
                <ul>
                  <li class="nav-item nav-course-tools-checklists">
                    <a href="${checklists_url}">${_("Checklists")}</a>
                  </li>
                  <li class="nav-item nav-course-tools-import">
                    <a href="${import_url}">${_("Import")}</a>
                  </li>
                  <li class="nav-item nav-course-tools-export">
                    <a href="${export_url}">${_("Export")}</a>
                  </li>
                  % if settings.FEATURES.get('ENABLE_EXPORT_GIT') and context_course.giturl:
                  <li class="nav-item nav-course-tools-export-git">
                    <a href="${reverse('export_git', kwargs=dict(course_key_string=unicode(course_key)))}">${_("Export to Git")}</a>
                  </li>
                  % endif
                </ul>
              </div>
            </div>
          </li>
        </ol>
      </nav>
      % elif context_library:
       <%
            library_key = context_library.location.course_key
            index_url = reverse('contentstore.views.library_handler', kwargs={'library_key_string': unicode(library_key)})
            import_url = reverse('contentstore.views.import_handler', kwargs={'course_key_string': unicode(library_key)})
            lib_users_url = reverse('contentstore.views.manage_library_users', kwargs={'library_key_string': unicode(library_key)})
            export_url = reverse('contentstore.views.export_handler', kwargs={'course_key_string': unicode(library_key)})
      %>
      <h2 class="info-course">
        <span class="sr">${_("Current Library:")}</span>
        <a class="course-link" href="${index_url}">
          <span class="course-org">${context_library.display_org_with_default | h}</span><span class="course-number">${context_library.display_number_with_default | h}</span>
          <span class="course-title" title="${context_library.display_name_with_default}">${context_library.display_name_with_default}</span>
        </a>
      </h2>

      <nav class="nav-course nav-dd ui-left" aria-label="${_('Course')}">
        <h2 class="sr">${_("Course Navigation")}</h2>
        <ol>

          <li class="nav-item nav-library-settings">
            <h3 class="title"><span class="label"><span class="label-prefix sr">${_("Library")} </span>${_("Settings")}</span> <i class="icon fa fa-caret-down ui-toggle-dd"></i></h3>
            <div class="wrapper wrapper-nav-sub">
              <div class="nav-sub">
                <ul>
                  <li class="nav-item nav-library-settings-team">
                    <a href="${lib_users_url}">${_("User Access")}</a>
                  </li>
                </ul>
              </div>
            </div>
          </li>
          <li class="nav-item nav-course-tools">
            <h3 class="title"><span class="label">${_("Tools")}</span> <i class="icon fa fa-caret-down ui-toggle-dd"></i></h3>

            <div class="wrapper wrapper-nav-sub">
              <div class="nav-sub">
                <ul>
                  <li class="nav-item nav-course-tools-import">
                    <a href="${import_url}">${_("Import")}</a>
                  </li>
                  <li class="nav-item nav-course-tools-export">
                    <a href="${export_url}">${_("Export")}</a>
                  </li>
                </ul>
              </div>
            </div>
          </li>
        </ol>
      </nav>
      % endif
    </div>

    <div class="wrapper wrapper-r">
      % if user.is_authenticated():
      <nav class="nav-account nav-is-signedin nav-dd ui-right" aria-label="${_('Account')}">
        <h2 class="sr">${_("Account Navigation")}</h2>
        <ol>
          <li class="nav-item nav-account-help">
            <h3 class="title"><span class="label"><a href="${get_online_help_info(online_help_token)['doc_url']}" title="${_("Contextual Online Help")}" target="_blank">${_("Help")}</a></span></h3>
          </li>

          <li class="nav-item nav-account-user">
            <h3 class="title"><span class="label"><span class="label-prefix sr">${_("Currently signed in as:")}</span><span class="account-username" title="${ user.username }">${ user.username }</span></span> <i class="icon fa fa-caret-down ui-toggle-dd"></i></h3>

            <div class="wrapper wrapper-nav-sub">
              <div class="nav-sub">
                <ul>
                  <li class="nav-item nav-account-dashboard">
                    <a href="/">${_("{studio_name} Home").format(studio_name=settings.STUDIO_SHORT_NAME)}</a>
                  </li>
                  <li class="nav-item nav-account-signout">
                    <a class="action action-signout" href="${reverse('logout')}">${_("Sign Out")}</a>
                  </li>
                </ul>
              </div>
            </div>
          </li>
        </ol>
      </nav>

      % else:
      <nav class="nav-not-signedin nav-pitch" aria-label="${_('Account')}">
        <h2 class="sr">${_("Account Navigation")}</h2>
        <ol>
          <li class="nav-item nav-not-signedin-help">
            <a href="${get_online_help_info(online_help_token)['doc_url']}" title="${_("Contextual Online Help")}" target="_blank">${_("Help")}</a>
          </li>
          <li class="nav-item nav-not-signedin-signup">
            <a class="action action-signup" href="${reverse('signup')}">${_("Sign Up")}</a>
          </li>
          <li class="nav-item nav-not-signedin-signin">
            <a class="action action-signin" href="${reverse('login')}">${_("Sign In")}</a>
          </li>
        </ol>
      </nav>
      % endif
    </div>
  </header>
</div>
