diff --git a/application/controllers/Cis/Compat.php b/application/controllers/Cis/Compat.php new file mode 100644 index 000000000..5c99d8bfc --- /dev/null +++ b/application/controllers/Cis/Compat.php @@ -0,0 +1,44 @@ + ['basis/cis:r'], + 'legacy' => ['basis/cis:r'], + + ]); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + + /** + * @access public + * @return void + */ + public function ci() + { + $this->load->view('CisRouterView/CisRouterView.php',['route' => 'Compat']); + } + + /** + * @access public + * @return void + */ + public function legacy() + { + $this->load->view('CisRouterView/CisRouterView.php',['route' => 'Compat']); + } + +} diff --git a/application/controllers/api/frontend/v1/CisMenu.php b/application/controllers/api/frontend/v1/CisMenu.php index 439f52df6..5324f348b 100644 --- a/application/controllers/api/frontend/v1/CisMenu.php +++ b/application/controllers/api/frontend/v1/CisMenu.php @@ -83,7 +83,7 @@ class CisMenu extends FHCAPI_Controller return site_url("/CisVue/Cms/content/" . $menuItem->content_id); } - if (!$menuItem->content || !mb_strlen($menuItem->content)) { + if (!isset($menuItem->content) || !$menuItem->content || !mb_strlen($menuItem->content)) { return ''; } diff --git a/public/js/apps/Cis/Cis.js b/public/js/apps/Cis/Cis.js index d4f846f25..2ce04b9e9 100644 --- a/public/js/apps/Cis/Cis.js +++ b/public/js/apps/Cis/Cis.js @@ -19,6 +19,7 @@ import DeadlineOverview from "../../components/Cis/Abgabetool/DeadlineOverview.j import Studium from "../../components/Cis/Studium/Studium.js"; import StgOrgLvPlan from "../../components/Cis/LvPlan/StgOrg.js"; import OtherLvPlan from "../../components/Cis/LvPlan/OtherLvPlan.js"; +import Compat from "../../components/Cis/Compat.js"; import ApiRouteInfo from '../../api/factory/routeinfo.js'; import {capitalize} from "../../helpers/StringHelpers.js"; @@ -29,6 +30,18 @@ const isMobile = window.matchMedia("(max-width: 767px)").matches; const router = VueRouter.createRouter({ history: VueRouter.createWebHistory(`/${ciPath}`), routes: [ + { + path: `/Cis/Compat/:mode(ci|legacy)/:path(.*)`, + name: 'Compat', + component: Compat, + props: (route) => { + return { + mode: route.params.mode, + path: route.params.path, + query_string: VueRouter.stringifyQuery(route.query) + }; + } + }, { path: `/Cis/Studium`, name: 'Studium', @@ -277,7 +290,7 @@ const app = Vue.createApp({ if (target && this.isInternalRoute(target.href)) { const url = new URL(target.href) - const path = url.pathname + const path = url.pathname + url.search; const base = this.$router.options.history.base const route = path.replace(base, '') || '/' diff --git a/public/js/components/Cis/Compat.js b/public/js/components/Cis/Compat.js new file mode 100644 index 000000000..e6fb653f7 --- /dev/null +++ b/public/js/components/Cis/Compat.js @@ -0,0 +1,93 @@ +export default { + name: "Compat", + props: { + mode: { type: String, required: true }, + path: { type: String, required: true }, + query_string: { type: String, required: true, default: ''} + }, + data: function() { + return { + lastLoadediFrameURL: '', + srcUrl: '' + }; + }, + computed: { + propsWatchHelper: function() { + return this.mode + '#' + this.path + '#' + this.query_string; + } + }, + mounted: function() { + this.srcUrl = this.buildSrcUrl(); + }, + watch: { + propsWatchHelper: function() { + if(this.lastLoadediFrameURL === '') { + return; + } + + let currentiFrameURL = this.$refs.compatiframe ? this.$refs.compatiframe.src : ''; + + let url = this.buildSrcUrl(); + if(this.lastLoadediFrameURL !== url) { + this.srcUrl = url; + if(this.srcUrl === url) { + this.$refs.compatiframe.contentWindow.location.href = url; + } + } + } + }, + methods: { + buildSrcUrl: function() { + let url = false; + switch(this.mode) { + case 'ci': + url = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'index.ci.php/' + this.path; + break; + case 'legacy': + url = FHC_JS_DATA_STORAGE_OBJECT.app_root + this.path; + break; + default: + url = false; + } + if(this.query_string !== '' && url) { + url += '?' + this.query_string; + } + + return url; + }, + loadHandler: function() { + let iframe_href = this.$refs.compatiframe.contentWindow.location.href; + let ci_urlstart = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'index.ci.php/'; + let legacy_urlstart = FHC_JS_DATA_STORAGE_OBJECT.app_root; + let routerpath = null; + + this.lastLoadediFrameURL = iframe_href; + + if(iframe_href.startsWith(ci_urlstart)) { + routerpath = iframe_href.replace( + ci_urlstart, '/Cis/Compat/ci/'); + } else if(iframe_href.startsWith(legacy_urlstart)) { + routerpath = iframe_href.replace( + legacy_urlstart, '/Cis/Compat/legacy/'); + } else { + return; + } + + if(this.$route.fullPath !== routerpath) { + this.$router.push(routerpath); + } + } + }, + template: ` +