/** * Index action method * * @return void */ public function index() { $content = new Model\Content(); $uri = $this->request->getRequestUri(); if ($uri != '/' && substr($uri, -1) == '/') { $uri = substr($uri, 0, -1); } $date = $this->isDate($uri); $content->separator = $this->application->module('phire-content')->config()['separator']; if (null !== $date) { $dateResult = $content->getByDate($date, $this->application->module('phire-content')['date_format'] . ' ' . $this->application->module('phire-content')['time_format'], $this->application->module('phire-content')->config()['filters'], $this->config->pagination, $this->request->getQuery('page')); $this->prepareView('content-public/date.phtml'); $this->view->title = $this->formatDateTitle($date); $this->view->pages = $content->getDatePages($date, $this->config->pagination); $this->view->archive = $content->getArchive($this->application->module('phire-content')['archive_count']); $this->view->items = $dateResult; $this->template = -2; $this->send(); } else { $content->getByUri($uri); if ($content->isLive($this->sess)) { if (($content->force_ssl || $content->content_type_force_ssl) && $_SERVER['SERVER_PORT'] != 443) { $this->redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } $this->prepareView('content-public/index.phtml'); $this->view->archive = $content->getArchive($this->application->module('phire-content')['archive_count']); $this->view->merge($content->toArray()); $this->template = $content->template; $this->send(200, ['Content-Type' => $content->content_type]); } else { $this->error(); } } }
/** * Parse any content group placeholders * * @param AbstractController $controller * @param Application $application * @return void */ public static function parseContent(AbstractController $controller, Application $application) { if ($controller->hasView() && ($controller instanceof \Phire\Categories\Controller\IndexController || $controller instanceof \Phire\Content\Controller\IndexController)) { $data = $controller->view()->getData(); foreach ($data as $key => $value) { if (is_string($value)) { $subIds = self::parseContentIds($value); if (count($subIds) > 0) { $content = new Model\Content(); foreach ($subIds as $sid) { $c = substr($value, strpos($value, '[{content_' . $sid . '}]')); $c = substr($c, 0, strpos($c, '[{/content_' . $sid . '}]') + strlen('[{/content_' . $sid . '}]')); $view = new \Pop\View\View($c, ['content_' . $sid => $content->getAllByTypeId($sid)]); $controller->view()->{$key} = str_replace($c, $view->render(), $value); } } } } $body = $controller->response()->getBody(); $ids = self::parseContentIds($body); if (count($ids) > 0) { $content = new Model\Content(); foreach ($ids as $id) { $key = 'content_' . $id; $controller->view()->{$key} = $content->getAllByTypeId($id); } } } }
/** * 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(); }