diff --git a/application/controllers/CisHmvc/Cms.php b/application/controllers/CisHmvc/Cms.php index eed1a5fea..544e3d6bb 100755 --- a/application/controllers/CisHmvc/Cms.php +++ b/application/controllers/CisHmvc/Cms.php @@ -69,12 +69,11 @@ class Cms extends Auth_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); - - if (isError($content)) - return $this->load->view('CisHmvc/Error', ['error' => getError($content)]); - - $this->load->view('CisHmvc/Cms/Content', ['content' => getData($content)]); + // return early if the content_id for the content is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** diff --git a/application/controllers/CisHtml/Cms.php b/application/controllers/CisHtml/Cms.php index f56b3eea3..5223fd4e5 100755 --- a/application/controllers/CisHtml/Cms.php +++ b/application/controllers/CisHtml/Cms.php @@ -45,12 +45,11 @@ class Cms extends FHC_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); - - if (isError($content)) - return $this->load->view('CisHtml/Error', ['error' => getError($content)]); - - $this->load->view('CisHtml/Cms/Content', ['content' => getData($content)]); + // return early if the content_id for the content is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** diff --git a/application/controllers/CisVue/Cms.php b/application/controllers/CisVue/Cms.php index 2c1fa1fc6..74b8d19ee 100755 --- a/application/controllers/CisVue/Cms.php +++ b/application/controllers/CisVue/Cms.php @@ -39,12 +39,11 @@ class Cms extends FHC_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); - - if (isError($content)) - return $this->load->view('CisHtml/Error', ['error' => getError($content)]); - - $this->load->view('CisHtml/Cms/Content', ['content' => getData($content)]); + // return early if the content_id for the content is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** diff --git a/application/controllers/api/frontend/v1/Cms.php b/application/controllers/api/frontend/v1/Cms.php new file mode 100644 index 000000000..f54353e28 --- /dev/null +++ b/application/controllers/api/frontend/v1/Cms.php @@ -0,0 +1,98 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end) + * Provides data to the ajax get calls about the searchbar component + * This controller works with JSON calls on the HTTP GET and the output is always JSON + */ +class Cms extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + // NOTE(chris): additional permission checks will be done in SearchBarLib + parent::__construct([ + 'ContentID' => self::PERM_LOGGED, + 'getOrtKurzbzContent' => self::PERM_LOGGED, + 'content' => self::PERM_LOGGED, + ]); + + $this->load->library('CmsLib'); + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function content() + { + // getting the get parameters + $content_id = $this->input->get("content_id",TRUE); + $version = $this->input->get("version",TRUE); + $sprache = $this->input->get("sprache",TRUE); + $sichtbar = $this->input->get("sichtbar",TRUE); + + // return early if the content_id is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing", self::ERROR_TYPE_GENERAL); + + $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); + + if (isError($content)) + $this->terminateWithError(getError($content), self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess(getData($content)); + } + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function ContentID() + { + // if error + //$this->terminateWithError(SearchBarLib::ERROR_WRONG_JSON, self::ERROR_TYPE_GENERAL); + + $ort_kurzbz = $this->input->get('ort_kurzbz',TRUE); + + if(!$ort_kurzbz){ + $this->terminateWithError("missing ort_kurzbz parameter", self::ERROR_TYPE_GENERAL); + } + + $result = $this->OrtModel->getContentID($ort_kurzbz); + + if(isError($result)){ + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $result = hasData($result) ? current(getData($result)) : null; + + $this->terminateWithSuccess($result->content_id ?? NULL); + } + + +} + diff --git a/application/views/CisHmvc/Cms/Content.php b/application/views/CisHmvc/Cms/Content.php index 7ca1347d3..f56c45eb6 100755 --- a/application/views/CisHmvc/Cms/Content.php +++ b/application/views/CisHmvc/Cms/Content.php @@ -10,11 +10,10 @@ $includesArray = array( $this->load->view('templates/FHC-Header', $includesArray); ?> -