Merge branch 'feature-25999/C4_cleanup' into feature-25999/C4_CMS_content_router

# Conflicts:
#	public/js/apps/Cis/Cms.js
#	public/js/components/Cis/Cms/Content.js
This commit is contained in:
Johann Hoffmann
2024-12-16 10:38:22 +01:00
19 changed files with 152 additions and 85 deletions
-42
View File
@@ -79,48 +79,6 @@ class Cms extends Auth_Controller
$this->load->view('CisVue/Cms/Content', ['infoscreen' => $infoscreen, 'studiengang_kz' => $studiengang_kz, 'semester' => $semester, 'mischen' => $mischen, 'titel' => $titel, 'edit' => $edit, 'sichtbar' => $sichtbar]);
}
public function getNews($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true)
{
$get_page = intval($this->input->get('page', true));
$get_page_size = intval($this->input->get('page_size', true));
if ($get_page) {
$page = $get_page;
}
if ($get_page_size) {
$page_size = $get_page_size;
} else {
$page_size = $this->page_size;
}
$news = $this->cmslib->getNews($infoscreen, $studiengang_kz, $semester, $mischen, $titel, $edit, $sichtbar, $page, $page_size);
if (isError($news)) {
$this->terminateWithJsonError(getError($news));
}
$news = hasData($news) ? getData($news) : null;
if ($news) {
echo json_encode($news);
} else {
show_error("News: No data found");
}
}
public function getNewsRowCount($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $fachbereich_kurzbz = null, $maxalter = 0, $edit = false, $sichtbar = true, $page = 1, $page_size = 10)
{
list($studiengang_kz, $semester) = $this->cmslib->getStgAndSem($studiengang_kz, $semester);
$all = $edit;
$num_rows = $this->NewsModel->countNewsWithContent(getSprache(), $studiengang_kz, $semester, $fachbereich_kurzbz, $sichtbar, $maxalter, $page, $this->page_size, $all, $mischen);
if (isError($num_rows)) {
$this->terminateWithJsonError(getError($num_rows));
}
$num_rows = hasData($num_rows) ? getData($num_rows) : null;
if ($num_rows) {
echo json_encode($num_rows);
} else {
show_error("News number rows: No data found");
}
}
public function getRoomInformation($ort_kurzbz){
$this->load->view('CisVue/Cms/RoomInformation',['ort_kurzbz'=>$ort_kurzbz]);
}
@@ -0,0 +1,58 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
class CisMenu extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getMenu' => self::PERM_LOGGED,
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* fetches the menu for CIS from the database based on the userLanguage
*/
public function getMenu()
{
$this->load->model('content/Content_model', 'ContentModel');
$this->load->config('cis');
$cis4_content_id =$this->config->item('cis_menu_root_content_id');
$result = $this->ContentModel->getMenu($cis4_content_id, getAuthUID(),getUserLanguage());
$result = $this->getDataOrTerminateWithError($result);
$menu = $result->childs ?? [];
$this->terminateWithSuccess($menu);
}
}
@@ -175,14 +175,18 @@ class Cms extends FHCAPI_Controller
// getting the GET parameters
$page = intval($this->input->get('page', true));
$page_size = intval($this->input->get('page_size', true));
$sprache = $this->input->get('sprache', true);
if(!$sprache)
{
$sprache = getUserLanguage();
}
// default value for the page_size is 10
$page_size = $page_size ?? 10;
$news = $this->cmslib->getNews($infoscreen, $studiengang_kz, $semester, $mischen, $titel, $edit, $sichtbar, $page, $page_size);
$news = $this->cmslib->getNews($infoscreen, $studiengang_kz, $semester, $mischen, $titel, $edit, $sichtbar, $page, $page_size, $sprache);
$news = $this->getDataOrTerminateWithError($news);
$this->addMeta('test', $this->p->t('global', 'studiengangsleitung'));
$this->addMeta('phrases', json_decode($this->p->getJson()));
$this->terminateWithSuccess($news);
+2 -2
View File
@@ -221,7 +221,7 @@ class CmsLib
*
* @return void
*/
public function getNews($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true, $page = 1, $page_size = 10)
public function getNews($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true, $page = 1, $page_size = 10, $sprache)
{
$this->ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
list($studiengang_kz, $semester) = $this->getStgAndSem($studiengang_kz, $semester);
@@ -230,7 +230,7 @@ class CmsLib
$xml = '<?xml version="1.0" encoding="UTF-8"?><content>';
$this->ci->load->model('content/News_model', 'NewsModel');
$news = $this->ci->NewsModel->getNewsWithContent(getSprache(), $studiengang_kz, $semester, null, $sichtbar, 0, $page, $page_size, $all, $mischen);
$news = $this->ci->NewsModel->getNewsWithContent($sprache, $studiengang_kz, $semester, null, $sichtbar, 0, $page, $page_size, $all, $mischen);
if (isError($news))
return $news;
+1 -10
View File
@@ -5,6 +5,7 @@ $includesArray = array(
'bootstrap5' => true,
'fontawesome6' => true,
'axios027' => true,
'primevue3' => true,
'customJSModules' => array_merge([
'public/js/apps/Cis.js'
], $customJSModules ?? []),
@@ -15,15 +16,6 @@ $includesArray = array(
$this->load->view('templates/FHC-Header', $includesArray);
if (!isset($menu)) {
$ci =& get_instance(); // get CI instance
$ci->load->model('content/Content_model', 'ContentModel');
$ci->load->config('cis');
$cis4_content_id = $ci->config->item('cis_menu_root_content_id');
$result = $ci->ContentModel->getMenu($cis4_content_id, getAuthUID());
$menu = getData($result)->childs ?? [];
}
?>
<script type="text/javascript">
@@ -39,7 +31,6 @@ if (!isset($menu)) {
logout-url="<?= site_url('Cis/Auth/logout'); ?>"
:searchbaroptions="searchbaroptions"
:searchfunction="searchfunction"
:menu="<?= htmlspecialchars(json_encode(array_values($menu)), ENT_QUOTES, 'UTF-8') ?>"
></cis-menu>
</header>
+2 -1
View File
@@ -12,12 +12,13 @@ export default {
},
//api function used for the news View that renders the html
getNews(page = 1, page_size = 10) {
getNews(page = 1, page_size = 10, sprache) {
return this.$fhcApi.get(
"/api/frontend/v1/Cms/getNews",
{
page,
page_size,
sprache,
},
);
},
+2
View File
@@ -34,6 +34,7 @@ import cms from "./cms.js";
import lehre from "./lehre.js";
import addons from "./addons.js";
import studiengang from "./studiengang.js";
import menu from "./menu.js";
export default {
search,
@@ -55,4 +56,5 @@ export default {
lehre,
addons,
studiengang,
menu,
};
+9
View File
@@ -0,0 +1,9 @@
export default {
getMenu: function () {
return this.$fhcApi.get(
"/api/frontend/v1/CisMenu/getMenu",
{}
);
}
}
+1
View File
@@ -107,6 +107,7 @@ const app = Vue.createApp({
}
});
app.use(FhcApi);
//TODO: EVERY View that uses CISVUE-HEADER includes Cis.js and needs to import primevue.js even if they don't use it (might be needed for Vue Router)
app.use(primevue.config.default, {
zIndex: {
overlay: 9000,
+2 -4
View File
@@ -105,8 +105,6 @@ const app = Vue.createApp({
setScrollbarWidth();
app.use(FhcApi);
app.use(router);
app.use(primevue.config.default, {zIndex: {overlay: 9999}});
app.use(Phrasen, {reload: true});
app.use(primevue.config.default, { zIndex: { overlay: 9999 } });
app.use(Phrasen);
app.mount("#cms");
+1 -1
View File
@@ -89,5 +89,5 @@ const app = Vue.createApp({
setScrollbarWidth();
app.use(Phrasen, {reload: true});
app.use(Phrasen);
app.mount('#content');
+1 -1
View File
@@ -11,4 +11,4 @@ const app = Vue.createApp({
setScrollbarWidth();
app.use(Phrasen, {reload: true}).mount('#content');
app.use(Phrasen).mount('#content');
+1 -1
View File
@@ -161,5 +161,5 @@ const app = Vue.createApp({
</fhc-calendar>
`
});
app.use(Phrasen, {reload: true});
app.use(Phrasen);
app.mount('#content');
+1 -1
View File
@@ -21,5 +21,5 @@ const app = Vue.createApp({
}
});
app
.use(Phrasen, {reload: true})
.use(Phrasen)
.mount('#wrapper');
+20 -5
View File
@@ -1,6 +1,7 @@
import raum_contentmittitel from './Content_types/Raum_contentmittitel.js'
import general from './Content_types/General.js'
export default {
name: "ContentComponent",
@@ -13,10 +14,6 @@ export default {
type: [String, Number],
default: null,
},
sprache: {
type: [String, Number],
default: null,
},
sichtbar: {
type: [String, Number],
default: null,
@@ -45,9 +42,23 @@ export default {
context.content_type = res.data.type;
});
},
fetchContent(){
return this.$fhcApi.factory.cms.content(this.content_id, this.version, this.sprache, this.sichtbar).then(res => {
this.content = res.data.content;
this.content_type = res.data.type;
});
}
},
watch:{
sprache: function(sprache){
this.fetchContent();
},
},
computed: {
sprache(){
return this.$p.user_language.value;
},
computeContentType: function () {
switch (this.content_type) {
case "raum_contentmittitel":
@@ -58,9 +69,13 @@ export default {
},
},
created() {
this.load()
this.$fhcApi.factory.cms.content(this.content_id, this.version, this.sprache, this.sichtbar).then(res => {
this.content = res.data.content;
this.content_type = res.data.type;
});
},
mounted() {
},
template: /*html*/ `
<!-- div that contains the content -->
+21 -6
View File
@@ -12,9 +12,28 @@ export default {
content: null,
maxPageCount: 0,
page_size: 10,
page:1,
};
},
watch:{
'$p.user_language.value':function(sprache){
this.fetchNews();
console.log("ere")
}
},
computed:{
sprache: function(){
return this.$p.user_language.value;
},
},
methods: {
fetchNews: function(){
return this.$fhcApi.factory.cms.getNews(this.page, this.page_size, this.sprache)
.then(res => res.data)
.then(result => {
this.content = result;
});
},
loadNewPageContent: function (data) {
this.$fhcApi.factory.cms.getNews(data.page, data.rows)
.then(res => res.data)
@@ -25,11 +44,7 @@ export default {
},
},
created() {
this.$fhcApi.factory.cms.getNews(1, this.page_size)
.then(res => res.data)
.then(result => {
this.content = result;
});
this.fetchNews();
this.$fhcApi.factory.cms.getNewsRowCount()
.then(res => res.data)
@@ -40,7 +55,7 @@ export default {
template: /*html*/ `
<h2 >News</h2>
<hr/>
<pagination v-show="content?true:false" :page_size="page_size" @page="loadNewPageContent" :maxPageCount="maxPageCount">
<pagination v-show="content?true:false" :page_size="page_size" @page="page=$event.page; loadNewPageContent($event)" :maxPageCount="maxPageCount">
</pagination>
<div class="container-fluid">
<div class="row">
+15 -4
View File
@@ -9,7 +9,6 @@ export default {
CisSprachen,
},
props: {
menu: Array,
rootUrl: String,
logoUrl: String,
avatarUrl: String,
@@ -51,6 +50,13 @@ export default {
}
},
methods: {
fetchMenu: function(){
return this.$fhcApi.factory.menu.getMenu()
.then(res => res.data)
.then(menu => {
this.entries = menu;
})
},
checkSettingsVisibility: function (event) {
// hides the settings collapsible if the user clicks somewhere else
if (!this.$refs.navUserDropdown.contains(event.target)) {
@@ -64,6 +70,10 @@ export default {
document.removeEventListener("click", this.checkSettingsVisibility);
},
makeParentContentActive(content_id, collection=this.entries, parent=null){
if(!collection) return;
if (typeof collection == 'object' && !Array.isArray(collection) && Object.entries(collection).length > 0) {
collection = Object.values(collection);
}
for(let entry of collection){
if(entry.content_id == content_id){
this.activeEntry = parent;
@@ -80,8 +90,10 @@ export default {
this.activeEntry = content_id;
},
},
created(){
this.fetchMenu();
},
mounted(){
this.entries = this.menu;
this.$p.loadCategory(['ui', 'global'])
this.navUserDropdown = new bootstrap.Collapse(this.$refs.navUserDropdown,{
toggle: false
@@ -105,7 +117,7 @@ export default {
id="nav-user-menu" class="top-100 end-0 collapse list-unstyled" aria-labelledby="nav-user-btn">
<li class="btn-level-2"><a class="btn btn-level-2 rounded-0 d-block" :href="site_url + '/Cis/Profil'" id="menu-profil">Profil</a></li>
<li class="btn-level-2">
<cis-sprachen></cis-sprachen>
<cis-sprachen @languageChanged="fetchMenu"></cis-sprachen>
</li>
<li class="btn-level-2"><hr class="dropdown-divider m-0 "></li>
<li><a class="btn btn-level-2 rounded-0 d-block" :href="logoutUrl">Logout</a></li>
@@ -119,7 +131,6 @@ export default {
</button>
</div>
<div class="offcanvas-body p-0">
<div id="nav-main-menu" class="nav-menu-collapse collapse collapse-horizontal show">
<div>
<cis-menu-entry :highestMatchingUrlCount="highestMatchingUrlCount" :activeContent="activeEntry" v-for="entry in entries" :key="entry.content_id" :entry="entry" />
+7 -1
View File
@@ -5,11 +5,17 @@ export default {
sprachenTranslation:null,
}
},
emits: ['languageChanged'],
methods:{
changeLanguage: function(lang){
if(this.allActiveLanguages.some(l => l === lang))
{
this.$p.setLanguage(lang, this.$fhcApi);
this.$p.setLanguage(lang, this.$fhcApi)
.then(res => res.data)
.then(data =>
{
this.$emit('languageChanged', lang);
})
}
},
getSprachenBezeichnung: function(lang){
+2 -4
View File
@@ -1,9 +1,8 @@
import FhcApi from './FhcApi.js';
const categories = Vue.reactive({});
const user_language = Vue.ref(FHC_JS_DATA_STORAGE_OBJECT.user_language);
const loadingModules = {};
let reload = false;
let user_language = Vue.ref(FHC_JS_DATA_STORAGE_OBJECT.user_language);
function extractCategory(obj, category) {
return obj.filter(e => e.category == category).reduce((res, elem) => {
@@ -22,10 +21,10 @@ function getValueForLoadedPhrase(category, phrase, params) {
}
const phrasen = {
user_language,
setLanguage(language, api) {
const catArray = Object.keys(categories)
return api.factory.phrasen.setLanguage(catArray, language).then(res => {
if(reload) window.location.reload()
res.data.forEach(row => {
categories[row.category][row.phrase] = row.text
@@ -79,7 +78,6 @@ const phrasen = {
export default {
install(app, options) {
reload = options?.reload ?? reload
app.use(FhcApi, options?.fhcApi || undefined);
app.config.globalProperties.$p = {
t: phrasen.t,