예제 #1
0
 public function handlePreview($id)
 {
     if (!($entity = $this->repository->find($id))) {
         throw new BadRequestException();
     }
     $route = $entity->getRoute();
     if (!$route->published) {
         $session = $this->getPresenter()->getSession(ContentPresenter::PREVIEW_SESSION);
         $session->setExpiration('+ 2 minutes');
         if (!isset($session->routes)) {
             $session->routes = array();
         }
         $session->routes[$route->id] = TRUE;
     }
     $this->getPresenter()->redirect(':Cms:Pages:Text:Route:', array('route' => $route, 'lang' => $this->getPresenter()->contentLang ?: $this->presenter->websiteManager->defaultLanguage));
 }
예제 #2
0
 public function formSuccess(Venne\Forms\Form $form)
 {
     if ($form['_submit']->isSubmittedBy()) {
         $action = $form['_action']->getValue();
         $button = $this[$action];
         $values = $form['items']->getValues();
         foreach ($values as $key => $value) {
             if ($value) {
                 $button->onClick($button, $this->repository->find(substr($key, 5)));
             }
         }
         $button->onSuccess($this);
     } else {
         if ($form['_filters']->isSubmittedBy()) {
             $this->filters = $form['filters']->getValues();
             foreach ($this->filters as $key => $value) {
                 if (!$value) {
                     unset($this->filters[$key]);
                 }
             }
             $this['vp']->page = 1;
             if (!$this->presenter->isAjax()) {
                 $this->redirect('this');
             }
             unset($this['actionForm']);
             unset($this['vp']);
             $this->invalidateControl('table-body');
             $this->invalidateControl('table-foot');
             $this->presenter->payload->url = $this->link('this');
         } else {
             if ($form['_reset']->isSubmittedBy()) {
                 $form['filters']->setValues(array());
                 $this->filters = array();
                 $this['vp']->page = 1;
                 if (!$this->presenter->isAjax()) {
                     $this->redirect('this');
                 }
                 unset($this['actionForm']);
                 unset($this['vp']);
                 $this->invalidateControl('table-body');
                 $this->invalidateControl('table-foot');
                 $this->presenter->payload->url = $this->link('this');
             } else {
                 if ($form['perPageSubmit']->isSubmittedBy()) {
                     $this->perPage = $form['perPage']->value;
                     $this['vp']->page = 1;
                     if (!$this->presenter->isAjax()) {
                         $this->redirect('this');
                     }
                     unset($this['actionForm']);
                     unset($this['vp']);
                     $this->invalidateControl('table-body');
                     $this->invalidateControl('table-foot');
                     $this->presenter->payload->url = $this->link('this');
                 }
             }
         }
     }
 }
예제 #3
0
 /** ------------------------ Callbacks --------------------------------- */
 public function tableDelete($action, $id, $redirect = TRUE)
 {
     if (is_array($id)) {
         foreach ($id as $item) {
             $this->tableDelete($action, $item, FALSE);
         }
     } else {
         $this->repository->delete($this->repository->find($id));
     }
     if ($redirect) {
         if (!$this->presenter->isAjax()) {
             $this->redirect('this');
         }
         $this->invalidateControl('table');
         $this->presenter->payload->url = $this->link('this');
     }
 }