{# testing, remove test_ from var names #}
{% set test_latest_version_available="4.0.0" %}
{% set test_piwikUrl='https://demo.matomo.org/' %}
{% set isPiwikDemo %}{{ piwikUrl == 'http://demo.matomo.org/' or piwikUrl == 'https://demo.matomo.org/' or piwikUrl == 'https://demo.matomo.cloud/' or piwikUrl == 'http://demo.matomo.cloud/' }}{% endset %}

{% set updateCheck %}
    <span id="updateCheckLinkContainer">
        <span class="icon icon-fixed icon-reload"></span>
                {{ 'CoreHome_CheckForUpdates'|translate }}
    </span>
{% endset %}

{% if (latest_version_available and not isPiwikDemo and hasSomeViewAccess and not isUserIsAnonymous and showUpdateNotificationToUser) or (isSuperUser and isAdminArea is defined and isAdminArea) %}
<div piwik-expand-on-hover
     id="header_message"
     class="piwikSelector borderedControl {% if not latest_version_available %}header_info{% else %}{% endif %} piwikTopControl {% if latest_version_available %}update_available{% endif %}"
        >

        {% if latest_version_available and not isPiwikDemo %}
            {% if isMultiServerEnvironment %}
                <span class="title" style="cursor:pointer;">
                    {{ 'General_NewUpdatePiwikX'|translate(latest_version_available) }}
                    <span class="icon-warning"></span>
                </span>
            {% else %}
                <a class="title" href="?module=CoreUpdater&action=newVersionAvailable" style="cursor:pointer;">
                    {{ 'General_NewUpdatePiwikX'|translate(latest_version_available) }}
                    <span class="icon-warning"></span>
                </a>
            {% endif %}
        {% elseif isSuperUser and isAdminArea is defined and isAdminArea %}
            {% if isInternetEnabled %}
            <a class="title">{{ updateCheck|raw }}</a>
            {% else %}
            <a class="title" href="https://matomo.org/changelog/" target="_blank" rel="noreferrer noopener">
                <span id="updateCheckLinkContainer">
                    {{ 'CoreHome_SeeAvailableVersions'|translate }}
                </span>
            </a>
            {% endif %}
        {% endif %}

    <div class="dropdown positionInViewport">
        {% if latest_version_available and isSuperUser %}
            {% if isMultiServerEnvironment %}
                {{ 'CoreHome_OneClickUpdateNotPossibleAsMultiServerEnvironment'|translate("<a rel='noreferrer noopener' href='https://builds.matomo.org/piwik-" ~ latest_version_available ~ ".zip'>builds.matomo.org</a>")|raw }}
            {% else %}
                {{ 'General_PiwikXIsAvailablePleaseUpdateNow'|translate(latest_version_available,"<br /><a href='index.php?module=CoreUpdater&amp;action=newVersionAvailable'>","</a>","<a target='_blank' rel='noreferrer noopener' href='https://matomo.org/changelog/'>","</a>")|raw }}
            {% endif %}
            <br />
        {% elseif latest_version_available and not isPiwikDemo and hasSomeViewAccess and not isUserIsAnonymous %}
            {% set updateSubject = 'General_NewUpdatePiwikX'|translate(latest_version_available)|e('url') %}
            {{ 'General_PiwikXIsAvailablePleaseNotifyPiwikAdmin'|translate("<a target='_blank' rel='noreferrer noopener' href='https://matomo.org/'>Matomo</a> <a target='_blank' rel='noreferrer noopener' href='https://matomo.org/changelog/'>" ~ latest_version_available ~ "</a>", "<a href='mailto:" ~ superUserEmails ~ "?subject=" ~ updateSubject ~ "'>", "</a>")|raw }}
            <br />
        {% endif %}

        {{ 'General_YouAreCurrentlyUsing'|translate(piwik_version) }}
    </div>
</div>

<span class="icon icon-arrowup"></span>
<div style="clear:right"></div>
{% else %}
<span class="icon icon-arrowup"></span>
{% endif %}
