From dced14cf52f85478a11ad07f39e7ba059c4c1cf6 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 2 Jan 2018 18:48:39 +0100 Subject: [PATCH] Upgraded initialization system --- assets/js/common/debug.js | 2 +- corePage/config/dev.config.php | 218 -------------------------- corePage/config/global.config.php | 17 -- corePage/helpers/assets.helper.php | 26 ---- corePage/initPage.php | 34 ---- index.php | 136 +++------------- system/config/dev.config.php | 240 +++++++++++++++++++++++++++++ system/config/global.config.php | 22 +++ system/system.php | 141 +++++++++++++++++ system/tpl/page.tpl | 55 +++++++ 10 files changed, 477 insertions(+), 414 deletions(-) delete mode 100644 corePage/config/dev.config.php delete mode 100644 corePage/config/global.config.php delete mode 100644 corePage/helpers/assets.helper.php delete mode 100644 corePage/initPage.php create mode 100644 system/config/dev.config.php create mode 100644 system/config/global.config.php create mode 100644 system/system.php create mode 100644 system/tpl/page.tpl diff --git a/assets/js/common/debug.js b/assets/js/common/debug.js index cd3c7a6f..33e2eaed 100644 --- a/assets/js/common/debug.js +++ b/assets/js/common/debug.js @@ -18,7 +18,7 @@ ComunicWeb.debug = { */ logMessage: function(message){ //We check we are not in production mode - if(ComunicWeb.__config.productionMode != 1){ + if(ComunicWeb.__config.productionMode != true){ console.log("ComunicWebApp debug message", message); } diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php deleted file mode 100644 index 8162a40c..00000000 --- a/corePage/config/dev.config.php +++ /dev/null @@ -1,218 +0,0 @@ -".(config['siteMode'] == 0 ? "\n\t\t" : ""); -} - -/** - * Returns the source code for including a CSS file - * - * @param String $file Path to the CSS file - * @return String HTML Source code to include the CSS file - */ -function CSSFileInclusionCode($file){ - return "".(config['siteMode'] == 0 ? "\n\t\t" : ""); -} diff --git a/corePage/initPage.php b/corePage/initPage.php deleted file mode 100644 index f904a7f0..00000000 --- a/corePage/initPage.php +++ /dev/null @@ -1,34 +0,0 @@ -", $_SERVER["REDIRECT_URL"])){ - //This is a 404 not found error... - echo "

Error! 404 not found

"; - http_response_code(404); - exit(); - } +//We check if it is a redirection to handle 404 errors +if(isset($_SERVER["REDIRECT_URL"])){ + //We check if it is an asset request + if(preg_match("", $_SERVER["REDIRECT_URL"])){ + //This is a 404 not found error... + echo "

Error! 404 not found

"; + http_response_code(404); + exit(); } -?> - - - - - - Comunic +//Include system +require __DIR__."/system/system.php"; - - - - - - - - - - - - - - - - - - - - - - -
- Welcome !
- Bienvenue !

- -

- - Please wait while Comunic is starting...
- Veuillez patienter pendant le démarrage de Comunic...

- - -

If this screen doesn't disappear after a while, please check javascript is enabled in your browser...

-
- - - - - - - - - \ No newline at end of file +//Load the page +echo load_page("dev"); diff --git a/system/config/dev.config.php b/system/config/dev.config.php new file mode 100644 index 00000000..49d1d9d7 --- /dev/null +++ b/system/config/dev.config.php @@ -0,0 +1,240 @@ + + + var ComunicConfig = { + + //Production mode + productionMode: ".($config::PROD_MODE ? "true" : "false").", + + //AppVersion + appVersion: '".Config::VERSION."', + + //Assets URL + assetsURL: '".$config::ASSETS_URL."', + + //Templates URL + templatesURL : '".$config::ASSETS_URL.$config::TEMPLATES_PATH."', + + //Site URL + siteURL: '".$config::SITE_URL."', + + //API configuration + apiURL: '".Config::API_URL."', + apiServiceName: '".Config::API_SERVICE_NAME."', + apiServiceToken: '".Config::API_SERVICE_TOKEN."', + + //Default language + defaultLanguage: '".$config::DEFAULT_LANGUAGE."', + + //LanguagesPath + languagesPath: '".$config::ASSETS_URL.$config::LANGUAGE_PATH."', + + }; + + "; + + return $js_config; +} + +/** + * Return the source code to include an array of css assets + * + * @param string $asset_url URL path to assets + * @param array $files The list of files to include + * @return string Generated source code + */ +function src_inc_list_css(string $assets_url, array $files) : string { + $source = ""; + + //Process the list of files + foreach($files as $file){ + $source .= src_inc_css($assets_url.$file)."\n\t\t"; + } + + return $source; +} + +/** + * Return the source code to include an array of javascript assets + * + * @param string $asset_url URL path to assets + * @param array $files The list of files to include + * @return string Generated source code + */ +function src_inc_list_js(string $assets_url, array $files) : string { + $source = ""; + + //Process the list of files + foreach($files as $file){ + $source .= src_inc_js($assets_url.$file)."\n\t\t"; + } + + return $source; +} + +/** + * Returns the source code to include a javascript file + * + * @param string $file The path to the file + * @return string Source code for including a javascript file + */ +function src_inc_js(string $file) : string{ + return ""; +} + +/** + * Returns the source code to include a CSS file + * + * @param string $file Path to the CSS file + * @return string HTML Source code to include the CSS file + */ +function src_inc_css(string $file) : string { + return ""; +} diff --git a/system/tpl/page.tpl b/system/tpl/page.tpl new file mode 100644 index 00000000..a5f3c7a2 --- /dev/null +++ b/system/tpl/page.tpl @@ -0,0 +1,55 @@ + + + + + + Comunic + + + + + + + + + + + + + {THIRD_PARTY_CSS} + + + {APP_CSS} + + + {js_config} + + + + +
+ Welcome !
+ Bienvenue !

+ +

+ + Please wait while Comunic is starting...
+ Veuillez patienter pendant le démarrage de Comunic...

+ + +

If this screen doesn't disappear after a while, please check javascript is enabled in your browser...

+
+ + + {THIRD_PARTY_JS} + + + {APP_JS} + + + \ No newline at end of file