Initial import of animal_management module
This commit is contained in:
104
views/gallery/animal_gallery_view.php
Normal file
104
views/gallery/animal_gallery_view.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
use humhub\libs\Html;
|
||||
use humhub\modules\animal_management\models\Animal;
|
||||
use humhub\modules\animal_management\models\AnimalGalleryItem;
|
||||
use humhub\modules\gallery\assets\Assets as GalleryAssets;
|
||||
use humhub\modules\gallery\helpers\Url;
|
||||
use humhub\modules\gallery\models\CustomGallery;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\widgets\Button;
|
||||
|
||||
/* @var CustomGallery $gallery */
|
||||
/* @var Animal|null $animal */
|
||||
/* @var AnimalGalleryItem[] $items */
|
||||
/* @var Space $container */
|
||||
/* @var bool|string $showMore */
|
||||
|
||||
GalleryAssets::register($this);
|
||||
|
||||
$animalName = $animal instanceof Animal ? $animal->getDisplayName() : Yii::t('AnimalManagementModule.base', 'Animal');
|
||||
$backUrl = Url::toGalleryOverview($container);
|
||||
$animalUrl = $animal instanceof Animal
|
||||
? $container->createUrl('/animal_management/animals/view', ['id' => (int)$animal->id])
|
||||
: null;
|
||||
$uiGalleryId = 'animal-gallery-native-' . (int)$gallery->id;
|
||||
$descriptionText = preg_replace('/\s*\[animal-gallery:\d+\]\s*/', ' ', (string)$gallery->description);
|
||||
$descriptionText = trim((string)$descriptionText);
|
||||
$headerTitle = trim((string)$gallery->title);
|
||||
$headerTitle = preg_replace('/\s+Gallery\s*$/i', '', $headerTitle);
|
||||
if ($headerTitle === '') {
|
||||
$headerTitle = $animalName;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="gallery-container" class="panel panel-default">
|
||||
<div class="panel-heading clearfix" style="background-color: <?= $this->theme->variable('background-color-secondary') ?>;">
|
||||
<div style="margin-right:40px;" class="pull-left">
|
||||
<?= Yii::t('GalleryModule.base', '<strong>Gallery</strong> ') . Html::encode($headerTitle) ?>
|
||||
</div>
|
||||
|
||||
<?= Button::back($backUrl, Yii::t('GalleryModule.base', 'Back to overview'))->right()->sm() ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?php if ($animalUrl !== null): ?>
|
||||
<div style="margin-bottom:10px;">
|
||||
<?= Html::a(Html::encode($animalName), $animalUrl, ['style' => 'font-size:20px;font-weight:700;line-height:1.2;']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($descriptionText !== ''): ?>
|
||||
<div class="row clearfix" style="padding-bottom:8px;">
|
||||
<div class="col-sm-12 gallery-description">
|
||||
<i class="fa fa-arrow-circle-right"></i>
|
||||
<?= Html::encode($descriptionText) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="gallery-list" class="col">
|
||||
<div id="gallery-media-container" class="row">
|
||||
<?php if (empty($items)): ?>
|
||||
<div class="col-sm-12 text-muted" style="margin-bottom:10px;">
|
||||
<?= Yii::t('AnimalManagementModule.base', 'No gallery images yet.') ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php
|
||||
if (!$item instanceof AnimalGalleryItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$imageUrl = trim((string)$item->getImageUrl());
|
||||
if ($imageUrl === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = trim((string)$item->caption);
|
||||
$altText = $title !== '' ? $title : $animalName;
|
||||
?>
|
||||
<div class="col-sm-6 col-md-4 gallery-list-entry" style="margin-bottom:12px;">
|
||||
<a href="<?= Html::encode($imageUrl) ?>#.jpeg"
|
||||
data-type="image"
|
||||
data-toggle="lightbox"
|
||||
data-parent="#gallery-content"
|
||||
data-ui-gallery="<?= Html::encode($uiGalleryId) ?>"
|
||||
data-description="<?= Html::encode($title) ?>"
|
||||
title="<?= Html::encode($title) ?>"
|
||||
style="display:block;position:relative;aspect-ratio:4 / 3;background:#d8dee8;border-radius:12px;overflow:hidden;box-shadow:0 8px 24px rgba(15,23,42,0.14);">
|
||||
<img class="gallery-img" src="<?= Html::encode($imageUrl) ?>" alt="<?= Html::encode($altText) ?>" style="display:none;position:absolute;inset:0;width:100%;height:100%;object-fit:cover;"/>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($showMore): ?>
|
||||
<div style="text-align:center;">
|
||||
<?= Button::primary(Yii::t('GalleryModule.base', 'Show more'))->action('gallery.showMore', (string)$showMore) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user