<?php
// Copyright 1999-2012. Parallels IP Holdings GmbH. All Rights Reserved.
?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function() {
    <?php if ($this->linkToSecurePasswords): ?>
        Jsw.addStatusMessage('warning',
            <?php echo $this->jsLmsg('toSecurePasswordsGoTo',
                array('link' => $this->htmlLink('', $this->lmsg('securePasswords'),
                    array('href' => $this->linkToSecurePasswords))
                )
            );?>,
                {
                    id: 'securePasswords',
                    closable: true,
                    renderTo: 'main',
                    onClose: function() {
                        $('securePasswords').remove();
                        new Ajax.Request(Jsw.prepareUrl('/web/hide-secure-passwords'), { method: 'post'});
                    }
                }
        );
    <?php endif; ?>

    <?php if ($this->linkToSyncDnsZones): ?>
        Jsw.addStatusMessage('warning',
            <?php echo $this->jsLmsg('upgradeDnsSyncSkip', array(
                'link' => $this->htmlLink('', $this->lmsg('serverDns'),
                    array('href' => $this->linkToSyncDnsZones)),
                'learnMoreLink' => $this->htmlLink('', $this->lmsg('learnMore'), array(
                        'href' => $this->baseUrl('/help/redirect/controller-name/redirect/action-name/pleskin/plesk-context/dns_t'),
                        'target' => '_blank'
                    )),
            ));?>,
                {
                    id: 'dnsSyncSkip',
                    closable: true,
                    renderTo: 'main',
                    onClose: function() {
                        $('dnsSyncSkip').remove();
                        new Ajax.Request(Jsw.prepareUrl('/web/hide-upgrade-dns-sync-skip'), { method: 'post'});
                    }
                }
        );
    <?php endif; ?>

    <?php if ($this->upgradeFailed): ?>
        new Jsw.UpgradeFailureNotification({
            renderTo: 'main',
            renderMode: 'top',
            isBootstrapRunning: <?php echo $this->isBootstrapRunning ? 'true' : 'false' ?>,
            bootstrapExecutionUrl: '/web/bootstrap-execution',
            bootstrapStatusUrl: '/web/bootstrap-status',
            upgradeFailedMessage: '<?php echo Plesk_Base_Utils_String::safeForJs($this->upgradeFailedMessage) ?>',
            bootstrapInProgressMessage: <?php echo $this->jsLmsg('components.upgrade-failure-notification.bootstrapInProgressMessage') ?>,
            bootstrapLinkTitle: <?php echo $this->jsLmsg('components.upgrade-failure-notification.bootstrapLinkTitle') ?>
        });
    <?php endif; ?>

    <?php if ($this->updateInProgress): ?>
        new Smb.WebSitesAndDomains.UpdateProgressNotification({
            renderTo: 'main',
            renderMode: 'top',
            message: <?php echo $this->jsLmsg('updateInProgress', array(
                'bold' => '<b>' . $this->lmsg('boldPartUpdateInProgress') . '</b>',
            )) ?>
        });
    <?php endif; ?>

    <?php if ($this->updateFailed): ?>
        new Smb.WebSitesAndDomains.UpdateResultNotification({
            renderTo: 'main',
            renderMode: 'top',
            status: 'error',
            message: '<?php echo Plesk_Base_Utils_String::safeForJs($this->updateFailedMessage) ?>'
        });
    <?php endif; ?>

    <?php if ($this->updateCompleted): ?>
        new Smb.WebSitesAndDomains.UpdateResultNotification({
            renderTo: 'main',
            renderMode: 'top',
            status: 'info',
            message: '<?php echo Plesk_Base_Utils_String::safeForJs($this->updateCompletedMessage) ?>'
        });
    <?php endif; ?>

    <?php if ($this->webserverConfigurationFailed): ?>
        <?php echo $this->partial('partials/webserver-configuration-failure.phtml', array(
            'returnUrl' => '/smb/',
            'configurationError' => $this->webserverConfigurationError,
        )); ?>
    <?php endif; ?>

    <?php if ($this->isSiteCopyTaskRunning): ?>
        new Jsw.Task.StatusMessage({
            id: <?php echo $this->siteCopyTaskId ?>,
            status: <?php echo Zend_Json::encode($this->siteCopyTaskStatus) ?>,
            gauge: false,
            percent: false,
            renderTo: 'main',
            renderMode: 'top'
        });
    <?php endif; ?>

    <?php if ($this->showForceUpdateApplicationsNotification): ?>
        Jsw.addStatusMessage('info', <?php echo $this->jsLmsg('forceUpdateApplicationsNotification', array(
                'link' => '<a href="' . $this->baseUrl('/app/force-update-all-applications') . '" data-method="post">' . $this->lmsg('forceUpdateAllApplicationsNotificationLink') . '</a>')
        ); ?>,
            {
                renderTo: 'main',
                id: 'forceUpdateApplication',
                closable: true,
                onClose: function() {
                    $('forceUpdateApplication').remove();
                    new Ajax.Request(Jsw.prepareUrl('/app/hide-force-update-applications-notification'), { method: 'post' });
                }
            }
        );
    <?php endif ?>

    <?php if ($this->updatedAutomaticallyApplications): ?>
        <?php $updatedAutomaticallyApplicationsMessage = $this->lmsg('updatedAutomaticallyApplicationsMessage'); ?>
        <?php foreach ($this->updatedAutomaticallyApplications as $application): ?>
            <?php $updatedAutomaticallyApplicationsMessage .= '<br>' . $this->escape($application); ?>
        <?php endforeach; ?>
        Jsw.addStatusMessage('info', '<?php echo $updatedAutomaticallyApplicationsMessage; ?>');
    <?php endif ?>

    <?php if ($this->unnotifiedApplicationsUpdates): ?>
        <?php $unnotifiedApplicationsUpdatesMessage = $this->lmsg('unnotifiedApplicationsUpdatesMessage'); ?>
        <?php foreach ($this->unnotifiedApplicationsUpdates as $application): ?>
            <?php $unnotifiedApplicationsUpdatesMessage .= '<br>' . $this->escape($application); ?>
        <?php endforeach; ?>
        Jsw.addStatusMessage('info', '<?php echo $unnotifiedApplicationsUpdatesMessage; ?>');
    <?php endif ?>

    $$('.btn-informer button').each(function(element) {
        element.observe('click', function(){
            $('main-disabled-block').show();
            $('modal-informer').show();
        });
    });
});
//]]>
</script>

<p><?php echo $this->lmsg('buttonsAreaDescription'); ?></p>

<?php echo $this->partial('partials/active-list/active-list-tools.phtml', array('buttons' => $this->commonButtons)); ?>
<hr>

<?php if ($this->sitesList->getActiveList()->isActiveListEnabled()): ?>
    <?php echo $this->partial('partials/active-list/active-list.phtml', array('list' => $this->sitesList->getActiveList())); ?>
<?php else: ?>
    <?php echo $this->render('web/view-classic.phtml'); ?>
<?php endif; ?>
