@@ -50,17 +50,17 @@ |
||
50 | 50 | */ |
51 | 51 | public function runScaffolding(array $aOptions = array()) |
52 | 52 | { |
53 | - if (!isset($aOptions['p'])) { $aOptions['p'] = 'Batch'; } |
|
53 | + if (!isset($aOptions['p'])) { $aOptions['p'] = 'Batch'; } |
|
54 | 54 | |
55 | - if (!isset($aOptions['b'])) { $aOptions['b'] = json_encode(Config::get('Db', $aOptions['p'])); } |
|
55 | + if (!isset($aOptions['b'])) { $aOptions['b'] = json_encode(Config::get('Db', $aOptions['p'])); } |
|
56 | 56 | |
57 | - $aOptions['g'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Entity'.DIRECTORY_SEPARATOR; |
|
58 | - $aOptions['h'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Model'.DIRECTORY_SEPARATOR; |
|
59 | - if (!defined('ENTITY_NAMESPACE')) { define('ENTITY_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Entity'); } |
|
57 | + $aOptions['g'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Entity'.DIRECTORY_SEPARATOR; |
|
58 | + $aOptions['h'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Model'.DIRECTORY_SEPARATOR; |
|
59 | + if (!defined('ENTITY_NAMESPACE')) { define('ENTITY_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Entity'); } |
|
60 | 60 | |
61 | - if (!defined('MODEL_NAMESPACE')) { define('MODEL_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Model'); } |
|
61 | + if (!defined('MODEL_NAMESPACE')) { define('MODEL_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Model'); } |
|
62 | 62 | |
63 | - $oBatch = new BatchEntity; |
|
64 | - $oBatch->runScaffolding($aOptions); |
|
63 | + $oBatch = new BatchEntity; |
|
64 | + $oBatch->runScaffolding($aOptions); |
|
65 | 65 | } |
66 | 66 | } |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | |
62 | 62 | $sActualDirectory = str_replace(DIRECTORY_SEPARATOR, '/', __DIR__); |
63 | 63 | $sPrivatePath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app', $sActualDirectory).DIRECTORY_SEPARATOR; |
64 | - $sPublicPath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'public', $sActualDirectory).DIRECTORY_SEPARATOR; |
|
64 | + $sPublicPath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'public', $sActualDirectory).DIRECTORY_SEPARATOR; |
|
65 | 65 | |
66 | - if (!is_writable($sActualDirectory.'/../../../')) { |
|
66 | + if (!is_writable($sActualDirectory.'/../../../')) { |
|
67 | 67 | |
68 | - echo 'The batch can`t create public folders for '.$sPortal.'! Please check the rights.'; |
|
69 | - throw new \Exception('The batch can`t create public folders for '.$sPortal.'! Please check the rights.'); |
|
70 | - } |
|
71 | - else { |
|
68 | + echo 'The batch can`t create public folders for '.$sPortal.'! Please check the rights.'; |
|
69 | + throw new \Exception('The batch can`t create public folders for '.$sPortal.'! Please check the rights.'); |
|
70 | + } |
|
71 | + else { |
|
72 | 72 | |
73 | - if (!file_exists($sPrivatePath.'Controller')) { |
|
73 | + if (!file_exists($sPrivatePath.'Controller')) { |
|
74 | 74 | |
75 | - mkdir($sPublicPath . 'css', 0777, true); |
|
76 | - mkdir($sPublicPath . 'js', 0777, true); |
|
77 | - mkdir($sPublicPath . 'img', 0777, true); |
|
78 | - } |
|
79 | - else { |
|
75 | + mkdir($sPublicPath . 'css', 0777, true); |
|
76 | + mkdir($sPublicPath . 'js', 0777, true); |
|
77 | + mkdir($sPublicPath . 'img', 0777, true); |
|
78 | + } |
|
79 | + else { |
|
80 | 80 | |
81 | - echo 'The Project (public part) ' . $sPrivatePath . " exists\n"; |
|
82 | - } |
|
83 | - } |
|
81 | + echo 'The Project (public part) ' . $sPrivatePath . " exists\n"; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | if (!is_writable($sActualDirectory.'/../../../')) { |
86 | 86 | |
@@ -98,19 +98,19 @@ discard block |
||
98 | 98 | mkdir($sPrivatePath . 'conf', 0777, true); |
99 | 99 | mkdir($sPrivatePath . 'common', 0777, true); |
100 | 100 | |
101 | - $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Controller.php'); |
|
102 | - $sContent = str_replace('Batch', $sPortal, $sContent); |
|
103 | - file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Controller.php', $sContent); |
|
101 | + $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Controller.php'); |
|
102 | + $sContent = str_replace('Batch', $sPortal, $sContent); |
|
103 | + file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Controller.php', $sContent); |
|
104 | 104 | |
105 | - $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Model.php'); |
|
106 | - $sContent = str_replace('Batch', $sPortal, $sContent); |
|
107 | - file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Model.php', $sContent); |
|
105 | + $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Model.php'); |
|
106 | + $sContent = str_replace('Batch', $sPortal, $sContent); |
|
107 | + file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Model.php', $sContent); |
|
108 | 108 | |
109 | - $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Entity.php'); |
|
110 | - $sContent = str_replace('Batch', $sPortal, $sContent); |
|
111 | - file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Entity.php', $sContent); |
|
109 | + $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Entity.php'); |
|
110 | + $sContent = str_replace('Batch', $sPortal, $sContent); |
|
111 | + file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Entity.php', $sContent); |
|
112 | 112 | |
113 | - $content = "<?php |
|
113 | + $content = "<?php |
|
114 | 114 | |
115 | 115 | namespace Venus\\src\\".$sPortal."\\Controller; |
116 | 116 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | "; |
131 | 131 | |
132 | - file_put_contents($sPrivatePath.'Controller'.DIRECTORY_SEPARATOR.$sPortal.'.php', $content); |
|
132 | + file_put_contents($sPrivatePath.'Controller'.DIRECTORY_SEPARATOR.$sPortal.'.php', $content); |
|
133 | 133 | } |
134 | 134 | else { |
135 | 135 |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | |
73 | 73 | if (!file_exists($sPrivatePath.'Controller')) { |
74 | 74 | |
75 | - mkdir($sPublicPath . 'css', 0777, true); |
|
76 | - mkdir($sPublicPath . 'js', 0777, true); |
|
77 | - mkdir($sPublicPath . 'img', 0777, true); |
|
75 | + mkdir($sPublicPath.'css', 0777, true); |
|
76 | + mkdir($sPublicPath.'js', 0777, true); |
|
77 | + mkdir($sPublicPath.'img', 0777, true); |
|
78 | 78 | } |
79 | 79 | else { |
80 | 80 | |
81 | - echo 'The Project (public part) ' . $sPrivatePath . " exists\n"; |
|
81 | + echo 'The Project (public part) '.$sPrivatePath." exists\n"; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | |
92 | 92 | if (!file_exists($sPrivatePath.'Controller')) { |
93 | 93 | |
94 | - mkdir($sPrivatePath . 'Controller', 0777, true); |
|
95 | - mkdir($sPrivatePath . 'Entity', 0777, true); |
|
96 | - mkdir($sPrivatePath . 'Model', 0777, true); |
|
97 | - mkdir($sPrivatePath . 'View', 0777, true); |
|
98 | - mkdir($sPrivatePath . 'conf', 0777, true); |
|
99 | - mkdir($sPrivatePath . 'common', 0777, true); |
|
94 | + mkdir($sPrivatePath.'Controller', 0777, true); |
|
95 | + mkdir($sPrivatePath.'Entity', 0777, true); |
|
96 | + mkdir($sPrivatePath.'Model', 0777, true); |
|
97 | + mkdir($sPrivatePath.'View', 0777, true); |
|
98 | + mkdir($sPrivatePath.'conf', 0777, true); |
|
99 | + mkdir($sPrivatePath.'common', 0777, true); |
|
100 | 100 | |
101 | 101 | $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Controller.php'); |
102 | 102 | $sContent = str_replace('Batch', $sPortal, $sContent); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | else { |
135 | 135 | |
136 | - echo 'The Project (private part) ' . $sPrivatePath . " exists\n"; |
|
136 | + echo 'The Project (private part) '.$sPrivatePath." exists\n"; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * option -p [portail] |
52 | 52 | */ |
53 | - if (isset($aOptions['p'])) { $sPortal = $aOptions['p']; } |
|
54 | - else { $sPortal = 'Batch'; } |
|
53 | + if (isset($aOptions['p'])) { $sPortal = $aOptions['p']; } else { $sPortal = 'Batch'; } |
|
55 | 54 | |
56 | 55 | if (!preg_match('/^[a-zA-Z0-9]+$/', $sPortal)) { |
57 | 56 | |
@@ -67,16 +66,14 @@ discard block |
||
67 | 66 | |
68 | 67 | echo 'The batch can`t create public folders for '.$sPortal.'! Please check the rights.'; |
69 | 68 | throw new \Exception('The batch can`t create public folders for '.$sPortal.'! Please check the rights.'); |
70 | - } |
|
71 | - else { |
|
69 | + } else { |
|
72 | 70 | |
73 | 71 | if (!file_exists($sPrivatePath.'Controller')) { |
74 | 72 | |
75 | 73 | mkdir($sPublicPath . 'css', 0777, true); |
76 | 74 | mkdir($sPublicPath . 'js', 0777, true); |
77 | 75 | mkdir($sPublicPath . 'img', 0777, true); |
78 | - } |
|
79 | - else { |
|
76 | + } else { |
|
80 | 77 | |
81 | 78 | echo 'The Project (public part) ' . $sPrivatePath . " exists\n"; |
82 | 79 | } |
@@ -86,8 +83,7 @@ discard block |
||
86 | 83 | |
87 | 84 | echo 'The batch can`t create private folders for '.$sPortal.'! Please check the rights.'; |
88 | 85 | throw new \Exception('The batch can`t create private folders for '.$sPortal.'! Please check the rights.'); |
89 | - } |
|
90 | - else { |
|
86 | + } else { |
|
91 | 87 | |
92 | 88 | if (!file_exists($sPrivatePath.'Controller')) { |
93 | 89 | |
@@ -130,8 +126,7 @@ discard block |
||
130 | 126 | "; |
131 | 127 | |
132 | 128 | file_put_contents($sPrivatePath.'Controller'.DIRECTORY_SEPARATOR.$sPortal.'.php', $content); |
133 | - } |
|
134 | - else { |
|
129 | + } else { |
|
135 | 130 | |
136 | 131 | echo 'The Project (private part) ' . $sPrivatePath . " exists\n"; |
137 | 132 | } |
@@ -17,44 +17,44 @@ discard block |
||
17 | 17 | spl_autoload_register(function (string $sClassName) |
18 | 18 | { |
19 | 19 | |
20 | - $sClassName = ltrim($sClassName, '\\'); |
|
21 | - $sFileName = ''; |
|
22 | - $iLastNsPos = strrpos($sClassName, '\\'); |
|
20 | + $sClassName = ltrim($sClassName, '\\'); |
|
21 | + $sFileName = ''; |
|
22 | + $iLastNsPos = strrpos($sClassName, '\\'); |
|
23 | 23 | |
24 | - if ($iLastNsPos) { |
|
24 | + if ($iLastNsPos) { |
|
25 | 25 | |
26 | - $sNamespace = substr($sClassName, 0, $iLastNsPos); |
|
27 | - $sClassName = substr($sClassName, $iLastNsPos + 1); |
|
26 | + $sNamespace = substr($sClassName, 0, $iLastNsPos); |
|
27 | + $sClassName = substr($sClassName, $iLastNsPos + 1); |
|
28 | 28 | $sFileName = str_replace('\\', DIRECTORY_SEPARATOR, $sNamespace).DIRECTORY_SEPARATOR; |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | - $sFileName = str_replace('/', '\\', $sFileName); |
|
31 | + $sFileName = str_replace('/', '\\', $sFileName); |
|
32 | 32 | |
33 | - $sFileName .= $sClassName.'.php'; |
|
33 | + $sFileName .= $sClassName.'.php'; |
|
34 | 34 | |
35 | - if (defined('PORTAL')) { |
|
35 | + if (defined('PORTAL')) { |
|
36 | 36 | |
37 | - $sFileClassName = str_replace(PORTAL, PORTAL.DIRECTORY_SEPARATOR.'app', str_replace(['\\', '/'], DIRECTORY_SEPARATOR, str_replace('conf', DIRECTORY_SEPARATOR, __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
38 | - $sFileClassName = preg_replace('/(tests\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
39 | - $sFileClassName = preg_replace('/(src\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
40 | - $sFileClassName = str_replace('\\\\', '\\', $sFileClassName); |
|
41 | - $sFileClassName = preg_replace('#bundles//tests/([^/]+)#', 'bundles/tests/$1/app', $sFileClassName); |
|
42 | - $sFileClassName = preg_replace('#bundles//src/([^/]+)#', 'bundles/src/$1/app', $sFileClassName); |
|
43 | - $sFileClassName = str_replace('app\\app', 'app', $sFileClassName); |
|
44 | - $sFileClassName = str_replace('app/app', 'app', $sFileClassName); |
|
37 | + $sFileClassName = str_replace(PORTAL, PORTAL.DIRECTORY_SEPARATOR.'app', str_replace(['\\', '/'], DIRECTORY_SEPARATOR, str_replace('conf', DIRECTORY_SEPARATOR, __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
38 | + $sFileClassName = preg_replace('/(tests\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
39 | + $sFileClassName = preg_replace('/(src\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
40 | + $sFileClassName = str_replace('\\\\', '\\', $sFileClassName); |
|
41 | + $sFileClassName = preg_replace('#bundles//tests/([^/]+)#', 'bundles/tests/$1/app', $sFileClassName); |
|
42 | + $sFileClassName = preg_replace('#bundles//src/([^/]+)#', 'bundles/src/$1/app', $sFileClassName); |
|
43 | + $sFileClassName = str_replace('app\\app', 'app', $sFileClassName); |
|
44 | + $sFileClassName = str_replace('app/app', 'app', $sFileClassName); |
|
45 | 45 | |
46 | - if (strstr($sFileName, 'Venus\\') && file_exists($sFileClassName)) { |
|
46 | + if (strstr($sFileName, 'Venus\\') && file_exists($sFileClassName)) { |
|
47 | 47 | |
48 | - require $sFileClassName; |
|
49 | - } |
|
50 | - } |
|
51 | - else { |
|
48 | + require $sFileClassName; |
|
49 | + } |
|
50 | + } |
|
51 | + else { |
|
52 | 52 | |
53 | - if (strstr($sFileName, 'Venus\\') && file_exists(preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))))) { |
|
53 | + if (strstr($sFileName, 'Venus\\') && file_exists(preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))))) { |
|
54 | 54 | |
55 | - require preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
56 | - } |
|
57 | - } |
|
55 | + require preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | }); |
59 | 59 | |
60 | 60 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | if (file_exists(preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php')) { |
65 | 65 | |
66 | - include preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php'; |
|
66 | + include preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | |
75 | 75 | if (isset($oConfig) && isset($oConfig->autoload)) { |
76 | 76 | |
77 | - $oAutoloadConf = $oConfig->autoload; |
|
77 | + $oAutoloadConf = $oConfig->autoload; |
|
78 | 78 | |
79 | - foreach ($oAutoloadConf as $sFile) { |
|
79 | + foreach ($oAutoloadConf as $sFile) { |
|
80 | 80 | |
81 | - require __DIR__.'/../'.$sFile; |
|
82 | - } |
|
81 | + require __DIR__.'/../'.$sFile; |
|
82 | + } |
|
83 | 83 | } |
@@ -42,749 +42,749 @@ |
||
42 | 42 | */ |
43 | 43 | class Router implements LoggerAwareInterface |
44 | 44 | { |
45 | - /** |
|
46 | - * The base Uri to construct the route |
|
47 | - * |
|
48 | - * @access private |
|
49 | - * @var string |
|
50 | - */ |
|
51 | - private $_sBaseUri = ''; |
|
52 | - |
|
53 | - /** |
|
54 | - * get the security of page |
|
55 | - * |
|
56 | - * @access private |
|
57 | - * @var \Venus\core\Security |
|
58 | - */ |
|
59 | - private $_oSecurity = null; |
|
60 | - |
|
61 | - /** |
|
62 | - * The Routes of the actual host |
|
63 | - * |
|
64 | - * @access private |
|
65 | - * @var object |
|
66 | - */ |
|
67 | - private $_oRoutes = null; |
|
68 | - |
|
69 | - /** |
|
70 | - * Logger |
|
71 | - * |
|
72 | - * @access private |
|
73 | - * @var object |
|
74 | - */ |
|
75 | - private $_oLogger = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * constructor |
|
79 | - * |
|
80 | - * @access public |
|
81 | - */ |
|
82 | - public function __construct() |
|
83 | - { |
|
84 | - $oLogger = Debug::getInstance(); |
|
85 | - $this->setLogger($oLogger); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * run the routeur |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @return null|boolean |
|
93 | - */ |
|
94 | - public function run() |
|
95 | - { |
|
96 | - date_default_timezone_set(Config::get('Const')->timezone); |
|
97 | - |
|
98 | - $this->_create_constant(); |
|
99 | - |
|
100 | - if (Request::isHttpRequest()) { |
|
45 | + /** |
|
46 | + * The base Uri to construct the route |
|
47 | + * |
|
48 | + * @access private |
|
49 | + * @var string |
|
50 | + */ |
|
51 | + private $_sBaseUri = ''; |
|
52 | + |
|
53 | + /** |
|
54 | + * get the security of page |
|
55 | + * |
|
56 | + * @access private |
|
57 | + * @var \Venus\core\Security |
|
58 | + */ |
|
59 | + private $_oSecurity = null; |
|
60 | + |
|
61 | + /** |
|
62 | + * The Routes of the actual host |
|
63 | + * |
|
64 | + * @access private |
|
65 | + * @var object |
|
66 | + */ |
|
67 | + private $_oRoutes = null; |
|
68 | + |
|
69 | + /** |
|
70 | + * Logger |
|
71 | + * |
|
72 | + * @access private |
|
73 | + * @var object |
|
74 | + */ |
|
75 | + private $_oLogger = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * constructor |
|
79 | + * |
|
80 | + * @access public |
|
81 | + */ |
|
82 | + public function __construct() |
|
83 | + { |
|
84 | + $oLogger = Debug::getInstance(); |
|
85 | + $this->setLogger($oLogger); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * run the routeur |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @return null|boolean |
|
93 | + */ |
|
94 | + public function run() |
|
95 | + { |
|
96 | + date_default_timezone_set(Config::get('Const')->timezone); |
|
97 | + |
|
98 | + $this->_create_constant(); |
|
99 | + |
|
100 | + if (Request::isHttpRequest()) { |
|
101 | 101 | |
102 | - // Search if a Less file exists |
|
103 | - if (defined('LESS_ACTIVE') && LESS_ACTIVE === true) { |
|
102 | + // Search if a Less file exists |
|
103 | + if (defined('LESS_ACTIVE') && LESS_ACTIVE === true) { |
|
104 | 104 | |
105 | - if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
106 | - && file_exists(preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
105 | + if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
106 | + && file_exists(preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
107 | 107 | |
108 | - Less::toCss($_SERVER['REQUEST_URI']); |
|
109 | - exit; |
|
110 | - } |
|
111 | - } |
|
108 | + Less::toCss($_SERVER['REQUEST_URI']); |
|
109 | + exit; |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | - // Search if a typescript file exists |
|
114 | - if (defined('TYPESCRIPT_ACTIVE') && TYPESCRIPT_ACTIVE === true) { |
|
113 | + // Search if a typescript file exists |
|
114 | + if (defined('TYPESCRIPT_ACTIVE') && TYPESCRIPT_ACTIVE === true) { |
|
115 | 115 | |
116 | - if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
117 | - && file_exists(preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
116 | + if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
117 | + && file_exists(preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
118 | 118 | |
119 | - Typescript::toJs($_SERVER['REQUEST_URI']); |
|
120 | - exit; |
|
121 | - } |
|
122 | - } |
|
119 | + Typescript::toJs($_SERVER['REQUEST_URI']); |
|
120 | + exit; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - // Search public files in all plugins |
|
125 | - if ($_SERVER['REQUEST_URI'] !== '/') { |
|
124 | + // Search public files in all plugins |
|
125 | + if ($_SERVER['REQUEST_URI'] !== '/') { |
|
126 | 126 | |
127 | - foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
127 | + foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
128 | 128 | |
129 | - if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI'])) { |
|
129 | + if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI'])) { |
|
130 | 130 | |
131 | - echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI']); |
|
132 | - exit; |
|
133 | - } else if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
134 | - && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
131 | + echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI']); |
|
132 | + exit; |
|
133 | + } else if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
134 | + && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
135 | 135 | |
136 | - Less::toCss(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI'])); |
|
137 | - exit; |
|
138 | - } else if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
139 | - && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
136 | + Less::toCss(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI'])); |
|
137 | + exit; |
|
138 | + } else if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
139 | + && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
140 | 140 | |
141 | - Typescript::toJs(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI'])); |
|
142 | - exit; |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
141 | + Typescript::toJs(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI'])); |
|
142 | + exit; |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - foreach (Config::get('Route') as $sMultiHost => $oHost) { |
|
147 | + foreach (Config::get('Route') as $sMultiHost => $oHost) { |
|
148 | 148 | |
149 | - foreach (explode(',', $sMultiHost) as $sHost) { |
|
149 | + foreach (explode(',', $sMultiHost) as $sHost) { |
|
150 | 150 | |
151 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) || (strstr($sHost, '/') |
|
152 | - && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
151 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) || (strstr($sHost, '/') |
|
152 | + && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
153 | 153 | |
154 | - $this->_oRoutes = $oHost; |
|
154 | + $this->_oRoutes = $oHost; |
|
155 | 155 | |
156 | - if (strstr($sHost, '/') |
|
157 | - && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
156 | + if (strstr($sHost, '/') |
|
157 | + && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
158 | 158 | |
159 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
160 | - } |
|
159 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
160 | + } |
|
161 | 161 | |
162 | - if (isset($oHost->location)) { |
|
162 | + if (isset($oHost->location)) { |
|
163 | 163 | |
164 | - header('Status: 301 Moved Permanently', false, 301); |
|
165 | - header('Location: '.$oHost->location); |
|
166 | - exit; |
|
167 | - } else if (preg_match('#getCss\?#', $_SERVER['REQUEST_URI'])) { |
|
164 | + header('Status: 301 Moved Permanently', false, 301); |
|
165 | + header('Location: '.$oHost->location); |
|
166 | + exit; |
|
167 | + } else if (preg_match('#getCss\?#', $_SERVER['REQUEST_URI'])) { |
|
168 | 168 | |
169 | - foreach ($_GET as $sKey => $sValue) { |
|
169 | + foreach ($_GET as $sKey => $sValue) { |
|
170 | 170 | |
171 | - if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')) { |
|
171 | + if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')) { |
|
172 | 172 | |
173 | - echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')."\n"; |
|
174 | - } |
|
175 | - } |
|
173 | + echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')."\n"; |
|
174 | + } |
|
175 | + } |
|
176 | 176 | |
177 | - exit; |
|
178 | - } else if (preg_match('#getJs\?#', $_SERVER['REQUEST_URI'])) { |
|
177 | + exit; |
|
178 | + } else if (preg_match('#getJs\?#', $_SERVER['REQUEST_URI'])) { |
|
179 | 179 | |
180 | - foreach ($_GET as $sKey => $sValue) { |
|
180 | + foreach ($_GET as $sKey => $sValue) { |
|
181 | 181 | |
182 | - if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')) { |
|
182 | + if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')) { |
|
183 | 183 | |
184 | - echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')."\n"; |
|
185 | - } |
|
186 | - } |
|
184 | + echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')."\n"; |
|
185 | + } |
|
186 | + } |
|
187 | 187 | |
188 | - exit; |
|
189 | - } else if (isset($oHost->routes)) { |
|
188 | + exit; |
|
189 | + } else if (isset($oHost->routes)) { |
|
190 | 190 | |
191 | - foreach ($oHost->routes as $sKey => $oRoute) { |
|
191 | + foreach ($oHost->routes as $sKey => $oRoute) { |
|
192 | 192 | |
193 | - $mReturn = $this->_route($oRoute, $_SERVER['REQUEST_URI']); |
|
193 | + $mReturn = $this->_route($oRoute, $_SERVER['REQUEST_URI']); |
|
194 | 194 | |
195 | - if ($mReturn === 403) { |
|
195 | + if ($mReturn === 403) { |
|
196 | 196 | |
197 | - $this->_getPage403(); |
|
198 | - } |
|
199 | - else if ($mReturn === true) { |
|
197 | + $this->_getPage403(); |
|
198 | + } |
|
199 | + else if ($mReturn === true) { |
|
200 | 200 | |
201 | - if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
201 | + if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
202 | 202 | |
203 | - return true; |
|
204 | - } |
|
205 | - } |
|
203 | + return true; |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | - $this->_getPage404(); |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - } |
|
212 | - } else if (Request::isCliRequest()) { |
|
207 | + $this->_getPage404(); |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + } |
|
212 | + } else if (Request::isCliRequest()) { |
|
213 | 213 | |
214 | - if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
215 | - else { $aArguments = []; } |
|
214 | + if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
215 | + else { $aArguments = []; } |
|
216 | 216 | |
217 | - define('PORTAL', 'Batch'); |
|
218 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
217 | + define('PORTAL', 'Batch'); |
|
218 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
219 | 219 | |
220 | - if (!isset($aArguments[1]) && strstr($aArguments[0], '/phpunit')) { |
|
220 | + if (!isset($aArguments[1]) && strstr($aArguments[0], '/phpunit')) { |
|
221 | 221 | |
222 | - $sBatchName = "phpunit"; |
|
223 | - $aArguments[0] = "bin/console"; |
|
224 | - $aArguments[1] = "phpunit"; |
|
225 | - } else { |
|
226 | - $sBatchName = $aArguments[1]; |
|
227 | - } |
|
222 | + $sBatchName = "phpunit"; |
|
223 | + $aArguments[0] = "bin/console"; |
|
224 | + $aArguments[1] = "phpunit"; |
|
225 | + } else { |
|
226 | + $sBatchName = $aArguments[1]; |
|
227 | + } |
|
228 | 228 | |
229 | - if (isset(Config::get('Route')->batch->script->{$sBatchName})) { |
|
229 | + if (isset(Config::get('Route')->batch->script->{$sBatchName})) { |
|
230 | 230 | |
231 | - $oBatch = Config::get('Route')->batch->script->{$sBatchName}; |
|
232 | - array_shift($aArguments); |
|
233 | - array_shift($aArguments); |
|
231 | + $oBatch = Config::get('Route')->batch->script->{$sBatchName}; |
|
232 | + array_shift($aArguments); |
|
233 | + array_shift($aArguments); |
|
234 | 234 | |
235 | - $aOptions = array(); |
|
235 | + $aOptions = array(); |
|
236 | 236 | |
237 | - while (count($aArguments) > 0) { |
|
237 | + while (count($aArguments) > 0) { |
|
238 | 238 | |
239 | - if (preg_match('/^-[a-z]/', $aArguments[0])) { |
|
239 | + if (preg_match('/^-[a-z]/', $aArguments[0])) { |
|
240 | 240 | |
241 | - $sOptionName = str_replace('-', '', $aArguments[0]); |
|
241 | + $sOptionName = str_replace('-', '', $aArguments[0]); |
|
242 | 242 | |
243 | - if (isset($aArguments[1])) { |
|
244 | - $sOptionValue = $aArguments[1]; |
|
245 | - } else { |
|
246 | - $sOptionValue = ''; |
|
247 | - } |
|
243 | + if (isset($aArguments[1])) { |
|
244 | + $sOptionValue = $aArguments[1]; |
|
245 | + } else { |
|
246 | + $sOptionValue = ''; |
|
247 | + } |
|
248 | 248 | |
249 | - if (isset($oBatch->options->$sOptionName) && $oBatch->options->$sOptionName === false) { |
|
249 | + if (isset($oBatch->options->$sOptionName) && $oBatch->options->$sOptionName === false) { |
|
250 | 250 | |
251 | - $aOptions[$sOptionName] = true; |
|
252 | - array_shift($aArguments); |
|
253 | - } else if (isset($oBatch->options->$sOptionName) && ($oBatch->options->$sOptionName === 'string' |
|
254 | - || $oBatch->options->$sOptionName === 'int') |
|
255 | - ) { |
|
251 | + $aOptions[$sOptionName] = true; |
|
252 | + array_shift($aArguments); |
|
253 | + } else if (isset($oBatch->options->$sOptionName) && ($oBatch->options->$sOptionName === 'string' |
|
254 | + || $oBatch->options->$sOptionName === 'int') |
|
255 | + ) { |
|
256 | 256 | |
257 | - $aOptions[$sOptionName] = $sOptionValue; |
|
258 | - array_shift($aArguments); |
|
259 | - array_shift($aArguments); |
|
260 | - } else { |
|
257 | + $aOptions[$sOptionName] = $sOptionValue; |
|
258 | + array_shift($aArguments); |
|
259 | + array_shift($aArguments); |
|
260 | + } else { |
|
261 | 261 | |
262 | - array_shift($aArguments); |
|
263 | - } |
|
264 | - } else { |
|
262 | + array_shift($aArguments); |
|
263 | + } |
|
264 | + } else { |
|
265 | 265 | |
266 | - array_shift($aArguments); |
|
267 | - } |
|
268 | - } |
|
269 | - } |
|
266 | + array_shift($aArguments); |
|
267 | + } |
|
268 | + } |
|
269 | + } |
|
270 | 270 | |
271 | - if (isset($oBatch->controller) && isset($oBatch->action)) { |
|
271 | + if (isset($oBatch->controller) && isset($oBatch->action)) { |
|
272 | 272 | |
273 | - echo $this->_loadController($oBatch->controller, $oBatch->action, array($aOptions)); |
|
274 | - } else { |
|
273 | + echo $this->_loadController($oBatch->controller, $oBatch->action, array($aOptions)); |
|
274 | + } else { |
|
275 | 275 | |
276 | - if (Request::isCliRequest()) { |
|
276 | + if (Request::isCliRequest()) { |
|
277 | 277 | |
278 | - echo "Error : The batch not exists - please verify your Route or the name passed in your command name.\n"; |
|
279 | - } |
|
280 | - } |
|
278 | + echo "Error : The batch not exists - please verify your Route or the name passed in your command name.\n"; |
|
279 | + } |
|
280 | + } |
|
281 | 281 | |
282 | - } |
|
283 | - } |
|
282 | + } |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * run the routeur by the forwarsd metho (in the controller) |
|
287 | - * |
|
288 | - * @access public |
|
289 | - * @param string $sRoute route we wantload |
|
290 | - * @param array $aParams parameters to passe |
|
291 | - * @return void |
|
292 | - */ |
|
293 | - public function runByFoward(string $sRoute, array $aParams) |
|
294 | - { |
|
295 | - $this->_create_constant(); |
|
285 | + /** |
|
286 | + * run the routeur by the forwarsd metho (in the controller) |
|
287 | + * |
|
288 | + * @access public |
|
289 | + * @param string $sRoute route we wantload |
|
290 | + * @param array $aParams parameters to passe |
|
291 | + * @return void |
|
292 | + */ |
|
293 | + public function runByFoward(string $sRoute, array $aParams) |
|
294 | + { |
|
295 | + $this->_create_constant(); |
|
296 | 296 | |
297 | - if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
297 | + if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
298 | 298 | |
299 | - foreach (Config::get('Route') as $sHost => $oHost) { |
|
299 | + foreach (Config::get('Route') as $sHost => $oHost) { |
|
300 | 300 | |
301 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
302 | - || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
301 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
302 | + || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
303 | 303 | |
304 | - $this->_oRoutes = $oHost; |
|
304 | + $this->_oRoutes = $oHost; |
|
305 | 305 | |
306 | - if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
306 | + if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
307 | 307 | |
308 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
309 | - } |
|
308 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
309 | + } |
|
310 | 310 | |
311 | - foreach ($oHost->routes as $sKey => $oRoute) { |
|
311 | + foreach ($oHost->routes as $sKey => $oRoute) { |
|
312 | 312 | |
313 | - $this->_route($oRoute, $sRoute); |
|
314 | - } |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - else if (defined('STDIN')) { |
|
313 | + $this->_route($oRoute, $sRoute); |
|
314 | + } |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + else if (defined('STDIN')) { |
|
319 | 319 | |
320 | - $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
|
321 | - echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
|
322 | - } |
|
323 | - } |
|
320 | + $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
|
321 | + echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
|
322 | + } |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * run the error http page |
|
327 | - * |
|
328 | - * @access public |
|
329 | - * @param int iError http error |
|
330 | - * @return void |
|
331 | - */ |
|
332 | - public function runHttpErrorPage(int $iError) |
|
333 | - { |
|
334 | - $this->_create_constant(); |
|
325 | + /** |
|
326 | + * run the error http page |
|
327 | + * |
|
328 | + * @access public |
|
329 | + * @param int iError http error |
|
330 | + * @return void |
|
331 | + */ |
|
332 | + public function runHttpErrorPage(int $iError) |
|
333 | + { |
|
334 | + $this->_create_constant(); |
|
335 | 335 | |
336 | - if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
336 | + if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
337 | 337 | |
338 | - foreach (Config::get('Route') as $sHost => $oHost) { |
|
338 | + foreach (Config::get('Route') as $sHost => $oHost) { |
|
339 | 339 | |
340 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
341 | - || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
340 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
341 | + || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
342 | 342 | |
343 | - $this->_oRoutes = $oHost->routes; |
|
343 | + $this->_oRoutes = $oHost->routes; |
|
344 | 344 | |
345 | - if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
345 | + if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
346 | 346 | |
347 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
348 | - } |
|
347 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
348 | + } |
|
349 | 349 | |
350 | - $sHttpErrorPageName = '_getPage'.iError; |
|
351 | - $this->$sHttpErrorPageName(); |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
350 | + $sHttpErrorPageName = '_getPage'.iError; |
|
351 | + $this->$sHttpErrorPageName(); |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * load a route |
|
359 | - * |
|
360 | - * @access private |
|
361 | - * @param \stdClass $oRoute one route |
|
362 | - * @param string $RequestUri URI |
|
363 | - * @return void |
|
364 | - */ |
|
365 | - private function _route(\stdClass $oRoute, string $RequestUri) |
|
366 | - { |
|
367 | - $sCharset = 'UTF-8'; |
|
357 | + /** |
|
358 | + * load a route |
|
359 | + * |
|
360 | + * @access private |
|
361 | + * @param \stdClass $oRoute one route |
|
362 | + * @param string $RequestUri URI |
|
363 | + * @return void |
|
364 | + */ |
|
365 | + private function _route(\stdClass $oRoute, string $RequestUri) |
|
366 | + { |
|
367 | + $sCharset = 'UTF-8'; |
|
368 | 368 | |
369 | - if (isset($oRoute->route)) { |
|
369 | + if (isset($oRoute->route)) { |
|
370 | 370 | |
371 | - $sRoute = str_replace("*", ".*", $oRoute->route); |
|
371 | + $sRoute = str_replace("*", ".*", $oRoute->route); |
|
372 | 372 | |
373 | - $sFinalRoute = preg_replace_callback( |
|
374 | - '|\[/{0,1}:([a-zA-Z_]+)\]|', |
|
375 | - function($aMatches) use ($oRoute) { |
|
376 | - return "/{0,1}(?P<".$aMatches[1].">".$oRoute->constraints->{$aMatches[1]}.")"; |
|
377 | - }, |
|
378 | - $sRoute |
|
379 | - ); |
|
380 | - } |
|
381 | - else { |
|
373 | + $sFinalRoute = preg_replace_callback( |
|
374 | + '|\[/{0,1}:([a-zA-Z_]+)\]|', |
|
375 | + function($aMatches) use ($oRoute) { |
|
376 | + return "/{0,1}(?P<".$aMatches[1].">".$oRoute->constraints->{$aMatches[1]}.")"; |
|
377 | + }, |
|
378 | + $sRoute |
|
379 | + ); |
|
380 | + } |
|
381 | + else { |
|
382 | 382 | |
383 | - $sFinalRoute = '.*'; |
|
384 | - } |
|
383 | + $sFinalRoute = '.*'; |
|
384 | + } |
|
385 | 385 | |
386 | - $RequestUri = preg_replace('/^([^?]+)\?.*$/', '$1', $RequestUri); |
|
387 | - $RequestUri = preg_replace('#^'.$this->_sBaseUri.'#', '', $RequestUri); |
|
386 | + $RequestUri = preg_replace('/^([^?]+)\?.*$/', '$1', $RequestUri); |
|
387 | + $RequestUri = preg_replace('#^'.$this->_sBaseUri.'#', '', $RequestUri); |
|
388 | 388 | |
389 | - if (preg_match('#^'.$sFinalRoute.'$#', $RequestUri, $aMatch)) { |
|
389 | + if (preg_match('#^'.$sFinalRoute.'$#', $RequestUri, $aMatch)) { |
|
390 | 390 | |
391 | - if (isset($oRoute->location)) { |
|
391 | + if (isset($oRoute->location)) { |
|
392 | 392 | |
393 | - $aParamEntries = array(); |
|
393 | + $aParamEntries = array(); |
|
394 | 394 | |
395 | - foreach ($oRoute->constraints as $sName => $sType) { |
|
395 | + foreach ($oRoute->constraints as $sName => $sType) { |
|
396 | 396 | |
397 | - if (isset($aMatch[$sName])) { |
|
397 | + if (isset($aMatch[$sName])) { |
|
398 | 398 | |
399 | - $aParamEntries[$sName] = $aMatch[$sName]; |
|
400 | - } |
|
401 | - } |
|
399 | + $aParamEntries[$sName] = $aMatch[$sName]; |
|
400 | + } |
|
401 | + } |
|
402 | 402 | |
403 | - $oUrlManager = new UrlManager; |
|
404 | - header('Status: 301 Moved Permanently', false, 301); |
|
405 | - header('Location: '.$oUrlManager->getUrl($oRoute->location, $aParamEntries)); |
|
406 | - exit; |
|
407 | - } |
|
403 | + $oUrlManager = new UrlManager; |
|
404 | + header('Status: 301 Moved Permanently', false, 301); |
|
405 | + header('Location: '.$oUrlManager->getUrl($oRoute->location, $aParamEntries)); |
|
406 | + exit; |
|
407 | + } |
|
408 | 408 | |
409 | - $this->_oSecurity = new Security; |
|
409 | + $this->_oSecurity = new Security; |
|
410 | 410 | |
411 | - if (!$this->_oSecurity->checkSecurity() !== null) { return 403; } |
|
411 | + if (!$this->_oSecurity->checkSecurity() !== null) { return 403; } |
|
412 | 412 | |
413 | - // create the $_GET by the URL |
|
413 | + // create the $_GET by the URL |
|
414 | 414 | |
415 | - foreach ($aMatch as $mKey => $sResults) { |
|
415 | + foreach ($aMatch as $mKey => $sResults) { |
|
416 | 416 | |
417 | - if (is_string($mKey)) { |
|
417 | + if (is_string($mKey)) { |
|
418 | 418 | |
419 | - $_GET[$mKey] = $sResults; |
|
420 | - } |
|
421 | - } |
|
419 | + $_GET[$mKey] = $sResults; |
|
420 | + } |
|
421 | + } |
|
422 | 422 | |
423 | - if (isset($oRoute->methods) && $oRoute->methods != $_SERVER['REQUEST_METHOD']) { return false; } |
|
423 | + if (isset($oRoute->methods) && $oRoute->methods != $_SERVER['REQUEST_METHOD']) { return false; } |
|
424 | 424 | |
425 | - if (isset($oRoute->schemes) && $oRoute->schemes == 'https' && !Request::isHttpsRequest()) { return false; } |
|
425 | + if (isset($oRoute->schemes) && $oRoute->schemes == 'https' && !Request::isHttpsRequest()) { return false; } |
|
426 | 426 | |
427 | - if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && !isset($_GET['flush'])) { |
|
427 | + if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && !isset($_GET['flush'])) { |
|
428 | 428 | |
429 | - $oMobileDetect = new \Mobile_Detect; |
|
429 | + $oMobileDetect = new \Mobile_Detect; |
|
430 | 430 | |
431 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
432 | - else { $sCacheExt = ''; } |
|
431 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
432 | + else { $sCacheExt = ''; } |
|
433 | 433 | |
434 | - $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
|
434 | + $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
|
435 | 435 | |
436 | - if ($mCacheReturn && count($_POST) < 1) { |
|
436 | + if ($mCacheReturn && count($_POST) < 1) { |
|
437 | 437 | |
438 | - echo $mCacheReturn; |
|
439 | - return true; |
|
440 | - } |
|
441 | - } |
|
438 | + echo $mCacheReturn; |
|
439 | + return true; |
|
440 | + } |
|
441 | + } |
|
442 | 442 | |
443 | - if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
443 | + if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
444 | 444 | |
445 | - if (isset($oRoute->controller)) { |
|
445 | + if (isset($oRoute->controller)) { |
|
446 | 446 | |
447 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->controller)); |
|
448 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
447 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->controller)); |
|
448 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
449 | 449 | |
450 | - if (isset($oRoute->content_type)) { |
|
450 | + if (isset($oRoute->content_type)) { |
|
451 | 451 | |
452 | - if ($oRoute->content_type == 'json') { |
|
452 | + if ($oRoute->content_type == 'json') { |
|
453 | 453 | |
454 | - header('Content-type: application/json; charset='.$sCharset.''); |
|
455 | - } else if ($oRoute->content_type == 'html') { |
|
454 | + header('Content-type: application/json; charset='.$sCharset.''); |
|
455 | + } else if ($oRoute->content_type == 'html') { |
|
456 | 456 | |
457 | - header('Content-type: text/html; charset='.$sCharset.''); |
|
458 | - } else if ($oRoute->content_type == 'jpeg') { |
|
457 | + header('Content-type: text/html; charset='.$sCharset.''); |
|
458 | + } else if ($oRoute->content_type == 'jpeg') { |
|
459 | 459 | |
460 | - header('Content-type: image/jpeg'); |
|
461 | - } |
|
462 | - } |
|
463 | - else { |
|
460 | + header('Content-type: image/jpeg'); |
|
461 | + } |
|
462 | + } |
|
463 | + else { |
|
464 | 464 | |
465 | - header('Content-type: text/html; charset='.$sCharset.''); |
|
466 | - } |
|
465 | + header('Content-type: text/html; charset='.$sCharset.''); |
|
466 | + } |
|
467 | 467 | |
468 | - $sControllerName = $oRoute->controller; |
|
469 | - $sActionName = $oRoute->action; |
|
468 | + $sControllerName = $oRoute->controller; |
|
469 | + $sActionName = $oRoute->action; |
|
470 | 470 | |
471 | - $oController = new $sControllerName; |
|
471 | + $oController = new $sControllerName; |
|
472 | 472 | |
473 | - $aEntries = array(); |
|
473 | + $aEntries = array(); |
|
474 | 474 | |
475 | - if (isset($oRoute->constraints) && is_object($oRoute->constraints)) { |
|
475 | + if (isset($oRoute->constraints) && is_object($oRoute->constraints)) { |
|
476 | 476 | |
477 | - $mReturn = null; |
|
477 | + $mReturn = null; |
|
478 | 478 | |
479 | - foreach ($oRoute->constraints as $sName => $sType) { |
|
479 | + foreach ($oRoute->constraints as $sName => $sType) { |
|
480 | 480 | |
481 | - if (isset($_GET[$sName]) && $_GET[$sName] != '') { |
|
481 | + if (isset($_GET[$sName]) && $_GET[$sName] != '') { |
|
482 | 482 | |
483 | - $aEntries[] = $_GET[$sName]; |
|
484 | - } else if (isset($oRoute->defaults_constraints) && is_object($oRoute->defaults_constraints) |
|
485 | - && isset($oRoute->defaults_constraints->{$sName})) { |
|
483 | + $aEntries[] = $_GET[$sName]; |
|
484 | + } else if (isset($oRoute->defaults_constraints) && is_object($oRoute->defaults_constraints) |
|
485 | + && isset($oRoute->defaults_constraints->{$sName})) { |
|
486 | 486 | |
487 | - $aEntries[] = $oRoute->defaults_constraints->{$sName}; |
|
488 | - } else if (isset($_GET[$sName])) { |
|
487 | + $aEntries[] = $oRoute->defaults_constraints->{$sName}; |
|
488 | + } else if (isset($_GET[$sName])) { |
|
489 | 489 | |
490 | - $aEntries[] = $_GET[$sName]; |
|
491 | - } else if (preg_match('/'.$sType.'/', '')) { |
|
490 | + $aEntries[] = $_GET[$sName]; |
|
491 | + } else if (preg_match('/'.$sType.'/', '')) { |
|
492 | 492 | |
493 | - $aEntries[] = ''; |
|
494 | - } else { |
|
493 | + $aEntries[] = ''; |
|
494 | + } else { |
|
495 | 495 | |
496 | - $this->_oLogger->warning('Error: Parameter '.$sName.' not exists!'); |
|
497 | - break; |
|
498 | - } |
|
499 | - } |
|
496 | + $this->_oLogger->warning('Error: Parameter '.$sName.' not exists!'); |
|
497 | + break; |
|
498 | + } |
|
499 | + } |
|
500 | 500 | |
501 | - if ($mReturn === null) { |
|
501 | + if ($mReturn === null) { |
|
502 | 502 | |
503 | - $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
503 | + $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
504 | 504 | |
505 | - } |
|
506 | - } |
|
507 | - else { |
|
505 | + } |
|
506 | + } |
|
507 | + else { |
|
508 | 508 | |
509 | - $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
510 | - } |
|
509 | + $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
510 | + } |
|
511 | 511 | |
512 | - if (isset($oRoute->content_type)) { |
|
512 | + if (isset($oRoute->content_type)) { |
|
513 | 513 | |
514 | - if ($oRoute->content_type === 'json') { |
|
514 | + if ($oRoute->content_type === 'json') { |
|
515 | 515 | |
516 | - $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
|
517 | - } |
|
518 | - } |
|
519 | - } |
|
520 | - else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
516 | + $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
|
517 | + } |
|
518 | + } |
|
519 | + } |
|
520 | + else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
521 | 521 | |
522 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
523 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
522 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
523 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
524 | 524 | |
525 | - $oLayout = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'); |
|
525 | + $oLayout = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'); |
|
526 | 526 | |
527 | - if (isset($oRoute->vars)) { |
|
527 | + if (isset($oRoute->vars)) { |
|
528 | 528 | |
529 | - foreach ($oRoute->vars as $sKey => $mValue) { |
|
529 | + foreach ($oRoute->vars as $sKey => $mValue) { |
|
530 | 530 | |
531 | - $oLayout->assign($sKey, $mValue); |
|
532 | - } |
|
533 | - } |
|
531 | + $oLayout->assign($sKey, $mValue); |
|
532 | + } |
|
533 | + } |
|
534 | 534 | |
535 | - $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
|
536 | - ->fetch(); |
|
537 | - } |
|
538 | - else if (isset($oRoute->template)) { |
|
535 | + $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
|
536 | + ->fetch(); |
|
537 | + } |
|
538 | + else if (isset($oRoute->template)) { |
|
539 | 539 | |
540 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
541 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
540 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
541 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
542 | 542 | |
543 | - $oTemplate = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl'); |
|
543 | + $oTemplate = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl'); |
|
544 | 544 | |
545 | - if (isset($oRoute->vars)) { |
|
545 | + if (isset($oRoute->vars)) { |
|
546 | 546 | |
547 | - foreach ($oRoute->vars as $sKey => $mValue) { |
|
547 | + foreach ($oRoute->vars as $sKey => $mValue) { |
|
548 | 548 | |
549 | - $oTemplate->assign($sKey, $mValue); |
|
550 | - } |
|
551 | - } |
|
549 | + $oTemplate->assign($sKey, $mValue); |
|
550 | + } |
|
551 | + } |
|
552 | 552 | |
553 | - $mReturn = $oTemplate->fetch(); |
|
554 | - } |
|
553 | + $mReturn = $oTemplate->fetch(); |
|
554 | + } |
|
555 | 555 | |
556 | - // management of return or cache of it |
|
556 | + // management of return or cache of it |
|
557 | 557 | |
558 | - if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && $mReturn) { |
|
558 | + if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && $mReturn) { |
|
559 | 559 | |
560 | - $oMobileDetect = new \Mobile_Detect; |
|
560 | + $oMobileDetect = new \Mobile_Detect; |
|
561 | 561 | |
562 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
563 | - else { $sCacheExt = ''; } |
|
562 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
563 | + else { $sCacheExt = ''; } |
|
564 | 564 | |
565 | - if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
565 | + if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
566 | 566 | |
567 | - $mReturn = str_replace(array("\t", "\r", " "), array("", "", " "), $mReturn); |
|
568 | - } |
|
567 | + $mReturn = str_replace(array("\t", "\r", " "), array("", "", " "), $mReturn); |
|
568 | + } |
|
569 | 569 | |
570 | - Cache::set($RequestUri.$sCacheExt, $mReturn, $oRoute->cache->max_age); |
|
571 | - } |
|
570 | + Cache::set($RequestUri.$sCacheExt, $mReturn, $oRoute->cache->max_age); |
|
571 | + } |
|
572 | 572 | |
573 | - if ($mReturn) { |
|
573 | + if ($mReturn) { |
|
574 | 574 | |
575 | - echo $mReturn; |
|
576 | - return true; |
|
577 | - } |
|
578 | - } |
|
579 | - } |
|
575 | + echo $mReturn; |
|
576 | + return true; |
|
577 | + } |
|
578 | + } |
|
579 | + } |
|
580 | 580 | |
581 | - /** |
|
582 | - * create the constants |
|
583 | - * |
|
584 | - * @access private |
|
585 | - * @return void |
|
586 | - */ |
|
587 | - private function _create_constant() |
|
588 | - { |
|
589 | - foreach (Config::get('Const') as $sKey => $mValue) { |
|
581 | + /** |
|
582 | + * create the constants |
|
583 | + * |
|
584 | + * @access private |
|
585 | + * @return void |
|
586 | + */ |
|
587 | + private function _create_constant() |
|
588 | + { |
|
589 | + foreach (Config::get('Const') as $sKey => $mValue) { |
|
590 | 590 | |
591 | - if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) { |
|
591 | + if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) { |
|
592 | 592 | |
593 | - define(strtoupper($sKey), $mValue); |
|
594 | - } |
|
595 | - } |
|
596 | - } |
|
593 | + define(strtoupper($sKey), $mValue); |
|
594 | + } |
|
595 | + } |
|
596 | + } |
|
597 | 597 | |
598 | - /** |
|
599 | - * load the controller |
|
600 | - * |
|
601 | - * @access private |
|
602 | - * @param object $oControllerName controller name |
|
603 | - * @param string $sActionName method name |
|
604 | - * @param array $aParams parameters |
|
605 | - * @return mixed |
|
606 | - */ |
|
607 | - private function _loadController($oControllerName, string $sActionName, array $aParams = array()) |
|
608 | - { |
|
609 | - $aPhpDoc = PhpDoc::getPhpDocOfMethod($oControllerName, $sActionName); |
|
598 | + /** |
|
599 | + * load the controller |
|
600 | + * |
|
601 | + * @access private |
|
602 | + * @param object $oControllerName controller name |
|
603 | + * @param string $sActionName method name |
|
604 | + * @param array $aParams parameters |
|
605 | + * @return mixed |
|
606 | + */ |
|
607 | + private function _loadController($oControllerName, string $sActionName, array $aParams = array()) |
|
608 | + { |
|
609 | + $aPhpDoc = PhpDoc::getPhpDocOfMethod($oControllerName, $sActionName); |
|
610 | 610 | |
611 | - if (isset($aPhpDoc['Cache'])) { |
|
611 | + if (isset($aPhpDoc['Cache'])) { |
|
612 | 612 | |
613 | - if (!isset($aPhpDoc['Cache']['maxage'])) { $aPhpDoc['Cache']['maxage'] = 0; } |
|
613 | + if (!isset($aPhpDoc['Cache']['maxage'])) { $aPhpDoc['Cache']['maxage'] = 0; } |
|
614 | 614 | |
615 | - $oMobileDetect = new \Mobile_Detect; |
|
615 | + $oMobileDetect = new \Mobile_Detect; |
|
616 | 616 | |
617 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
618 | - else { $sCacheExt = ''; } |
|
617 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
618 | + else { $sCacheExt = ''; } |
|
619 | 619 | |
620 | - $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
|
620 | + $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
|
621 | 621 | |
622 | - if ($mCacheReturn !== false) { return $mCacheReturn; } |
|
623 | - } |
|
622 | + if ($mCacheReturn !== false) { return $mCacheReturn; } |
|
623 | + } |
|
624 | 624 | |
625 | - if (isset($aPhpDoc['Secure'])) { |
|
625 | + if (isset($aPhpDoc['Secure'])) { |
|
626 | 626 | |
627 | - if (isset($aPhpDoc['Secure']['roles']) && $this->_oSecurity->getUserRole() != $aPhpDoc['Secure']['roles']) { |
|
627 | + if (isset($aPhpDoc['Secure']['roles']) && $this->_oSecurity->getUserRole() != $aPhpDoc['Secure']['roles']) { |
|
628 | 628 | |
629 | - $this->_getPage403(); |
|
630 | - } |
|
631 | - } |
|
629 | + $this->_getPage403(); |
|
630 | + } |
|
631 | + } |
|
632 | 632 | |
633 | - $oController = new $oControllerName; |
|
633 | + $oController = new $oControllerName; |
|
634 | 634 | |
635 | - ob_start(); |
|
635 | + ob_start(); |
|
636 | 636 | |
637 | - if (!defined('PORTAL')) { define('PORTAL', 'Batch'); } |
|
637 | + if (!defined('PORTAL')) { define('PORTAL', 'Batch'); } |
|
638 | 638 | |
639 | - if (method_exists($oController, 'beforeExecuteRoute')) { |
|
639 | + if (method_exists($oController, 'beforeExecuteRoute')) { |
|
640 | 640 | |
641 | - call_user_func_array(array($oController, 'beforeExecuteRoute'), array()); |
|
642 | - } |
|
641 | + call_user_func_array(array($oController, 'beforeExecuteRoute'), array()); |
|
642 | + } |
|
643 | 643 | |
644 | - $mReturnController = call_user_func_array(array($oController, $sActionName), $aParams); |
|
644 | + $mReturnController = call_user_func_array(array($oController, $sActionName), $aParams); |
|
645 | 645 | |
646 | - if (method_exists($oController, 'afterExecuteRoute')) { |
|
646 | + if (method_exists($oController, 'afterExecuteRoute')) { |
|
647 | 647 | |
648 | - call_user_func_array(array($oController, 'afterExecuteRoute'), array()); |
|
649 | - } |
|
648 | + call_user_func_array(array($oController, 'afterExecuteRoute'), array()); |
|
649 | + } |
|
650 | 650 | |
651 | - $mReturn = ob_get_clean(); |
|
651 | + $mReturn = ob_get_clean(); |
|
652 | 652 | |
653 | - if ($mReturn == '') { $mReturn = $mReturnController; } |
|
653 | + if ($mReturn == '') { $mReturn = $mReturnController; } |
|
654 | 654 | |
655 | - if (isset($aPhpDoc['Cache'])) { |
|
655 | + if (isset($aPhpDoc['Cache'])) { |
|
656 | 656 | |
657 | - $oMobileDetect = new \Mobile_Detect; |
|
657 | + $oMobileDetect = new \Mobile_Detect; |
|
658 | 658 | |
659 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
660 | - else { $sCacheExt = ''; } |
|
659 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
660 | + else { $sCacheExt = ''; } |
|
661 | 661 | |
662 | - if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
662 | + if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
663 | 663 | |
664 | - $mReturn = str_replace(array("\t", "\r", " "), array("", "", "", " "), $mReturn); |
|
665 | - } |
|
664 | + $mReturn = str_replace(array("\t", "\r", " "), array("", "", "", " "), $mReturn); |
|
665 | + } |
|
666 | 666 | |
667 | - Cache::set($sActionName.$sCacheExt, $mReturn, $aPhpDoc['Cache']['maxage']); |
|
668 | - } |
|
667 | + Cache::set($sActionName.$sCacheExt, $mReturn, $aPhpDoc['Cache']['maxage']); |
|
668 | + } |
|
669 | 669 | |
670 | - return $mReturn; |
|
671 | - } |
|
670 | + return $mReturn; |
|
671 | + } |
|
672 | 672 | |
673 | - /** |
|
674 | - * get the page 403 |
|
675 | - * |
|
676 | - * @access private |
|
677 | - * @return void |
|
678 | - */ |
|
679 | - private function _getPage403() |
|
680 | - { |
|
681 | - header("HTTP/1.0 403 Forbidden"); |
|
673 | + /** |
|
674 | + * get the page 403 |
|
675 | + * |
|
676 | + * @access private |
|
677 | + * @return void |
|
678 | + */ |
|
679 | + private function _getPage403() |
|
680 | + { |
|
681 | + header("HTTP/1.0 403 Forbidden"); |
|
682 | 682 | |
683 | - if (isset($this->_oRoutes->e403)) { |
|
683 | + if (isset($this->_oRoutes->e403)) { |
|
684 | 684 | |
685 | - $this->_oRoutes->e403->route = '/'; |
|
686 | - $_SERVER['REQUEST_URI'] = '/'; |
|
687 | - $this->_route($this->_oRoutes->e403, $_SERVER['REQUEST_URI']); |
|
688 | - } |
|
685 | + $this->_oRoutes->e403->route = '/'; |
|
686 | + $_SERVER['REQUEST_URI'] = '/'; |
|
687 | + $this->_route($this->_oRoutes->e403, $_SERVER['REQUEST_URI']); |
|
688 | + } |
|
689 | 689 | |
690 | - exit; |
|
691 | - } |
|
690 | + exit; |
|
691 | + } |
|
692 | 692 | |
693 | - /** |
|
694 | - * get the page 404 |
|
695 | - * |
|
696 | - * @access private |
|
697 | - * @return void |
|
698 | - */ |
|
699 | - private function _getPage404() |
|
700 | - { |
|
701 | - header("HTTP/1.0 404 Not Found"); |
|
693 | + /** |
|
694 | + * get the page 404 |
|
695 | + * |
|
696 | + * @access private |
|
697 | + * @return void |
|
698 | + */ |
|
699 | + private function _getPage404() |
|
700 | + { |
|
701 | + header("HTTP/1.0 404 Not Found"); |
|
702 | 702 | |
703 | - if (isset($this->_oRoutes->e404)) { |
|
703 | + if (isset($this->_oRoutes->e404)) { |
|
704 | 704 | |
705 | - $this->_oRoutes->e404->route = '/'; |
|
706 | - $_SERVER['REQUEST_URI'] = '/'; |
|
707 | - $this->_route($this->_oRoutes->e404, $_SERVER['REQUEST_URI']); |
|
708 | - } |
|
705 | + $this->_oRoutes->e404->route = '/'; |
|
706 | + $_SERVER['REQUEST_URI'] = '/'; |
|
707 | + $this->_route($this->_oRoutes->e404, $_SERVER['REQUEST_URI']); |
|
708 | + } |
|
709 | 709 | |
710 | - exit; |
|
711 | - } |
|
710 | + exit; |
|
711 | + } |
|
712 | 712 | |
713 | - /** |
|
714 | - * check the cache - just if it's not yet defined |
|
715 | - * |
|
716 | - * @access private |
|
717 | - * @param \stdClass $oCache object of cache configuration |
|
718 | - * @return void |
|
719 | - */ |
|
720 | - private function _checkCache(\stdClass $oCache) |
|
721 | - { |
|
722 | - /** |
|
723 | - * cache-control http |
|
724 | - */ |
|
713 | + /** |
|
714 | + * check the cache - just if it's not yet defined |
|
715 | + * |
|
716 | + * @access private |
|
717 | + * @param \stdClass $oCache object of cache configuration |
|
718 | + * @return void |
|
719 | + */ |
|
720 | + private function _checkCache(\stdClass $oCache) |
|
721 | + { |
|
722 | + /** |
|
723 | + * cache-control http |
|
724 | + */ |
|
725 | 725 | |
726 | - $sHearderValidity = false; |
|
727 | - $sHeader = "Cache-Control:"; |
|
726 | + $sHearderValidity = false; |
|
727 | + $sHeader = "Cache-Control:"; |
|
728 | 728 | |
729 | - if (isset($oCache->visibility) && ($oCache->visibility = 'public' || $oCache->visibility = 'private')) { |
|
729 | + if (isset($oCache->visibility) && ($oCache->visibility = 'public' || $oCache->visibility = 'private')) { |
|
730 | 730 | |
731 | - $sHearderValidity = true; |
|
732 | - $sHeader .= " ".$oCache->visibility.","; |
|
733 | - } |
|
731 | + $sHearderValidity = true; |
|
732 | + $sHeader .= " ".$oCache->visibility.","; |
|
733 | + } |
|
734 | 734 | |
735 | - if (isset($oCache->max_age)) { |
|
735 | + if (isset($oCache->max_age)) { |
|
736 | 736 | |
737 | - $sHearderValidity = true; |
|
738 | - $sHeader .= " maxage=".$oCache->max_age.","; |
|
739 | - } |
|
737 | + $sHearderValidity = true; |
|
738 | + $sHeader .= " maxage=".$oCache->max_age.","; |
|
739 | + } |
|
740 | 740 | |
741 | - if (isset($oCache->must_revalidate) && $oCache->must_revalidate === true) { |
|
741 | + if (isset($oCache->must_revalidate) && $oCache->must_revalidate === true) { |
|
742 | 742 | |
743 | - $sHearderValidity = true; |
|
744 | - $sHeader .= " must-revalidate,"; |
|
745 | - } |
|
743 | + $sHearderValidity = true; |
|
744 | + $sHeader .= " must-revalidate,"; |
|
745 | + } |
|
746 | 746 | |
747 | - if ($sHearderValidity === true) { |
|
747 | + if ($sHearderValidity === true) { |
|
748 | 748 | |
749 | - $sHeader = substr($sHeader, 0, -1); |
|
749 | + $sHeader = substr($sHeader, 0, -1); |
|
750 | 750 | |
751 | - if (!headers_sent()) { header($sHeader); } |
|
752 | - } |
|
751 | + if (!headers_sent()) { header($sHeader); } |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * ETag http |
|
756 | - */ |
|
754 | + /** |
|
755 | + * ETag http |
|
756 | + */ |
|
757 | 757 | |
758 | - if (isset($oCache->ETag)) { header("ETag: \"".$oCache->ETag."\""); } |
|
758 | + if (isset($oCache->ETag)) { header("ETag: \"".$oCache->ETag."\""); } |
|
759 | 759 | |
760 | - /** |
|
761 | - * expire |
|
762 | - */ |
|
760 | + /** |
|
761 | + * expire |
|
762 | + */ |
|
763 | 763 | |
764 | - if (isset($oCache->max_age)) { if (!headers_sent()) { header('Expires: '.gmdate('D, d M Y H:i:s', time() + $oCache->max_age).' GMT'); } } |
|
764 | + if (isset($oCache->max_age)) { if (!headers_sent()) { header('Expires: '.gmdate('D, d M Y H:i:s', time() + $oCache->max_age).' GMT'); } } |
|
765 | 765 | |
766 | - /** |
|
767 | - * Last-Modified http |
|
768 | - */ |
|
766 | + /** |
|
767 | + * Last-Modified http |
|
768 | + */ |
|
769 | 769 | |
770 | - if (isset($oCache->last_modified)) { if (!headers_sent()) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + $oCache->last_modified).' GMT'); } } |
|
770 | + if (isset($oCache->last_modified)) { if (!headers_sent()) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + $oCache->last_modified).' GMT'); } } |
|
771 | 771 | |
772 | - /** |
|
773 | - * vary http |
|
774 | - */ |
|
772 | + /** |
|
773 | + * vary http |
|
774 | + */ |
|
775 | 775 | |
776 | - if (isset($oCache->vary)) { header('Vary: '.$oCache->vary); } |
|
777 | - } |
|
776 | + if (isset($oCache->vary)) { header('Vary: '.$oCache->vary); } |
|
777 | + } |
|
778 | 778 | |
779 | - /** |
|
780 | - * Sets a logger instance on the object |
|
781 | - * |
|
782 | - * @access private |
|
783 | - * @param LoggerInterface $logger |
|
784 | - * @return null |
|
785 | - */ |
|
786 | - public function setLogger(LoggerInterface $logger) { |
|
779 | + /** |
|
780 | + * Sets a logger instance on the object |
|
781 | + * |
|
782 | + * @access private |
|
783 | + * @param LoggerInterface $logger |
|
784 | + * @return null |
|
785 | + */ |
|
786 | + public function setLogger(LoggerInterface $logger) { |
|
787 | 787 | |
788 | - $this->_oLogger = $logger; |
|
789 | - } |
|
788 | + $this->_oLogger = $logger; |
|
789 | + } |
|
790 | 790 | } |
@@ -195,8 +195,7 @@ discard block |
||
195 | 195 | if ($mReturn === 403) { |
196 | 196 | |
197 | 197 | $this->_getPage403(); |
198 | - } |
|
199 | - else if ($mReturn === true) { |
|
198 | + } else if ($mReturn === true) { |
|
200 | 199 | |
201 | 200 | if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
202 | 201 | |
@@ -211,8 +210,7 @@ discard block |
||
211 | 210 | } |
212 | 211 | } else if (Request::isCliRequest()) { |
213 | 212 | |
214 | - if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
215 | - else { $aArguments = []; } |
|
213 | + if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } else { $aArguments = []; } |
|
216 | 214 | |
217 | 215 | define('PORTAL', 'Batch'); |
218 | 216 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -314,8 +312,7 @@ discard block |
||
314 | 312 | } |
315 | 313 | } |
316 | 314 | } |
317 | - } |
|
318 | - else if (defined('STDIN')) { |
|
315 | + } else if (defined('STDIN')) { |
|
319 | 316 | |
320 | 317 | $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
321 | 318 | echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
@@ -377,8 +374,7 @@ discard block |
||
377 | 374 | }, |
378 | 375 | $sRoute |
379 | 376 | ); |
380 | - } |
|
381 | - else { |
|
377 | + } else { |
|
382 | 378 | |
383 | 379 | $sFinalRoute = '.*'; |
384 | 380 | } |
@@ -428,8 +424,7 @@ discard block |
||
428 | 424 | |
429 | 425 | $oMobileDetect = new \Mobile_Detect; |
430 | 426 | |
431 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
432 | - else { $sCacheExt = ''; } |
|
427 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
433 | 428 | |
434 | 429 | $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
435 | 430 | |
@@ -459,8 +454,7 @@ discard block |
||
459 | 454 | |
460 | 455 | header('Content-type: image/jpeg'); |
461 | 456 | } |
462 | - } |
|
463 | - else { |
|
457 | + } else { |
|
464 | 458 | |
465 | 459 | header('Content-type: text/html; charset='.$sCharset.''); |
466 | 460 | } |
@@ -503,8 +497,7 @@ discard block |
||
503 | 497 | $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
504 | 498 | |
505 | 499 | } |
506 | - } |
|
507 | - else { |
|
500 | + } else { |
|
508 | 501 | |
509 | 502 | $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
510 | 503 | } |
@@ -516,8 +509,7 @@ discard block |
||
516 | 509 | $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
517 | 510 | } |
518 | 511 | } |
519 | - } |
|
520 | - else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
512 | + } else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
521 | 513 | |
522 | 514 | define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
523 | 515 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -534,8 +526,7 @@ discard block |
||
534 | 526 | |
535 | 527 | $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
536 | 528 | ->fetch(); |
537 | - } |
|
538 | - else if (isset($oRoute->template)) { |
|
529 | + } else if (isset($oRoute->template)) { |
|
539 | 530 | |
540 | 531 | define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
541 | 532 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -559,8 +550,7 @@ discard block |
||
559 | 550 | |
560 | 551 | $oMobileDetect = new \Mobile_Detect; |
561 | 552 | |
562 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
563 | - else { $sCacheExt = ''; } |
|
553 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
564 | 554 | |
565 | 555 | if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
566 | 556 | |
@@ -614,8 +604,7 @@ discard block |
||
614 | 604 | |
615 | 605 | $oMobileDetect = new \Mobile_Detect; |
616 | 606 | |
617 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
618 | - else { $sCacheExt = ''; } |
|
607 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
619 | 608 | |
620 | 609 | $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
621 | 610 | |
@@ -656,8 +645,7 @@ discard block |
||
656 | 645 | |
657 | 646 | $oMobileDetect = new \Mobile_Detect; |
658 | 647 | |
659 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
660 | - else { $sCacheExt = ''; } |
|
648 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
661 | 649 | |
662 | 650 | if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
663 | 651 |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public static function get(string $sName, string $sPortal = null, bool $bNoDoRedirect = false) |
51 | 51 | { |
52 | - $aDirectories = []; |
|
53 | - $sJsonFile=''; |
|
52 | + $aDirectories = []; |
|
53 | + $sJsonFile=''; |
|
54 | 54 | |
55 | - if ($bNoDoRedirect === true) { $sNameCache = $sName.'_true'; } else { $sNameCache = $sName; } |
|
55 | + if ($bNoDoRedirect === true) { $sNameCache = $sName.'_true'; } else { $sNameCache = $sName; } |
|
56 | 56 | |
57 | 57 | if ($sPortal === null || !is_string($sPortal)) { |
58 | 58 | |
59 | - if (defined('PORTAL')) { |
|
59 | + if (defined('PORTAL')) { |
|
60 | 60 | |
61 | 61 | $sPortal = PORTAL; |
62 | 62 | $aDirectories = array($sPortal); |
@@ -71,97 +71,97 @@ discard block |
||
71 | 71 | |
72 | 72 | $base = new \stdClass; |
73 | 73 | |
74 | - if (count($aDirectories) < 1) { $aDirectories = [$sPortal]; } |
|
74 | + if (count($aDirectories) < 1) { $aDirectories = [$sPortal]; } |
|
75 | 75 | |
76 | 76 | foreach ($aDirectories as $sPortal) { |
77 | 77 | |
78 | - if ($sPortal != '..' && $sPortal != '.') { |
|
78 | + if ($sPortal != '..' && $sPortal != '.') { |
|
79 | 79 | |
80 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
80 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
81 | 81 | |
82 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
83 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
84 | - } |
|
82 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
83 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
84 | + } |
|
85 | 85 | |
86 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
86 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
87 | 87 | |
88 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
89 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
90 | - } |
|
88 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
89 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
90 | + } |
|
91 | 91 | |
92 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
92 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
93 | 93 | |
94 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
95 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
96 | - } |
|
94 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
95 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
96 | + } |
|
97 | 97 | |
98 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
98 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
99 | 99 | |
100 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
101 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
102 | - } |
|
100 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
101 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
102 | + } |
|
103 | 103 | |
104 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
104 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
105 | 105 | |
106 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
107 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
108 | - } |
|
106 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
107 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
108 | + } |
|
109 | 109 | |
110 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
110 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
111 | 111 | |
112 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
113 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
114 | - } |
|
112 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
113 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
114 | + } |
|
115 | 115 | |
116 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
116 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
117 | 117 | |
118 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
119 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
120 | - } |
|
118 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
119 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
120 | + } |
|
121 | 121 | |
122 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
122 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
123 | 123 | |
124 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
125 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
126 | - } |
|
124 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
125 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
126 | + } |
|
127 | 127 | |
128 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
128 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
129 | 129 | |
130 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
131 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
132 | - } |
|
130 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
131 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
132 | + } |
|
133 | 133 | |
134 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
134 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
135 | 135 | |
136 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
137 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
138 | - } |
|
136 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
137 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
138 | + } |
|
139 | 139 | |
140 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
140 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
141 | 141 | |
142 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
143 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
144 | - } |
|
142 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
143 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
144 | + } |
|
145 | 145 | |
146 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf')) { |
|
146 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf')) { |
|
147 | 147 | |
148 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
149 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
150 | - } |
|
148 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
149 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
150 | + } |
|
151 | 151 | |
152 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
153 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
154 | - } |
|
155 | - } |
|
152 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
153 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
154 | + } |
|
155 | + } |
|
156 | 156 | |
157 | - if ($base === '') { |
|
157 | + if ($base === '') { |
|
158 | 158 | |
159 | 159 | trigger_error("Error in your Json format in this file : ".$sJsonFile, E_USER_NOTICE); |
160 | 160 | } |
161 | 161 | |
162 | 162 | if (isset($base->redirect) && $bNoDoRedirect === false) { |
163 | 163 | |
164 | - $base = self::get($sName, $base->redirect); |
|
164 | + $base = self::get($sName, $base->redirect); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | self::$_aConfCache[$sNameCache] = $base; |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public static function getBundleLocationName(string $sName): string |
187 | 187 | { |
188 | - $oConfig = self::get($sName, null, true); |
|
188 | + $oConfig = self::get($sName, null, true); |
|
189 | 189 | |
190 | - if (isset($oConfig->redirect)) { return $oConfig->redirect; } else { return PORTAL; } |
|
190 | + if (isset($oConfig->redirect)) { return $oConfig->redirect; } else { return PORTAL; } |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | echo "The Json ".$sFileToMerge." has an error! Please verify!\n"; |
212 | 212 | $oDebug = Debug::getInstance(); |
213 | 213 | $oDebug->error("The Json ".$sFileToMerge." has an error! Please verify!\n"); |
214 | - new \Exception("The Json ".$sFileToMerge." has an error! Please verify!\n"); |
|
214 | + new \Exception("The Json ".$sFileToMerge." has an error! Please verify!\n"); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } else if (is_array($oConfFiles) && is_array($base) && !isset($base[$sKey])) { |
234 | 234 | |
235 | 235 | $base[$sKey] = $oConfFiles[$sKey]; |
236 | - } else if (!isset($base->$sKey) && is_array($mOne)) { |
|
236 | + } else if (!isset($base->$sKey) && is_array($mOne)) { |
|
237 | 237 | |
238 | 238 | $base->$sKey = new \StdClass; |
239 | 239 | list($oConfFiles, $base) = self::_recursiveGet($mOne, $base->$sKey); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | public static function get(string $sName, string $sPortal = null, bool $bNoDoRedirect = false) |
51 | 51 | { |
52 | 52 | $aDirectories = []; |
53 | - $sJsonFile=''; |
|
53 | + $sJsonFile = ''; |
|
54 | 54 | |
55 | 55 | if ($bNoDoRedirect === true) { $sNameCache = $sName.'_true'; } else { $sNameCache = $sName; } |
56 | 56 |