Пример #1
0
 /**
  * Wall posts admin grid factory
  * @param name $name
  * @return Grid
  */
 public function createComponentWallPostsGrid($name)
 {
     $articleStates = [null => null] + WallPostStatus::getOptions();
     $commentModes = [null => null] + CommentMode::getOptions();
     try {
         $users = [null => null] + $this->usersService->getSelectUsers();
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataLoad(null, "default", $ex);
     }
     $grid = new Grid($this, $name);
     $grid->setModel($this->wallService->getWallPostsDatasource());
     $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("wallsModule.admin.grid.title"))->setTruncate(20)->setSortable()->setFilterText();
     $headerTitle = $grid->getColumn('title')->headerPrototype;
     $headerTitle->class[] = 'center';
     $grid->addColumnText('status', $this->tt("wallsModule.admin.grid.status"))->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($articleStates);
     $headerStatus = $grid->getColumn('status')->headerPrototype;
     $headerStatus->class[] = 'center';
     $grid->addColumnText('commentMode', $this->tt("wallsModule.admin.grid.cmntMode"))->setCustomRender($this->commentModeRender)->setSortable()->setFilterSelect($commentModes);
     $headerStatus = $grid->getColumn('commentMode')->headerPrototype;
     $headerStatus->class[] = 'center';
     $grid->addColumnText('author', $this->tt("wallsModule.admin.grid.author"))->setSortable()->setFilterSelect($users);
     $headerAuthor = $grid->getColumn('author')->headerPrototype;
     $headerAuthor->class[] = 'center';
     $grid->addColumnDate('updated', $this->tt("wallsModule.admin.grid.change"), self::DATETIME_FORMAT)->setSortable()->setFilterDateRange();
     $headerAuthor = $grid->getColumn('updated')->headerPrototype;
     $headerAuthor->class[] = 'center';
     $grid->addActionHref('delete', '', 'deleteWallPost!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("wallsModule.admin.grid.delete")]))->setConfirm(function ($u) {
         return $this->tt("wallsModule.admin.grid.messages.rlyDelWallPost", null, ["id" => $u->getId()]);
     });
     $grid->addActionHref('edit', '', 'updateWallPost')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("wallsModule.admin.grid.update")]));
     $grid->setOperation(["delete" => $this->tt("system.common.delete")], $this->wpostGridOpsHandler);
     $grid->setFilterRenderType($this->filterRenderType);
     $grid->setExport("admin-wallposts" . date("Y-m-d H:i:s", time()));
     return $grid;
 }
Пример #2
0
 protected function createComponentWallHistoryControl($name)
 {
     $c = new WallHistoryControl($this, $name);
     $data = $group = null;
     try {
         $abbr = $this->getParameter("abbr");
         $gid = empty($abbr) ? self::ROOT_GROUP : $abbr;
         if (is_numeric($gid)) {
             $group = $this->sportGroupService->getSportGroup($gid);
         } else {
             $group = $this->sportGroupService->getSportGroupAbbr($gid);
         }
         $data = $this->wallService->getOldWallPosts($group);
     } catch (Exceptions\DataErrorException $ex) {
         $this->presenter->handleDataLoad(null, ":System:Default:clubRoot", $ex);
     }
     $c->setData($data);
     $c->setParam($gid);
     return $c;
 }