<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var $title
 * @var $page_title
 * @var $data
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title,
    ]
);
?>
<div class="mb-3">
    <?= $this->fetch('album::user_row', ['item' => $data['user']]) ?>
</div>

<?php if (! empty($data['create_url'])): ?>
    <div class="mb-3">
        <a href="<?= $data['create_url'] ?>" class="btn btn-primary"><?= __('Create Album') ?></a>
    </div>
<?php endif; ?>

<?php foreach ($data['albums'] as $album): ?>
    <div class="forum-section mb-2">
        <div class="section-header d-flex justify-content-between <?= (empty($album['description']) ? 'border-0 pb-0' : '') ?>">
            <div class="d-flex align-items-center">
                <a class="user-login mr-2" href="<?= $album['album_url'] ?>"><?= $album['name'] ?></a>
                <span class="badge badge-pill badge-light border ml-3"><?= $album['count_photos'] ?></span>
            </div>
        </div>
        <?php if (! empty($album['description'])): ?>
            <div class="small pt-1 text-muted">
                <div><?= $album['description'] ?></div>
            </div>
        <?php endif; ?>
        <?php if (! empty($album['has_edit'])): ?>
            <div class="pt-1 small">
                <a href="<?= $album['up_url'] ?>" class="mr-2"><?= __('Up') ?></a>
                <a href="<?= $album['down_url'] ?>" class="mr-2"><?= __('Down') ?></a>
                <a href="<?= $album['edit_url'] ?>" class="mr-2"><?= __('Edit') ?></a>
                <a href="<?= $album['delete_url'] ?>" class="mr-2"><?= __('Delete') ?></a>
            </div>
        <?php endif; ?>
    </div>
<?php endforeach; ?>
