protected function fetchSitemapUrls() { $this->addUrl('gallery/index/index'); foreach ($this->galleryRepository->getAll($this->date->getCurrentDateTime()) as $result) { $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN_GALLERY, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d')); foreach ($this->pictureRepository->getPicturesByGalleryId($result['id']) as $picture) { $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN_PICTURE, $picture['id']), $this->date->format($result['updated_at'], 'Y-m-d')); } } }
/** * @param ModelSaveEvent $event */ public function generatePictureAliases(ModelSaveEvent $event) { if ($this->aliases && $this->metaStatements && $this->uriAliasManager) { $galleryId = $event->getEntryId(); $pictures = $this->pictureRepository->getPicturesByGalleryId($galleryId); $alias = $this->aliases->getUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId), true); $seoKeywords = $this->metaStatements->getKeywords(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId)); $seoDescription = $this->metaStatements->getDescription(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId)); foreach ($pictures as $picture) { $this->uriAliasManager->insertUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE, $picture['id']), !empty($alias) ? $alias . '/img-' . $picture['id'] : '', $seoKeywords, $seoDescription); } } }
/** * @param int $id * * @return array */ protected function executeListPictures($id) { $pictures = $this->pictureRepository->getPicturesByGalleryId($id); /** @var Core\Helpers\DataGrid $dataGrid */ $dataGrid = $this->get('core.helpers.data_grid'); $dataGrid->setResults($pictures)->setRecordsPerPage($this->resultsPerPage->getResultsPerPage(Schema::MODULE_NAME))->setIdentifier('#acp-table')->setResourcePathDelete('admin/gallery/pictures/delete/id_' . $id)->setResourcePathEdit('admin/gallery/pictures/edit'); $this->addDataGridColumns($dataGrid); return ['grid' => $dataGrid->render(), 'show_mass_delete_button' => $dataGrid->countDbResults() > 0]; }
/** * Erstellt den Galerie-Cache anhand der angegebenen ID * * @param integer $galleryId * * @return boolean */ public function saveCache($galleryId) { $pictures = $this->pictureRepository->getPicturesByGalleryId($galleryId); $cPictures = count($pictures); $settings = $this->config->getSettings(Schema::MODULE_NAME); for ($i = 0; $i < $cPictures; ++$i) { $pictures[$i]['width'] = $settings['thumbwidth']; $pictures[$i]['height'] = $settings['thumbheight']; $picInfos = @getimagesize($this->appPath->getModulesDir() . 'gallery/' . $pictures[$i]['file']); if ($picInfos !== false) { if ($picInfos[0] > $settings['thumbwidth'] || $picInfos[1] > $settings['thumbheight']) { $newHeight = $settings['thumbheight']; $newWidth = intval($picInfos[0] * $newHeight / $picInfos[1]); } $pictures[$i]['width'] = isset($newWidth) ? $newWidth : $picInfos[0]; $pictures[$i]['height'] = isset($newHeight) ? $newHeight : $picInfos[1]; } } return $this->cache->save(self::CACHE_ID . $galleryId, $pictures); }
/** * @param integer $galleryId * * @return boolean */ protected function deletePictureAliases($galleryId) { if ($this->uriAliasManager) { $pictures = $this->pictureRepository->getPicturesByGalleryId($galleryId); $cPictures = count($pictures); for ($i = 0; $i < $cPictures; ++$i) { $this->uriAliasManager->deleteUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE, $pictures[$i]['id'])); } } return true; }