protected function createComponentGrid($name) { $grid = new Grid($this, $name); $photoService = $this->getPhotogalleryService()->getPhotoService(); $model = $photoService->getFinder()->whereGallery($this->getGallery())->getGriditoModel(); $grid->setModel($model); // columns $grid->addColumn("image", "Náhled")->setRenderer(function ($photo) { $thumb = ThumbnailHelper::createThumbnail($photo->getImage(), 80, 80); echo Html::el("a")->href($photo->image->src)->target("_blank")->add($thumb->getHtml()); }); $grid->addColumn("description", "Popis")->setSortable(true); // buttons $presenter = $this; $service = $this->service; $grid->addButton("delete", "Smazat", array( "handler" => function ($entity) use ($service, $presenter, $grid) { $service->delete($entity); $galleryId = $entity->getGallery()->getId(); $presenter->flashMessage("Fotografie byl úspěšně smazána."); $grid->redirect("this"); }, "icon" => "ui-icon-closethick", "confirmationQuestion" => "Opravdu chcete smazat fotografii?" )); }
protected function createComponentGrid($name) { $grid = new Grid($this, $name); $gallery = $this->galleryService->find($this->getParam('id')); $model = $this->service->getFinder()->whereGallery($gallery)->orderByOrder()->getGriditoModel(); $grid->setModel($model); // columns $template = $this->createTemplate()->setFile(__DIR__ . "/../templates/Photo/@thumb.phtml"); $grid->addColumn("image", "Náhled")->setRenderer(function ($photo) use($template) { $template->image = $photo; $template->render(); }); $grid->addColumn("description", "Popis")->setSortable(true); $grid->addColumn('itemOrder', 'Pořadí')->setSortable(true); // buttons $presenter = $this; $grid->addToolbarButton("edit", "Upravit galerii", array("icon" => "ui-icon-pencil", "link" => $this->link("edit", $this->getParam("id")))); $grid->addToolbarButton("sort", "Řadit fotografie", array("icon" => "ui-icon-arrow-4", "link" => $this->link("sortPhotos", $this->getParam("id")))); $photoService = $this->service; $grid->addButton("editPhoto", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($entity) use($presenter) { return $presenter->link("editPhoto", $entity->getId()); })); $grid->addButton("delete", "Smazat", array("handler" => function ($entity) use($photoService, $presenter, $grid) { $photoService->delete($entity); $galleryId = $entity->getGallery()->getId(); $presenter->flashMessage("Fotografie byl úspěšně smazána."); $grid->redirect("this"); }, "icon" => "ui-icon-closethick", "confirmationQuestion" => "Opravdu chcete smazat fotografii?")); }