139 lines
5.2 KiB
PHP
139 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
*
|
|
* This file is part of a Moko Consulting project.
|
|
*
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* FILE INFORMATION
|
|
* DEFGROUP: MokoOnyx.Override
|
|
* INGROUP: MokoOnyx
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoOnyx
|
|
* PATH: /html/com_joomgallery/gallery/default.php
|
|
* VERSION: 02.10.00
|
|
* BRIEF: Gallery view override — main image grid with masonry/justified layout
|
|
*/
|
|
|
|
// No direct access
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Router\Route;
|
|
use Joomla\CMS\Language\Text;
|
|
use Joomla\CMS\Layout\LayoutHelper;
|
|
|
|
// Image params
|
|
$image_type = $this->params['configs']->get('jg_gallery_view_type_image', 'thumbnail', 'STRING');
|
|
$gallery_class = $this->params['configs']->get('jg_gallery_view_class', 'masonry', 'STRING');
|
|
$num_columns = $this->params['configs']->get('jg_gallery_view_num_columns', 3, 'INT');
|
|
$image_class = $this->params['configs']->get('jg_gallery_view_image_class', 0, 'INT');
|
|
$justified_height = $this->params['configs']->get('jg_gallery_view_justified_height', 200, 'INT');
|
|
$justified_gap = $this->params['configs']->get('jg_gallery_view_justified_gap', 5, 'INT');
|
|
$image_link = $this->params['configs']->get('jg_gallery_view_image_link', 'defaultview', 'STRING');
|
|
$lightbox_image = $this->params['configs']->get('jg_category_view_lightbox_image', 'detail', 'STRING');
|
|
$browse_categories_link = $this->params['configs']->get('jg_gallery_view_browse_categories_link', 1, 'INT');
|
|
|
|
// Import CSS & JS
|
|
$wa = $this->document->getWebAssetManager();
|
|
$wa->useStyle('com_joomgallery.site');
|
|
$wa->useStyle('com_joomgallery.jg-icon-font');
|
|
|
|
if ($gallery_class == 'masonry') {
|
|
$wa->useScript('com_joomgallery.masonry');
|
|
}
|
|
|
|
if ($gallery_class == 'justified') {
|
|
$wa->useScript('com_joomgallery.justified');
|
|
$wa->addInlineStyle('.jg-images[class*=" justified-"] .jg-image-caption-hover { right: ' . $justified_gap . 'px; }');
|
|
}
|
|
|
|
$lightbox = false;
|
|
if ($image_link == 'lightgallery') {
|
|
$lightbox = true;
|
|
$wa->useScript('com_joomgallery.lightgallery');
|
|
$wa->useScript('com_joomgallery.lg-thumbnail');
|
|
$wa->useStyle('com_joomgallery.lightgallery-bundle');
|
|
}
|
|
|
|
// Initialise the grid script
|
|
$iniJS = 'window.joomGrid = {';
|
|
$iniJS .= ' itemid: ' . $this->item->id . ',';
|
|
$iniJS .= ' pagination: 0,';
|
|
$iniJS .= ' layout: "' . $gallery_class . '",';
|
|
$iniJS .= ' num_columns: ' . $num_columns . ',';
|
|
$iniJS .= ' lightbox: ' . ($lightbox ? 'true' : 'false') . ',';
|
|
$iniJS .= ' justified: {height: ' . $justified_height . ', gap: ' . $justified_gap . '}';
|
|
$iniJS .= '};';
|
|
|
|
$wa->addInlineScript($iniJS, ['position' => 'before'], [], ['com_joomgallery.joomgrid']);
|
|
$wa->useScript('com_joomgallery.joomgrid');
|
|
?>
|
|
|
|
<div class="com-joomgallery-gallery" itemscope itemtype="https://schema.org/ImageGallery">
|
|
<?php if ($this->params['menu']->get('show_page_heading')) : ?>
|
|
<div class="page-header">
|
|
<h1><?php echo $this->escape($this->params['menu']->get('page_heading')); ?></h1>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php // Browse categories link (top) ?>
|
|
<?php if ($browse_categories_link == '1') : ?>
|
|
<div class="text-center mb-4">
|
|
<a class="btn btn-outline-primary" href="<?php echo Route::_('index.php?option=com_joomgallery&view=category&id=1'); ?>">
|
|
<i class="jg-icon-folder me-1" aria-hidden="true"></i><?php echo Text::_('COM_JOOMGALLERY_GALLERY_VIEW_BROWSE_CATEGORIES'); ?>
|
|
</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($this->item->images->items) == 0) : ?>
|
|
<div class="alert alert-info" role="alert">
|
|
<p class="mb-0"><?php echo Text::_('COM_JOOMGALLERY_GALLERY_NO_IMAGES'); ?></p>
|
|
</div>
|
|
<?php else : ?>
|
|
<?php
|
|
$imgsData = [
|
|
'id' => (int) $this->item->id,
|
|
'layout' => $gallery_class,
|
|
'items' => $this->item->images->items,
|
|
'num_columns' => (int) $num_columns,
|
|
'caption_align' => 'center',
|
|
'image_class' => $image_class,
|
|
'image_type' => $image_type,
|
|
'lightbox_type' => $lightbox_image,
|
|
'image_link' => $image_link,
|
|
'image_title' => false,
|
|
'title_link' => 'defaultview',
|
|
'image_desc' => false,
|
|
'image_date' => false,
|
|
'image_author' => false,
|
|
'image_tags' => false,
|
|
];
|
|
?>
|
|
<?php echo LayoutHelper::render('joomgallery.grids.images', $imgsData); ?>
|
|
|
|
<?php // Pagination ?>
|
|
<nav class="mt-4" aria-label="<?php echo Text::_('JLIB_HTML_PAGINATION'); ?>">
|
|
<?php echo $this->item->images->pagination->getListFooter(); ?>
|
|
</nav>
|
|
<?php endif; ?>
|
|
|
|
<?php // Browse categories link (bottom) ?>
|
|
<?php if ($browse_categories_link == '2') : ?>
|
|
<div class="text-center mt-4">
|
|
<a class="btn btn-outline-primary" href="<?php echo Route::_('index.php?option=com_joomgallery&view=category&id=1'); ?>">
|
|
<i class="jg-icon-folder me-1" aria-hidden="true"></i><?php echo Text::_('COM_JOOMGALLERY_GALLERY_VIEW_BROWSE_CATEGORIES'); ?>
|
|
</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<script>
|
|
if (window.joomGrid.layout != 'justified') {
|
|
document.querySelectorAll('.' + window.joomGrid.imgclass).forEach(function(image) {
|
|
image.addEventListener('load', function() {
|
|
this.closest('.' + window.joomGrid.imgboxclass).classList.add('loaded');
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
</div>
|