From 04e2e1c54b1c57412046ef79c5ae0a69fa33925f Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 11 Jul 2018 13:43:18 +0200 Subject: [PATCH] - Moved functions from FHC-Header to fhc_header_helper - Added function backwardCompatibleJSMsIe to fhc_header_helper for backward compatibility with older versions of MS IE - FHC_Controller now loads helper fhc_header too - Added afarkas/html5shiv and scottjehl/Respond to composer - Rename function sendMail in fhc_sancho_helper.php to sendSanchoMail --- application/controllers/jobs/AmpelMail.php | 4 +- application/core/FHC_Controller.php | 3 + .../helpers/fhc_authentication_helper.php | 14 +- application/helpers/fhc_header_helper.php | 159 ++++++++++++ application/helpers/fhc_language_helper.php | 4 + application/helpers/fhc_sancho_helper.php | 7 +- application/views/templates/FHC-Header.php | 231 +++++------------- composer.json | 29 ++- composer.lock | 46 +++- 9 files changed, 300 insertions(+), 197 deletions(-) create mode 100644 application/helpers/fhc_header_helper.php diff --git a/application/controllers/jobs/AmpelMail.php b/application/controllers/jobs/AmpelMail.php index 5727187d9..58f5b8c2a 100644 --- a/application/controllers/jobs/AmpelMail.php +++ b/application/controllers/jobs/AmpelMail.php @@ -156,7 +156,7 @@ class AmpelMail extends FHC_Controller // Send mails for new ampeln merged by user foreach ($new_ampel_data_arr as $new_ampel_data) { - sendMail( + sendSanchoMail( 'Sancho_Content_AmpelNeu', $new_ampel_data, $new_ampel_data['uid']. '@'. DOMAIN, @@ -167,7 +167,7 @@ class AmpelMail extends FHC_Controller // Send mails for overdue ampeln merged by user foreach ($overdue_ampel_data_arr as $overdue_ampel_data) { - sendMail( + sendSanchoMail( 'Sancho_Content_AmpelUeberfaellig', $overdue_ampel_data, $overdue_ampel_data['uid']. '@'. DOMAIN, diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 33bde6c4e..edab4b399 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -31,6 +31,9 @@ class FHC_Controller extends CI_Controller // Loads language helper $this->load->helper('fhc_language'); + + // Loads header helper + $this->load->helper('fhc_header'); } //------------------------------------------------------------------------------------------------------------------ diff --git a/application/helpers/fhc_authentication_helper.php b/application/helpers/fhc_authentication_helper.php index e8b553dd3..dd25b2a38 100644 --- a/application/helpers/fhc_authentication_helper.php +++ b/application/helpers/fhc_authentication_helper.php @@ -1,4 +1,5 @@ '; + + if (isset($CSSs)) + { + $tmpCSSs = is_array($CSSs) ? $CSSs : array($CSSs); + + for ($tmpCSSsCounter = 0; $tmpCSSsCounter < count($tmpCSSs); $tmpCSSsCounter++) + { + $toPrint = sprintf($cssLink, base_url($tmpCSSs[$tmpCSSsCounter])).PHP_EOL; + + if ($tmpCSSsCounter > 0) $toPrint = "\t\t".$toPrint; + + echo $toPrint; + } + } +} + +/** + * Generates global JS-Object to pass parms to other javascripts + */ +function generateJSDataStorageObject($indexPage, $calledPath, $calledMethod) +{ + $toPrint = "\n"; + $toPrint .= ''; + $toPrint .= "\n\n"; + + echo $toPrint; +} + +/** + * Generates global JS-Object to pass phrases to other javascripts + */ +function generateJSPhrasesStorageObject($phrases) +{ + $ci =& get_instance(); + $ci->load->library('PhrasesLib', array($phrases), 'pj'); + + $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 + */ +function generateJSsInclude($JSs) +{ + $jsInclude = ''; + + if (isset($JSs)) + { + $tmpJSs = is_array($JSs) ? $JSs : array($JSs); + + for ($tmpJSsCounter = 0; $tmpJSsCounter < count($tmpJSs); $tmpJSsCounter++) + { + $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter])).PHP_EOL; + + if ($tmpJSsCounter > 0) $toPrint = "\t\t".$toPrint; + + echo $toPrint; + } + } +} + +/** + * Generates all the includes needed by the Addons + */ +function generateAddonsJSsInclude($calledFrom) +{ + $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); + } + } + } +} + +/** + * This function merely print some useful HTML to help some vacuous browsers to handle modern JS features + */ +function backwardCompatibleJSMsIe() +{ + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; +} diff --git a/application/helpers/fhc_language_helper.php b/application/helpers/fhc_language_helper.php index cf6b94fe5..ce01c5f0d 100644 --- a/application/helpers/fhc_language_helper.php +++ b/application/helpers/fhc_language_helper.php @@ -12,6 +12,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +// ------------------------------------------------------------------------ +// Functions needed to manage the user language preference +// ------------------------------------------------------------------------ + /** * Function to retrive the language of the logged user * If is not possible to retrive it, then the default system language is returnd diff --git a/application/helpers/fhc_sancho_helper.php b/application/helpers/fhc_sancho_helper.php index a8e9f05c9..c788f1bbf 100644 --- a/application/helpers/fhc_sancho_helper.php +++ b/application/helpers/fhc_sancho_helper.php @@ -1,4 +1,5 @@ load->library('email'); diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index e63ebff75..b3e00a98b 100755 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -1,160 +1,38 @@ config->item('index_page'); -$calledPath = $this->router->directory.$this->router->class; -$calledMethod = $this->router->method; + // Retrives the name of the index page, the URL path of the called controller and the called controller + // NOTE: placed here because it doesn't work inside functions + $indexPage = $this->config->item('index_page'); + $calledPath = $this->router->directory.$this->router->class; + $calledMethod = $this->router->method; -// By default set the parameters to null -$title = isset($title) ? $title : null; -$customCSSs = isset($customCSSs) ? $customCSSs : null; -$customJSs = isset($customJSs) ? $customJSs : null; -$phrases = isset($phrases) ? $phrases : null; - -// By default set the parameters to false -$jquery = isset($jquery) ? $jquery : false; -$jqueryui = isset($jqueryui) ? $jqueryui : false; -$ajaxlib = isset($ajaxlib) ? $ajaxlib : false; -$bootstrap = isset($bootstrap) ? $bootstrap : false; -$fontawesome = isset($fontawesome) ? $fontawesome : false; -$tablesorter = isset($tablesorter) ? $tablesorter : false; -$tinymce = isset($tinymce) ? $tinymce : false; -$sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; -$addons = isset($addons) ? $addons : false; -$filterwidget = isset($filterwidget) ? $filterwidget : false; -$navigationwidget = isset($navigationwidget) ? $navigationwidget : false; - -/** - * Print the given title of the page - * NOTE: this is a required field, must be specified otherwise an error is shown - */ -function _printTitle($title) -{ - if ($title != null) - { - echo $title; - } - else - { - show_error('The title for this page is not set'); - } -} - -/** - * Generates tags for the style sheets you want to include, the parameter could by a string or an array of strings - */ -function _generateCSSsInclude($CSSs) -{ - $cssLink = ''; - - if (isset($CSSs)) - { - $tmpCSSs = is_array($CSSs) ? $CSSs : array($CSSs); - - for ($tmpCSSsCounter = 0; $tmpCSSsCounter < count($tmpCSSs); $tmpCSSsCounter++) - { - $toPrint = sprintf($cssLink, base_url($tmpCSSs[$tmpCSSsCounter])).PHP_EOL; - - if ($tmpCSSsCounter > 0) $toPrint = "\t\t".$toPrint; - - echo $toPrint; - } - } -} - -/** - * Generates global JS-Object to pass parms to other javascripts - */ -function _generateJSDataStorageObject($indexPage, $calledPath, $calledMethod) -{ - $toPrint = "\n"; - $toPrint .= ''; - $toPrint .= "\n\n"; - - echo $toPrint; -} - -/** - * Generates global JS-Object to pass phrases to other javascripts - */ -function _generateJSPhrasesStorageObject($phrases) -{ - $ci =& get_instance(); - $ci->load->library('PhrasesLib', array($phrases), 'pj'); - - $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 - */ -function _generateJSsInclude($JSs) -{ - $jsInclude = ''; - - if (isset($JSs)) - { - $tmpJSs = is_array($JSs) ? $JSs : array($JSs); - - for ($tmpJSsCounter = 0; $tmpJSsCounter < count($tmpJSs); $tmpJSsCounter++) - { - $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter])).PHP_EOL; - - if ($tmpJSsCounter > 0) $toPrint = "\t\t".$toPrint; - - echo $toPrint; - } - } -} - -/** - * Generates all the includes needed by the Addons - */ -function _generateAddonsJSsInclude($calledFrom) -{ - $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); - } - } - } -} + // By default set the parameters to null + $title = isset($title) ? $title : null; + $customCSSs = isset($customCSSs) ? $customCSSs : null; + $customJSs = isset($customJSs) ? $customJSs : null; + $phrases = isset($phrases) ? $phrases : null; + // By default set the parameters to false + $jquery = isset($jquery) ? $jquery : false; + $jqueryui = isset($jqueryui) ? $jqueryui : false; + $ajaxlib = isset($ajaxlib) ? $ajaxlib : false; + $bootstrap = isset($bootstrap) ? $bootstrap : false; + $fontawesome = isset($fontawesome) ? $fontawesome : false; + $tablesorter = isset($tablesorter) ? $tablesorter : false; + $tinymce = isset($tinymce) ? $tinymce : false; + $sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; + $addons = isset($addons) ? $addons : false; + $filterwidget = isset($filterwidget) ? $filterwidget : false; + $navigationwidget = isset($navigationwidget) ? $navigationwidget : false; ?> + - <?php _printTitle($title); ?> + <?php printPageTitle($title); ?> @@ -163,39 +41,39 @@ function _generateAddonsJSsInclude($calledFrom) // CSS // jQuery UI CSS - if ($jqueryui === true) _generateCSSsInclude('vendor/components/jqueryui/themes/base/jquery-ui.min.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'); + 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'); + if ($fontawesome === true) generateCSSsInclude('vendor/components/font-awesome/css/font-awesome.min.css'); // AjaxLib CSS - if ($ajaxlib === true) _generateCSSsInclude('public/css/AjaxLib.css'); + if ($ajaxlib === true) generateCSSsInclude('public/css/AjaxLib.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'); + generateCSSsInclude('vendor/mottie/tablesorter/dist/css/theme.default.min.css'); + generateCSSsInclude('vendor/mottie/tablesorter/dist/css/jquery.tablesorter.pager.min.css'); } // SB Admin 2 template CSS if ($sbadmintemplate === true) { - _generateCSSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.css'); - _generateCSSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/css/sb-admin-2.min.css'); + generateCSSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.css'); + generateCSSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/css/sb-admin-2.min.css'); } // FilterWidget CSS - if ($filterwidget === true) _generateCSSsInclude('public/css/FilterWidget.css'); + if ($filterwidget === true) generateCSSsInclude('public/css/FilterWidget.css'); // NavigationWidget CSS - if ($navigationwidget === true) _generateCSSsInclude('public/css/NavigationWidget.css'); + if ($navigationwidget === true) generateCSSsInclude('public/css/NavigationWidget.css'); // Eventually required CSS - _generateCSSsInclude($customCSSs); // Eventually required CSS + generateCSSsInclude($customCSSs); // Eventually required CSS // -------------------------------------------------------------------------------------------------------- @@ -203,61 +81,62 @@ function _generateAddonsJSsInclude($calledFrom) // Generates the global object to pass useful parameters to other javascripts // NOTE: must be called before any other JS include - _generateJSDataStorageObject($indexPage, $calledPath, $calledMethod); + generateJSDataStorageObject($indexPage, $calledPath, $calledMethod); // Generates the global object to pass phrases to javascripts // NOTE: must be called before including the PhrasesLib.js - if ($phrases != null) _generateJSPhrasesStorageObject($phrases); + if ($phrases != null) generateJSPhrasesStorageObject($phrases); // JQuery V3 - if ($jquery === true) _generateJSsInclude('vendor/components/jquery/jquery.min.js'); + if ($jquery === true) generateJSsInclude('vendor/components/jquery/jquery.min.js'); // JQuery UI if ($jqueryui === true) { - _generateJSsInclude('vendor/components/jqueryui/jquery-ui.min.js'); - _generateJSsInclude('vendor/components/jqueryui/ui/i18n/datepicker-de.js'); // datepicker german language file + generateJSsInclude('vendor/components/jqueryui/jquery-ui.min.js'); + generateJSsInclude('vendor/components/jqueryui/ui/i18n/datepicker-de.js'); // datepicker german language file } // Bootstrap JS - if ($bootstrap === true) _generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); + if ($bootstrap === true) generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); // Table sorter JS if ($tablesorter === true) { - _generateJSsInclude('vendor/mottie/tablesorter/dist/js/jquery.tablesorter.min.js'); - _generateJSsInclude('vendor/mottie/tablesorter/dist/js/jquery.tablesorter.widgets.min.js'); - _generateJSsInclude('vendor/mottie/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js'); + generateJSsInclude('vendor/mottie/tablesorter/dist/js/jquery.tablesorter.min.js'); + 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') ; + if($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js') ; // SB Admin 2 template JS if ($sbadmintemplate === true) { - _generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.js'); - _generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/js/sb-admin-2.min.js'); + generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.js'); + generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/js/sb-admin-2.min.js'); + backwardCompatibleJSMsIe(); } // AjaxLib JS // NOTE: must be called before including others JS libraries that use it - if ($ajaxlib === true) _generateJSsInclude('public/js/AjaxLib.js'); + if ($ajaxlib === true) generateJSsInclude('public/js/AjaxLib.js'); // PhrasesLib JS - if ($phrases != null) _generateJSsInclude('public/js/PhrasesLib.js'); + if ($phrases != null) generateJSsInclude('public/js/PhrasesLib.js'); // FilterWidget JS - if($filterwidget === true) _generateJSsInclude('public/js/FilterWidget.js') ; + if($filterwidget === true) generateJSsInclude('public/js/FilterWidget.js') ; // NavigationWidget JS - if($navigationwidget === true) _generateJSsInclude('public/js/NavigationWidget.js') ; + if($navigationwidget === true) generateJSsInclude('public/js/NavigationWidget.js') ; // Load addon hooks JS - if ($addons === true) _generateAddonsJSsInclude($calledPath.'/'.$calledMethod); + if ($addons === true) generateAddonsJSsInclude($calledPath.'/'.$calledMethod); // Eventually required JS - _generateJSsInclude($customJSs); + generateJSsInclude($customJSs); ?> diff --git a/composer.json b/composer.json index 25d4e3407..afb3071c1 100644 --- a/composer.json +++ b/composer.json @@ -220,49 +220,67 @@ "reference": "73690a9df26dbc1a49981f9335df2a9cd9808813" } } + }, + { + "type": "package", + "package": { + "name": "scottjehl/Respond", + "version": "1.4.2", + "dist": { + "url": "https://github.com/scottjehl/Respond/archive/1.4.2.zip", + "type": "zip" + } + } } ], "require": { "php": ">=5.4.0", + "afarkas/html5shiv": "^3.7", "alvaro-prieto/colResizable": "^1.6", + "borgar/textile-js": "1.0", "BlackrockDigital/startbootstrap-sb-admin-2": "^3.3", - "christianbach/tablesorter": "^1.0", + "christianbach/tablesorter": "^1.0", "codeigniter/framework": "3.*", "codeigniter-restserver": "2.6", - "components/jquery": "^3.2", "components/jqueryui": "^1.12", "components/font-awesome": "^4.7", "components/angular.js": "1.3.16", "easyrdf/easyrdf": "0.9.*", + "fgelinas/timepicker": "^0.3.3", "fzaninotto/faker": "1.*", - "joeldbirch/superfish": "^1.7", + "joeldbirch/superfish": "^1.7", "jquery/jqueryV1": "^1.12", "jquery/jqueryV2": "^2.2", "jquery/sizzle": "^1.0", - "jquery-archive/jquery-metadata": "^1.0", "json-forms": "1.4.0", "jsoneditor": "5.5.6", + "kingsquare/json-schema-form": "*", + "ludo/jquery-treetable": "^3.2", + "michelf/php-markdown": "1.5.0", "ml/json-ld": "1.*", "mottie/tablesorter": "^2.29", + "netcarver/textile": "^3.5", "nicolaskruchten/pivottable": "^2.15.0", - "rmariuzzo/jquery-checkboxes": "1.0.7", + "rmariuzzo/jquery-checkboxes": "1.0.7", "rougin/combustor": "1.1.*", "rougin/refinery": "*", + "scottjehl/Respond": "^1.4", + "tapmodo/Jcrop": "^2.0", "tinymce/tinymce": "4.*", "tomazdragar/SimpleCropper": "^1.0", @@ -280,4 +298,3 @@ "bin-dir": "vendor/bin" } } - diff --git a/composer.lock b/composer.lock index 506882e61..d8bf79168 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "00d176bc89167feef10405c7457b6d6a", - "content-hash": "8cd3ddef525145593a8fe885184ef4cc", + "hash": "3f0f6c60692efa0e8970d047b507f988", + "content-hash": "114153c22310130fed0c1c41f74c5a62", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -17,6 +17,37 @@ }, "type": "library" }, + { + "name": "afarkas/html5shiv", + "version": "3.7.3", + "source": { + "type": "git", + "url": "https://github.com/aFarkas/html5shiv.git", + "reference": "ed28c56c071bddfe7d635ad88995674957a016be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aFarkas/html5shiv/zipball/ed28c56c071bddfe7d635ad88995674957a016be", + "reference": "ed28c56c071bddfe7d635ad88995674957a016be", + "shasum": "" + }, + "type": "component", + "extra": { + "component": { + "scripts": [ + "dist/html5shiv.js" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT", + "GPL-2.0" + ], + "description": "Defacto way to enable use of HTML5 sectioning elements in legacy Internet Explorer.", + "homepage": "http://paulirish.com/2011/the-history-of-the-html5-shiv/", + "time": "2015-07-20 20:04:00" + }, { "name": "alvaro-prieto/colResizable", "version": "1.6", @@ -1599,6 +1630,17 @@ ], "time": "2015-10-23 08:27:10" }, + { + "name": "scottjehl/Respond", + "version": "1.4.2", + "dist": { + "type": "zip", + "url": "https://github.com/scottjehl/Respond/archive/1.4.2.zip", + "reference": null, + "shasum": null + }, + "type": "library" + }, { "name": "symfony/console", "version": "v2.8.38",