/** * Get content * * @param array $data * @return array */ protected function setContent(array $data) { $type = new ContentType(); $type->getById($data['type_id']); $data['content_type'] = $type->content_type; $data['content_type_force_ssl'] = $type->force_ssl; $data['strict_publishing'] = $type->strict_publishing; if (!empty($data['publish'])) { $publish = explode(' ', $data['publish']); $data['publish_date'] = $publish[0]; $data['publish_time'] = $publish[1]; if (isset($this->date_format)) { $data['publish_date'] = date($this->date_format, strtotime($data['publish_date'])); } if (isset($this->time_format)) { $data['publish_time'] = date($this->time_format, strtotime($data['publish_time'])); } } if (!empty($data['expire'])) { $expire = explode(' ', $data['expire']); $data['expire_date'] = $expire[0]; $data['expire_time'] = $expire[1]; if (isset($this->date_format)) { $data['expire_date'] = date($this->date_format, strtotime($data['expire_date'])); } if (isset($this->time_format)) { $data['expire_time'] = date($this->time_format, strtotime($data['expire_time'])); } } if (!empty($content->created_by)) { $createdBy = \Phire\Table\Users::findById($content->created_by); if (isset($createdBy->id)) { $data['created_by_username'] = $createdBy->username; } } if (!empty($content->updated_by)) { $updatedBy = \Phire\Table\Users::findById($content->updated_by); if (isset($updatedBy->id)) { $data['updated_by_username'] = $updatedBy->username; } } $data['content_parent_id'] = $data['parent_id']; $data['content_status'] = $data['status']; $data['content_template'] = $data['template']; $data['breadcrumb'] = $this->getBreadcrumb($data['id'], null !== $this->separator ? $this->separator : '>'); $data['breadcrumb_text'] = strip_tags($data['breadcrumb'], 'span'); if (!is_array($data['roles']) && is_string($data['roles'])) { $data['roles'] = unserialize($data['roles']); } $this->data = array_merge($this->data, $data); return $this->data; }
/** * Edit action method * * @param int $id * @return void */ public function edit($id) { $type = new Model\ContentType(); $type->getById($id); $this->prepareView('content/types/edit.phtml'); $this->view->title = 'Content : Types'; $this->view->content_type_name = $type->name; $fields = $this->application->config()['forms']['Phire\\Content\\Form\\ContentType']; $fields[1]['name']['attributes']['onkeyup'] = 'phire.changeTitle(this.value);'; $this->view->form = new Form\ContentType($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\ContentType(); $type->update($this->view->form->getFields()); $this->view->id = $type->id; $this->sess->setRequestValue('saved', true); $this->redirect(BASE_PATH . APP_URI . '/content/types/edit/' . $type->id); } } $this->send(); }
/** * Trash action method * * @param int $tid * @return void */ public function trash($tid) { $this->prepareView('content/trash.phtml'); $content = new Model\Content(); $type = new Model\ContentType(); $type->getById($tid); if (!isset($type->id)) { $this->redirect(BASE_PATH . APP_URI . '/content'); } if ($content->hasPages($this->config->pagination, $tid, -2)) { $limit = $this->config->pagination; $pages = new Paginator($content->getCount($tid, -2), $limit); $pages->useInput(true); } else { $limit = null; $pages = null; } $this->view->title = 'Content : ' . $type->name . ' : Trash'; $this->view->pages = $pages; $this->view->tid = $tid; $this->view->queryString = $this->getQueryString('sort'); $this->view->content = $content->getAll($tid, $this->request->getQuery('sort'), $this->request->getQuery('title'), true); $this->send(); }