protected function _onAccessible()
 {
     $type = $this->task->vars->get('type');
     if (!$this->factory()->module->setTypes->has($type)) {
         $this->parseError(ResponseCode::CODE_404);
         return;
     }
     $this->status = new StatusContainer();
     $this->type = $type;
     $this->id = $this->task->request->post->get('id', $this->task->vars->get('id'));
     if (!$this->_loadSet()) {
         $this->parseError(ResponseCode::CODE_404);
         return;
     }
     $q = ManagedFactory::get($this->app)->appQuick();
     if ($this->request()->post->get('delete')) {
         if ($this->set->delete()) {
             $this->deleted = true;
             if (!$this->set->status->hasSuccessMessage('success')) {
                 $this->set->postSuccess('success', $q->t('Der Inhalt wurde erfolgreich gelöscht.'));
             }
         } else {
             if (!$this->set->status->hasError('error')) {
                 $this->set->postError('error', $q->t('Der Inhalt konnte nicht gelöscht werden.'));
             }
         }
     }
     $this->submitUrl = $this->factory()->module->getRouteUrl('delete-set', array('type' => $type, 'id' => $this->set->getId()));
     $this->setResult($this->factory()->appTemplates()->load('sets/delete.html'));
 }
예제 #2
0
 protected function _onAccessible()
 {
     $type = $this->task->vars->get('type');
     if (!$this->factory()->module->setTypes->has($type)) {
         $this->parseError(ResponseCode::CODE_404);
         return;
     }
     $this->type = $type;
     $this->id = $this->task->request->post->get('set_id', $this->task->vars->get('id'));
     $this->status = new StatusContainer();
     if (!$this->_loadSet()) {
         $this->parseError(ResponseCode::CODE_404);
         return;
     }
     $q = ManagedFactory::get($this->app)->appQuick();
     if ($this->request()->post->get('save')) {
         $this->set->populate($this->request()->post->data);
         $this->set->check();
         if (!$this->set->status->error) {
             if (!$this->set->status->hasSuccessMessage('success')) {
                 $this->set->postSuccess('success', $q->t('Der Inhalt wurde erfolgreich gespeichert.'));
             }
             $this->set->save();
         }
     } else {
         $this->status = new StatusContainer();
     }
     if (!$this->set->getId()) {
         $this->submitUrl = $this->factory()->module->getRouteUrl('add-set', array('type' => $type));
     } else {
         $this->submitUrl = $this->factory()->module->getRouteUrl('edit-set', array('type' => $type, 'id' => $this->set->getId()));
         $this->deleteUrl = $this->factory()->module->getRouteUrl('delete-set', array('type' => $type, 'id' => $this->set->getId()));
     }
     // >> Translate status
     if ($this->status->hasSuccessMessages) {
         foreach ($this->status->successMessages as $message) {
             if ($message) {
                 $message->message = $q->t($message->message);
             }
         }
     }
     if ($this->status->hasErrorMessages) {
         foreach ($this->status->errors as $message) {
             if ($message) {
                 $message->message = $q->t($message->message);
             }
         }
     }
     if ($this->status->hasInfoMessages) {
         foreach ($this->status->infoMessages as $message) {
             if ($message) {
                 $message->message = $q->t($message->message);
             }
         }
     }
     $this->setResult($this->factory()->appTemplates()->load('sets/edit.html'));
 }
 public function renderPagination()
 {
     if (!$this->set->getCapabilities()->pagination) {
         return '';
     }
     $u = $this->factory()->appUi();
     $pagerArgs = $this->getUrlArguments('pagination');
     $pagerArgs['page'] = '__page__';
     return $u->pageSelector($u->calculatePageSelector($this->countPages, $this->page, 3, 3), $this->pageUrl . $this->encodeArgs($pagerArgs), array('pagePlaceholder' => '__page__'));
 }
 protected function _loadSets()
 {
     $this->sets = $this->set->listSets($this->_prepareLoadSetsOptions());
 }