diff --git a/application/config/search.php b/application/config/search.php
index 14b6e89d8..f52d755dd 100644
--- a/application/config/search.php
+++ b/application/config/search.php
@@ -671,3 +671,97 @@ $config['room'] = [
LEFT JOIN public.tbl_adresse address
USING (adresse_id)"
];
+
+$config['cms'] = [
+ 'primarykey' => 'contentsprache_id',
+ 'table' => 'cms',
+ 'prepare' => "
+ cms_auth (content_id) AS (
+ SELECT content_id
+ FROM campus.tbl_content c
+ WHERE NOT EXISTS (SELECT 1 FROM campus.tbl_contentgruppe g WHERE g.content_id=c.content_id)
+ UNION
+ SELECT content_id
+ FROM public.vw_gruppen g
+ JOIN campus.tbl_contentgruppe c USING (gruppe_kurzbz)
+ WHERE uid = (TABLE auth)
+ ),
+ cms_active (content_id, template_kurzbz) AS (
+ SELECT content_id, template_kurzbz
+ FROM cms_auth
+ JOIN campus.tbl_content USING (content_id)
+ WHERE aktiv = TRUE
+ ),
+ cms_active_redirect (content_id) AS (
+ SELECT content_id
+ FROM cms_active
+ WHERE template_kurzbz = 'redirect'
+ ),
+ cms_active_redirect_linked (content_id) AS (
+ SELECT content_id
+ FROM cms_active_redirect
+ JOIN campus.tbl_contentsprache USING (content_id)
+ WHERE LEFT((xpath('string(/content/url)', content))[1]::text, 1) <> '#'
+ ),
+ cms_active_others (content_id) AS (
+ SELECT content_id
+ FROM cms_active
+ WHERE template_kurzbz IN ('contentmittitel', 'contentohnetitel', 'contentmittitel_filterwidget')
+ ),
+ cms (contentsprache_id) AS (
+ SELECT contentsprache_id
+ FROM campus.tbl_contentsprache
+ WHERE content_id IN (
+ SELECT content_id
+ FROM cms_active_redirect_linked
+ UNION
+ SELECT content_id
+ FROM cms_active_others
+ )
+ AND version = campus.get_highest_content_version(content_id)
+ )
+ ",
+ 'searchfields' => [
+ 'content' => [
+ 'alias' => ['inhalt'],
+ 'comparison' => "vector",
+ 'field' => "(setweight(to_tsvector('simple', COALESCE(titel, '')), 'A') || setweight(to_tsvector('simple', COALESCE(content, '')::text), 'B'))",
+ 'join' => [
+ 'table' => "campus.tbl_contentsprache",
+ 'using' => "contentsprache_id"
+ ]
+ ],
+ 'content_id' => [
+ 'alias' => ['id'],
+ 'comparison' => "equal-int",
+ 'field' => "content_id",
+ 'join' => [
+ 'table' => "campus.tbl_contentsprache",
+ 'using' => "contentsprache_id"
+ ]
+ ],
+ 'lang' => [
+ 'alias' => ['language', 'sprache'],
+ 'comparison' => "equals",
+ 'field' => "sprache",
+ 'join' => [
+ 'table' => "campus.tbl_contentsprache",
+ 'using' => "contentsprache_id"
+ ]
+ ]
+ ],
+ 'resultfields' => [
+ "contentsprache.content_id",
+ "content.template_kurzbz",
+ "contentsprache.version",
+ "contentsprache.sprache AS language",
+ "contentsprache.titel AS title",
+ "contentsprache.content",
+ "(xpath('string(/content/url)', contentsprache.content))[1] AS content_url"
+ ],
+ 'resultjoin' => "
+ JOIN campus.tbl_contentsprache contentsprache
+ USING (contentsprache_id)
+ JOIN campus.tbl_content content
+ USING (content_id)"
+];
diff --git a/application/config/searchfunctions.php b/application/config/searchfunctions.php
index c8244e9a3..898069aed 100644
--- a/application/config/searchfunctions.php
+++ b/application/config/searchfunctions.php
@@ -25,7 +25,7 @@ $config['similar'] = [
$config['vector'] = [
'priority' => 1,
- 'rank' => "ts_rank_cd({field}, to_tsquery('simple', {word}))",
+ 'rank' => "ts_rank({field}, to_tsquery('simple', {word}))",
'compare' => "to_tsquery('simple', {word}) @@ {field}"
];
diff --git a/application/controllers/api/frontend/v1/Language.php b/application/controllers/api/frontend/v1/Language.php
new file mode 100644
index 000000000..797af4804
--- /dev/null
+++ b/application/controllers/api/frontend/v1/Language.php
@@ -0,0 +1,47 @@
+.
+ */
+
+if (! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * This controller operates between (interface) the JS (GUI) and the back-end
+ * Provides data to the ajax get calls about languages
+ * This controller works with JSON calls on the HTTP GET and the output is always JSON
+ */
+class Language extends FHCAPI_Controller
+{
+ public function __construct()
+ {
+ parent::__construct([
+ 'get' => self::PERM_LOGGED
+ ]);
+
+ // Load models
+ $this->load->model('system/Sprache_model', 'SpracheModel');
+ }
+
+ public function get()
+ {
+ $this->SpracheModel->addOrder('sprache');
+
+ $result = $this->SpracheModel->load();
+ $data = $this->getDataOrTerminateWithError($result);
+
+ $this->terminateWithSuccess($data);
+ }
+}
diff --git a/application/libraries/SearchBarLib.php b/application/libraries/SearchBarLib.php
index c3528978d..782e30843 100644
--- a/application/libraries/SearchBarLib.php
+++ b/application/libraries/SearchBarLib.php
@@ -168,6 +168,9 @@ class SearchBarLib
FROM public.tbl_sprache
WHERE sprache=" . $this->_ci->db->escape($lang) . "
LIMIT 1
+ ),
+ auth (uid) AS (
+ SELECT " . $this->_ci->db->escape(getAuthUID()) . " AS uid
)";
if ($sql_with) {
@@ -248,6 +251,9 @@ class SearchBarLib
WHERE sprache=" . $this->_ci->db->escape($lang) . "
LIMIT 1
)");
+ array_unshift($with, "auth (uid) AS (
+ SELECT " . $this->_ci->db->escape(getAuthUID()) . " AS uid
+ )");
return success("
WITH " . implode(", ", $with) . "
diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js
index 655bfa409..26ed8847b 100644
--- a/public/js/api/fhcapifactory.js
+++ b/public/js/api/fhcapifactory.js
@@ -23,6 +23,7 @@ import studstatus from "./studstatus.js";
import stv from "./stv.js";
import notiz from "./notiz.js";
import betriebsmittel from "./betriebsmittel.js";
+import language from "./language.js";
export default {
search,
@@ -32,5 +33,6 @@ export default {
studstatus,
stv,
notiz,
- betriebsmittel
+ betriebsmittel,
+ language
};
diff --git a/public/js/api/language.js b/public/js/api/language.js
new file mode 100644
index 000000000..6a11d193b
--- /dev/null
+++ b/public/js/api/language.js
@@ -0,0 +1,22 @@
+/**
+ * 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
+
+
+