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

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

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

        {% if isPiwikDemo %}
        <a class="title" style="cursor:default;">
            {{ 'General_YouAreViewingDemoShortMessage'|translate }}
          </a>
        {% elseif latest_version_available %}
        <a class="title" href="?module=CoreUpdater&action=newVersionAvailable" style="cursor:pointer;">
            {{ 'General_NewUpdatePiwikX'|translate(latest_version_available) }}
            <span class="icon-warning"></span>
          </a>
        {% elseif isSuperUser and isAdminArea is defined and isAdminArea %}
        <a class="title">
            {{ updateCheck|raw }}
          </a>
        {% endif %}

    <div class="dropdown positionInViewport">
        {% if isPiwikDemo %}
            {{ 'General_DownloadFullVersion'|translate("<a rel='noreferrer' href='https://piwik.org/'>","</a>","<a rel='noreferrer' href='https://piwik.org'>piwik.org</a>")|raw }}
            <br/>
            {% if isSuperUser and isAdminArea is defined and isAdminArea %}
                <br/>
            {% endif %}
        {% endif %}
        {% if latest_version_available and isSuperUser %}
            {% if isMultiServerEnvironment %}
                {{ 'CoreHome_OneClickUpdateNotPossibleAsMultiServerEnvironment'|translate("<a rel='noreferrer' href='https://builds.piwik.org/piwik-" ~ latest_version_available ~ ".zip'>","</a>")|raw }}
            {% else %}
                {{ 'General_PiwikXIsAvailablePleaseUpdateNow'|translate(latest_version_available,"<br /><a href='index.php?module=CoreUpdater&amp;action=newVersionAvailable'>","</a>","<a href='?module=Proxy&amp;action=redirect&amp;url=http://piwik.org/changelog/' target='_blank'>","</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 href='?module=Proxy&action=redirect&url=http://piwik.org/' target='_blank'>Piwik</a> <a href='?module=Proxy&action=redirect&url=http://piwik.org/changelog/' target='_blank'>" ~ latest_version_available ~ "</a>", "<a href='mailto:" ~ superUserEmails ~ "?subject=" ~ updateSubject ~ "'>", "</a>")|raw }}
            <br />
        {% endif %}

        {% if isPiwikDemo and isSuperUser and isAdminArea is defined and isAdminArea %}
            <br/>
            {{ updateCheck|raw }}
            <br/>
            <br/>
        {% endif %}

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

<div style="clear:right"></div>
{% endif %}
