From d92ad0a6c6669055d03bcd586761da0f8b2e638d Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Fri, 14 Jun 2024 14:42:02 +0200 Subject: [PATCH 01/21] links the ort_kurzbz from the Stundenplan in the Dashboard to the Ort Information Content --- .../controllers/api/frontend/v1/Ort.php | 71 +++++++++++++++++++ application/models/ressource/Ort_model.php | 12 ++++ public/js/api/fhcapifactory.js | 4 +- public/js/api/ort.js | 10 +++ public/js/apps/Dashboard/Admin.js | 2 + public/js/apps/Dashboard/Fhc.js | 2 + .../components/DashboardWidget/Stundenplan.js | 21 +++++- 7 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 application/controllers/api/frontend/v1/Ort.php create mode 100644 public/js/api/ort.js diff --git a/application/controllers/api/frontend/v1/Ort.php b/application/controllers/api/frontend/v1/Ort.php new file mode 100644 index 000000000..2bc0f945b --- /dev/null +++ b/application/controllers/api/frontend/v1/Ort.php @@ -0,0 +1,71 @@ +. + */ + +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 Ort extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + // NOTE(chris): additional permission checks will be done in SearchBarLib + parent::__construct([ + 'ContentID' => self::PERM_LOGGED + ]); + + $this->load->model('ressource/Ort_model', 'OrtModel'); + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * 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/models/ressource/Ort_model.php b/application/models/ressource/Ort_model.php index 59b213a54..de0c8e331 100755 --- a/application/models/ressource/Ort_model.php +++ b/application/models/ressource/Ort_model.php @@ -20,4 +20,16 @@ class Ort_model extends DB_Model return $this->OrtModel->loadWhere(array("raumtyp_kurzbz" => $raumtyp_kurzbz)); } + + public function getContentID($ort_kurzbz) + { + + return $this->execReadOnlyQuery(" + SELECT content_id + FROM public.tbl_ort + WHERE ort_kurzbz = ?; + ",[$ort_kurzbz]); + + } + } \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 41c89ef50..a41730548 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -20,11 +20,13 @@ import phrasen from "./phrasen.js"; import navigation from "./navigation.js"; import filter from "./filter.js"; import studstatus from "./studstatus.js"; +import ort from "./ort.js"; export default { search, phrasen, navigation, filter, - studstatus + studstatus, + ort, }; diff --git a/public/js/api/ort.js b/public/js/api/ort.js new file mode 100644 index 000000000..32f114565 --- /dev/null +++ b/public/js/api/ort.js @@ -0,0 +1,10 @@ +export default { + getContentID($ort_kurbz) { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/api/frontend/v1/Ort/ContentID", + { ort_kurzbz: $ort_kurbz } + ); + }, +} \ No newline at end of file diff --git a/public/js/apps/Dashboard/Admin.js b/public/js/apps/Dashboard/Admin.js index 426a2fce4..70254c955 100755 --- a/public/js/apps/Dashboard/Admin.js +++ b/public/js/apps/Dashboard/Admin.js @@ -1,5 +1,6 @@ import {CoreNavigationCmpt} from '../../components/navigation/Navigation.js'; import DashboardAdmin from '../../components/Dashboard/Admin.js'; +import FhcApi from '../../plugin/FhcApi.js'; const app = Vue.createApp({ data: () => ({ @@ -11,4 +12,5 @@ const app = Vue.createApp({ } }); app.config.unwrapInjectedRef = true; +app.use(FhcApi); app.mount('#main'); diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index ebcbb4b78..89d1e2c1e 100755 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -1,4 +1,5 @@ import FhcDashboard from '../../components/Dashboard/Dashboard.js'; +import FhcApi from '../../plugin/FhcApi.js'; const app = Vue.createApp({ data: () => ({ @@ -9,4 +10,5 @@ const app = Vue.createApp({ } }); app.config.unwrapInjectedRef = true; +app.use(FhcApi); app.mount('#content'); diff --git a/public/js/components/DashboardWidget/Stundenplan.js b/public/js/components/DashboardWidget/Stundenplan.js index b74095b32..91b8d48cd 100755 --- a/public/js/components/DashboardWidget/Stundenplan.js +++ b/public/js/components/DashboardWidget/Stundenplan.js @@ -19,6 +19,7 @@ export default { } }, computed: { + currentEvents() { return (this.events || []).filter(evt => evt.end < this.dayAfterCurrentDay && evt.start >= this.currentDay); }, @@ -29,12 +30,28 @@ export default { } }, methods: { + printEntry: function(item){ + console.log(item); + }, selectDay(day) { this.currentDay = day; this.minimized = true; + }, + showRoomInfo: function($ort_kurzbz){ + + this.$fhcApi.factory.ort.getContentID($ort_kurzbz).then(res =>{ + + window.location.href = FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/CisHtml/Cms/content/" + res.data; + + }) } + }, created() { + + this.$emit('setConfig', false); axios .get(this.apiurl + '/components/Cis/Stundenplan/Stunden').then(res => { @@ -67,11 +84,11 @@ export default {
-
+
{{evt.title}}
- {{evt.ort_kurzbz}} + {{evt.ort_kurzbz}} {{evt.start.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}-{{evt.end.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}
From bb9d4bda04156567d73b25bf75b6b94a9d56e5c5 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 17 Jun 2024 11:39:14 +0200 Subject: [PATCH 02/21] adds a general modal for the lehrveranstaltungs Uebersicht with all the links connected to the lehrveranstaltung --- public/js/apps/Dashboard/Admin.js | 2 + public/js/apps/Dashboard/Fhc.js | 2 + public/js/components/Cis/Mylv/LvUebersicht.js | 48 +++++++++++++++++++ .../components/DashboardWidget/Stundenplan.js | 23 ++++++--- 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 public/js/components/Cis/Mylv/LvUebersicht.js diff --git a/public/js/apps/Dashboard/Admin.js b/public/js/apps/Dashboard/Admin.js index 70254c955..e0b21cfb5 100755 --- a/public/js/apps/Dashboard/Admin.js +++ b/public/js/apps/Dashboard/Admin.js @@ -1,6 +1,7 @@ import {CoreNavigationCmpt} from '../../components/navigation/Navigation.js'; import DashboardAdmin from '../../components/Dashboard/Admin.js'; import FhcApi from '../../plugin/FhcApi.js'; +import Phrasen from '../../plugin/Phrasen.js'; const app = Vue.createApp({ data: () => ({ @@ -13,4 +14,5 @@ const app = Vue.createApp({ }); app.config.unwrapInjectedRef = true; app.use(FhcApi); +app.use(Phrasen); app.mount('#main'); diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 89d1e2c1e..8dd8fe44b 100755 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -1,5 +1,6 @@ import FhcDashboard from '../../components/Dashboard/Dashboard.js'; import FhcApi from '../../plugin/FhcApi.js'; +import Phrasen from '../../plugin/Phrasen.js'; const app = Vue.createApp({ data: () => ({ @@ -11,4 +12,5 @@ const app = Vue.createApp({ }); app.config.unwrapInjectedRef = true; app.use(FhcApi); +app.use(Phrasen); app.mount('#content'); diff --git a/public/js/components/Cis/Mylv/LvUebersicht.js b/public/js/components/Cis/Mylv/LvUebersicht.js new file mode 100644 index 000000000..c21cf200d --- /dev/null +++ b/public/js/components/Cis/Mylv/LvUebersicht.js @@ -0,0 +1,48 @@ +import BsModal from "../../Bootstrap/Modal"; + +export default { + + + data(){ + return { + // reactive data + items:["lehrveranstaltungsInformationen","Notenlisten","Moodle","Gesamtnote","E-mail","Pinboard","Alle Termine der LV","Anrechnung","Evaluierung","Neue Einmeldung"], + lehreinheit:null, + stg:null, + lv:null, + + result: false, + } + }, + mixins:[BsModal], + components:{ + BsModal, + }, + mounted(){ + this.modal = this.$refs.modalContainer; + }, + template:/*html*/` + + + + + + `, +}; \ No newline at end of file diff --git a/public/js/components/DashboardWidget/Stundenplan.js b/public/js/components/DashboardWidget/Stundenplan.js index 91b8d48cd..d2e1f9693 100755 --- a/public/js/components/DashboardWidget/Stundenplan.js +++ b/public/js/components/DashboardWidget/Stundenplan.js @@ -1,6 +1,8 @@ import Phrasen from '../../mixins/Phrasen.js'; import AbstractWidget from './Abstract.js'; import FhcCalendar from '../Calendar/Calendar.js'; +import LvUebersicht from '../Cis/Mylv/LvUebersicht.js'; + export default { mixins: [ @@ -8,14 +10,17 @@ export default { AbstractWidget ], components: { - FhcCalendar + FhcCalendar, + LvUebersicht, }, + data() { return { stunden: [], minimized: true, events: null, - currentDay: new Date() + currentDay: new Date(), + } }, computed: { @@ -30,9 +35,14 @@ export default { } }, methods: { - printEntry: function(item){ - console.log(item); + showLvUebersicht: function (event){ + + this.$refs.lvUebersicht.lehreinheit = event.lehreinheit_id; + this.$refs.lvUebersicht.lv = event.title; + this.$refs.lvUebersicht.stg = event.stg_typ + event.stg_kurzbz + (event.verband?'-' + event.verband:'' ); + this.$refs.lvUebersicht.show(); }, + selectDay(day) { this.currentDay = day; this.minimized = true; @@ -76,15 +86,16 @@ export default { }) .catch(err => { console.error('ERROR: ', err.response.data) }); }, - template: ` + template: /*html*/`
+
-
+
{{evt.title}}
From b3dfcdc29543259fd28e7c93252212f044b04efa Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 17 Jun 2024 14:01:02 +0200 Subject: [PATCH 03/21] the calendar modal is correctly opened when the correct event is called --- application/views/Cis/Stundenplan.php | 4 ++-- public/js/apps/Cis/Stundenplan.js | 21 ++++++++++++++++--- public/js/components/Calendar/Calendar.js | 15 ++----------- .../Cis/Profil/ProfilModal/EditProfil.js | 3 ++- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/application/views/Cis/Stundenplan.php b/application/views/Cis/Stundenplan.php index cb8f8a712..99103b373 100755 --- a/application/views/Cis/Stundenplan.php +++ b/application/views/Cis/Stundenplan.php @@ -8,10 +8,10 @@ $includesArray = array( $this->load->view('templates/CISHTML-Header', $includesArray); ?> -
+

Stundenplan


- +
load->view('templates/CISHTML-Footer', $includesArray); ?> diff --git a/public/js/apps/Cis/Stundenplan.js b/public/js/apps/Cis/Stundenplan.js index 25823b193..edcad1da8 100755 --- a/public/js/apps/Cis/Stundenplan.js +++ b/public/js/apps/Cis/Stundenplan.js @@ -1,16 +1,28 @@ import FhcCalendar from "../../components/Calendar/Calendar.js"; +import CalendarModal from '../../components/Calendar/CalendarModal.js'; import Phrasen from "../../plugin/Phrasen.js"; const app = Vue.createApp({ components: { - FhcCalendar + FhcCalendar, + CalendarModal }, data() { return { stunden: [], - events: null + events: null, + currentlySelectedEvent:null, } }, + methods:{ + selectEvent: function(event){ + this.currentlySelectedEvent = event; + Vue.nextTick(()=>{ + this.$refs.calendarModal.show(); + }) + + }, + }, created() { axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan/Stunden').then(res => { res.data.retval.forEach(std => { @@ -48,7 +60,10 @@ const app = Vue.createApp({ }); }); }); - } + }, + template:` + + ` }); app.config.unwrapInjectedRef = true; app.use(Phrasen); diff --git a/public/js/components/Calendar/Calendar.js b/public/js/components/Calendar/Calendar.js index 4ce70911e..79260e191 100755 --- a/public/js/components/Calendar/Calendar.js +++ b/public/js/components/Calendar/Calendar.js @@ -5,7 +5,7 @@ import CalendarWeek from './Week.js'; import CalendarWeeks from './Weeks.js'; import CalendarMinimized from './Minimized.js'; import CalendarDate from '../../composables/CalendarDate.js'; -import CalendarModal from './CalendarModal.js'; + // TODO(chris): week/month toggle @@ -17,7 +17,6 @@ export default { CalendarWeek, CalendarWeeks, CalendarMinimized, - CalendarModal }, provide() { return { @@ -105,15 +104,6 @@ export default { }, methods: { handleInput(day) { - // set the event when clicking on the lernveranstaltung in the data - this.currentlySelectedEvent = day[1]; - console.log(this.currentlySelectedEvent) - // showing the modal - Vue.nextTick(()=>{ - this.$refs.calendarModal.show(); - }) - - console.log(day,"this is the day") this.$emit(day[0], day[1]); } }, @@ -145,9 +135,8 @@ export default { }).observe(this.$refs.container); } }, - template: ` + template: /*html*/`
- diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfil.js b/public/js/components/Cis/Profil/ProfilModal/EditProfil.js index 189dd8f5d..befb733d5 100755 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfil.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfil.js @@ -153,7 +153,8 @@ export default { this.modal = this.$refs.modalContainer.modal; }, popup(options) { - return BsModal.popup.bind(this)(null, options); + BsModal.popup.bind(this); + return BsModal.popup(null, options); }, template: /*html*/ ` From 6230aa47aeb032dd171842ecfb9aa05d14bf7a32 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 18 Jun 2024 15:03:36 +0200 Subject: [PATCH 04/21] now also displays the room information inside a modal and does not redirect to the content site --- .../controllers/api/frontend/v1/Ort.php | 26 +++++++++- public/js/api/ort.js | 10 +++- public/js/components/Cis/Cms/ContentModal.js | 47 +++++++++++++++++++ public/js/components/Cis/Mylv/LvUebersicht.js | 3 +- .../components/DashboardWidget/Stundenplan.js | 38 +++++++++++++-- 5 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 public/js/components/Cis/Cms/ContentModal.js diff --git a/application/controllers/api/frontend/v1/Ort.php b/application/controllers/api/frontend/v1/Ort.php index 2bc0f945b..8c4059824 100644 --- a/application/controllers/api/frontend/v1/Ort.php +++ b/application/controllers/api/frontend/v1/Ort.php @@ -33,7 +33,8 @@ class Ort extends FHCAPI_Controller { // NOTE(chris): additional permission checks will be done in SearchBarLib parent::__construct([ - 'ContentID' => self::PERM_LOGGED + 'ContentID' => self::PERM_LOGGED, + 'getOrtKurzbzContent' => self::PERM_LOGGED, ]); $this->load->model('ressource/Ort_model', 'OrtModel'); @@ -67,5 +68,28 @@ class Ort extends FHCAPI_Controller $this->terminateWithSuccess($result->content_id ?? NULL); } + + /** + * @param int $version + * @param string $sprache + * @param boolean $sichtbar + * + * @return $content + */ + public function getOrtKurzbzContent($version = null, $sprache = null, $sichtbar = true) + { + $content_id = $this->input->get("content_id",TRUE); + + $this->load->library('CmsLib'); + + $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); + + if (isError($content)) + $this->terminateWithError(getError($content), self::ERROR_TYPE_GENERAL); + + $content = hasData($content) ? getData($content) : null; + + $this->terminateWithSuccess($content); + } } diff --git a/public/js/api/ort.js b/public/js/api/ort.js index 32f114565..c92ac0be0 100644 --- a/public/js/api/ort.js +++ b/public/js/api/ort.js @@ -1,5 +1,5 @@ export default { - getContentID($ort_kurbz) { + getContentID($ort_kurbz) { return this.$fhcApi.get( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + @@ -7,4 +7,12 @@ export default { { ort_kurzbz: $ort_kurbz } ); }, + getOrtKuzbzContent($ort_kurzbz_content_id) { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/api/frontend/v1/Ort/getOrtKurzbzContent", + { content_id: $ort_kurzbz_content_id } + ); + }, } \ No newline at end of file diff --git a/public/js/components/Cis/Cms/ContentModal.js b/public/js/components/Cis/Cms/ContentModal.js new file mode 100644 index 000000000..3613648ee --- /dev/null +++ b/public/js/components/Cis/Cms/ContentModal.js @@ -0,0 +1,47 @@ +import BsModal from "../../Bootstrap/Modal"; + + +export default { + + + mixins:[BsModal], + + components:{ + BsModal, + }, + data(){ + return{ + content_id:null, + content:null, + ort_kurzbz:null, + result: false, + }; + }, + methods:{ + modalShown: function(){ + + } + }, + mounted(){ + this.modal = this.$refs.modalContainer; + document.addEventListener("show.bs.modal", function(){ + console.log("modal is shown inside the mounted hook") + }) + }, + + template:/*html*/` + + + + + + ` +}; \ No newline at end of file diff --git a/public/js/components/Cis/Mylv/LvUebersicht.js b/public/js/components/Cis/Mylv/LvUebersicht.js index c21cf200d..b2ee20833 100644 --- a/public/js/components/Cis/Mylv/LvUebersicht.js +++ b/public/js/components/Cis/Mylv/LvUebersicht.js @@ -40,8 +40,7 @@ export default {
`, diff --git a/public/js/components/DashboardWidget/Stundenplan.js b/public/js/components/DashboardWidget/Stundenplan.js index d2e1f9693..3a1d3484c 100755 --- a/public/js/components/DashboardWidget/Stundenplan.js +++ b/public/js/components/DashboardWidget/Stundenplan.js @@ -2,7 +2,7 @@ import Phrasen from '../../mixins/Phrasen.js'; import AbstractWidget from './Abstract.js'; import FhcCalendar from '../Calendar/Calendar.js'; import LvUebersicht from '../Cis/Mylv/LvUebersicht.js'; - +import ContentModal from '../Cis/Cms/ContentModal.js' export default { mixins: [ @@ -12,6 +12,7 @@ export default { components: { FhcCalendar, LvUebersicht, + ContentModal, }, data() { @@ -35,6 +36,33 @@ export default { } }, methods: { + + showRoomInfoModal: function(ort_kurzbz){ + + // getting the content_id of the ort_kurzbz + this.$fhcApi.factory.ort.getContentID(ort_kurzbz).then(res =>{ + + let ort_kurzbz_content_id = res.data; + + this.$refs.contentModal.content_id = ort_kurzbz_content_id; + + this.$fhcApi.factory.ort.getOrtKuzbzContent(ort_kurzbz_content_id).then(res =>{ + let result = res.data; + console.log("this is the result of the query", result); + this.$refs.contentModal.content = result; + this.$refs.contentModal.ort_kurzbz = ort_kurzbz; + if(this.$refs.contentModal.content){ + this.$refs.contentModal.show(); + } + + + }) + + + + }) + + }, showLvUebersicht: function (event){ this.$refs.lvUebersicht.lehreinheit = event.lehreinheit_id; @@ -60,6 +88,7 @@ export default { }, created() { + this.$emit('setConfig', false); @@ -89,17 +118,20 @@ export default { template: /*html*/`
+
-
+
{{evt.title}}
- {{evt.ort_kurzbz}} + + + {{evt.ort_kurzbz}} {{evt.start.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}-{{evt.end.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}
From 629ea3716ebeadba3dea204d3c0541941800c21b Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Wed, 19 Jun 2024 11:15:06 +0200 Subject: [PATCH 05/21] changes how the content and the news are displayed and also modifies the modals for the roominformation which now get their data from props instead of passing them directly via refs --- application/controllers/CisHmvc/Cms.php | 11 +-- application/controllers/CisHtml/Cms.php | 11 +-- application/controllers/CisVue/Cms.php | 11 +-- .../controllers/api/frontend/v1/Cms.php | 98 +++++++++++++++++++ application/views/CisHmvc/Cms/Content.php | 5 +- application/views/CisHtml/Cms/Content.php | 3 +- application/views/CisVue/Cms/Content.php | 4 +- public/js/api/cms.js | 15 +++ public/js/api/fhcapifactory.js | 2 + public/js/api/ort.js | 12 +-- public/js/apps/Cis/Cms.js | 10 +- public/js/components/Bootstrap/Modal.js | 2 +- public/js/components/Cis/Cms/Content.js | 48 +++++---- public/js/components/Cis/Cms/ContentModal.js | 38 +++++-- public/js/components/Cis/Cms/News.js | 34 +++++++ .../components/DashboardWidget/Stundenplan.js | 34 +++---- 16 files changed, 249 insertions(+), 89 deletions(-) create mode 100644 application/controllers/api/frontend/v1/Cms.php create mode 100644 public/js/api/cms.js create mode 100644 public/js/components/Cis/Cms/News.js 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); ?> -
-'); ?> + +' : ''); ?>
- load->view('templates/FHC-Footer', $includesArray); ?> diff --git a/application/views/CisHtml/Cms/Content.php b/application/views/CisHtml/Cms/Content.php index ac62c985a..d3e03ea04 100755 --- a/application/views/CisHtml/Cms/Content.php +++ b/application/views/CisHtml/Cms/Content.php @@ -12,8 +12,9 @@ $this->load->view('templates/CISHTML-Header', $includesArray); ?>
-'); ?> +' : ''); ?> +
load->view('templates/CISHTML-Footer', $includesArray); ?> \ No newline at end of file diff --git a/application/views/CisVue/Cms/Content.php b/application/views/CisVue/Cms/Content.php index 02aa42b57..ed9d90ef2 100755 --- a/application/views/CisVue/Cms/Content.php +++ b/application/views/CisVue/Cms/Content.php @@ -11,7 +11,9 @@ $this->load->view('templates/CISVUE-Header', $includesArray); ?>
-'); ?> + +' : ''); ?> +
load->view('templates/CISVUE-Footer', $includesArray); ?> diff --git a/public/js/api/cms.js b/public/js/api/cms.js new file mode 100644 index 000000000..5602c7bf8 --- /dev/null +++ b/public/js/api/cms.js @@ -0,0 +1,15 @@ +export default { + content(content_id, version=null, sprache=null, sichtbar=null) { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/api/frontend/v1/Cms/content", + { content_id: content_id, + ...(version?{version}:{}), + ...(sprache?{sprache}:{}), + ...(sichtbar?{sichtbar}:{}), + } + ); + }, + + } \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index a41730548..31c6fe9ab 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -21,6 +21,7 @@ import navigation from "./navigation.js"; import filter from "./filter.js"; import studstatus from "./studstatus.js"; import ort from "./ort.js"; +import cms from "./cms.js"; export default { search, @@ -29,4 +30,5 @@ export default { filter, studstatus, ort, + cms, }; diff --git a/public/js/api/ort.js b/public/js/api/ort.js index c92ac0be0..4c8e2ce73 100644 --- a/public/js/api/ort.js +++ b/public/js/api/ort.js @@ -1,18 +1,10 @@ export default { - getContentID($ort_kurbz) { + getContentID(ort_kurbz) { return this.$fhcApi.get( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/api/frontend/v1/Ort/ContentID", - { ort_kurzbz: $ort_kurbz } - ); - }, - getOrtKuzbzContent($ort_kurzbz_content_id) { - return this.$fhcApi.get( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - "/api/frontend/v1/Ort/getOrtKurzbzContent", - { content_id: $ort_kurzbz_content_id } + { ort_kurzbz: ort_kurbz } ); }, } \ No newline at end of file diff --git a/public/js/apps/Cis/Cms.js b/public/js/apps/Cis/Cms.js index cd2b5f6e9..dd059fb92 100755 --- a/public/js/apps/Cis/Cms.js +++ b/public/js/apps/Cis/Cms.js @@ -1,13 +1,14 @@ import BsConfirm from "../../components/Bootstrap/Confirm.js"; //import Pagination from "../../components/Pagination/Pagination.js"; -import Content from "../../components/Cis/Cms/Content.js"; -import Fhcapi from "../api/fhcapifactory.js"; +import CmsNews from "../../components/Cis/Cms/News.js"; +import CmsContent from "../../components/Cis/Cms/Content.js"; +import Fhcapi from "../../plugin/FhcApi.js"; -Vue.$fhcapi = Fhcapi; const app = Vue.createApp({ components: { - Content, + CmsNews, + CmsContent, }, mounted() { document.querySelectorAll("#cms [data-confirm]").forEach((el) => { @@ -34,5 +35,6 @@ const app = Vue.createApp({ }, }); app.use(primevue.config.default, { zIndex: { overlay: 9999 } }); +app.use(Fhcapi); app.mount("#cms"); //#cms [data-confirm], #cms [data-href] diff --git a/public/js/components/Bootstrap/Modal.js b/public/js/components/Bootstrap/Modal.js index 734a3bdb9..e390319e8 100755 --- a/public/js/components/Bootstrap/Modal.js +++ b/public/js/components/Bootstrap/Modal.js @@ -109,7 +109,7 @@ export default { document.body.appendChild(wrapper); }); }, - template: `