예제 #1
0
 protected function createComponentGrid($name)
 {
     $dataSource = $this->entityModel->reflection("datasource");
     $dibiSource = $dataSource->setTable("content")->table(NULL);
     $grid = new \Natsu\Control\GridControl();
     $grid->setName($name);
     $grid->setPk('id');
     $grid->setDibiSource($dibiSource);
     $grid->setColumns(array('id' => 'ID', 'sectionId' => 'Sekce', 'title' => 'Title', 'isNews' => 'Novinka'));
     $grid->setCallBack(array('type' => function ($item) {
         if ($item->isDraft) {
             return "Draft";
         } else {
             if ($item->isNews) {
                 return "Novinka";
             } else {
                 return "Stránka";
             }
         }
     }));
     $grid->setButtons(array('form' => 'Form', 'view' => 'View'));
     $grid->run();
     return $grid->getGrid();
 }
예제 #2
0
 protected function createComponentUserList($name)
 {
     if (!($this->user->loggedIn && ($this->user->identity->roleId == 1 || $this->user->identity->roleId == 2))) {
         throw new \Nette\Application\ForbiddenRequestException();
     }
     $dataSource = $this->entityModel->reflection("datasource");
     $dibiSource = $dataSource->userList();
     $grid = new \Natsu\Control\GridControl();
     $grid->setName($name);
     $grid->setPk('id');
     $grid->setPresenter("Sign");
     $grid->setDibiSource($dibiSource);
     $grid->setColumns(array('id' => 'ID', 'username' => 'Username', 'fullname' => 'Fullname', 'email' => 'Email'));
     $grid->setButtons(array('edit' => 'Změnit'));
     $grid->run();
     return $grid->getGrid();
 }