<div class="controls">
  <?= $this->tabs ?>
</div>
<div class="content">
  <?php if (! $module): ?>
    <?= $this->translate('There is no such module installed.') ?>
  <?php return; endif ?>
  <?php
    $dependencies = $module->getDependencies();
    $restrictions = $module->getProvidedRestrictions();
    $permissions = $module->getProvidedPermissions();
    $state = $moduleData->enabled ? ($moduleData->loaded ? 'enabled' : 'failed') : 'disabled'
  ?>
  <table class="name-value-table">
    <tr>
      <th><?= $this->escape($this->translate('Name')) ?></th>
      <td><?= $this->escape($module->getName()) ?></td>
    </tr>
    <tr>
      <th><?= $this->translate('State') ?></th>
      <td><?= $state ?><?php if ($state === 'enabled'): ?>
      <?= $this->qlink(
        $this->translate('disable'),
        'config/moduledisable',
        array('name' => $module->getName()),
        array('title' => sprintf($this->translate('Disable the %s module'), $module->getName()), 'class' => 'action-link')
      ); ?>
      <?php endif ?>
      <?php if ($state === 'disabled'): ?>
      <?= $this->qlink(
        $this->translate('enable'),
        'config/moduleenable',
        array('name' => $module->getName()),
        array('title' => sprintf($this->translate('Enable the %s module'), $module->getName()), 'class' => 'action-link')
      ); ?>
      <?php endif ?>
      </td>
    <tr>
      <th><?= $this->escape($this->translate('Version')) ?></th>
      <td><?= $this->escape($module->getVersion()) ?></td>
    </tr>
    <?php if (isset($moduleGitCommitId) && $moduleGitCommitId !== false): ?>
      <tr>
        <th><?= $this->escape($this->translate('Git commit')) ?></th>
        <td><?= $this->escape($moduleGitCommitId) ?></td>
      </tr>
    <?php endif ?>
    <tr>
      <th><?= $this->escape($this->translate('Description')) ?></th>
      <td>
        <strong><?= $this->escape($module->getTitle()) ?></strong><br>
        <?= nl2br($this->escape($module->getDescription())) ?>
      </td>
    </tr>
    <tr>
      <th><?= $this->escape($this->translate('Dependencies')) ?></th>
      <td>
        <?php
          if (empty($dependencies)):
            echo $this->translate('This module has no dependencies');
          else: foreach ($dependencies as $name => $versionString): ?>
            <strong><?= $this->escape($name) ?></strong><?php if ($versionString !== true): ?>: <?= $this->escape($versionString) ?><?php endif ?><br />
        <?php endforeach; endif ?>
      </td>
    </tr>
    <?php if (! empty($permissions)): ?>
      <tr>
        <th><?= $this->escape($this->translate('Permissions')) ?></th>
        <td>
          <?php foreach ($permissions as $permission): ?>
            <strong><?= $this->escape($permission->name) ?></strong>: <?= $this->escape($permission->description) ?><br />
          <?php endforeach ?>
        </td>
      </tr>
    <?php endif ?>
    <?php if (! empty($restrictions)): ?>
      <tr>
        <th><?= $this->escape($this->translate('Restrictions')) ?></th>
        <td>
          <?php foreach ($restrictions as $restriction): ?>
            <strong><?= $this->escape($restriction->name) ?></strong>: <?= $this->escape($restriction->description) ?><br />
          <?php endforeach ?>
        </td>
      </tr>
    <?php endif ?>
  </table>
</div>
