[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Bootstrap.php
<?php /** -------------------------------------------------------------------------------- * Boostraps various parts of modules * * * @package Grow CRM * @author NextLoop *----------------------------------------------------------------------------------*/ namespace App\Http\Middleware\Modules; use Closure; use Exception; use Log; use Nwidart\Modules\Facades\Module; class Bootstrap { /** * handle various boostrapping for modules * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { //exit if setup is not complete if (env('SETUP_STATUS') != 'COMPLETED') { return $next($request); } //skip for ajax request if (request()->ajax()) { return $next($request); } try { //get all modules (status will be checked later) $modules = Module::all(); if (count($modules) == 0) { return $next($request); } //set header and footer include files $this->setHeaderFooter($modules); //return return $next($request); } catch (\Exception$e) { Log::error("MODULES - - bootstrapping modules - failed - error: " . $error_message, ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); return $next($request); } } /** * include any headers and footers * * @return \Illuminate\Http\Response */ public function setHeaderFooter($modules) { Log::info("MODULES - Bootstraping [css][js] - setting head and footer css and js includes for modules - started", ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); try { //generate menus foreach ($modules as $module) { //set some basic information about this module $module_name = $module->getName(); $module_path = $module->getPath(); //expected files $module_css = $module_path . '/Resources/assets/css/module.css'; $module_custom_css = $module_path . '/Resources/assets/css/custom.css'; $module_js = $module_path . '/Resources/assets/js/module.js'; //place holders $css = ''; $js = ''; $custom_css = ''; //check if the module is enabled in the database if (!in_array($module_name, config('modules.enabled'))) { Log::info("MODULES - Bootstraping [css][js] - [$module_name] is not enabled in the crm. Will skip it", ['process' => 'middleware.modules.menus', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); continue; } //check if a head css file exists if (file_exists($module_css)) { Log::info("MODULES - Bootstraping [css][js] - [$module_name] has a css file [module.css]. it has been added to the <head>", ['process' => 'middleware.modules.menus', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); $css = '<link rel="stylesheet" href="/application/modules/' . strtolower($module_name) . '/resources/assets/css/module.css">'; } else { Log::info("MODULES - Bootstraping [css][js] - [$module_name] - include file not found (module.css) - will skip - ($module_css)", ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); } //check if a head css file exists if (file_exists($module_custom_css)) { Log::info("MODULES - Bootstraping [css][js] - [$module_name] has a custom.css file [module.css]. it has been added to the <head>", ['process' => 'middleware.modules.menus', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); $custom_css = '<link rel="stylesheet" href="/application/modules/' . strtolower($module_name) . '/resources/assets/css/custom.css">'; } else { Log::info("MODULES - Bootstraping [css][js] - [$module_name] - include file not found (custom.css) - will skip - ($module_custom_css)", ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); } //check if a head css file exists if (file_exists($module_js)) { Log::info("MODULES - Bootstraping [css][js] - [$module_name] has a js file [module.js]. it has been added to the <footer>", ['process' => 'middleware.modules.menus', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); $js = '<script src="/application/modules/' . strtolower($module_name) . '/resources/assets/js/module.js"></script>'; } else { Log::info("MODULES - Bootstraping [css][js] - [$module_name] - include file not found (module.js) - will skip - ($module_js)", ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); } //append to the head and footer if ($css != "") { config([ 'css.modules' => config('css.modules') . "\n" . $css, ]); } if ($custom_css != "") { config([ 'css.modules' => config('css.modules') . "\n" . $custom_css, ]); } if ($js != "") { config([ 'js.modules' => config('js.modules') . "\n" . $js, ]); } } Log::info("MODULES - Bootstraping [css][js] -setting head and footer css and js includes for modules - finished", ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); } catch (Exception $e) { $error_message = $e->getMessage(); Log::error("MODULES - Bootstraping [css][js] -setting head and footer css and js includes for modules - failed - error: " . $error_message, ['middleware.modules.bootstrap', config('app.debug_ref'), basename(__FILE__), __line__]); } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002