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')); }
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 renderTable() { $q = $this->factory()->appQuick(); $u = $this->factory()->appUi(); $globalDelete = $this->set->allowDelete; $globalEdit = $this->set->allowEdit; $table = '<table><thead><tr>'; $capabilities = $this->set->getCapabilities(); $content = $this->set->firstContent; do { if ($content->config->get('visible')) { $c = $content->config->get('label'); if ($content->config->get('escapeLabel', true)) { $c = $q->e($c); } if ($capabilities->sort && $content->sortable) { $arguments = $this->getUrlArguments('sort'); $arguments['sortBy'] = $content->name; if ($this->sortBy == $content->name && $this->sortDirection == 'desc') { $arguments['sortDirection'] = 'asc'; } else { $arguments['sortDirection'] = 'desc'; } $url = $this->pageUrl . $this->encodeArgs($arguments); $c = '<a href="' . $q->e($url) . '">' . $c . '</a>'; } $table .= '<td>' . $c . '</td>'; } } while ($content = $content->nextContent); if ($globalEdit) { $table .= '<td>' . $q->t('Bearbeiten') . '</td>'; } if ($globalDelete) { $table .= '<td>' . $q->t('Löschen') . '</td>'; } $table .= '</tr></thead><tbody>'; while ($set = $this->sets->getNext()) { $this->_onRenderTableSetChanged(); $content = $this->set->firstContent; $table .= '<tr>'; do { if ($content->config->get('visible')) { $table .= '<td>' . $content->render('list'); } } while ($content = $content->nextContent); if ($globalEdit) { if ($this->set->allowEdit) { $table .= '<td>' . $u->link($this->getEditUrl($this->set->getId()), $q->t('Bearbeiten')) . '</td>'; } else { $table .= '<td></td>'; } } if ($globalDelete) { if ($this->set->allowDelete) { $table .= '<td>' . $u->link($this->getDeleteUrl($this->set->getId()), $q->t('Löschen')) . '</td>'; } else { $table .= '<td></td>'; } } $table .= '</tr>'; } $table .= '</tbody></table>'; return $table; }