protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->service->getFinder()->getGriditoModel()); // columns $grid->addColumn("id", "ID")->setSortable(true); $grid->addColumn("name", "Název")->setSortable(true); $grid->addColumn("url", "URL")->setSortable(true); $grid->addColumn("description", "Popis")->setSortable(true); $grid->addColumn("allowed", "Samostatný")->setSortable(true); // buttons $presenter = $this; $service = $this->service; $grid->addButton("edit", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($page) use($presenter) { return $presenter->link("edit", array("id" => $page->id)); }, "showText" => false)); $grid->addButton("delete", "Smazat", array("icon" => "ui-icon-closethick", "handler" => function ($entity) use($service, $presenter) { $service->delete($entity); $presenter->flashMessage("Stránka byla úspěšně smazána."); $presenter->redirect("default"); }, "confirmationQuestion" => function ($page) { return "Opravdu chcete smazat stránku '{$page->name}'?"; }, "showText" => false)); // toolbar $grid->addToolbarButton("new", "Nová stránka", array("icon" => "ui-icon-plusthick", "link" => $this->link("add"))); }
protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->service->getFinder()->getGriditoModel()); // columns $grid->addColumn("name", "Jméno")->setSortable(true); $grid->addColumn("surname", "Příjmení")->setSortable(true); $grid->addColumn("username", "Uživatelské jméno")->setSortable(true); $grid->addColumn("mail", "E-mail")->setSortable(true); // buttons $presenter = $this; $service = $this->service; $grid->addButton("edit", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($entity) use($presenter) { return $presenter->link("edit", array("id" => $entity->id)); })); $grid->addButton("delete", "Smazat", array("icon" => "ui-icon-closethick", "handler" => function ($entity) use($service, $presenter) { $service->delete($entity); $presenter->flashMessage("Uživatel byl úspěšně smazán."); $presenter->redirect("default"); }, "confirmationQuestion" => function ($entity) { return "Opravdu chcete smazat uživatele '{$entity->name}'?"; })); // toolbar $grid->addToolbarButton("newuser", "Nový uživatel", array("icon" => "ui-icon-plusthick", "link" => $this->link("add"))); }
protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->service->getFinder()->getGriditoModel()); $grid->addColumn("name", "Název")->setSortable(true); $grid->addColumn("itemCount", "Počet článků")->setSortable(true); $presenter = $this; $grid->addButton("edit", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($entity) use($presenter) { return $presenter->link("edit", $entity->getId()); })); $service = $this->service; $grid->addButton("delete", "Smazat", array("icon" => "ui-icon-closethick", "handler" => function ($entity) use($presenter, $service) { $service->delete($entity); $presenter->flashMessage("Tag byl smazán."); $presenter->redirect("this"); })); $grid->addToolbarButton("add", "Přidat", array("icon" => "ui-icon-plusthick", "link" => $this->link("add"))); }
protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->service->getFinder()->getGriditoModel()); $grid->addColumn("insertKey", "Klíč")->setSortable(true); $presenter = $this; $grid->addButton("edit", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($entity) use($presenter) { return $presenter->link("edit", $entity->getId()); })); $service = $this->service; $grid->addButton("delete", "Smazat", array("icon" => "ui-icon-closethick", "handler" => function ($entity) use($presenter, $service) { $service->delete($entity); $presenter->flashMessage("Výstřižek byl smazán"); $presenter->redirect("this"); }, "confirmationQuestion" => function ($entity) { return "Smazat výstřižek {$entity->insertKey}?"; })); $grid->addToolbarButton("add", "Přidat", array("icon" => "ui-icon-plusthick", "link" => $this->link("add"))); }
public static function createGrid($model, $neonString) { $settings = Neon::decode($neonString); /** Create Grid and set the model */ $grid = new Grid(); $grid->setModel($model); /** Add columns */ foreach ($settings['columns'] as $key => $column) { $grid->addColumn($key, null, $column); } /** Create buttons */ foreach ($settings['buttons'] as $key => $button) { $call = empty($button['toolbar']) ? 'add' : 'addToolbar'; $call .= empty($button['window']) ? '' : 'Window'; $call .= empty($button['check']) ? 'Button' : 'CheckButton'; unset($button['toolbar']); unset($button['window']); unset($button['check']); call_user_func(array($grid, $call), $key, null, $button); } return $grid; }
protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->service->getGriditoModel()); $grid->setItemsPerPage($this->service->count()); $grid->addColumn("name", "Popis", array("renderer" => function ($node) { echo str_repeat(" ", $node->getLevel() * 4); echo Html::el("a")->href($node->getNode()->getUrl())->setText($node->getNode()->getName()); })); $presenter = $this; $grid->addButton("add", "Přidat", array("icon" => "ui-icon-plusthick", "link" => function ($node) use($presenter) { return $presenter->link("add", $node->getId()); }, "showText" => false)); $grid->addButton("edit", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($node) use($presenter) { return $presenter->link("edit", $node->getId()); }, "showText" => false)); $grid->addButton("delete", "Smazat", array("icon" => "ui-icon-closethick", "handler" => function ($node) use($grid) { $node->delete(); $grid->flashMessage("Položka menu byla smazána."); }, "confirmationQuestion" => function ($node) { return "Opravdu smazat položku " . $node->getNode()->getName() . "?"; }, "visible" => function ($node) { return !$node->isRoot(); }, "showText" => false, "ajax" => true)); $grid->addButton("up", "Nahoru", array("icon" => "ui-icon-arrowthick-1-n", "handler" => function ($node) use($grid) { $node->moveAsPrevSiblingOf($node->getPrevSibling()); $grid->flashMessage("Odkaz přesunut."); }, "visible" => function ($node) { return $node->getPrevSibling() !== null; }, "showText" => false, "ajax" => true)); $grid->addButton("down", "Dolů", array("icon" => "ui-icon-arrowthick-1-s", "handler" => function ($node) use($grid) { $node->moveAsNextSiblingOf($node->getNextSibling()); $grid->flashMessage("Odkaz přesunut."); }, "visible" => function ($node) { return $node->getNextSibling() !== null; }, "showText" => false, "ajax" => true)); }
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?" )); }
public function setModel(IModel $model) { $this->editableModel = null; return parent::setModel($model); }
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?")); }