/** * @return Form */ public function create() { $form = $this->factory->create(); $galleries = $this->galleriesRepository->getAll()->fetchPairs('id', 'name'); $themes = $this->articlesRepository->getAllThemes(); $form->addHidden('id', 'ID'); $form->addText('name', 'Název')->setAttribute('placeholder', 'Název článku')->setAttribute('class', 'form-control input-sm')->setRequired('Zadejte prosím Název článku'); $form->addText('url', 'URL')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'URL stránky'); $form->addCheckbox('active', 'Aktivní')->setAttribute('class', 'bootstrap'); $form->addText('title', 'Titulek')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Titulek v prohlížeči'); $form->addText('description', 'Description')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Popisek'); $form->addText('keywords', 'Keywords')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Klíčová slova'); $form->addTextArea('text', 'Text')->setAttribute('placeholder', 'Text stránky'); $form->addTextArea('secretText', 'Text po přihlášení')->setAttribute('placeholder', 'Text pro přihlášené uživatele'); $form->addText('pictureName', 'Obrázek')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Připojený obrázek')->setAttribute('onclick', 'openKCFinder(this)'); $form->addText('pictureDescription', 'Popisek obrázku')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Popisek obrázku'); $form->addMultiSelect('galleryIds', 'Svázané galerie', $galleries)->setAttribute('class', 'form-control input-sm select2')->setAttribute('placeholder', 'Galerie'); $form->addSelect('idTheme', 'Téma článku', $themes)->setAttribute('class', 'form-control input-sm select2')->setAttribute('placeholder', 'Téma článku'); $form->addText('theme', 'Nové téma')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Nové téma'); $form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary'); $form->addSubmit('saveandstay', 'Uložit a zůstat')->setAttribute('class', 'btn btn-default'); $form->setRenderer(new BootstrapRenderer()); $form->getElementPrototype()->class('form-horizontal'); $form->onSuccess[] = function (Form $form) { $this->formSubmitted($form); }; return $form; }
/** * @return Form */ public function create() { $form = $this->factory->create(); $galleries = $this->galleriesRepository->getAll()->fetchPairs('id', 'name'); $form->addHidden('parent'); $form->addText('name', 'Název')->setAttribute('placeholder', 'Název stránky')->setAttribute('class', 'form-control input-sm')->setRequired('Zadejte prosím Název'); $form->addText('url', 'URL')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'URL stránky'); $form->addCheckbox('onHomepage', 'Na úvodní stranu')->setAttribute('class', 'bootstrap'); $form->addCheckboxList('inMenu', 'Položka menu:', ['topMenu' => 'Horní menu', 'footerMenu' => 'Menu v patičce', 'sideMenu' => 'Postranní menu', 'otherMenu' => 'Jiné menu'])->setAttribute('class', 'bootstrap'); $form->addCheckbox('active', 'Aktivní')->setAttribute('class', 'bootstrap'); $form->addCheckbox('secret', 'Pro přihlášené')->setAttribute('class', 'bootstrap'); $form->addText('menuTitle', 'Název do menu')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Název v menu'); $form->addText('title', 'Titulek')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Titulek v prohlížeči'); $form->addText('description', 'Description')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Popisek'); $form->addText('keywords', 'Keywords')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Klíčová slova'); $form->addTextArea('perex', 'Perex')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Perex'); $form->addTextArea('text', 'Text')->setAttribute('placeholder', 'Text stránky'); $form->addTextArea('secretText', 'Text po přihlášení')->setAttribute('placeholder', 'Text pro přihlášené uživatele'); $form->addText('pictureName', 'Obrázek')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Připojený obrázek')->setAttribute('onclick', 'openKCFinder(this)'); $form->addText('pictureDescription', 'Popisek obrázku')->setAttribute('class', 'form-control input-sm')->setAttribute('placeholder', 'Popisek obrázku'); $form->addMultiSelect('galleryIds', 'Svázané galerie', $galleries)->setAttribute('class', 'form-control input-sm select2')->setAttribute('placeholder', 'Galerie'); $form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary'); $form->addSubmit('saveandstay', 'Uložit a zůstat')->setAttribute('class', 'btn btn-default'); $form->setRenderer(new BootstrapRenderer()); $form->getElementPrototype()->class('form-horizontal'); $form->onSuccess[] = function (Form $form) { $this->formSubmitted($form); }; return $form; }
/** * @param Form $form */ public function formSucceeded(Form $form) { $values = $form->getValues(); $galleries = new GalleriesEntity(); $galleries->name($values->name); $galleries->description($values->description); $galleries->url(Strings::webalize($values->name)); $this->galleriesRepository->save($galleries); }
/** * */ public function render() { if (!is_null($this->page)) { $this->getTemplate()->galleries = $this->galleriesRepository->getAllGalleriesWithPictures($this->page); } else { $this->getTemplate()->galleries = $this->galleriesRepository->getAllGalleriesWithPictures($this->article); } $this->getTemplate()->setFile(__DIR__ . '/GalleriesControl.latte'); $this->getTemplate()->render(); }
/** * @param $name * @return Grid * @throws \Grido\Exception */ protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->translator->lang = 'cs'; $fluent = $this->galleriesRepository->getAll(); $grid->model = $fluent; $grid->addColumnText('id', 'ID')->setSortable(); $grid->getColumn('id')->headerPrototype->style['width'] = '1%'; $grid->addColumnText('name', 'Název')->setSortable()->setFilterText(); $grid->getColumn('name')->headerPrototype->style['width'] = '25%'; $grid->addColumnText('description', 'Popis')->setSortable()->setFilterText(); $grid->getColumn('description')->headerPrototype->style['width'] = '40%'; $grid->addActionHref('edit', '')->setIcon('pencil'); $grid->addActionEvent('delete', '')->setCustomRender(function ($item) { $i = Html::el('i', ['class' => 'fa fa-trash']); $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("delete!", $item->id))->setHtml($i); return $el; }); $grid->setDefaultPerPage(50); $grid->filterRenderType = $this->filterRenderType; $grid->setExport(); return $grid; }