<div class="controls">
    <?= $this->tabs ?>
</div>
<div class="content">
    <h1><?= t('Dashboard Settings'); ?></h1>

    <table class="avp action" data-base-target="_next">
        <thead>
            <tr>
                <th>
                    <strong><?= t('Dashlet Name') ?></strong>
                </th>
                <th>
                    <strong><?= t('Url') ?></strong>
                </th>
                <th class="icon-col">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->dashboard->getPanes() as $pane): ?>
                <?php if ($pane->getDisabled()) continue; ?>
                <tr>
                    <th colspan="2">
                    <?php if ($pane->isUserWidget()): ?>
                        <?= $this->qlink(
                            $pane->getName(),
                            'dashboard/rename-pane',
                            array('pane' => $pane->getName()),
                            array('title' => sprintf($this->translate('Edit pane %s'), $pane->getName()))
                        ) ?>
                    <?php else: ?>
                        <?= $this->escape($pane->getName()) ?>
                    <?php endif ?>
                    </th>
                    <th>
                        <?= $this->qlink(
                            '',
                            'dashboard/remove-pane',
                            array('pane' => $pane->getName()),
                            array(
                                'icon'  => 'cancel',
                                'class' => 'action-link',
                                'title' => sprintf($this->translate('Remove pane %s'), $pane->getName())
                            )
                        ); ?>
                    </th>
                </tr>
                <?php $dashlets = $pane->getDashlets(); ?>
                <?php if(empty($dashlets)): ?>
                    <tr>
                        <td colspan="3">
                            <?= $this->translate('No dashlets added to dashboard') ?>.
                        </td>
                    </tr>
                <?php else: ?>
                    <?php foreach ($dashlets as $dashlet): ?>
                    <?php if ($dashlet->getDisabled()) continue; ?>
                        <tr>
                            <td>
                                <?= $this->qlink(
                                    $dashlet->getTitle(),
                                    'dashboard/update-dashlet',
                                    array('pane' => $pane->getName(), 'dashlet' => $dashlet->getName()),
                                    array('title' => sprintf($this->translate('Edit dashlet %s'), $dashlet->getTitle()))
                                ); ?>
                            </td>
                            <td>
                                <?= $this->qlink(
                                    $dashlet->getUrl()->getRelativeUrl(),
                                    $dashlet->getUrl()->getRelativeUrl(),
                                    null,
                                    array('title' => sprintf($this->translate('Show dashlet %s'), $dashlet->getTitle()))
                                ); ?>
                            </td>
                            <td>
                                <?= $this->qlink(
                                    '',
                                    'dashboard/remove-dashlet',
                                    array('pane' => $pane->getName(), 'dashlet' => $dashlet->getName()),
                                    array(
                                        'icon'  => 'cancel',
                                        'class' => 'action-link',
                                        'title' => sprintf($this->translate('Remove dashlet %s from pane %s'), $dashlet->getTitle(), $pane->getTitle())
                                    )
                                ); ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>
