View file modules/downloads/templates/view.phtml

File size: 6.7Kb
<?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 $in_bookmarks
 * @var $file
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title,
    ]
);
?>

<?php if (! $config['mod_down']): ?>
    <div class="alert alert-danger border-0 shadow">
        <?= __('Downloads are closed') ?>
    </div>
<?php endif; ?>

<?php if (isset($file['vote_accepted'])): ?>
    <div class="row">
        <div class="col-md-6">
            <div class="alert alert-success border-0 shadow">
                <?= __('Vote accepted') ?>
            </div>
        </div>
    </div>
<?php endif; ?>

<?php if (! empty($file['screenshots'])): ?>
    <div class="<?= count($file['screenshots']) > 1 ? 'screenshots' : '' ?> border-bottom mb-2 pb-3 swiper-container">
        <div class="swiper-wrapper image-gallery">
            <?php foreach ($file['screenshots'] as $number => $screenshot): ?>
                <div class="swiper-slide <?= count($file['screenshots']) < 2 ? 'text-left' : '' ?>">
                    <a href="<?= $screenshot['url'] ?>"
                       title="<?= __('Screenshot:') ?> <?= ($number + 1) ?>"
                       data-source="<?= $screenshot['url'] ?>"
                       class="gallery-item">
                        <img src="<?= $screenshot['preview'] ?>" alt=".">
                    </a>
                </div>
            <?php endforeach; ?>
        </div>
        <div class="swiper-pagination"></div>
    </div>
<?php endif; ?>

<?php if ($file['file_type'] === 'audio'): ?>
    <div class="row">
        <div class="col-xl-8">
            <audio src="<?= $file['main_file']['source_url'] ?>" controls></audio>
        </div>
    </div>
<?php endif; ?>

<?php if ($file['file_type'] === 'video'): ?>
    <div class="row">
        <div class="col-xl-8">
            <div class="embed-responsive embed-responsive-16by9">
                <video src="<?= $file['main_file']['source_url'] ?>" controls></video>
            </div>
        </div>
    </div>
<?php endif; ?>

<?php if (! empty($file['description'])): ?>
    <div class="border-bottom pb-2">
        <?= $file['description'] ?>
    </div>
<?php endif; ?>

<?php if (! empty($file['file_properties'])): ?>
    <div class="mt-2 mb-3 border-bottom pb-2">
        <?php foreach ($file['file_properties'] as $property): ?>
            <div><?= $property['name'] ?>: <?= $property['value'] ?></div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>

<div class="text-muted mt-2 mb-3 border-bottom pb-2">
    <div><?= __('File name:') ?> <?= $file['name'] ?></div>
    <div><?= __('Uploaded by:') ?> <?= $file['upload_user']['name'] ?></div>
    <div><?= __('Downloads:') ?> <?= $file['field'] ?></div>
    <div><?= __('Rating:') ?>
        <?php if ($file['can_vote']): ?>
            <a href="?act=view&amp;id=<?= $id ?>&amp;plus" class="btn btn-sm btn-light">
                <svg class="icon download-button-icon mr-1 mt-n1">
                    <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#like"/>
                </svg>
            </a>
        <?php endif; ?>
        <span><?= implode(' / ', $file['rate']) ?></span>
        <?php if ($file['can_vote']): ?>
            <a href="?act=view&amp;id=<?= $id ?>&amp;minus" class="btn btn-sm btn-light">
                <svg class="icon download-button-icon mr-1 mt-n1">
                    <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#dislike"/>
                </svg>
            </a>
        <?php endif; ?>
    </div>
</div>
<div class="mb-1">
    <svg class="icon download-button-icon mr-1 mt-n1">
        <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#download"/>
    </svg>
    <a href="<?= $file['main_file']['url'] ?>"><?= $file['main_file']['name'] ?></a> (<?= $file['main_file']['size'] ?>)
</div>
<?php if (! empty($file['additional_files'])): ?>
    <?php foreach ($file['additional_files'] as $additional_file): ?>
        <div class="mb-1">
            <svg class="icon download-button-icon mr-1 mt-n1">
                <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#download"/>
            </svg>
            <a href="<?= $additional_file['url'] ?>"><?= $additional_file['name'] ?></a> (<?= $additional_file['size'] ?>)
        </div>
    <?php endforeach; ?>
<?php endif; ?>
<div class="border-bottom mt-3"></div>
<?php if ($config['mod_down_comm'] || $systemUser->rights >= 7): ?>
    <div class="mt-3">
        <svg class="icon download-button-icon mr-1">
            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#forum"/>
        </svg>
        <a href="?act=comments&amp;id=<?= $id ?>"><?= __('Comments') ?></a> (<?= $file['comm_count'] ?>)
    </div>
<?php endif; ?>
<div class="mt-4">
    <?php if ($user->rights === 4 || $user->rights >= 6): ?>
        <div class="btn-group">
            <div class="dropdown">
                <button class="btn btn-danger dropdown-toggle btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <?= __('Actions') ?>
                </button>
                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                    <?php if (! empty($id)): ?>
                        <a class="dropdown-item" href="?act=edit_file&amp;id=<?= $id ?>"><?= __('Edit File') ?></a>
                        <a class="dropdown-item" href="?act=edit_screen&amp;id=<?= $id ?>"><?= __('Managing Screenshots') ?></a>
                        <a class="dropdown-item" href="?act=files_more&amp;id=<?= $id ?>"><?= __('Additional Files') ?></a>
                        <a class="dropdown-item" href="?act=delete_file&amp;do=clean&amp;id=<?= $id ?>"><?= __('Delete File') ?></a>
                        <a class="dropdown-item" href="?act=transfer_file&amp;id=<?= $id ?>"><?= __('Move File') ?></a>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    <?php endif; ?>
    <?php if ($user->isValid()): ?>
        <div class="mt-3">
            <?php if ($in_bookmarks): ?>
                <a href="?act=view&amp;id=<?= $id ?>&amp;delBookmark"><?= __('Remove from Favorites') ?></a>
            <?php else: ?>
                <a href="?act=view&amp;id=<?= $id ?>&amp;addBookmark"><?= __('Add to Favorites') ?></a>
            <?php endif; ?>
        </div>
    <?php endif; ?>

    <div class="mt-2">
        <div>
            <a href="<?= $urls['back'] ?>"><?= __('Back') ?></a>
        </div>
        <div>
            <a href="<?= $urls['downloads'] ?>"><?= __('Downloads') ?></a>
        </div>
    </div>
</div>