/**
  * @param ModelSaveEvent $event
  */
 public function insertUriAlias(ModelSaveEvent $event)
 {
     $formData = $event->getRawData();
     if ($event->getModuleName() !== Schema::MODULE_NAME && !empty($formData['seo_uri_pattern'])) {
         $this->uriAliasManager->insertUriAlias(sprintf($formData['seo_uri_pattern'], $event->getEntryId()), $formData['alias'], $formData['seo_keywords'], $formData['seo_description'], (int) $formData['seo_robots']);
     }
 }
 /**
  * @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 ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     if (!$event->isDeleteStatement()) {
         return;
     }
     foreach ($event->getEntryId() as $item) {
         if ($this->commentsHelpers) {
             $this->commentsHelpers->deleteCommentsByModuleAndResult($this->modules->getModuleId(Schema::MODULE_NAME), $item);
         }
         $this->cache->getCacheDriver()->delete(Cache::CACHE_ID . $item);
         if ($this->uriAliasManager) {
             $this->uriAliasManager->deleteUriAlias(sprintf(Helpers::URL_KEY_PATTERN, $item));
         }
     }
 }
 /**
  * @param ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     if ($event->isDeleteStatement()) {
         return;
     }
     foreach ($event->getEntryId() as $entryId) {
         $this->articlesCache->getCacheDriver()->delete(Cache::CACHE_ID . $entryId);
         $uri = sprintf(Helpers::URL_KEY_PATTERN, $entryId);
         if ($this->manageMenuItemHelper) {
             $this->manageMenuItemHelper->manageMenuItem($uri, false);
         }
         if ($this->uriAliasManager) {
             $this->uriAliasManager->deleteUriAlias($uri);
         }
     }
 }
Example #5
0
File: Delete.php Project: acp3/cms
 /**
  * @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);
 }
Example #6
0
File: Delete.php Project: acp3/cms
 /**
  * @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;
 }
Example #7
0
File: Create.php Project: acp3/cms
 /**
  * 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;
 }
 /**
  * @param ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     if (!$event->isDeleteStatement()) {
         return;
     }
     $upload = new Upload($this->applicationPath, Schema::MODULE_NAME);
     foreach ($event->getEntryId() as $item) {
         $upload->removeUploadedFile($this->filesRepository->getFileById($item));
         if ($this->commentsHelpers) {
             $this->commentsHelpers->deleteCommentsByModuleAndResult($this->modules->getModuleId(Schema::MODULE_NAME), $item);
         }
         $this->cache->getCacheDriver()->delete(Cache::CACHE_ID . $item);
         if ($this->uriAliasManager) {
             $this->uriAliasManager->deleteUriAlias(sprintf(Helpers::URL_KEY_PATTERN, $item));
         }
     }
 }