Beispiel #1
0
 /**
  * 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;
 }
 /**
  * Remove action method
  *
  * @return void
  */
 public function remove()
 {
     if ($this->request->isPost()) {
         $type = new Model\ContentType();
         $type->remove($this->request->getPost());
     }
     $this->sess->setRequestValue('removed', true);
     $this->redirect(BASE_PATH . APP_URI . '/content/types');
 }
 /**
  * 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();
 }