<?php
$translate = $this->plugin('translate');
?>
<?php if ($this->setting('version_notifications')): ?>
<?php $this->headScript()->prependFile($this->assetUrl('vendor/compare-versions/index.js', 'Omeka')); ?>
<div class="version-notification" style="display: none;">
    <?php echo sprintf(
        $translate('A new version of Omeka S is available. %s'),
        sprintf(
            '<a href="%s">%s</a>',
            'http://omeka.org/s/download/',
            $translate('Get the new version.')
        )
    ); ?>
</div>
<script>
var currentVersion = '<?php echo $this->escapeJs(Omeka\Module::VERSION); ?>';
$.get('https://api.omeka.org/latest-version-s')
    .done(function(latestVersion) {
        if (compareVersions.compareVersions(currentVersion, latestVersion.trim()) === -1) {
            $('.version-notification').show();
        }
    });
</script>
<?php endif; ?>
