Ejemplo n.º 1
0
 public function single($id)
 {
     $gallery = GalleryQuery::create()->findPk($id);
     $images = $gallery->getImages();
     if (!$gallery) {
         $this->addPopup('danger', 'Galerie se specifikovaným identifikačním číslem neexistuje.');
         redirectTo('/galerie');
     }
     $this->view('Gallery/single', 'base_template', ['active' => 'gallery', 'title' => 'Galerie', 'recent' => ArticleQuery::recent(), 'gallery' => $gallery, 'images' => $images, 'js' => 'plugins/fotorama/fotorama', 'css' => 'plugins/fotorama/fotorama']);
 }
Ejemplo n.º 2
0
 /**
  * Returns the number of related Gallery objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      ConnectionInterface $con
  * @return int             Count of related Gallery objects.
  * @throws PropelException
  */
 public function countGalleries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collGalleriesPartial && !$this->isNew();
     if (null === $this->collGalleries || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collGalleries) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getGalleries());
         }
         $query = ChildGalleryQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByUser($this)->count($con);
     }
     return count($this->collGalleries);
 }
Ejemplo n.º 3
0
 public function deleteGallery($id)
 {
     $gal = GalleryQuery::create()->findPk($id);
     if ($this->isEditor() && $gal->getIdUser() != $_SESSION["user"]->getId()) {
         $this->addPopup("danger", "Na odstranění této galerie nemáte dostatečná práva.");
         redirectTo('/administrace/galerie');
     }
     $images = $gal->getImages();
     foreach ($images as $i) {
         $imgs[] = $i->getId();
     }
     $maps = ImageGalleryMapQuery::create()->filterByIdGallery($id)->filterByIdImage($imgs)->find();
     foreach ($maps as $m) {
         $m->delete();
     }
     $gal->delete();
     $this->addPopup('success', 'Galerie ' . $gal->getName() . ' byla úspěšně odstraněna!');
     redirectTo('/administrace/galerie');
 }