<?php
/**
 * @version 7.9 [rev.7.9.01]
 */
?>
<nav class="navbar navbar-filter">
    <div class="navbar-left">

        <a class="btn btn-default"
           href="<?php echo $this->url(array('action' => 'add-page')); ?>">
            <?php echo $this->_('Create Page'); ?>
        </a>

        <a class="btn btn-default"
           href="<?php echo $this->url(array('controller' => 'tables', 'action' => 'index', 'table' => 'relational.ContentSections'), null, false, null, true, false); ?>">
            <?php echo $this->_('View Sections'); ?>
        </a>

    </div>

    <form class="navbar-form navbar-right"
          action="<?php echo $this->url(null, null, true, array('title', 'submit')); ?>"
          method="get">
        <div class="form-group">
            <?php echo $this->formElement('text', 'title', $this->title)
                ->setAttributes(array('placeholder' => $this->_('Page Name'), 'class' => 'form-control input-medium'))
                ->render();
            ?>
        </div>
        <?php echo $this->formElement('submit', 'submit', $this->_('Search'))
            ->setAttributes(array('class' => 'btn btn-default'))
            ->render();
        ?>
    </form>
</nav>
<div class="table-responsive">
    <table class="table table-striped table-hover">
        <caption>
            <strong><?php echo $this->paginator->getPages()->totalItemCount; ?></strong> <?php echo $this->_('pages found.'); ?>

            <?php if ($this->paginator->getPages()->totalItemCount) { ?>
                <?php echo $this->_('Showing results'); ?>
                <strong><?php echo $this->paginator->getPages()->firstItemNumber; ?></strong>
                <?php echo $this->_('to'); ?>
                <strong><?php echo $this->paginator->getPages()->lastItemNumber; ?></strong>
            <?php } ?>
        </caption>
        <?php if ($this->paginator->getPages()->totalItemCount) { ?>
            <thead>
            <tr>
                <th class="size-large"><?php echo $this->_('Section'); ?></th>
                <th><?php echo $this->_('Title'); ?></th>
                <th class="size-tiny"><?php echo $this->_('Language'); ?></th>
                <th class="size-mini"><?php echo $this->_('Date'); ?></th>
                <th class="size-tiny"></th>
            </tr>
            </thead>
        <?php } ?>
        <tbody>
        <?php
        /** @var \Cube\Db\Table\Row $page */
        foreach ($this->paginator as $page) {
            ?>
            <tr>

                <td>
                    <?php echo $this->contentSections()->getContentSections()->getFullName($page['section_id']); ?>
                </td>
                <td>
                    <?php echo $this->fieldDisplay($page['title'], null, '-'); ?>
                </td>
                <td>
                    <?php echo $page['language']; ?>
                </td>
                <td>
                    <?php echo $this->date(max(array($page['created_at'], $page['updated_at'])), true); ?>
                </td>
                <td>
                    <div class="btn-group-vertical">
                        <a class="btn btn-default btn-sm"
                           href="<?php echo $this->url(array('action' => 'edit-page', 'id' => $page['id'])); ?>"
                           title="<?php echo $this->_('Edit Page'); ?>">
                            <i class="fa fa-folder-open"></i>
                        </a>
                        <a class="btn btn-danger btn-sm confirm-box"
                           href="<?php echo $this->url(array('action' => 'delete-page', 'id' => $page['id']),
                               null, true); ?>"
                           title="<?php echo $this->_('Delete Page'); ?>"
                           data-message="<?php echo $this->_('Are you sure you want to delete this page?'); ?>">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
</div>

<?php echo $this->pagination($this->paginator, 'sliding', 'partials/pagination.phtml'); ?>