<?php

if (! $this->undeployedChanges && ! $this->totalUndeployedChanges) {
    return; 
}

if (! $this->hasPermission('director/deploy')) {
    return;
}

if ($this->undeployedChanges === 0) {
    if ($this->totalUndeployedChanges) {
        $msg = $this->translate('There is a single pending change');
    } else {
        $msg = sprintf(
            $this->translate('There are %d pending changes'),
            $this->totalUndeployedChanges
        );
    }
} elseif ($this->totalUndeployedChanges === 1) {
    $msg = $this->translate('There has been a single change to this object, nothing else has been modified');
} elseif ($this->totalUndeployedChanges === $this->undeployedChanges) {
    $msg = sprintf(
        $this->translate('There have been %d changes to this object, nothing else has been modified'),
        $this->undeployedChanges
    );
} else {
    $msg = sprintf(
        $this->translate('There are %d pending changes, %d of them applied to this object'),
        $this->totalUndeployedChanges,
        $this->undeployedChanges
    );
}

echo ' ' . $this->qlink(
    $this->translate('Deploy'),
    'director/config/deploy',
    null,
    array(
        'title' => $msg,
        'class' => 'icon-wrench state-critical'
    )
);

