/** * Export action method * * @param int $tid * @return void */ public function export($tid) { $entities = new Model\Entity(['tid' => $tid]); $type = new Model\EntityType(); $type->getById($tid); if (!isset($type->id)) { $this->redirect(BASE_PATH . APP_URI . '/entities'); } if ($this->services['acl']->isAllowed($this->sess->user->role, 'entity-type-' . $type->id, 'export')) { $rows = $entities->getAllForExport($tid); $data = new Data($rows); $data->serialize('csv', ['omit' => 'type_id']); $data->outputToHttp($type->name . '_' . date('Y-m-d') . '.csv'); } else { $this->redirect(BASE_PATH . APP_URI . '/entities/' . $tid); } }
/** * Edit action method * * @param int $id * @return void */ public function edit($id) { $type = new Model\EntityType(); $type->getById($id); if (!isset($type->id)) { $this->redirect(BASE_PATH . APP_URI . '/entities'); } $this->prepareView('entities/types/edit.phtml'); $this->view->title = 'Entity Types'; $this->view->entity_type_name = $type->name; $fields = $this->application->config()['forms']['Phire\\Entities\\Form\\EntityType']; $fields[1]['name']['attributes']['onkeyup'] = 'phire.changeTitle(this.value);'; $this->view->form = new Form\EntityType($fields); $this->view->form->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($type->toArray()); if ($this->request->isPost()) { $this->view->form->setFieldValues($this->request->getPost()); if ($this->view->form->isValid()) { $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter(); $type = new Model\EntityType(); $type->update($this->view->form->getFields()); $this->view->id = $type->id; $this->sess->setRequestValue('saved', true); $this->redirect(BASE_PATH . APP_URI . '/entities/types/edit/' . $type->id); } } $this->send(); }