@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | abstract class Controller extends Mother |
44 | 44 | { |
45 | 45 | |
46 | - /** |
|
47 | - * Cache to know if a model was initialize or not because we must initialize it just one time by script |
|
48 | - * |
|
49 | - * @access private |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - private static $_aInitialize = array(); |
|
46 | + /** |
|
47 | + * Cache to know if a model was initialize or not because we must initialize it just one time by script |
|
48 | + * |
|
49 | + * @access private |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + private static $_aInitialize = array(); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Constructor |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | */ |
96 | 96 | if (method_exists(get_called_class(), 'initialize')) { |
97 | 97 | |
98 | - if (!isset(self::$_aInitialize[get_called_class()])) { |
|
98 | + if (!isset(self::$_aInitialize[get_called_class()])) { |
|
99 | 99 | |
100 | - static::initialize(); |
|
101 | - self::$_aInitialize[get_called_class()] = true; |
|
102 | - } |
|
100 | + static::initialize(); |
|
101 | + self::$_aInitialize[get_called_class()] = true; |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function __get($mKey) |
171 | 171 | { |
172 | - if (isset($this->di) && property_exists($this, 'di')) { |
|
172 | + if (isset($this->di) && property_exists($this, 'di')) { |
|
173 | 173 | |
174 | - $mDi = $this->di->get($mKey); |
|
174 | + $mDi = $this->di->get($mKey); |
|
175 | 175 | |
176 | - if (isset($mDi) && $mDi != false) { return $mDi; } |
|
177 | - } |
|
176 | + if (isset($mDi) && $mDi != false) { return $mDi; } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | return parent::__get($mKey); |
180 | 180 | } |
@@ -118,8 +118,7 @@ |
||
118 | 118 | */ |
119 | 119 | public function redirect(string $sUrl, int $iHttpCode = 301) |
120 | 120 | { |
121 | - if ($iHttpCode === 301) { header('Status: 301 Moved Permanently', false, 301); } |
|
122 | - else if ($iHttpCode === 302) { header('Status: Moved Temporarily', false, 301); } |
|
121 | + if ($iHttpCode === 301) { header('Status: 301 Moved Permanently', false, 301); } else if ($iHttpCode === 302) { header('Status: Moved Temporarily', false, 301); } |
|
123 | 122 | |
124 | 123 | header('Location: '.$sUrl); |
125 | 124 | exit; |
@@ -46,20 +46,20 @@ |
||
46 | 46 | |
47 | 47 | $this->installDb = function() |
48 | 48 | { |
49 | - $oDb = Config::get('Db'); |
|
50 | - $oTables = json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.preg_replace('/^.*\\\\([a-zA-Z0-9]+)$/', '$1', get_called_class()).DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Db.conf')); |
|
49 | + $oDb = Config::get('Db'); |
|
50 | + $oTables = json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.preg_replace('/^.*\\\\([a-zA-Z0-9]+)$/', '$1', get_called_class()).DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Db.conf')); |
|
51 | 51 | |
52 | - $oDb->configuration->tables = $oTables; |
|
52 | + $oDb->configuration->tables = $oTables; |
|
53 | 53 | |
54 | - $aOptions = [ |
|
55 | - "p" => CREATE_PORTAL, |
|
56 | - "c" => true, |
|
57 | - "e" => true, |
|
58 | - "b" => json_encode($oDb) |
|
59 | - ]; |
|
54 | + $aOptions = [ |
|
55 | + "p" => CREATE_PORTAL, |
|
56 | + "c" => true, |
|
57 | + "e" => true, |
|
58 | + "b" => json_encode($oDb) |
|
59 | + ]; |
|
60 | 60 | |
61 | - $oEntity = new Entity; |
|
62 | - $oEntity->runScaffolding($aOptions); |
|
61 | + $oEntity = new Entity; |
|
62 | + $oEntity->runScaffolding($aOptions); |
|
63 | 63 | }; |
64 | 64 | } |
65 | 65 | } |
@@ -32,37 +32,37 @@ |
||
32 | 32 | */ |
33 | 33 | class Demo extends Controller |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @return object |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - parent::__construct(); |
|
44 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @return object |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + parent::__construct(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * bootstrap |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function bootstrap() |
|
53 | - { |
|
54 | - ; |
|
55 | - } |
|
46 | + /** |
|
47 | + * bootstrap |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function bootstrap() |
|
53 | + { |
|
54 | + ; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * install method |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * @param string $sPortal |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - public function install($sPortal) |
|
65 | - { |
|
66 | - $this->installDb; |
|
67 | - } |
|
57 | + /** |
|
58 | + * install method |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * @param string $sPortal |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + public function install($sPortal) |
|
65 | + { |
|
66 | + $this->installDb; |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -63,6 +63,6 @@ |
||
63 | 63 | |
64 | 64 | $response->send(); |
65 | 65 | |
66 | - exit; |
|
66 | + exit; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -7,68 +7,68 @@ |
||
7 | 7 | |
8 | 8 | class Server extends Controller |
9 | 9 | { |
10 | - /** |
|
11 | - * new method to launch a web server |
|
12 | - * @param array $options |
|
13 | - * @tutorial php bin/console server:run |
|
14 | - * php bin/console server:run -a 192.168.0.1:8000 |
|
15 | - */ |
|
16 | - public function run(array $options = array()) |
|
17 | - { |
|
18 | - ob_get_clean(); |
|
10 | + /** |
|
11 | + * new method to launch a web server |
|
12 | + * @param array $options |
|
13 | + * @tutorial php bin/console server:run |
|
14 | + * php bin/console server:run -a 192.168.0.1:8000 |
|
15 | + */ |
|
16 | + public function run(array $options = array()) |
|
17 | + { |
|
18 | + ob_get_clean(); |
|
19 | 19 | |
20 | - if (!isset($options['a'])) { |
|
21 | - $options['a'] = 'localhost:8000'; |
|
22 | - } |
|
20 | + if (!isset($options['a'])) { |
|
21 | + $options['a'] = 'localhost:8000'; |
|
22 | + } |
|
23 | 23 | |
24 | - echo "\n\n"; |
|
25 | - echo Bash::setBackground(" ", 'green'); |
|
26 | - echo Bash::setBackground(" [OK] Start web server ", 'green'); |
|
27 | - echo Bash::setBackground(" ", 'green'); |
|
28 | - echo "\n\n"; |
|
29 | - echo " > Use ".$options['a']." in browser"; |
|
30 | - echo "\n\n"; |
|
31 | - echo " > Clic Ctrl+C to stop the web server"; |
|
32 | - echo "\n\n"; |
|
24 | + echo "\n\n"; |
|
25 | + echo Bash::setBackground(" ", 'green'); |
|
26 | + echo Bash::setBackground(" [OK] Start web server ", 'green'); |
|
27 | + echo Bash::setBackground(" ", 'green'); |
|
28 | + echo "\n\n"; |
|
29 | + echo " > Use ".$options['a']." in browser"; |
|
30 | + echo "\n\n"; |
|
31 | + echo " > Clic Ctrl+C to stop the web server"; |
|
32 | + echo "\n\n"; |
|
33 | 33 | |
34 | - exec('php -S '.$options['a'].' /public/index.php'); |
|
35 | - } |
|
34 | + exec('php -S '.$options['a'].' /public/index.php'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * check if a server web is launched |
|
39 | - * @param array $options |
|
40 | - * @tutorial php bin/console server:status |
|
41 | - * php bin/console server:status -a 192.168.0.1:8000 |
|
42 | - */ |
|
43 | - public function status(array $options = array()) |
|
44 | - { |
|
45 | - ob_get_clean(); |
|
37 | + /** |
|
38 | + * check if a server web is launched |
|
39 | + * @param array $options |
|
40 | + * @tutorial php bin/console server:status |
|
41 | + * php bin/console server:status -a 192.168.0.1:8000 |
|
42 | + */ |
|
43 | + public function status(array $options = array()) |
|
44 | + { |
|
45 | + ob_get_clean(); |
|
46 | 46 | |
47 | - if (!isset($options['a'])) { |
|
48 | - $options['a'] = 'localhost:8000'; |
|
49 | - } |
|
47 | + if (!isset($options['a'])) { |
|
48 | + $options['a'] = 'localhost:8000'; |
|
49 | + } |
|
50 | 50 | |
51 | - list($hostname, $port) = explode(':', $options['a']); |
|
51 | + list($hostname, $port) = explode(':', $options['a']); |
|
52 | 52 | |
53 | - if (false !== $fp = @fsockopen($hostname, $port, $errno, $errstr, 1)) { |
|
54 | - fclose($fp); |
|
53 | + if (false !== $fp = @fsockopen($hostname, $port, $errno, $errstr, 1)) { |
|
54 | + fclose($fp); |
|
55 | 55 | |
56 | - echo "\n\n"; |
|
57 | - echo Bash::setBackground(" ", 'green'); |
|
58 | - echo Bash::setBackground(" [OK] A web server is launched ", 'green'); |
|
59 | - echo Bash::setBackground(" ", 'green'); |
|
60 | - echo "\n\n"; |
|
61 | - echo " > Check realized on ".$options['a']; |
|
62 | - echo "\n\n"; |
|
63 | - } |
|
64 | - else { |
|
65 | - echo "\n\n"; |
|
66 | - echo Bash::setBackground(" ", 'red'); |
|
67 | - echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); |
|
68 | - echo Bash::setBackground(" ", 'red'); |
|
69 | - echo "\n\n"; |
|
70 | - echo " > Check realized on ".$options['a']; |
|
71 | - echo "\n\n"; |
|
72 | - } |
|
73 | - } |
|
56 | + echo "\n\n"; |
|
57 | + echo Bash::setBackground(" ", 'green'); |
|
58 | + echo Bash::setBackground(" [OK] A web server is launched ", 'green'); |
|
59 | + echo Bash::setBackground(" ", 'green'); |
|
60 | + echo "\n\n"; |
|
61 | + echo " > Check realized on ".$options['a']; |
|
62 | + echo "\n\n"; |
|
63 | + } |
|
64 | + else { |
|
65 | + echo "\n\n"; |
|
66 | + echo Bash::setBackground(" ", 'red'); |
|
67 | + echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); |
|
68 | + echo Bash::setBackground(" ", 'red'); |
|
69 | + echo "\n\n"; |
|
70 | + echo " > Check realized on ".$options['a']; |
|
71 | + echo "\n\n"; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -60,8 +60,7 @@ |
||
60 | 60 | echo "\n\n"; |
61 | 61 | echo " > Check realized on ".$options['a']; |
62 | 62 | echo "\n\n"; |
63 | - } |
|
64 | - else { |
|
63 | + } else { |
|
65 | 64 | echo "\n\n"; |
66 | 65 | echo Bash::setBackground(" ", 'red'); |
67 | 66 | echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); |
@@ -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,16 +91,16 @@ 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 | else { |
102 | 102 | |
103 | - echo 'The Project (private part) ' . $sPrivatePath . " exists\n"; |
|
103 | + echo 'The Project (private part) '.$sPrivatePath." exists\n"; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Controller.php'); |
@@ -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 | |
@@ -97,8 +93,7 @@ discard block |
||
97 | 93 | mkdir($sPrivatePath . 'View', 0777, true); |
98 | 94 | mkdir($sPrivatePath . 'conf', 0777, true); |
99 | 95 | mkdir($sPrivatePath . 'common', 0777, true); |
100 | - } |
|
101 | - else { |
|
96 | + } else { |
|
102 | 97 | |
103 | 98 | echo 'The Project (private part) ' . $sPrivatePath . " exists\n"; |
104 | 99 | } |
@@ -50,20 +50,20 @@ |
||
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; |
|
57 | + $aOptions['g'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Entity'.DIRECTORY_SEPARATOR; |
|
58 | 58 | |
59 | - $aOptions['h'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Model'.DIRECTORY_SEPARATOR; |
|
59 | + $aOptions['h'] = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$aOptions['p'].DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Model'.DIRECTORY_SEPARATOR; |
|
60 | 60 | |
61 | 61 | |
62 | - if (!defined('ENTITY_NAMESPACE')) { define('ENTITY_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Entity'); } |
|
62 | + if (!defined('ENTITY_NAMESPACE')) { define('ENTITY_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Entity'); } |
|
63 | 63 | |
64 | - if (!defined('MODEL_NAMESPACE')) { define('MODEL_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Model'); } |
|
64 | + if (!defined('MODEL_NAMESPACE')) { define('MODEL_NAMESPACE', '\Venus\src\\'.$aOptions['p'].'\Model'); } |
|
65 | 65 | |
66 | - $oBatch = new BatchEntity; |
|
67 | - $oBatch->runScaffolding($aOptions); |
|
66 | + $oBatch = new BatchEntity; |
|
67 | + $oBatch->runScaffolding($aOptions); |
|
68 | 68 | } |
69 | 69 | } |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function install(array $aOptions = array()) |
49 | 49 | { |
50 | - $sFile = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Plugins.conf'); |
|
51 | - $aPlugins = json_decode($sFile); |
|
50 | + $sFile = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Plugins.conf'); |
|
51 | + $aPlugins = json_decode($sFile); |
|
52 | 52 | |
53 | - if (isset($aOptions['p'])) { |
|
53 | + if (isset($aOptions['p'])) { |
|
54 | 54 | |
55 | - define('CREATE_PORTAL', $aOptions['p']); |
|
56 | - } |
|
55 | + define('CREATE_PORTAL', $aOptions['p']); |
|
56 | + } |
|
57 | 57 | |
58 | - foreach ($aPlugins->list as $sPluginName) { |
|
58 | + foreach ($aPlugins->list as $sPluginName) { |
|
59 | 59 | |
60 | - $sClassName = 'Venus\src\plugins\\'.$sPluginName.'\Controller\\'.$sPluginName; |
|
61 | - $oPlugin = new $sClassName; |
|
62 | - $oPlugin->install($aOptions['p']); |
|
63 | - } |
|
60 | + $sClassName = 'Venus\src\plugins\\'.$sPluginName.'\Controller\\'.$sPluginName; |
|
61 | + $oPlugin = new $sClassName; |
|
62 | + $oPlugin->install($aOptions['p']); |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,23 +73,23 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function create(array $aOptions = array()) |
75 | 75 | { |
76 | - $sDefaultFolder = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$aOptions['n']; |
|
77 | - mkdir($sDefaultFolder, 0777, true); |
|
78 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'conf', 0777, true); |
|
79 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'Controller', 0777, true); |
|
80 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'data', 0777, true); |
|
81 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'i18n', 0777, true); |
|
82 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'meta', 0777, true); |
|
83 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public', 0777, true); |
|
84 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'css', 0777, true); |
|
85 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'img', 0777, true); |
|
86 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'js', 0777, true); |
|
87 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'View', 0777, true); |
|
76 | + $sDefaultFolder = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$aOptions['n']; |
|
77 | + mkdir($sDefaultFolder, 0777, true); |
|
78 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'conf', 0777, true); |
|
79 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'Controller', 0777, true); |
|
80 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'data', 0777, true); |
|
81 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'i18n', 0777, true); |
|
82 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'meta', 0777, true); |
|
83 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public', 0777, true); |
|
84 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'css', 0777, true); |
|
85 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'img', 0777, true); |
|
86 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'js', 0777, true); |
|
87 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'View', 0777, true); |
|
88 | 88 | |
89 | - file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Db.conf', '{}'); |
|
90 | - file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Plugin.conf', '{}'); |
|
89 | + file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Db.conf', '{}'); |
|
90 | + file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Plugin.conf', '{}'); |
|
91 | 91 | |
92 | - $sContent = "<?php |
|
92 | + $sContent = "<?php |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Controller of the plugin ".$aOptions['n']." |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | } |
158 | 158 | }"; |
159 | 159 | |
160 | - file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'Controller'.DIRECTORY_SEPARATOR.$aOptions['n'].'.php', $sContent); |
|
161 | - mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'i18n'.DIRECTORY_SEPARATOR.'en_US'.DIRECTORY_SEPARATOR.'LC_MESSAGES', 0777, true); |
|
162 | - file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'meta'.DIRECTORY_SEPARATOR.'LICENSE.md', ''); |
|
163 | - file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'meta'.DIRECTORY_SEPARATOR.'README.md', ''); |
|
160 | + file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'Controller'.DIRECTORY_SEPARATOR.$aOptions['n'].'.php', $sContent); |
|
161 | + mkdir($sDefaultFolder.DIRECTORY_SEPARATOR.'i18n'.DIRECTORY_SEPARATOR.'en_US'.DIRECTORY_SEPARATOR.'LC_MESSAGES', 0777, true); |
|
162 | + file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'meta'.DIRECTORY_SEPARATOR.'LICENSE.md', ''); |
|
163 | + file_put_contents($sDefaultFolder.DIRECTORY_SEPARATOR.'meta'.DIRECTORY_SEPARATOR.'README.md', ''); |
|
164 | 164 | } |
165 | 165 | } |
@@ -17,45 +17,45 @@ discard block |
||
17 | 17 | spl_autoload_register(function (string $sClassName) |
18 | 18 | { |
19 | 19 | |
20 | - $sClassName = ltrim($sClassName, '\\'); |
|
21 | - $sFileName = ''; |
|
22 | - $sNamespace = ''; |
|
23 | - $iLastNsPos = strrpos($sClassName, '\\'); |
|
20 | + $sClassName = ltrim($sClassName, '\\'); |
|
21 | + $sFileName = ''; |
|
22 | + $sNamespace = ''; |
|
23 | + $iLastNsPos = strrpos($sClassName, '\\'); |
|
24 | 24 | |
25 | - if ($iLastNsPos) { |
|
25 | + if ($iLastNsPos) { |
|
26 | 26 | |
27 | - $sNamespace = substr($sClassName, 0, $iLastNsPos); |
|
28 | - $sClassName = substr($sClassName, $iLastNsPos + 1); |
|
27 | + $sNamespace = substr($sClassName, 0, $iLastNsPos); |
|
28 | + $sClassName = substr($sClassName, $iLastNsPos + 1); |
|
29 | 29 | $sFileName = str_replace('\\', DIRECTORY_SEPARATOR, $sNamespace).DIRECTORY_SEPARATOR; |
30 | - } |
|
30 | + } |
|
31 | 31 | |
32 | - $sFileName = str_replace('/', '\\', $sFileName); |
|
32 | + $sFileName = str_replace('/', '\\', $sFileName); |
|
33 | 33 | |
34 | - $sFileName .= $sClassName.'.php'; |
|
34 | + $sFileName .= $sClassName.'.php'; |
|
35 | 35 | |
36 | - if (defined('PORTAL')) { |
|
36 | + if (defined('PORTAL')) { |
|
37 | 37 | |
38 | - $sFileClassName = str_replace(PORTAL, PORTAL.DIRECTORY_SEPARATOR.'app', str_replace(['\\', '/'], DIRECTORY_SEPARATOR, str_replace('conf', DIRECTORY_SEPARATOR, __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
39 | - $sFileClassName = preg_replace('/(tests\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
40 | - $sFileClassName = preg_replace('/(src\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
41 | - $sFileClassName = str_replace('\\\\', '\\', $sFileClassName); |
|
42 | - $sFileClassName = preg_replace('#bundles//tests/([^/]+)#', 'bundles/tests/$1/app', $sFileClassName); |
|
43 | - $sFileClassName = preg_replace('#bundles//src/([^/]+)#', 'bundles/src/$1/app', $sFileClassName); |
|
44 | - $sFileClassName = str_replace('app\\app', 'app', $sFileClassName); |
|
45 | - $sFileClassName = str_replace('app/app', 'app', $sFileClassName); |
|
38 | + $sFileClassName = str_replace(PORTAL, PORTAL.DIRECTORY_SEPARATOR.'app', str_replace(['\\', '/'], DIRECTORY_SEPARATOR, str_replace('conf', DIRECTORY_SEPARATOR, __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
39 | + $sFileClassName = preg_replace('/(tests\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
40 | + $sFileClassName = preg_replace('/(src\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
|
41 | + $sFileClassName = str_replace('\\\\', '\\', $sFileClassName); |
|
42 | + $sFileClassName = preg_replace('#bundles//tests/([^/]+)#', 'bundles/tests/$1/app', $sFileClassName); |
|
43 | + $sFileClassName = preg_replace('#bundles//src/([^/]+)#', 'bundles/src/$1/app', $sFileClassName); |
|
44 | + $sFileClassName = str_replace('app\\app', 'app', $sFileClassName); |
|
45 | + $sFileClassName = str_replace('app/app', 'app', $sFileClassName); |
|
46 | 46 | |
47 | - if (strstr($sFileName, 'Venus\\') && file_exists($sFileClassName)) { |
|
47 | + if (strstr($sFileName, 'Venus\\') && file_exists($sFileClassName)) { |
|
48 | 48 | |
49 | - require $sFileClassName; |
|
50 | - } |
|
51 | - } |
|
52 | - else { |
|
49 | + require $sFileClassName; |
|
50 | + } |
|
51 | + } |
|
52 | + else { |
|
53 | 53 | |
54 | - 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 | + if (strstr($sFileName, 'Venus\\') && file_exists(preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))))) { |
|
55 | 55 | |
56 | - require preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
57 | - } |
|
58 | - } |
|
56 | + require preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | }); |
60 | 60 | |
61 | 61 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | if (file_exists(preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php')) { |
66 | 66 | |
67 | - include preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php'; |
|
67 | + include preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | |
76 | 76 | if (isset($oConfig) && isset($oConfig->autoload)) { |
77 | 77 | |
78 | - $oAutoloadConf = $oConfig->autoload; |
|
78 | + $oAutoloadConf = $oConfig->autoload; |
|
79 | 79 | |
80 | - foreach ($oAutoloadConf as $sFile) { |
|
80 | + foreach ($oAutoloadConf as $sFile) { |
|
81 | 81 | |
82 | - require __DIR__.'/../'.$sFile; |
|
83 | - } |
|
82 | + require __DIR__.'/../'.$sFile; |
|
83 | + } |
|
84 | 84 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * new version with SPL to have the capacity to add external autoload |
16 | 16 | */ |
17 | -spl_autoload_register(function (string $sClassName) |
|
17 | +spl_autoload_register(function(string $sClassName) |
|
18 | 18 | { |
19 | 19 | |
20 | 20 | $sClassName = ltrim($sClassName, '\\'); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | $sNamespace = substr($sClassName, 0, $iLastNsPos); |
28 | 28 | $sClassName = substr($sClassName, $iLastNsPos + 1); |
29 | - $sFileName = str_replace('\\', DIRECTORY_SEPARATOR, $sNamespace).DIRECTORY_SEPARATOR; |
|
29 | + $sFileName = str_replace('\\', DIRECTORY_SEPARATOR, $sNamespace).DIRECTORY_SEPARATOR; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $sFileName = str_replace('/', '\\', $sFileName); |
@@ -48,8 +48,7 @@ |
||
48 | 48 | |
49 | 49 | require $sFileClassName; |
50 | 50 | } |
51 | - } |
|
52 | - else { |
|
51 | + } else { |
|
53 | 52 | |
54 | 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))))) { |
55 | 54 |