{% extends "@templates/"~template~"/view/base.html.twig" %}


{% block javascript %}
    {{ parent() }}
    <script src="{{ asset('media/Public/js/index.js') }}"></script>
{% endblock %}

{% block content %}
    <section class="article">
        <div class="grid-container">
            <div class="grid-x">
                <div class="cell">
                    <h1>Mapa strony</h1>
                </div>
            </div>
            <div class="grid-x">
                <div class="cell">
                    <label for="searchIndexPage">Szukaj:</label>
                    <input type="search" id="searchIndexPage">
                </div>
            </div>
            <div class="siteMap">
                <div class="grid-x small-up-1 medium-up-2">
                    {% if groups|length > 0 %}
                        <div class="cell">
                            <h2>Strony:</h2>
                            {% for pagePref in pagesPref %}
                                {% set metaData = getMetaArrayValues(pagePref) %}
                                <li>
                                    <a href="{{ metaData.canonical }}" title="{{ pagePref.title }}">
                                        {% if(params.showImagePublicIndex and metaData.image is not null) %}
                                            <span class="imagesData imagesInfoSpan" data-img="{{ metaData.image }}" data-alt="{{ metaData.title }} - {{ metaData.description }}"></span>
                                        {% endif %}
                                        <span>{{ pagePref.title }}</span>
                                    </a>
                                </li>
                            {% endfor %}
                            {% for group in groups if group.id != 1 %}
                                <h3>{{ group.name }}</h3>
                                {% set pagesGroup = group.pages %}
                                {% for page in pagesGroup %}
                                    {% set metaData = getMetaArrayValues(page) %}
                                    <li>
                                        <a href="{{ metaData.canonical }}" title="{{ page.title }}">
                                            {% if(params.showImagePublicIndex and metaData.image is not null) %}
                                                <span class="imagesData imagesInfoSpan" data-img="{{ metaData.image }}" data-alt="{{ metaData.title }} - {{ metaData.description }}"></span>
                                            {% endif %}
                                            <span>{{ page.title }}</span>
                                        </a>
                                    </li>
                                {% endfor %}
                            {% endfor %}
                        </div>
                    {% endif %}
                    {% if pages|length > 0 %}
                        <div class="cell">
                            <h2>Strony:</h2>
                            <nav>
                                <ul>
                                    {% for page in pages %}
                                        {% set metaData = getMetaArrayValues(page) %}
                                        <li>
                                            <a href="{{ metaData.canonical }}" title="{{ page.title }}">
                                                {% if(params.showImagePublicIndex and metaData.image is not null) %}
                                                    <span class="imagesData imagesInfoSpan" data-img="{{ metaData.image }}" data-alt="{{ metaData.title }} - {{ metaData.description }}"></span>
                                                {% endif %}
                                                <span>{{ page.title }}</span>
                                            </a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            </nav>
                        </div>
                    {% endif %}
                    {% if params.splitNewsPerCategory %}
                        <div class="cell">
                            <h2>Newsy</h2>
                            {% for category in categories %}
                                {% set month = '' %}
                                <h3>{{ category.name }}</h3>
                                <nav>
                                    <ul>
                                        {% for newsItem in getNewsNoLimit(category.id) %}
                                            {% set metaData = getMetaArrayValues(newsItem) %}
                                            {% if params.splitNewsPerMonth and newsItem.dateOfPublication|date('F Y') != month %}
                                                {% set month = newsItem.dateOfPublication|date('F Y') %}
                                                <li class="monthIndexNews">
                                                    {{ month }}
                                                </li>
                                            {% endif %}
                                            <li>
                                                <a href="{{ metaData.canonical }}" title="{{ newsItem.title }}">
                                                    {% if(params.showImagePublicIndex and metaData.image is not null) %}
                                                        <span class="imagesData imagesInfoSpan" data-img="{{ metaData.image }}" data-alt="{{ metaData.title }} - {{ metaData.description }}"></span>
                                                    {% endif %}
                                                    <span>{{ newsItem.title }}</span>
                                                </a>
                                            </li>
                                        {% endfor %}
                                    </ul>
                                </nav>
                            {% endfor %}
                            <h2>Newsy według kategorii:</h2>
                            <nav>
                                <ul>
                                    {% for category in categories %}
                                        <li>
                                            <a href="{{ path('wi_front_core_indexNewsCategory', {'id': category.id}) }}" title="{{ category.name }}">{{ category.name }}</a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            </nav>
                        </div>
                    {% endif %}
                    {% if not params.splitNewsPerCategory %}
                        <div class="cell">
                            <h2>Newsy:</h2>
                            <nav>
                                <ul>
                                    {% set month = '' %}
                                    {% for newsItem in getNewsNoLimit() %}
                                        {% set metaData = getMetaArrayValues(newsItem) %}
                                        {% if params.splitNewsPerMonth and newsItem.dateOfPublication|date('F Y') != month %}
                                            {% set month = newsItem.dateOfPublication|date('F Y') %}
                                            <li class="monthIndexNews">
                                                {{ month }}
                                            </li>
                                        {% endif %}
                                        <li>
                                            <a href="{{ metaData.canonical }}" title="{{ newsItem.title }}">
                                                {% if(params.showImagePublicIndex and metaData.image is not null) %}
                                                    <span class="imagesData imagesInfoSpan" data-img="{{ metaData.image }}" data-alt="{{ metaData.title }} - {{ metaData.description }}"></span>
                                                {% endif %}
                                                <span>{{ newsItem.title }}</span>
                                            </a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            </nav>
                        </div>
                    {% endif %}
                    {% if categories|length > 0 %}
                        <div class="cell">
                            <h2>Kategorie newsów</h2>
                            <nav>
                                <ul>
                                    {% for category in categories %}
                                        <li>
                                            <a href="{{ path('wi_front_news_by_category_index', {'id': category.id, 'slug': slugify(category.name)}) }}" title="{{ category.name }}">
                                            <span>
                                                {{ category.name }}
                                            </span>
                                            </a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            </nav>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </section>
{% endblock %}
