Commit e5f9e5fe authored by Tino Goratsch's avatar Tino Goratsch

Merge branch 'release/v4.31.0'

parents 4ccd8fae 542f4a7b
Pipeline #33714684 passed with stages
in 8 minutes and 57 seconds
......@@ -16,7 +16,7 @@ interface BootstrapInterface extends HttpKernelInterface
/**
* Contains the current ACP3 version string.
*/
const VERSION = '4.30.4';
const VERSION = '4.31.0';
/**
* Performs some startup checks.
......
......@@ -35,6 +35,7 @@ abstract class AbstractFormValidation
/**
* @param array $formData
*
* @throws \ACP3\Core\Validation\Exceptions\ValidationRuleNotFoundException
* @throws \ACP3\Core\Validation\Exceptions\InvalidFormTokenException
* @throws \ACP3\Core\Validation\Exceptions\ValidationFailedException
*/
......
......@@ -63,7 +63,7 @@ class Details extends Core\Controller\AbstractFrontendAction
* @throws Core\Controller\Exception\ResultNotExistsException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($id)
public function execute(int $id)
{
if ($this->filesRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) {
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
......
......@@ -61,7 +61,7 @@ class Download extends Core\Controller\AbstractFrontendAction
* @throws Core\Controller\Exception\ResultNotExistsException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($id)
public function execute(int $id)
{
if ($this->filesRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) {
$file = $this->filesCache->getCache($id);
......
......@@ -58,7 +58,7 @@ class Files extends Core\Controller\AbstractFrontendAction
* @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($cat)
public function execute(int $cat)
{
if ($this->categoryRepository->resultExists($cat) === true) {
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
......
......@@ -84,6 +84,8 @@ class FilesRepository extends Core\Model\Repository\AbstractRepository
* @param int|null $categoryId
*
* @return int
*
* @throws \Doctrine\DBAL\DBALException
*/
public function countAll(string $time = '', ?int $categoryId = null)
{
......
......@@ -17,11 +17,11 @@
"prefer-stable": true,
"require": {
"acp3/composer-installer": "^1.0",
"acp3/core": "^4.30.4",
"acp3/core": "^4.31.0",
"acp3/setup": "^4.30.0",
"acp3/module-errors": "^4.29.4",
"acp3/module-permissions": "^4.30.0",
"acp3/module-system": "^4.30.0",
"acp3/module-system": "^4.31.0",
"acp3/module-users": "^4.30.0",
"acp3/module-categories": "^4.30.2"
},
......
......@@ -59,6 +59,7 @@ class Cache extends Core\Modules\AbstractCacheStorage
* @return array
*
* @throws \ACP3\Core\Picture\Exception\PictureGenerateException
* @throws \Doctrine\DBAL\DBALException
*/
public function getCache(int $galleryId)
{
......@@ -77,6 +78,7 @@ class Cache extends Core\Modules\AbstractCacheStorage
* @return bool
*
* @throws \ACP3\Core\Picture\Exception\PictureGenerateException
* @throws \Doctrine\DBAL\DBALException
*/
public function saveCache(int $galleryId)
{
......
......@@ -24,17 +24,23 @@ class Create extends Core\Controller\AbstractFrontendAction
* @var Gallery\Model\GalleryModel
*/
protected $galleryModel;
/**
* @var \ACP3\Core\Helpers\Forms
*/
private $formsHelper;
/**
* Create constructor.
*
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param Gallery\Model\GalleryModel $galleryModel
* @param \ACP3\Modules\ACP3\Gallery\Validation\GalleryFormValidation $galleryFormValidation
*/
public function __construct(
Core\Controller\Context\FrontendContext $context,
Core\Helpers\Forms $formsHelper,
Core\Helpers\FormToken $formTokenHelper,
Gallery\Model\GalleryModel $galleryModel,
Gallery\Validation\GalleryFormValidation $galleryFormValidation
......@@ -44,6 +50,7 @@ class Create extends Core\Controller\AbstractFrontendAction
$this->formTokenHelper = $formTokenHelper;
$this->galleryModel = $galleryModel;
$this->galleryFormValidation = $galleryFormValidation;
$this->formsHelper = $formsHelper;
}
/**
......@@ -53,11 +60,13 @@ class Create extends Core\Controller\AbstractFrontendAction
{
$defaults = [
'title' => '',
'description' => '',
'start' => '',
'end' => '',
];
return [
'active' => $this->formsHelper->yesNoCheckboxGenerator('active', 1),
'form' => \array_merge($defaults, $this->request->getPost()->all()),
'form_token' => $this->formTokenHelper->renderFormToken(),
'SEO_URI_PATTERN' => Gallery\Helpers::URL_KEY_PATTERN_GALLERY,
......@@ -67,6 +76,8 @@ class Create extends Core\Controller\AbstractFrontendAction
/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @throws \Doctrine\DBAL\ConnectionException
*/
public function executePost()
{
......
......@@ -24,17 +24,23 @@ class Edit extends Core\Controller\AbstractFrontendAction
* @var Gallery\Model\GalleryModel
*/
protected $galleryModel;
/**
* @var \ACP3\Core\Helpers\Forms
*/
private $formsHelper;
/**
* Edit constructor.
*
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param Gallery\Model\GalleryModel $galleryModel
* @param \ACP3\Modules\ACP3\Gallery\Validation\GalleryFormValidation $galleryFormValidation
*/
public function __construct(
Core\Controller\Context\FrontendContext $context,
Core\Helpers\Forms $formsHelper,
Core\Helpers\FormToken $formTokenHelper,
Gallery\Model\GalleryModel $galleryModel,
Gallery\Validation\GalleryFormValidation $galleryFormValidation
......@@ -44,6 +50,7 @@ class Edit extends Core\Controller\AbstractFrontendAction
$this->formTokenHelper = $formTokenHelper;
$this->galleryModel = $galleryModel;
$this->galleryFormValidation = $galleryFormValidation;
$this->formsHelper = $formsHelper;
}
/**
......@@ -52,8 +59,9 @@ class Edit extends Core\Controller\AbstractFrontendAction
* @return array
*
* @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($id)
public function execute(int $id)
{
$gallery = $this->galleryModel->getOneById($id);
......@@ -61,6 +69,7 @@ class Edit extends Core\Controller\AbstractFrontendAction
$this->title->setPageTitlePrefix($gallery['title']);
return [
'active' => $this->formsHelper->yesNoCheckboxGenerator('active', $gallery['active']),
'form' => \array_merge($gallery, $this->request->getPost()->all()),
'form_token' => $this->formTokenHelper->renderFormToken(),
'SEO_URI_PATTERN' => Gallery\Helpers::URL_KEY_PATTERN_GALLERY,
......@@ -75,8 +84,10 @@ class Edit extends Core\Controller\AbstractFrontendAction
* @param int $id
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @throws \Doctrine\DBAL\ConnectionException
*/
public function executePost($id)
public function executePost(int $id)
{
return $this->actionHelper->handleSaveAction(function () use ($id) {
$formData = $this->request->getPost()->all();
......
......@@ -65,11 +65,21 @@ class Index extends Core\Controller\AbstractFrontendAction
protected function addDataGridColumns(Core\DataGrid\Input $input)
{
$input
->addColumn([
'label' => $this->translator->t('gallery', 'active'),
'type' => Core\DataGrid\ColumnRenderer\ReplaceValueColumnRenderer::class,
'fields' => ['active'],
'custom' => [
'search' => [0, 1],
'replace' => [$this->translator->t('system', 'no'), $this->translator->t('system', 'yes')],
],
], 40)
->addColumn([
'label' => $this->translator->t('system', 'publication_period'),
'type' => Core\DataGrid\ColumnRenderer\DateColumnRenderer::class,
'fields' => ['start', 'end'],
'default_sort' => true,
'default_sort_direction' => 'desc',
], 30)
->addColumn([
'label' => $this->translator->t('gallery', 'title'),
......
......@@ -69,8 +69,9 @@ class Create extends AbstractFormAction
* @return array
*
* @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($id)
public function execute(int $id)
{
if ($this->galleryRepository->galleryExists($id) === true) {
$gallery = $this->galleryRepository->getGalleryTitle($id);
......@@ -84,7 +85,7 @@ class Create extends AbstractFormAction
}
return [
'form' => \array_merge(['description' => ''], $this->request->getPost()->all()),
'form' => \array_merge(['title' => '', 'description' => ''], $this->request->getPost()->all()),
'gallery_id' => $id,
'form_token' => $this->formTokenHelper->renderFormToken(),
];
......@@ -97,8 +98,10 @@ class Create extends AbstractFormAction
* @param int $id
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @throws \Doctrine\DBAL\ConnectionException
*/
public function executePost($id)
public function executePost(int $id)
{
return $this->actionHelper->handleSaveAction(
function () use ($id) {
......@@ -110,7 +113,7 @@ class Create extends AbstractFormAction
$this->pictureFormValidation
->setFileRequired(true)
->setFile($file)
->validate([]);
->validate($formData);
$result = $this->galleryUploadHelper->moveFile($file->getPathname(), $file->getClientOriginalName());
......
......@@ -33,23 +33,29 @@ class Edit extends AbstractFormAction
* @var \ACP3\Core\Helpers\Upload
*/
private $galleryUploadHelper;
/**
* @var \ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository
*/
private $galleryRepository;
/**
* Edit constructor.
*
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Modules\ACP3\Gallery\Helpers $galleryHelpers
* @param Gallery\Model\PictureModel $pictureModel
* @param \ACP3\Modules\ACP3\Gallery\Validation\PictureFormValidation $pictureFormValidation
* @param \ACP3\Core\Helpers\Upload $galleryUploadHelper
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Helpers\Forms $formsHelper
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Modules\ACP3\Gallery\Helpers $galleryHelpers
* @param \ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository $galleryRepository
* @param Gallery\Model\PictureModel $pictureModel
* @param \ACP3\Modules\ACP3\Gallery\Validation\PictureFormValidation $pictureFormValidation
* @param \ACP3\Core\Helpers\Upload $galleryUploadHelper
*/
public function __construct(
Core\Controller\Context\FrontendContext $context,
Core\Helpers\Forms $formsHelper,
Core\Helpers\FormToken $formTokenHelper,
Gallery\Helpers $galleryHelpers,
Gallery\Model\Repository\GalleryRepository $galleryRepository,
Gallery\Model\PictureModel $pictureModel,
Gallery\Validation\PictureFormValidation $pictureFormValidation,
Core\Helpers\Upload $galleryUploadHelper
......@@ -61,6 +67,7 @@ class Edit extends AbstractFormAction
$this->pictureFormValidation = $pictureFormValidation;
$this->pictureModel = $pictureModel;
$this->galleryUploadHelper = $galleryUploadHelper;
$this->galleryRepository = $galleryRepository;
}
/**
......@@ -69,8 +76,9 @@ class Edit extends AbstractFormAction
* @return array|\Symfony\Component\HttpFoundation\RedirectResponse
*
* @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($id)
public function execute(int $id)
{
$picture = $this->pictureModel->getOneById($id);
......@@ -92,6 +100,11 @@ class Edit extends AbstractFormAction
return [
'form' => \array_merge($picture, $this->request->getPost()->all()),
'galleries' => $this->formsHelper->choicesGenerator(
'gallery_id',
$this->getGalleries(),
$picture['gallery_id']
),
'gallery_id' => $picture['gallery_id'],
'form_token' => $this->formTokenHelper->renderFormToken(),
];
......@@ -100,12 +113,30 @@ class Edit extends AbstractFormAction
throw new Core\Controller\Exception\ResultNotExistsException();
}
/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
private function getGalleries(): array
{
$galleries = [];
foreach ($this->galleryRepository->getAll() as $gallery) {
$galleries[$gallery['id']] = $gallery['title'];
}
return $galleries;
}
/**
* @param int $id
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @throws \Doctrine\DBAL\ConnectionException
* @throws \Doctrine\DBAL\DBALException
*/
public function executePost($id)
public function executePost(int $id)
{
$picture = $this->pictureModel->getOneById($id);
......@@ -118,7 +149,7 @@ class Edit extends AbstractFormAction
$this->pictureFormValidation
->setFileRequired(false)
->setFile($file)
->validate([]);
->validate($formData);
if (!empty($file)) {
$result = $this->galleryUploadHelper->moveFile($file->getPathname(), $file->getClientOriginalName());
......@@ -128,8 +159,6 @@ class Edit extends AbstractFormAction
$formData['file'] = $result['name'];
}
$formData['gallery_id'] = $picture['gallery_id'];
return $this->pictureModel->save($formData, $id);
},
'acp/gallery/pictures/index/id_' . $picture['gallery_id']
......
......@@ -102,6 +102,11 @@ class Index extends AbstractFrontendAction
},
],
], 40)
->addColumn([
'label' => $this->translator->t('gallery', 'title'),
'type' => Core\DataGrid\ColumnRenderer\TextColumnRenderer::class,
'fields' => ['title'],
], 35)
->addColumn([
'label' => $this->translator->t('system', 'description'),
'type' => Core\DataGrid\ColumnRenderer\TextColumnRenderer::class,
......
......@@ -70,10 +70,16 @@ class Details extends AbstractAction
$this->breadcrumb
->append($this->translator->t('gallery', 'gallery'), 'gallery')
->append($picture['gallery_title'], 'gallery/index/pics/id_' . $picture['gallery_id'])
->append($this->translator->t('gallery', 'picture_x', ['%picture%' => $picture['pic']]));
->append($picture['gallery_title'], 'gallery/index/pics/id_' . $picture['gallery_id']);
$this->title->setPageTitlePrefix($picture['gallery_title']);
if (!empty($picture['title'])) {
$this->breadcrumb->append($picture['title']);
} else {
$this->breadcrumb
->append($this->translator->t('gallery', 'picture_x', ['%picture%' => $picture['pic']]));
}
$this->title->setPageTitlePostfix($picture['gallery_title']);
$output = $this->thumbnailGenerator->generateThumbnail($picture['file'], '');
$picture['file'] = $output->getFileWeb();
......
......@@ -55,22 +55,24 @@ class Pics extends AbstractAction
* @return array
*
* @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
* @throws \ACP3\Core\Picture\Exception\PictureGenerateException
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($id)
public function execute(int $id)
{
if ($this->galleryRepository->galleryExists($id, $this->date->getCurrentDateTime()) === true) {
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$galleryTitle = $this->galleryRepository->getGalleryTitle($id);
$gallery = $this->galleryRepository->getOneById($id);
$this->breadcrumb
->append($this->translator->t('gallery', 'gallery'), 'gallery')
->append($galleryTitle);
$this->title->setPageTitle($galleryTitle);
->append($gallery['title']);
$this->title->setPageTitle($gallery['title']);
return [
'pictures' => $this->galleryCache->getCache($id),
'gallery' => $gallery,
'overlay' => (int) $this->settings['overlay'],
];
}
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Modules\ACP3\Gallery\Controller\Widget\Index;
use ACP3\Core\Cache\CacheResponseTrait;
use ACP3\Core\Controller\AbstractWidgetAction;
use ACP3\Core\Controller\Context\WidgetContext;
use ACP3\Modules\ACP3\Gallery\Cache;
use ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository;
use ACP3\Modules\ACP3\System\Installer\Schema;
class Pictures extends AbstractWidgetAction
{
use CacheResponseTrait;
/**
* @var GalleryRepository
*/
private $galleryRepository;
/**
* @var Cache
*/
private $galleryCache;
/**
* Pictures constructor.
*
* @param WidgetContext $context
* @param GalleryRepository $galleryRepository
* @param Cache $galleryCache
*/
public function __construct(
WidgetContext $context,
GalleryRepository $galleryRepository,
Cache $galleryCache
) {
parent::__construct($context);
$this->galleryRepository = $galleryRepository;
$this->galleryCache = $galleryCache;
}
/**
* @param int $id
* @param string $template
*
* @return array
*
* @throws \Doctrine\DBAL\DBALException
* @throws \ACP3\Core\Picture\Exception\PictureGenerateException
*/
public function execute(int $id, string $template = '')
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$this->setTemplate(\urldecode($template));
return [
'gallery' => $this->galleryRepository->getOneById($id),
'pictures' => $this->galleryCache->getCache($id),
];
}
}
......@@ -73,6 +73,19 @@ class Migration extends Modules\Installer\AbstractMigration
'ALTER TABLE `{pre}gallery_pictures` MODIFY COLUMN `description` TEXT {charset} NOT NULL;',
'ALTER TABLE `{pre}gallery_pictures` CONVERT TO {charset};',
],
44 => [
'ALTER TABLE `{pre}gallery_pictures` ADD COLUMN `title` VARCHAR(120) NOT NULL AFTER `file`;',
],
45 => [
'ALTER TABLE `{pre}gallery` ADD COLUMN `description` TEXT NOT NULL AFTER `title`;',
],
46 => [
"INSERT INTO `{pre}acl_resources` (`id`, `module_id`, `area`, `controller`, `page`, `params`, `privilege_id`) VALUES('', '{moduleId}', 'widget', 'index', 'pictures', '', 1);",
],
47 => [
'ALTER TABLE `{pre}gallery` ADD COLUMN `active` TINYINT(1) NOT NULL AFTER `id`;',
'UPDATE `{pre}gallery` SET `active` = 1',
],
];
}
......
......@@ -47,6 +47,7 @@ class Schema implements Modules\Installer\SchemaInterface
'widget' => [
'index' => [
'index' => PrivilegeEnum::FRONTEND_VIEW,
'pictures' => PrivilegeEnum::FRONTEND_VIEW,
],
],
];
......@@ -65,7 +66,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getSchemaVersion()
{
return 43;
return 47;
}
/**
......@@ -76,10 +77,12 @@ class Schema implements Modules\Installer\SchemaInterface
return [
'CREATE TABLE `{pre}gallery` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`active` TINYINT(1) NOT NULL,
`start` DATETIME NOT NULL,
`end` DATETIME NOT NULL,
`updated_at` DATETIME NOT NULL,
`title` VARCHAR(120) NOT NULL,
`description` TEXT NOT NULL,
`user_id` INT UNSIGNED,
PRIMARY KEY (`id`),
INDEX (`user_id`),
......@@ -90,6 +93,7 @@ class Schema implements Modules\Installer\SchemaInterface
`pic` INT(10) UNSIGNED NOT NULL,
`gallery_id` INT(10) UNSIGNED NOT NULL,
`file` VARCHAR(120) NOT NULL,
`title` VARCHAR(120) NOT NULL,
`description` TEXT NOT NULL,
`comments` TINYINT(1) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
......
......@@ -32,10 +32,12 @@ class GalleryModel extends AbstractModel implements UpdatedAtAwareModelInterface
protected function getAllowedColumns()
{
return [
'active' => DataProcessor\ColumnTypes::COLUMN_TYPE_BOOLEAN,
'start' => DataProcessor\ColumnTypes::COLUMN_TYPE_DATETIME,
'end' => DataProcessor\ColumnTypes::COLUMN_TYPE_DATETIME,
'updated_at' => DataProcessor\ColumnTypes::COLUMN_TYPE_DATETIME,
'title' => DataProcessor\ColumnTypes::COLUMN_TYPE_TEXT,
'description' => DataProcessor\ColumnTypes::COLUMN_TYPE_TEXT_WYSIWYG,
'user_id' => DataProcessor\ColumnTypes::COLUMN_TYPE_INT,
];
}
......
......@@ -60,13 +60,32 @@ class PictureModel extends AbstractModel
]);
if ($entryId === null) {
$picNum = $this->repository->getLastPictureByGalleryId($data['gallery_id']);
$data['pic'] = !\is_null($picNum) ? $picNum + 1 : 1;
$data['pic'] = $this->getPictureSortIndex($data['gallery_id']);
} else {
$picture = $this->repository->getOneById($entryId);
if ((int) $data['gallery_id'] !== (int) $picture['gallery_id']) {
$data['pic'] = $this->getPictureSortIndex($data['gallery_id']);
}
}
return parent::save($data, $entryId);
}
/**
* @param int $galleryId
*
* @return int
*
* @throws \Doctrine\DBAL\DBALException
*/
private function getPictureSortIndex(int $galleryId): int
{
$picNum = $this->repository->getLastPictureByGalleryId($galleryId);
return !\is_null($picNum) ? $picNum + 1 : 1;
}
/**
* @return array
*/
......@@ -74,6 +93,7 @@ class PictureModel extends AbstractModel
{
return [
'gallery_id' => DataProcessor\ColumnTypes::COLUMN_TYPE_INT,
'title' => DataProcessor\ColumnTypes::COLUMN_TYPE_TEXT,
'description' => DataProcessor\ColumnTypes::COLUMN_TYPE_TEXT_WYSIWYG,
'comments' => DataProcessor\ColumnTypes::COLUMN_TYPE_INT,
'file' => DataProcessor\ColumnTypes::COLUMN_TYPE_RAW,
......
......@@ -22,6 +22,7 @@ class GalleryDataGridRepository extends AbstractDataGridRepository
{
return [
'main.id',
'main.active',
'main.start',
'main.end',
'main.title',
......@@ -49,15 +50,4 @@ class GalleryDataGridRepository extends AbstractDataGridRepository
{
$queryBuilder->addGroupBy('main.id');
}
/**
* {@inheritdoc}
*/
protected function setOrderBy(ColumnPriorityQueue $gridColumns, QueryBuilder $queryBuilder)
{
$queryBuilder
->addOrderBy('main.start', 'DESC')
->addOrderBy('main.end', 'DESC')
->addOrderBy('main.id', 'DESC');
}
}
......@@ -25,11 +25,11 @@ class GalleryRepository extends Core\Model\Repository\AbstractRepository
*/
public function galleryExists(int $galleryId, string $time = '')
{
$period = empty($time) === false ? ' AND ' . $this->getPublicationPeriod() : '';
$period = !empty($time) ? ' AND `active` = :active AND ' . $this->getPublicationPeriod() : '';
return (int) $this->db->fetchColumn(
'SELECT COUNT(*) FROM ' . $this->getTableName() . ' WHERE id = :id' . $period,
['id' => $galleryId, 'time' => $time]
['id' => $galleryId, 'active' => 1, 'time' => $time]
) > 0;
}
......@@ -42,7 +42,10 @@ class GalleryRepository extends Core\Model\Repository\AbstractRepository
*/
public function getGalleryTitle(int $galleryId)
{
return $this->db->fetchColumn('SELECT title FROM ' . $this->getTableName() . ' WHERE id = ?', [$galleryId]);
return $this->db->fetchColumn(
'SELECT title FROM ' . $this->getTableName() . ' WHERE id = ?',
[$galleryId]
);
}
/**
......@@ -54,11 +57,11 @@ class GalleryRepository extends Core\Model\Repository\AbstractRepository
*/
public function countAll(string $time)