diff --git a/application/config/Events.php b/application/config/Events.php index 3e0a5248f..80a8f03b3 100644 --- a/application/config/Events.php +++ b/application/config/Events.php @@ -6,30 +6,30 @@ use CI3_Events as Events; Events::on('loadRenderers', function ($renderers) { $fhc_core_renderers =& $renderers(); $fhc_core_renderers["lehreinheit"] = array( - 'calendarEvent' => APP_ROOT.'public/js/components/Cis/Renderer/Lehreinheit/calendarEvent.js', - 'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Lehreinheit/modalTitle.js', - 'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Lehreinheit/modalContent.js', - 'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css' + 'calendarEvent' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Lehreinheit/calendarEvent.js'), + 'modalTitle' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Lehreinheit/modalTitle.js'), + 'modalContent' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Lehreinheit/modalContent.js'), + 'calendarEventStyles' => APP_ROOT . 'public/css/Cis4/CoreCalendarEvents.css' ); }); Events::on('loadRenderers', function ($renderers) { $fhc_core_renderers =& $renderers(); $fhc_core_renderers["reservierung"] = array( - 'calendarEvent' => APP_ROOT.'public/js/components/Cis/Renderer/Reservierungen/calendarEvent.js', - 'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Reservierungen/modalTitle.js', - 'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Reservierungen/modalContent.js', - 'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css' + 'calendarEvent' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Reservierungen/calendarEvent.js'), + 'modalTitle' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Reservierungen/modalTitle.js'), + 'modalContent' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Reservierungen/modalContent.js'), + 'calendarEventStyles' => APP_ROOT . 'public/css/Cis4/CoreCalendarEvents.css' ); }); Events::on('loadRenderers', function ($renderers) { $fhc_core_renderers =& $renderers(); $fhc_core_renderers["ferien"] = array( - 'calendarEvent' => APP_ROOT.'public/js/components/Cis/Renderer/Feiertage/calendarEvent.js', - 'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Feiertage/modalTitle.js', - 'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Feiertage/modalContent.js', - 'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css' + 'calendarEvent' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Feiertage/calendarEvent.js'), + 'modalTitle' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Feiertage/modalTitle.js'), + 'modalContent' => absoluteJsImportUrl('public/js/components/Cis/Renderer/Feiertage/modalContent.js'), + 'calendarEventStyles' => APP_ROOT . 'public/css/Cis4/CoreCalendarEvents.css' ); }); diff --git a/application/config/javascript.php b/application/config/javascript.php index 6f82810e2..7b8342ef8 100644 --- a/application/config/javascript.php +++ b/application/config/javascript.php @@ -7,3 +7,6 @@ $config['use_vuejs_dev_version'] = false; $config['use_bundled_javascript'] = false; // systemerror_mailto use in FHC-Alert Plugin - if empty Link will not be rendered $config['systemerror_mailto'] = ''; +// use fhcomplete_build_version as path element after public (requires apache mod_rewrite) +// see /public/.htaccess_sample for details +$config['use_fhcomplete_build_version_in_path'] = false; diff --git a/application/controllers/api/frontend/v1/lv/Setup.php b/application/controllers/api/frontend/v1/lv/Setup.php index a2c167dd6..eea4befa5 100644 --- a/application/controllers/api/frontend/v1/lv/Setup.php +++ b/application/controllers/api/frontend/v1/lv/Setup.php @@ -47,22 +47,22 @@ class Setup extends FHCAPI_Controller { $tabs['details'] = array ( 'title' => 'Details', - 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Details.js', + 'component' => absoluteJsImportUrl('public/js/components/LVVerwaltung/Tabs/Details.js'), 'config' => [] ); $tabs['gruppen'] = array ( 'title' => 'Gruppen', - 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Gruppen.js', + 'component' => absoluteJsImportUrl('public/js/components/LVVerwaltung/Tabs/Gruppen.js'), 'config' => [] ); $tabs['lektor'] = array ( 'title' => 'LektorInnenzuteilung', - 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Lektor.js', + 'component' => absoluteJsImportUrl('public/js/components/LVVerwaltung/Tabs/Lektor.js'), 'config' => [] ); $tabs['notiz'] = array ( 'title' => 'Notizen', - 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Notiz.js', + 'component' => absoluteJsImportUrl('public/js/components/LVVerwaltung/Tabs/Notiz.js'), 'config' => [] ); $this->terminateWithSuccess($tabs); diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index d633aefa2..bc1fbebfe 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -506,7 +506,7 @@ class Config extends FHCAPI_Controller { $result['combinePeople'] = [ 'title' => $this->p->t('stv', 'tab_combine_people'), - 'component' => './Stv/Studentenverwaltung/Details/CombinePeople.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/CombinePeople.js'), 'config' => $config['combinePeople'] ]; } diff --git a/application/controllers/dashboard/Widget.php b/application/controllers/dashboard/Widget.php index 0da6fe8da..9966ddc12 100644 --- a/application/controllers/dashboard/Widget.php +++ b/application/controllers/dashboard/Widget.php @@ -33,19 +33,26 @@ class Widget extends Auth_Controller return $this->outputJsonSuccess([ "widget_id" => 0, "widget_kurzbz" => "notfound", - "arguments" => json_encode([ + "arguments" => [ "className" => 'alert-danger', "title" => 'Widget Not Found', "msg" => 'The widget with the id ' . $widget_id . ' could not be found' - ]), - "setup" => json_encode([ + ], + "setup" => [ "name" => 'Widget Not Found', - "file" => 'DashboardWidget/Default.js', + "file" => absoluteJsImportUrl('public/js/components/DashboardWidget/Default.js'), "width" => 1, "height" => 1 - ]) + ] ]); - return $this->outputJsonSuccess(current(getData($widget))); + + $widget = current(getData($widget)); + $widget->arguments = json_decode($widget->arguments); + $tmpsetup = json_decode($widget->setup); + $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); + $widget->setup = $tmpsetup; + + return $this->outputJsonSuccess($widget); } public function getAll() @@ -56,7 +63,16 @@ class Widget extends Auth_Controller if (isError($result)) return $this->outputJsonError(getError($result)); - $this->outputJsonSuccess(getData($result) ?: []); + $tmpwidgets = getData($result) ?: []; + $widgets = array_map(function($widget) { + $widget->arguments = json_decode($widget->arguments); + $tmpsetup = json_decode($widget->setup); + $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); + $widget->setup = $tmpsetup; + return $widget; + }, $tmpwidgets); + + $this->outputJsonSuccess($widgets); } public function getWidgetsForDashboard() @@ -71,7 +87,16 @@ class Widget extends Auth_Controller ]); } - $this->outputJsonSuccess(getData($result) ?: []); + $tmpwidgets = getData($result) ?: []; + $widgets = array_map(function($widget) { + $widget->arguments = json_decode($widget->arguments); + $tmpsetup = json_decode($widget->setup); + $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); + $widget->setup = $tmpsetup; + return $widget; + }, $tmpwidgets); + + $this->outputJsonSuccess($widgets); } public function setAllowed() diff --git a/application/helpers/hlp_header_helper.php b/application/helpers/hlp_header_helper.php index 309bdedbd..41d40ca0d 100644 --- a/application/helpers/hlp_header_helper.php +++ b/application/helpers/hlp_header_helper.php @@ -185,7 +185,15 @@ function generateJSModulesInclude($JSModules) for ($tmpJSsCounter = 0; $tmpJSsCounter < count($tmpJSs); $tmpJSsCounter++) { - $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter].$cachetoken)).PHP_EOL; + if($ci->config->item('use_fhcomplete_build_version_in_path')) + { + $relurl = preg_replace('#public/#', 'public/' . $ci->config->item('fhcomplete_build_version') . '/', $tmpJSs[$tmpJSsCounter]); + $toPrint = sprintf($jsInclude, base_url($relurl)).PHP_EOL; + } + else + { + $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter].$cachetoken)).PHP_EOL; + } if ($tmpJSsCounter > 0) $toPrint = "\t\t".$toPrint; @@ -250,6 +258,14 @@ function generateSkipLink($skipID) function absoluteJsImportUrl($relurl) { $ci =& get_instance(); - $url = base_url($relurl) . '?'. $ci->config->item('fhcomplete_build_version'); + $ci->load->config('javascript'); + if($ci->config->item('use_fhcomplete_build_version_in_path')) + { + $url = base_url(preg_replace('#^public/#', 'public/' . $ci->config->item('fhcomplete_build_version') . '/', $relurl)); + } + else + { + $url = base_url($relurl) . '?'. $ci->config->item('fhcomplete_build_version'); + } return $url; -} \ No newline at end of file +} diff --git a/public/.htaccess_sample b/public/.htaccess_sample new file mode 100644 index 000000000..e3f3485f6 --- /dev/null +++ b/public/.htaccess_sample @@ -0,0 +1,9 @@ + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^[0-9]{10}/(.*)$ $1 [L] + RewriteCond %{REQUEST_URI} ^(.*?)/public/index.ci.php/ + RewriteRule ^index.ci.php/(.*)$ %1/index.ci.php/$1 [R=303] + + diff --git a/public/js/components/Dashboard/Dashboard.js b/public/js/components/Dashboard/Dashboard.js index 3d781ac72..652a2778e 100644 --- a/public/js/components/Dashboard/Dashboard.js +++ b/public/js/components/Dashboard/Dashboard.js @@ -151,10 +151,6 @@ export default { db: this.dashboard } }).then(res => { - res.data.retval.forEach(widget => { - widget.arguments = JSON.parse(widget.arguments); - widget.setup = JSON.parse(widget.setup); - }); this.widgets = res.data.retval; }).catch(err => console.error('ERROR:', err)); diff --git a/public/js/components/Dashboard/Item.js b/public/js/components/Dashboard/Item.js index d2ad4ae75..06a03ae3a 100644 --- a/public/js/components/Dashboard/Item.js +++ b/public/js/components/Dashboard/Item.js @@ -144,7 +144,7 @@ export default { }, async created() { this.widget = await CachedWidgetLoader.loadWidget(this.id); - let component = (await import("../" + this.widget.setup.file)).default; + let component = (await import(this.widget.setup.file)).default; this.$options.components["widget" + this.widget.widget_id] = component; this.component = "widget" + this.widget.widget_id; this.arguments = { ...this.widget.arguments, ...this.config }; diff --git a/public/js/composables/Dashboard/CachedWidgetLoader.js b/public/js/composables/Dashboard/CachedWidgetLoader.js index 3ebe6ddcb..a92e3e557 100644 --- a/public/js/composables/Dashboard/CachedWidgetLoader.js +++ b/public/js/composables/Dashboard/CachedWidgetLoader.js @@ -16,8 +16,6 @@ export default { __widgetsStarted[id] = new Promise((resolve, reject) => { axios.get(__path, {params:{id}}).then(res => { - res.data.retval.arguments = JSON.parse(res.data.retval.arguments); - res.data.retval.setup = JSON.parse(res.data.retval.setup); __widgets[id] = res.data.retval; __widgetsStarted[id] = undefined; resolve(__widgets[id]); diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index add43ff72..79867ab57 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -89,6 +89,7 @@ require_once('dbupdate_3.4/67490_studstatus_suche_abort_controller_haengt.php'); require_once('dbupdate_3.4/69065_Projektarbeiten_Firmen_verwalten.php'); require_once('dbupdate_3.4/68744_StV_settings.php'); require_once('dbupdate_3.4/62889_reihungstest_ueberwachung_mit_constructor.php'); +require_once('dbupdate_3.4/71399_dashboard_update_widget_paths.php'); // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; diff --git a/system/dbupdate_3.4/25999_C4_dashboard.php b/system/dbupdate_3.4/25999_C4_dashboard.php index aab20089c..186866f73 100644 --- a/system/dbupdate_3.4/25999_C4_dashboard.php +++ b/system/dbupdate_3.4/25999_C4_dashboard.php @@ -39,7 +39,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur 'hallowelt', 'Hallo Welt Widget', '{"css": "d-flex justify-content-center align-items-center h-100", "title": "Hallo Welt"}'::jsonb, - '{"file": "DashboardWidget/Default.js", "icon": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Farben-Testbild.svg", "name": "Hallo Welt", "width": {"max": 99}, "height": {"max": 99}, "hideFooter": false}'::jsonb + '{"file": "public/js/components/DashboardWidget/Default.js", "icon": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Farben-Testbild.svg", "name": "Hallo Welt", "width": {"max": 99}, "height": {"max": 99}, "hideFooter": false}'::jsonb ); EOWHW; @@ -71,7 +71,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur 'news', 'News Widget', '{}'::jsonb, - '{"file": "DashboardWidget/News.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "News", "width": {"max": 4, "min": 1}, "height": {"max": 2, "min": 1}, "cis4link": "/CisVue/Cms/news", "hideFooter": false}'::jsonb + '{"file": "public/js/components/DashboardWidget/News.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "News", "width": {"max": 4, "min": 1}, "height": {"max": 2, "min": 1}, "cis4link": "/CisVue/Cms/news", "hideFooter": false}'::jsonb ); EOWHW; @@ -103,7 +103,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur 'url', 'Bookmark Widget', '{}'::jsonb, - '{"file": "DashboardWidget/Url.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Bookmark", "width": 1, "height": {"max": 2, "min": 1}, "hideFooter": true}'::jsonb + '{"file": "public/js/components/DashboardWidget/Url.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Bookmark", "width": 1, "height": {"max": 2, "min": 1}, "hideFooter": true}'::jsonb ); EOWHW; @@ -135,7 +135,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur 'ampel', 'Ampel Widget', '{}'::jsonb, - '{"file": "DashboardWidget/Ampel.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Ampel", "width": 1, "height": {"max": 2, "min": 1}, "hideFooter": false}'::jsonb + '{"file": "public/js/components/DashboardWidget/Ampel.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Ampel", "width": 1, "height": {"max": 2, "min": 1}, "hideFooter": false}'::jsonb ); EOWHW; @@ -162,7 +162,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur widget_kurzbz = 'lvplan', beschreibung = 'LV-Plan Widget', arguments = '{"bodyClass": "p-0"}'::jsonb, - setup = '{"file": "DashboardWidget/LvPlan.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "LV-Plan", "width": {"max": 4, "min": 1}, "height": {"max": 3, "min": 1}, "cis4link": "/Cis/LvPlan", "hideFooter": false}'::jsonb + setup = '{"file": "public/js/components/DashboardWidget/LvPlan.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "LV-Plan", "width": {"max": 4, "min": 1}, "height": {"max": 3, "min": 1}, "cis4link": "/Cis/LvPlan", "hideFooter": false}'::jsonb WHERE widget_kurzbz = 'stundenplan'; EOWHW; @@ -195,7 +195,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur 'lvplan', 'LV-Plan Widget', '{"bodyClass": "p-0"}'::jsonb, - '{"file": "DashboardWidget/LvPlan.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "LV-Plan", "width": {"max": 4, "min": 1}, "height": {"max": 3, "min": 1}, "cis4link": "/Cis/LvPlan", "hideFooter": false}'::jsonb + '{"file": "public/js/components/DashboardWidget/LvPlan.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "LV-Plan", "width": {"max": 4, "min": 1}, "height": {"max": 3, "min": 1}, "cis4link": "/Cis/LvPlan", "hideFooter": false}'::jsonb ); EOWHW; @@ -227,7 +227,7 @@ if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kur 'studiengang', 'Das Studiengang-Widget enthält Informationen über den Studiengang eines Studenten.', '{}'::jsonb, - '{"file": "DashboardWidget/Studiengang.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Studiengang", "width": {"max": 2, "min": 1}, "height": {"max": 4, "min": 1}, "hideFooter": true}'::jsonb + '{"file": "public/js/components/DashboardWidget/Studiengang.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Studiengang", "width": {"max": 2, "min": 1}, "height": {"max": 4, "min": 1}, "hideFooter": true}'::jsonb ); EOWHW; @@ -349,4 +349,4 @@ EOGP; echo 'dashboard.tbl_dashboard_preset: Added Student Preset for Dashboard "CIS"
'; } } -} \ No newline at end of file +} diff --git a/system/dbupdate_3.4/71399_dashboard_update_widget_paths.php b/system/dbupdate_3.4/71399_dashboard_update_widget_paths.php new file mode 100644 index 000000000..3849d6ec5 --- /dev/null +++ b/system/dbupdate_3.4/71399_dashboard_update_widget_paths.php @@ -0,0 +1,77 @@ +, + * + * Beschreibung: + * Dashboard DB Aenderungen + */ +if (! defined('DB_NAME')) exit('No direct script access allowed'); + +$corewidgetssql = 'select tw.* from dashboard.tbl_widget tw where regexp_match((setup->\'file\')::text, \'^"DashboardWidget\') is not NULL'; +if (($rescore = $db->db_query($corewidgetssql))) +{ + if ($db->db_num_rows($rescore) > 0) + { + $coreqry = <<'file')::text, '^"DashboardWidget', '"public/js/components/DashboardWidget')::jsonb) + where + regexp_match((setup->'file')::text, '^"DashboardWidget') is not NULL; + +EOCOREQRY; + + if (!$db->db_query($coreqry)) + { + echo 'Dashboard Core Widgets Paths Update: '.$db->db_last_error().'
'; + } + else + { + echo '
Dashboard Core Widgets Paths updated.'; + } + } +} + +$extwidgetssql = 'select tw.* from dashboard.tbl_widget tw where regexp_match((setup->\'file\')::text, \'^"../../\') is not NULL'; +if (($resext = $db->db_query($extwidgetssql))) +{ + if ($db->db_num_rows($resext) > 0) + { + $extqry = <<'file')::text, '^"../../', '"public/')::jsonb) + where + regexp_match((setup->'file')::text, '^"../../') is not NULL; + +EOEXTQRY; + + if (!$db->db_query($extqry)) + { + echo 'Dashboard Extensions Widgets Paths Update: '.$db->db_last_error().'
'; + } + else + { + echo '
Dashboard Extensions Widgets Paths updated.'; + } + } +} \ No newline at end of file