From 5992cedd9ead992c87fde9b6c81cbc258e0356aa Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 12 Apr 2018 13:21:57 +0200 Subject: [PATCH] FHC_Header: - Added global variable called calledFrom that contains the URL path of the called controller + controller method - Added function _generateJSDataStorageObject to generate the global JS object FHC_JS_DATA_STORAGE_OBJECT - The global JS object is renamed from FHC_ADDON_DATA_STORAGE_OBJECT to FHC_JS_DATA_STORAGE_OBJECT - Added funtion _generateAddonsJSsInclude to generate all the includes needed by the Addons --- .../system/infocenter/InfoCenter.php | 5 -- application/views/templates/FHC-Header.php | 81 +++++++++++++------ 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index cbb9e9b8c..23b4972c2 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -559,11 +559,6 @@ class InfoCenter extends VileSci_Controller { $toPrint = "%s=%s"; - if ($this->router->method != 'index') - { - - } - $tofill['children'][] = array( 'link' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filter_id'), $filterId), 'description' => $description, diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index b309f4a22..cbf20b0ec 100755 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -2,6 +2,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +// Retrives the URL path of the called controller + controller method +// NOTE: placed here because it doesn't work inside functions +$calledFrom = $this->router->directory.$this->router->class.'/'.$this->router->method; + // By default set the parameters to null $title = isset($title) ? $title : null; $customCSSs = isset($customCSSs) ? $customCSSs : null; @@ -55,6 +59,26 @@ function _generateCSSsInclude($CSSs) } } +/** + * Generates global JS-Object to pass parms to other javascripts + */ +function _generateJSDataStorageObject($calledFrom) +{ + $toPrint = "\n"; + $toPrint .= ''; + $toPrint .= "\n\n"; + + echo $toPrint; +} + /** * Generates tags for the javascripts you want to include, the parameter could by a string or an array of strings */ @@ -78,13 +102,25 @@ function _generateJSsInclude($JSs) } /** - * Generates global JS-Object to pass parms to addon-js-functions + * Generates all the includes needed by the Addons */ -function _generateAddonDataStorageObject() +function _generateAddonsJSsInclude($calledFrom) { - echo '\n"; + $aktive_addons = array_filter(explode(";", ACTIVE_ADDONS)); + + foreach ($aktive_addons as $addon) + { + $hookfile = DOC_ROOT.'addons/'.$addon.'/hooks.config.inc.php'; + if (file_exists($hookfile)) + { + include($hookfile); + if (key_exists($calledFrom, $js_hooks)) + { + foreach ($js_hooks[$calledFrom] as $js_file) + _generateJSsInclude('addons/'.$addon.'/'.$js_file); + } + } + } } ?> @@ -102,16 +138,20 @@ function _generateAddonDataStorageObject() // jQuery UI CSS if ($jqueryui === true) _generateCSSsInclude('vendor/components/jqueryui/themes/base/jquery-ui.min.css'); + // bootstrap CSS if ($bootstrap === true) _generateCSSsInclude('vendor/twbs/bootstrap/dist/css/bootstrap.min.css'); + // font awesome CSS if ($fontawesome === true) _generateCSSsInclude('vendor/components/font-awesome/css/font-awesome.min.css'); + // Table sorter CSS if ($tablesorter === true) { _generateCSSsInclude('vendor/mottie/tablesorter/dist/css/theme.default.min.css'); _generateCSSsInclude('vendor/mottie/tablesorter/dist/css/jquery.tablesorter.pager.min.css'); } + // sb admin template CSS if ($sbadmintemplate === true) { @@ -125,8 +165,13 @@ function _generateAddonDataStorageObject() // -------------------------------------------------------------------------------------------------------- // Javascripts + // Generates the global object to pass useful parms to the other javascripts + // NOTE: must be called before any other JS include + _generateJSDataStorageObject($calledFrom); + // JQuery V3 if ($jquery === true) _generateJSsInclude('vendor/components/jquery/jquery.min.js'); + // JQuery UI if ($jqueryui === true) { @@ -134,8 +179,10 @@ function _generateAddonDataStorageObject() //datepicker german language file _generateJSsInclude('vendor/components/jqueryui/ui/i18n/datepicker-de.js'); } + // bootstrap JS if ($bootstrap === true) _generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); + // Table sorter JS if ($tablesorter === true) { @@ -143,6 +190,7 @@ function _generateAddonDataStorageObject() _generateJSsInclude('vendor/mottie/tablesorter/dist/js/jquery.tablesorter.widgets.min.js'); _generateJSsInclude('vendor/mottie/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js'); } + //tinymce JS if($tinymce === true) _generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js') ; @@ -153,27 +201,8 @@ function _generateAddonDataStorageObject() _generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/js/sb-admin-2.min.js'); } - // load addon hooks JS - if ($addons === true) - { - _generateAddonDataStorageObject(); - - $aktive_addons = array_filter(explode(";", ACTIVE_ADDONS)); - $called_from = $this->router->directory.$this->router->class.'/'.$this->router->method; - foreach ($aktive_addons as $addon) - { - $hookfile = DOC_ROOT.'addons/'.$addon.'/hooks.config.inc.php'; - if (file_exists($hookfile)) - { - include($hookfile); - if (key_exists($called_from, $js_hooks)) - { - foreach ($js_hooks[$called_from] as $js_file) - _generateJSsInclude('addons/'.$addon.'/'.$js_file); - } - } - } - } + // Load addon hooks JS + if ($addons === true) _generateAddonsJSsInclude($calledFrom); // Eventually required JS _generateJSsInclude($customJSs);