/** * @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); } } }
/** * Returns the SEO form fields * * @param string $path * * @return array */ public function formFields($path = '') { if (!empty($path)) { $path .= !preg_match('/\\/$/', $path) ? '/' : ''; $alias = $this->request->getPost()->get('alias', $this->aliases->getUriAlias($path, true)); $keywords = $this->request->getPost()->get('seo_keywords', $this->metaStatements->getKeywords($path)); $description = $this->request->getPost()->get('seo_description', $this->metaStatements->getDescription($path)); $robots = $this->metaStatements->getSeoInformation($path, 'robots', 0); } else { $alias = $keywords = $description = ''; $robots = 0; } return ['alias' => $alias, 'keywords' => $keywords, 'description' => $description, 'robots' => $this->formsHelper->choicesGenerator('seo_robots', $this->getRobotsChoicesGeneratorValues(), $robots)]; }
/** * Setzt einen einzelnen Alias für ein Bild einer Fotogalerie * * @param integer $pictureId * * @return boolean */ protected function generatePictureAlias($pictureId) { if ($this->aliases && $this->metaStatements && $this->uriAliasManager) { $galleryId = $this->pictureRepository->getGalleryIdFromPictureId($pictureId); $alias = $this->aliases->getUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId), true); if (!empty($alias)) { $alias .= '/img-' . $pictureId; } $seoKeywords = $this->metaStatements->getKeywords(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId)); $seoDescription = $this->metaStatements->getDescription(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId)); return $this->uriAliasManager->insertUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE, $pictureId), $alias, $seoKeywords, $seoDescription); } return true; }