@@ -51,6 +51,9 @@ |
||
| 51 | 51 | return $this->composerLoader; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | + /** |
|
| 55 | + * @param string $configKey |
|
| 56 | + */ |
|
| 54 | 57 | public function getConfig($configKey) |
| 55 | 58 | { |
| 56 | 59 | return $this->config->getConfig($configKey); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public static function getInstance($options = []) |
| 41 | 41 | { |
| 42 | - if(self::$instance === null) { |
|
| 42 | + if (self::$instance === null) { |
|
| 43 | 43 | self::$instance = new self($options); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | protected function initSession() |
| 114 | 114 | { |
| 115 | - if($this->options->getOption('runSession') === false) { |
|
| 115 | + if ($this->options->getOption('runSession') === false) { |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | public function run() |
| 155 | 155 | { |
| 156 | - foreach($this->runPhases as $action) { |
|
| 156 | + foreach ($this->runPhases as $action) { |
|
| 157 | 157 | $action(); |
| 158 | 158 | |
| 159 | 159 | $notifyAction = $action; |
| 160 | - if(is_array($action)) { |
|
| 160 | + if (is_array($action)) { |
|
| 161 | 161 | $notifyAction = $action[1]; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,16 +171,16 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $memcacheConfig = $this->getConfig('memcached'); |
| 173 | 173 | |
| 174 | - if($memcacheConfig['enabled'] === false) { |
|
| 174 | + if ($memcacheConfig['enabled'] === false) { |
|
| 175 | 175 | return; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $class = $memcacheConfig['class']; |
| 179 | - if(empty($class)) { |
|
| 179 | + if (empty($class)) { |
|
| 180 | 180 | throw new Exception('Memcached is active but no class is define'); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if(class_exists($class) === false) { |
|
| 183 | + if (class_exists($class) === false) { |
|
| 184 | 184 | throw new Exception('Memcache class '.$class.' not found.'); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $listModules = array_diff(scandir(MODULES_DIR), ['.', '..']); |
| 193 | 193 | |
| 194 | - foreach($listModules as $moduleName) { |
|
| 194 | + foreach ($listModules as $moduleName) { |
|
| 195 | 195 | $moduleName = realpath($moduleName); //Symlink |
| 196 | 196 | |
| 197 | - if(!is_dir($moduleName)) { |
|
| 197 | + if (!is_dir($moduleName)) { |
|
| 198 | 198 | continue; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | protected function loadAllCoreModules() |
| 208 | 208 | { |
| 209 | - foreach($this->getConfig('modules') as $moduleInfos) { |
|
| 209 | + foreach ($this->getConfig('modules') as $moduleInfos) { |
|
| 210 | 210 | $moduleName = $moduleInfos['name']; |
| 211 | 211 | $moduleEnabled = $moduleInfos['enabled']; |
| 212 | 212 | |
| 213 | - if(empty($moduleName) || $moduleEnabled === false) { |
|
| 213 | + if (empty($moduleName) || $moduleEnabled === false) { |
|
| 214 | 214 | continue; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $tree = $this->modules->getLoadTree(); |
| 224 | 224 | |
| 225 | - foreach($tree as $firstLine) |
|
| 225 | + foreach ($tree as $firstLine) |
|
| 226 | 226 | { |
| 227 | - foreach($firstLine as $secondLine) |
|
| 227 | + foreach ($firstLine as $secondLine) |
|
| 228 | 228 | { |
| 229 | - foreach($secondLine as $moduleName) |
|
| 229 | + foreach ($secondLine as $moduleName) |
|
| 230 | 230 | { |
| 231 | 231 | $this->loadModule($moduleName); |
| 232 | 232 | } |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | protected function runCliFile() |
| 244 | 244 | { |
| 245 | - if(PHP_SAPI !== 'cli') { |
|
| 245 | + if (PHP_SAPI !== 'cli') { |
|
| 246 | 246 | return; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $opt = getopt('f:'); |
| 250 | - if(!isset($opt['f'])) { |
|
| 250 | + if (!isset($opt['f'])) { |
|
| 251 | 251 | throw new Exception('Error: No file specified.'); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | $file = $opt['f']; |
| 255 | - if(!file_exists(CLI_DIR.$file.'.php')) { |
|
| 255 | + if (!file_exists(CLI_DIR.$file.'.php')) { |
|
| 256 | 256 | throw new Exception('File to execute not found.'); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -15,6 +15,9 @@ |
||
| 15 | 15 | $this->formId = $formId; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | + /** |
|
| 19 | + * @param stdClass $saveInfos |
|
| 20 | + */ |
|
| 18 | 21 | protected function saveToken($saveInfos) |
| 19 | 22 | { |
| 20 | 23 | //Default to session |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | global $_SESSION; |
| 40 | 40 | |
| 41 | - if(!isset($_SESSION['token'])) { |
|
| 41 | + if (!isset($_SESSION['token'])) { |
|
| 42 | 42 | throw new Exception('no token found'); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(!isset($_SESSION['token'][$this->formId])) { |
|
| 45 | + if (!isset($_SESSION['token'][$this->formId])) { |
|
| 46 | 46 | throw new Exception('no token found for form id '.$this->formId); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public function createToken() |
| 53 | 53 | { |
| 54 | - if(is_null($this->idForm)) { |
|
| 54 | + if (is_null($this->idForm)) { |
|
| 55 | 55 | throw new Exception('Form id is undefined.'); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return $token; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function checkToken($tokenToCheck, $timeExp=15) |
|
| 69 | + public function checkToken($tokenToCheck, $timeExp = 15) |
|
| 70 | 70 | { |
| 71 | 71 | //Throw Exception |
| 72 | 72 | $tokenInfos = $this->getToken(); |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | $token = $tokenInfos->token; |
| 75 | 75 | $dateCreate = $tokenInfos->date; |
| 76 | 76 | |
| 77 | - if($token !== $tokenToCheck) { |
|
| 77 | + if ($token !== $tokenToCheck) { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $limitDate = new DateTime; |
| 82 | 82 | $limitDate->modify('-'.(int) $timeExp.' minutes'); |
| 83 | 83 | |
| 84 | - if($dateCreate < $limitDate) { |
|
| 84 | + if ($dateCreate < $limitDate) { |
|
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -28,6 +28,9 @@ discard block |
||
| 28 | 28 | $this->status->load = true; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | + /** |
|
| 32 | + * @param string $pathName |
|
| 33 | + */ |
|
| 31 | 34 | public static function installInfos($pathName) |
| 32 | 35 | { |
| 33 | 36 | $this->loadModulesInstallInfos(); |
@@ -94,6 +97,9 @@ discard block |
||
| 94 | 97 | ); |
| 95 | 98 | } |
| 96 | 99 | |
| 100 | + /** |
|
| 101 | + * @param string $jsonFilePath |
|
| 102 | + */ |
|
| 97 | 103 | protected function loadJsonFile($jsonFilePath) |
| 98 | 104 | { |
| 99 | 105 | if(!file_exists($jsonFilePath)) { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | protected function loadConfig() |
| 73 | 73 | { |
| 74 | - if(!file_exists(CONFIG_DIR.$this->pathName)) { |
|
| 74 | + if (!file_exists(CONFIG_DIR.$this->pathName)) { |
|
| 75 | 75 | return; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | protected function loadJsonFile($jsonFilePath) |
| 98 | 98 | { |
| 99 | - if(!file_exists($jsonFilePath)) { |
|
| 99 | + if (!file_exists($jsonFilePath)) { |
|
| 100 | 100 | throw new Exception('File '.$jsonFilePath.' not found.'); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $infos = json_decode(file_get_contents($jsonFilePath)); |
| 104 | - if($infos === null) { |
|
| 104 | + if ($infos === null) { |
|
| 105 | 105 | throw new Exception(json_last_error_msg()); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | $moduleInfos = $this->loadInfos; |
| 114 | 114 | $runnerFile = ''; |
| 115 | 115 | |
| 116 | - if(property_exists($moduleInfos, 'runner')) { |
|
| 116 | + if (property_exists($moduleInfos, 'runner')) { |
|
| 117 | 117 | $runnerFile = (string) $moduleInfos->runner; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if($runnerFile === '') { |
|
| 120 | + if ($runnerFile === '') { |
|
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | .'/'.$runnerFile |
| 127 | 127 | ; |
| 128 | 128 | |
| 129 | - if(!file_exists($runnerFile)) { |
|
| 129 | + if (!file_exists($runnerFile)) { |
|
| 130 | 130 | throw new Exception( |
| 131 | 131 | 'Runner file for module '.$this->pathName.' not found.' |
| 132 | 132 | ); |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | * Permet de rediriger une page |
| 134 | 134 | * |
| 135 | 135 | * @param string $page : la page vers laquelle rediriger |
| 136 | - * @param bool $permaet : If it's a permanent redirection for this url or not |
|
| 136 | + * @param bool $permanent : If it's a permanent redirection for this url or not |
|
| 137 | 137 | */ |
| 138 | 138 | function redirection($page, $permanent=false) |
| 139 | 139 | { |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | //--- Gestion de type de data --- |
| 28 | 28 | $filterType = 'text'; |
| 29 | 29 | |
| 30 | - if($type === 'int' || $type === 'integer') { |
|
| 30 | + if ($type === 'int' || $type === 'integer') { |
|
| 31 | 31 | $filterType = FILTER_VALIDATE_INT; |
| 32 | 32 | } |
| 33 | - elseif($type === 'float' || $type === 'double') { |
|
| 33 | + elseif ($type === 'float' || $type === 'double') { |
|
| 34 | 34 | $filterType = FILTER_VALIDATE_FLOAT; |
| 35 | 35 | } |
| 36 | - elseif($type === 'bool' || $type === 'boolean') { |
|
| 36 | + elseif ($type === 'bool' || $type === 'boolean') { |
|
| 37 | 37 | $filterType = FILTER_VALIDATE_BOOLEAN; |
| 38 | 38 | } |
| 39 | - elseif($type === 'email') { |
|
| 39 | + elseif ($type === 'email') { |
|
| 40 | 40 | $filterType = FILTER_VALIDATE_EMAIL; |
| 41 | 41 | } |
| 42 | 42 | //--- FIN Gestion de type de data --- |
| 43 | 43 | |
| 44 | - if($filterType === 'text') { |
|
| 44 | + if ($filterType === 'text') { |
|
| 45 | 45 | throw new Exception('Unknown type'); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | function securise($data, $type, $htmlentities) |
| 52 | 52 | { |
| 53 | - if(is_array($data)) { |
|
| 54 | - foreach($data as $key => $val) { |
|
| 53 | + if (is_array($data)) { |
|
| 54 | + foreach ($data as $key => $val) { |
|
| 55 | 55 | unset($data[$key]); |
| 56 | 56 | |
| 57 | 57 | $key = securise($key, true); |
@@ -66,21 +66,21 @@ discard block |
||
| 66 | 66 | try { |
| 67 | 67 | return securiseKnownTypes($data, $type); |
| 68 | 68 | } |
| 69 | - catch(Exception $ex) { |
|
| 70 | - if($ex->getMessage() !== 'Unknown type') { |
|
| 69 | + catch (Exception $ex) { |
|
| 70 | + if ($ex->getMessage() !== 'Unknown type') { |
|
| 71 | 71 | throw new Exception($ex->getCode(), $ex->getMessage()); |
| 72 | 72 | } |
| 73 | 73 | //Else : Use securise text type |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $sqlSecureMethod = getSqlSecureMethod(); |
| 77 | - if($sqlSecureMethod !== false) { |
|
| 77 | + if ($sqlSecureMethod !== false) { |
|
| 78 | 78 | $data = $sqlSecureMethod($data); |
| 79 | 79 | } else { |
| 80 | 80 | $data = addslashes($data); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if($htmlentities === false) { |
|
| 83 | + if ($htmlentities === false) { |
|
| 84 | 84 | $data = htmlentities($data, ENT_COMPAT | ENT_HTML401, 'UTF-8'); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $fct = $app->getConfig('sqlSecureMethod'); |
| 94 | 94 | |
| 95 | 95 | $callableName = ''; |
| 96 | - if(!is_callable($fct, true, $callableName)) { |
|
| 96 | + if (!is_callable($fct, true, $callableName)) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | * @param string $page : la page vers laquelle rediriger |
| 136 | 136 | * @param bool $permaet : If it's a permanent redirection for this url or not |
| 137 | 137 | */ |
| 138 | -function redirection($page, $permanent=false) |
|
| 138 | +function redirection($page, $permanent = false) |
|
| 139 | 139 | { |
| 140 | 140 | $httpStatus = 302; |
| 141 | - if($permanent === true) { |
|
| 141 | + if ($permanent === true) { |
|
| 142 | 142 | $httpStatus = 301; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | function getSecurisedKeyInArray(&$array, $key, $type, $htmlentities = false) |
| 151 | 151 | { |
| 152 | - if(!isset($array[$key])) { |
|
| 152 | + if (!isset($array[$key])) { |
|
| 153 | 153 | throw new Exception('The key '.$key.' not exist'); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -188,32 +188,32 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | function verifTypeData($vars) |
| 190 | 190 | { |
| 191 | - if(!is_array($vars)) { |
|
| 191 | + if (!is_array($vars)) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - foreach($vars as $var) { |
|
| 196 | - if(!is_array($var)) { |
|
| 195 | + foreach ($vars as $var) { |
|
| 196 | + if (!is_array($var)) { |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if(!(!empty($var['type']) && isset($var['data']))) { |
|
| 200 | + if (!(!empty($var['type']) && isset($var['data']))) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if(!is_string($var['type'])) { |
|
| 204 | + if (!is_string($var['type'])) { |
|
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if($var['type'] === 'int') { |
|
| 208 | + if ($var['type'] === 'int') { |
|
| 209 | 209 | $var['type'] = 'integer'; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if($var['type'] === 'float') { |
|
| 212 | + if ($var['type'] === 'float') { |
|
| 213 | 213 | $var['type'] = 'double'; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if(gettype($var['data']) !== $var['type']) { |
|
| 216 | + if (gettype($var['data']) !== $var['type']) { |
|
| 217 | 217 | return false; |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | function sessionIsStarted() |
| 242 | 242 | { |
| 243 | - if(PHP_SAPI === 'cli') { |
|
| 243 | + if (PHP_SAPI === 'cli') { |
|
| 244 | 244 | return false; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if(session_status() === PHP_SESSION_ACTIVE) { |
|
| 247 | + if (session_status() === PHP_SESSION_ACTIVE) { |
|
| 248 | 248 | return true; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -29,14 +29,11 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | if($type === 'int' || $type === 'integer') { |
| 31 | 31 | $filterType = FILTER_VALIDATE_INT; |
| 32 | - } |
|
| 33 | - elseif($type === 'float' || $type === 'double') { |
|
| 32 | + } elseif($type === 'float' || $type === 'double') { |
|
| 34 | 33 | $filterType = FILTER_VALIDATE_FLOAT; |
| 35 | - } |
|
| 36 | - elseif($type === 'bool' || $type === 'boolean') { |
|
| 34 | + } elseif($type === 'bool' || $type === 'boolean') { |
|
| 37 | 35 | $filterType = FILTER_VALIDATE_BOOLEAN; |
| 38 | - } |
|
| 39 | - elseif($type === 'email') { |
|
| 36 | + } elseif($type === 'email') { |
|
| 40 | 37 | $filterType = FILTER_VALIDATE_EMAIL; |
| 41 | 38 | } |
| 42 | 39 | //--- FIN Gestion de type de data --- |
@@ -65,8 +62,7 @@ discard block |
||
| 65 | 62 | |
| 66 | 63 | try { |
| 67 | 64 | return securiseKnownTypes($data, $type); |
| 68 | - } |
|
| 69 | - catch(Exception $ex) { |
|
| 65 | + } catch(Exception $ex) { |
|
| 70 | 66 | if($ex->getMessage() !== 'Unknown type') { |
| 71 | 67 | throw new Exception($ex->getCode(), $ex->getMessage()); |
| 72 | 68 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * |
| 37 | 37 | * @throws \Exception Erreur dsans les paramètres donnée à la méthode |
| 38 | 38 | * |
| 39 | - * @return boolean|null |
|
| 39 | + * @return boolean |
|
| 40 | 40 | */ |
| 41 | 41 | public function majExpire($key, $expire) |
| 42 | 42 | { |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | public function ifExists($key) |
| 18 | 18 | { |
| 19 | 19 | $verifParams = verifTypeData([['type' => 'string', 'data' => $key]]); |
| 20 | - if(!$verifParams) { |
|
| 20 | + if (!$verifParams) { |
|
| 21 | 21 | throw new \Exception('The $key parameters must be a string'); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - if($this->get($key) === false) { |
|
| 24 | + if ($this->get($key) === false) { |
|
| 25 | 25 | return false; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ['type' => 'int', 'data' => $expire] |
| 46 | 46 | ]); |
| 47 | 47 | |
| 48 | - if(!$verifParams) { |
|
| 48 | + if (!$verifParams) { |
|
| 49 | 49 | throw new \Exception( |
| 50 | 50 | 'Once of parameters $key or $expire not have a correct type.' |
| 51 | 51 | ); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | //On la "modifie" en remettant la même valeur mais en changeant le temps |
| 57 | 57 | //avant expiration si une valeur a été retournée |
| 58 | - if($value !== false && $this->replace($key, $value, 0, $expire)) { |
|
| 58 | + if ($value !== false && $this->replace($key, $value, 0, $expire)) { |
|
| 59 | 59 | return true; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -32,22 +32,22 @@ discard block |
||
| 32 | 32 | public function run($path) |
| 33 | 33 | { |
| 34 | 34 | $dir = opendir($path); |
| 35 | - if($dir === false) { |
|
| 35 | + if ($dir === false) { |
|
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | //Tant qu'il y a des fichiers à lire dans le dossier |
| 40 | - while(($file = readdir($dir)) !== false) { |
|
| 40 | + while (($file = readdir($dir)) !== false) { |
|
| 41 | 41 | $action = $this->fileAction($file, $dir); |
| 42 | 42 | |
| 43 | - if($action === 'continue') { |
|
| 43 | + if ($action === 'continue') { |
|
| 44 | 44 | continue; |
| 45 | - } elseif($action === 'break') { |
|
| 45 | + } elseif ($action === 'break') { |
|
| 46 | 46 | break; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | //If it's a directory and not a file |
| 50 | - if(is_dir($dir.'/'.$file)) { |
|
| 50 | + if (is_dir($dir.'/'.$file)) { |
|
| 51 | 51 | //We run the reading of this directory |
| 52 | 52 | $read = new readDirectory($this->list); |
| 53 | 53 | $read->run($dir.'/'.$file); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | protected function fileAction($fileName, $pathToFile) |
| 61 | 61 | { |
| 62 | - if(in_array($fileName, $this->ignore)) { |
|
| 62 | + if (in_array($fileName, $this->ignore)) { |
|
| 63 | 63 | return 'continue'; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | { |
| 9 | 9 | $parentAction = parent::fileAction($fileName, $pathToFile); |
| 10 | 10 | |
| 11 | - if($parentAction !== '') { |
|
| 11 | + if ($parentAction !== '') { |
|
| 12 | 12 | return $parentAction; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if(file_exists($pathToFile.'/bfwModulesInfos.json')) { |
|
| 15 | + if (file_exists($pathToFile.'/bfwModulesInfos.json')) { |
|
| 16 | 16 | $this->itemList[] = $pathToFile; |
| 17 | 17 | |
| 18 | 18 | return 'break'; |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | $this->srcPath = $infos->srcPath; |
| 104 | 104 | $this->configPath = $infos->srcPath; |
| 105 | 105 | |
| 106 | - if(property_exists($infos, 'configFiles')) { |
|
| 106 | + if (property_exists($infos, 'configFiles')) { |
|
| 107 | 107 | $this->configFiles = (array) $infos->configFiles; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(property_exists($infos, 'configPath')) { |
|
| 110 | + if (property_exists($infos, 'configPath')) { |
|
| 111 | 111 | $this->configPath = $infos->configPath; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(property_exists($infos, 'installScript')) { |
|
| 114 | + if (property_exists($infos, 'installScript')) { |
|
| 115 | 115 | $this->installScript = $infos->installScript; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -154,24 +154,24 @@ discard block |
||
| 154 | 154 | $targetPath = $this->bfwModulePath; |
| 155 | 155 | $alreadyCreated = file_exists($targetPath); |
| 156 | 156 | |
| 157 | - if($alreadyCreated && $this->forceReinstall === true) { |
|
| 157 | + if ($alreadyCreated && $this->forceReinstall === true) { |
|
| 158 | 158 | echo '[Force Reinstall: Remove symlink] '; |
| 159 | 159 | $alreadyCreated = false; |
| 160 | 160 | |
| 161 | - if(!unlink($targetPath)) { |
|
| 161 | + if (!unlink($targetPath)) { |
|
| 162 | 162 | echo "\033[1;31m Symbolic link remove fail.\033[0m\n"; |
| 163 | 163 | throw new Exception('Reinstall fail. Symlink remove error'); |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | //If module already exist in "modules" directory |
| 168 | - if($alreadyCreated) { |
|
| 168 | + if ($alreadyCreated) { |
|
| 169 | 169 | echo "\033[1;33m Not created. Module already exist in 'modules' directory.\033[0m\n"; |
| 170 | 170 | return; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | //If symbolic link create fail. |
| 174 | - if(!symlink($this->srcPath, $targetPath)) |
|
| 174 | + if (!symlink($this->srcPath, $targetPath)) |
|
| 175 | 175 | { |
| 176 | 176 | echo "...\033[1;31m Symbolic link creation fail.\033[0m\n"; |
| 177 | 177 | return; |
@@ -190,20 +190,20 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | echo ' > Copy config files : '."\n"; |
| 192 | 192 | |
| 193 | - if($this->configFiles === []) { |
|
| 193 | + if ($this->configFiles === []) { |
|
| 194 | 194 | echo ' >> '."\033[1;33m".'No config file declared. Pass'."\033[0m\n"; |
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | $configDirStatus = $this->createConfigDirectory(); |
| 199 | - if($configDirStatus === false) { |
|
| 199 | + if ($configDirStatus === false) { |
|
| 200 | 200 | return; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - foreach($this->configFiles as $configFile) { |
|
| 203 | + foreach ($this->configFiles as $configFile) { |
|
| 204 | 204 | try { |
| 205 | 205 | $this->copyConfigFile($configFile); |
| 206 | - } catch(Exception $e) { |
|
| 206 | + } catch (Exception $e) { |
|
| 207 | 207 | trigger_error( |
| 208 | 208 | 'Module '.$this->name.' Config file '.$configFile.' copy error: '.$e->getMessage(), |
| 209 | 209 | E_USER_WARNING |
@@ -226,22 +226,22 @@ discard block |
||
| 226 | 226 | $targetDirectory = $this->bfwConfigPath; |
| 227 | 227 | $alreadyExist = file_exists($targetDirectory); |
| 228 | 228 | |
| 229 | - if($alreadyExist && $this->forceReinstall === true) { |
|
| 229 | + if ($alreadyExist && $this->forceReinstall === true) { |
|
| 230 | 230 | echo '[Force Reinstall: Remove symlink] '; |
| 231 | 231 | $alreadyExist = false; |
| 232 | 232 | |
| 233 | - if(!rmdir($targetDirectory)) { |
|
| 233 | + if (!rmdir($targetDirectory)) { |
|
| 234 | 234 | echo "\033[1;31m Remove module config directory fail.\033[0m\n"; |
| 235 | 235 | throw new Exception('Reinstall fail. Remove module config directory error.'); |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if($alreadyExist) { |
|
| 239 | + if ($alreadyExist) { |
|
| 240 | 240 | echo "\033[1;33m Already exist.\033[0m\n"; |
| 241 | 241 | return true; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if(mkdir($targetDirectory, 0755)) { |
|
| 244 | + if (mkdir($targetDirectory, 0755)) { |
|
| 245 | 245 | echo "\033[1;32m Created. \033[0m\n"; |
| 246 | 246 | return true; |
| 247 | 247 | } |
@@ -269,19 +269,19 @@ discard block |
||
| 269 | 269 | $targetFile = realpath($this->bfwConfigPath.'/'.$configFileName); |
| 270 | 270 | |
| 271 | 271 | //Check if config file already exist |
| 272 | - if(file_exists($targetFile)) { |
|
| 272 | + if (file_exists($targetFile)) { |
|
| 273 | 273 | echo "\033[1;33m Existe déjà.\033[0m\n"; |
| 274 | 274 | return; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | //If source file not exist |
| 278 | - if(!file_exists($sourceFile)) { |
|
| 278 | + if (!file_exists($sourceFile)) { |
|
| 279 | 279 | echo "\033[1;31m Config file not exist in module source.\033[0m\n"; |
| 280 | 280 | throw new Exception('Source file not exist'); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | //Alors on copie le fichier vers le dossier /configs/[monModule]/ |
| 284 | - if(!copy($sourceFile, $targetFile)) |
|
| 284 | + if (!copy($sourceFile, $targetFile)) |
|
| 285 | 285 | { |
| 286 | 286 | echo "\033[1;31m Copy fail.\033[0m\n"; |
| 287 | 287 | throw new Exception('Copy fail'); |
@@ -299,12 +299,12 @@ discard block |
||
| 299 | 299 | { |
| 300 | 300 | echo ' >> Run install specific script : '; |
| 301 | 301 | |
| 302 | - if($this->installScript === '' || $this->installScript === false) { |
|
| 302 | + if ($this->installScript === '' || $this->installScript === false) { |
|
| 303 | 303 | echo ' >> '."\033[1;33m".'No specific script declared. Pass'."\033[0m\n"; |
| 304 | 304 | return; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if($this->installScript === true) { |
|
| 307 | + if ($this->installScript === true) { |
|
| 308 | 308 | $this->installScript = 'runInstallModule.php'; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | define('cliMode', true); |
| 5 | 5 | |
| 6 | 6 | //If this file is not call from cli, we display an error |
| 7 | -if(PHP_SAPI !== 'cli') { |
|
| 7 | +if (PHP_SAPI !== 'cli') { |
|
| 8 | 8 | echo 'cli.php should be used only from the command.'; |
| 9 | 9 | exit; |
| 10 | 10 | } |