示例#1
0
 /**
  * @return Nette\Application\IRouter
  */
 public function createRouter()
 {
     $langRoute = array('language');
     foreach ($this->languages->getAll() as $language) {
         $langRoute[] = $language['link'];
     }
     $uri = explode('/', $_SERVER['REQUEST_URI']);
     if (isset($uri[1])) {
         $language = $this->languages->where('link', $uri[1])->fetch();
     } else {
         $language = $this->languages->get(1);
     }
     $router = new RouteList();
     $router[] = $adminRouter = new RouteList('Admin');
     $adminRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]admin/<presenter>/<action>', 'Homepage:default');
     $router[] = $frontRouter = new RouteList('Front');
     $pages = $this->pages->where('NOT module', null)->fetchAll();
     foreach ($pages as $page) {
         $link = $page['link'];
         //jen staticka
         if (in_array($page['module'], array())) {
             //vypis => detail s ID
         } elseif (in_array($page['module'], array())) {
             //katalog
             $frontRouter[] = new Route('[<locale=cs cs|en>/]' . $link . '/<link>/<id [0-9]+>/', array('action' => 'default', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
             $frontRouter[] = new Route('[<locale=cs cs|en>/]' . $link . '/<url>/', array('action' => 'default', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
             //jen specialni stranka modulu
         } else {
             $frontRouter[] = new Route('[<locale=cs cs|en>/]<presenter>/', array('action' => 'default', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
             $frontRouter[] = new Route('[<locale=cs cs|en>/]<presenter>/[<id>/]', array('action' => 'detail', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
         }
     }
     //obrazky
     $frontRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]<presenter image>/<action preview>/', array('presenter' => 'Homepage', 'action' => 'default'));
     //stranky
     $frontRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]<url .*>/', array('presenter' => 'Page', 'action' => 'default'));
     //vychozi router
     $frontRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]<presenter>/<action>/[<id>/]', array('presenter' => 'Homepage', 'action' => 'default'));
     return $router;
 }
示例#2
0
 protected function createComponentGrid()
 {
     $grid = new \App\Grid\GridTree('page');
     $grid->setModel($this->model->where('parent_id ?', null));
     $grid->addColumn(new \App\Grid\Column\Column('name', $this->translator->translate('page.name')));
     $grid->addColumn(new \App\Grid\Column\Column('link', $this->translator->translate('page.link')));
     $grid->addColumn(new \App\Grid\Column\YesNo('in_menu', $this->translator->translate('page.inMenu')));
     $grid->addColumn(new \App\Grid\Column\Column('id', $this->translator->translate('admin.grid.id')));
     $grid->addMenu(new \App\Grid\Menu\Update('edit', $this->translator->translate('admin.form.edit')));
     $grid->addMenu(new \App\Grid\Menu\Delete('delete', $this->translator->translate('admin.grid.delete')));
     $grid->setOrder('position');
     $grid->setOrdering('ordering');
     return $grid;
 }