public function actionDefault($keyword = null) { // no search without keyword if (empty($keyword)) { $this->redirect(":System:Homepage:default"); } try { $articles = $this->articleService->fulltextSearch($keyword); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad($keyword, "Homepage:default", $ex); } $this->template->keyword = $keyword; $this->template->articles = $articles; }
/** * Handler for delete article comment * @param ArticleComment $comm */ public function deleteComment($comm) { try { $this->articleService->deleteComment($comm, $this->getEntity()); } catch (Exceptions\DataErrorException $ex) { $this->handleDataDelete($comm->getId(), "this", $ex); } if ($this->isAjax()) { $this->redrawControl("commentsData"); } else { $this->redirect("this"); } }
/** * Admin articles grid factory. * @param string $name * @return Grid */ public function createComponentArticlesGrid($name) { $articleStates = [null => null] + ArticleStatus::getOptions(); $commentModes = [null => null] + CommentMode::getOptions(); try { $users = [null => null] + $this->usersService->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleException($ex); } $grid = new Grid($this, $name); $grid->setModel($this->articleService->getArticlesDataSource()); $grid->setTranslator($this->getTranslator()); $grid->setPrimaryKey("id"); $grid->addColumnNumber("id", "#")->cellPrototype->class[] = "center"; $headerId = $grid->getColumn("id")->headerPrototype; $headerId->class[] = "center"; $headerId->rowspan = "2"; $headerId->style["width"] = '0.1%'; $grid->addColumnText('title', $this->tt("articlesModule.admin.grid.title"))->setSortable()->setCustomRender($this->titleRender)->setFilterText(); $headerTitle = $grid->getColumn('title')->headerPrototype; $headerTitle->class[] = 'center'; $grid->addColumnText('status', $this->tt("articlesModule.admin.grid.state"))->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($articleStates); $headerStatus = $grid->getColumn('status')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('commentMode', $this->tt("articlesModule.admin.grid.comments"))->setSortable()->setCustomRender($this->commentModeRender)->setFilterSelect($commentModes); $headerStatus = $grid->getColumn('commentMode')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('author', $this->tt("articlesModule.admin.grid.author"))->setSortable()->setFilterSelect($users); $headerAuthor = $grid->getColumn('author')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addColumnDate('updated', $this->tt("articlesModule.admin.grid.change"), self::DATETIME_FORMAT)->setSortable()->setFilterDateRange(); $headerAuthor = $grid->getColumn('updated')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addActionHref('delete', '', 'deleteArticle!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("articlesModule.admin.grid.rlyDelArticle", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updateArticle')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.update")])); $grid->addActionHref("goto", "", "goToArticle")->setIcon('eye-open')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.view")])); $grid->setOperation(["delete" => $this->tt("system.common.delete")], $this->articlesGridOperationHandler); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-articles" . date("Y-m-d H:i:s", time())); return $grid; }
public function renderDefault() { $this->template->articles = $this->articleService->getArticles(); $this->template->highlights = $this->articleService->getHighLights(); }