/** * @param int $id * @param string $action * * @return mixed * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id, $action = '') { return $this->actionHelper->handleDeleteAction($action, function (array $items) { $bool = false; foreach ($items as $item) { if (!empty($item) && $this->pictureRepository->pictureExists($item) === true) { $picture = $this->pictureRepository->getOneById($item); $this->pictureRepository->updatePicturesNumbers($picture['pic'], $picture['gallery_id']); $this->galleryHelpers->removePicture($picture['file']); $bool = $this->pictureRepository->delete($item); if ($this->uriAliasManager) { $this->uriAliasManager->deleteUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE, $item)); } $this->galleryCache->saveCache($picture['gallery_id']); } } Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http'); return $bool; }, 'acp/gallery/pictures/delete/id_' . $id, 'acp/gallery/index/edit/id_' . $id); }
/** * @param int $id * * @return array * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id) { if ($this->pictureRepository->pictureExists($id, $this->date->getCurrentDateTime()) === true) { $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']); $picture = $this->pictureRepository->getOneById($id); $this->breadcrumb->append($this->translator->t('gallery', 'gallery'), 'gallery')->append($picture['title'], 'gallery/index/pics/id_' . $picture['gallery_id'])->append($this->translator->t('gallery', 'details')); $this->title->setPageTitlePrefix($picture['title'])->setPageTitlePostfix($this->translator->t('gallery', 'picture_x', ['%picture%' => $picture['pic']])); $picture = $this->calculatePictureDimensions($picture); $previousPicture = $this->pictureRepository->getPreviousPictureId($picture['pic'], $picture['gallery_id']); if (!empty($previousPicture)) { $this->setPreviousPage((int) $previousPicture); } $nextPicture = $this->pictureRepository->getNextPictureId($picture['pic'], $picture['gallery_id']); if (!empty($nextPicture)) { $this->setNextPage((int) $nextPicture); } return ['picture' => $picture, 'picture_next' => $nextPicture, 'picture_previous' => $previousPicture, 'comments_allowed' => $this->isCommentsAllowed($picture)]; } throw new Core\Controller\Exception\ResultNotExistsException(); }