summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-02 02:09:56 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-02 02:09:56 +0200
commit9e217d87c095170460a8580d5215ddf7cbe639f4 (patch)
tree3b426fe52e70ef0f1395edcb354f1be4788ca329 /templates
parentac48332166ce28fcb1a2fc130c7f5adbc760e42d (diff)
Template refactoring to use twig
Diffstat (limited to 'templates')
-rw-r--r--templates/layouts/app.twig56
-rw-r--r--templates/layouts/parts/footer.twig36
-rw-r--r--templates/layouts/parts/navbar.twig74
3 files changed, 123 insertions, 43 deletions
diff --git a/templates/layouts/app.twig b/templates/layouts/app.twig
index 42d5610c..20ea853b 100644
--- a/templates/layouts/app.twig
+++ b/templates/layouts/app.twig
@@ -11,59 +11,29 @@
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.7.1/css/bootstrap-datepicker3.min.css"/>
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
- {% if atom_feed -%}
- <link href="{{ url('atom', atom_feed) }}" type="application/atom+xml" rel="alternate" title="Atom Feed">
+ {% if page() in ['news', 'user-meetings', '/'] and is_user() -%}
+ {% set parameters = {'key': user.api_key} -%}
+ {% if page() == 'user-meetings' -%}
+ {% set parameters = parameters|merge({'meetings': 1}) -%}
+ {% endif %}
+ <link href="{{ url('atom', parameters) }}" type="application/atom+xml" rel="alternate" title="Atom Feed">
{% endif %}
{% endblock %}
</head>
<body>
{% block body %}
- <div class="navbar navbar-default navbar-fixed-top">
- {% block header %}
- <div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed"
- data-toggle="collapse" data-target="#navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="{{ url('/') }}">
- <span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
- </a>
- </div>
-
- {% block navbar %}
- <div class="collapse navbar-collapse" id="navbar-collapse-1">
- {{ menu|raw }}
- {{ header_toolbar|raw }}
- </div>
- {% endblock %}
- </div>
- {% endblock %}
- </div>
+ {% block header %}
+ {% include "layouts/parts/navbar.twig" %}
+ {% endblock %}
<div class="container-fluid">
- <div class="row">{% block content %}{{ content|raw }}{% endblock %}</div>
+ <div class="row">
+ {% block content %}{{ content|raw }}{% endblock %}
+ </div>
<div class="row" id="footer">
{% block footer %}
- <div class="col-md-12">
- <hr/>
- <div class="text-center footer" style="margin-bottom: 10px;">
- {% block eventinfo %}
- {{ event_info|raw }}
- {% endblock %}
- <a href="{{ config('faq_url') }}">FAQ</a>
- · <a href="{{ config('contact_email') }}">
- <span class="glyphicon glyphicon-envelope"></span>Contact
- </a>
- · <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
- · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
- · <a href="{{ url('credits') }}">Credits</a>
- </div>
- </div>
+ {% include "layouts/parts/footer.twig" %}
{% endblock %}
</div>
</div>
diff --git a/templates/layouts/parts/footer.twig b/templates/layouts/parts/footer.twig
new file mode 100644
index 00000000..e986963a
--- /dev/null
+++ b/templates/layouts/parts/footer.twig
@@ -0,0 +1,36 @@
+<div class="col-md-12">
+ <hr/>
+ <div class="text-center footer" style="margin-bottom: 10px;">
+ {% block eventinfo %}
+ {% if event_config.event_name %}
+ {% if event_config.event_start_date and event_config.event_end_date %}
+ {{ __('%s, from %s to %s', [
+ event_config.event_name,
+ date(event_config.event_start_date).format(__('Y-m-d')),
+ date(event_config.event_end_date).format(__('Y-m-d'))
+ ]) }}
+ {% elseif event_config.event_start_date %}
+ {{ __('%s, starting %s', [
+ event_config.event_name,
+ date(event_config.event_start_date).format(__('Y-m-d'))
+ ]) }}
+ {% else %}
+ {{ event_config.event_name }}
+ {% endif %} <br>
+ {% elseif event_config.event_start_date and event_config.event_end_date %}
+ {{ __('Event from %s to %s', [
+ date(event_config.event_start_date).format(__('Y-m-d')),
+ date(event_config.event_end_date).format(__('Y-m-d'))
+ ]) }} <br>
+ {% endif %}
+ {% endblock %}
+
+ <a href="{{ config('faq_url') }}">{{ __('FAQ') }}</a>
+ · <a href="{{ config('contact_email') }}">
+ <span class="glyphicon glyphicon-envelope"></span> {{ __('Contact') }}
+ </a>
+ · <a href="https://github.com/engelsystem/engelsystem/issues">{{ __('Bugs / Features') }}</a>
+ · <a href="https://github.com/engelsystem/engelsystem/">{{ __('Development Platform') }}</a>
+ · <a href="{{ url('credits') }}">{{ __('Credits') }}</a>
+ </div>
+</div>
diff --git a/templates/layouts/parts/navbar.twig b/templates/layouts/parts/navbar.twig
new file mode 100644
index 00000000..a718fc48
--- /dev/null
+++ b/templates/layouts/parts/navbar.twig
@@ -0,0 +1,74 @@
+{% import _self as elements %}
+
+{% macro toolbar_item(label, link, active_page, icon) %}
+ <li{% if page() == active_page %} class="active"{% endif %}>
+ <a href="{{ link }}">
+ {% if icon %}<span class="glyphicon {{ icon }}"></span>{% endif %}
+ {{ label|raw }}
+ </a>
+ </li>
+{% endmacro %}
+
+<div class="navbar navbar-default navbar-fixed-top">
+ <div class="container-fluid">
+ {% block navbar %}
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed"
+ data-toggle="collapse" data-target="#navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="{{ url('/') }}">
+ <span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
+ </a>
+ </div>
+
+ {% block menu %}
+ <div class="collapse navbar-collapse" id="navbar-collapse-1">
+ {% block menu_items %}
+ {{ menu() }}
+ {% endblock %}
+
+ {% block menu_toolbar %}
+ <ul class="nav navbar-nav navbar-right">
+
+ {% if is_user() %}
+ {{ elements.toolbar_item(menuUserShiftState(user), url('shifts', {'action': 'next'}), '', 'glyphicon-time') }}
+ {% elseif has_permission_to('register') and config('registration_enabled') %}
+ {{ elements.toolbar_item(__('Register'), url('register'), 'register', 'glyphicon-plus') }}
+ {% endif %}
+
+ {% if has_permission_to('login') %}
+ {{ elements.toolbar_item(__('Login'), url('login'), 'login', 'glyphicon-log-in') }}
+ {% endif %}
+
+ {% if is_user() and has_permission_to('user_messages') %}
+ {{ elements.toolbar_item(menuUserMessages(), url('user-messages'), 'user-messages', 'glyphicon-envelope') }}
+ {% endif %}
+
+ {{ menuUserHints() }}
+
+ {% if has_permission_to('user_myshifts') %}
+ {{ elements.toolbar_item(user.Nick, url('users', {'action': 'view'}), 'users', 'icon-icon_angel') }}
+ {% endif %}
+
+ {% if has_permission_to('user_settings') or has_permission_to('logout') %}
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu" role="menu">
+ {{ menuUserSubmenu()|join(" ")|raw }}
+ </ul>
+ </li>
+ {% endif %}
+
+ </ul>
+ {% endblock %}
+ </div>
+ {% endblock %}
+ {% endblock %}
+ </div>
+</div>