@@ -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 | } |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | $opt = getCliParams('vhp', array('version::', 'help::', 'parameters::')); |
| 9 | 9 | |
| 10 | -if(isset($opt['v']) || isset($opt['version'])) |
|
| 10 | +if (isset($opt['v']) || isset($opt['version'])) |
|
| 11 | 11 | { |
| 12 | 12 | displayMsg('v0.2'); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -if(isset($opt['p']) || isset($opt['paramters'])) |
|
| 15 | +if (isset($opt['p']) || isset($opt['paramters'])) |
|
| 16 | 16 | { |
| 17 | 17 | displayMsg(print_r($opt, true)); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if(isset($opt['h']) || isset($opt['help'])) |
|
| 20 | +if (isset($opt['h']) || isset($opt['help'])) |
|
| 21 | 21 | { |
| 22 | 22 | displayMsg(''); |
| 23 | 23 | displayMsg('Helping Informations : Parameters script'); |
@@ -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 | |
@@ -53,31 +53,31 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function displayMsg($msg, $colorTxt = null, $colorBg = null, $style = 'normal') |
| 55 | 55 | { |
| 56 | - if($colorTxt == null) { |
|
| 56 | + if ($colorTxt == null) { |
|
| 57 | 57 | echo $msg."\n"; |
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | //Gestion cas avec couleur |
| 62 | 62 | $styleNum = styleForShell($style); |
| 63 | - if($styleNum === false) { |
|
| 63 | + if ($styleNum === false) { |
|
| 64 | 64 | $styleNum = styleForShell('normal'); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $colorTxtNum = colorForShell('white', 'txt'); |
| 68 | - if($colorTxt !== null) { |
|
| 68 | + if ($colorTxt !== null) { |
|
| 69 | 69 | $colorTxtNumArg = colorForShell($colorTxt, 'txt'); |
| 70 | 70 | |
| 71 | - if($colorTxtNumArg !== false) { |
|
| 71 | + if ($colorTxtNumArg !== false) { |
|
| 72 | 72 | $colorTxtNum = $colorTxtNumArg; |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $colorBgNum = colorForShell('black', 'bg'); |
| 77 | - if($colorBg !== null) { |
|
| 77 | + if ($colorBg !== null) { |
|
| 78 | 78 | $colorBgNumArg = colorForShell($colorBg, 'bg'); |
| 79 | 79 | |
| 80 | - if($colorBgNumArg !== false) { |
|
| 80 | + if ($colorBgNumArg !== false) { |
|
| 81 | 81 | $colorBgNum = $colorBgNumArg; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | 'white' => 7 |
| 110 | 110 | ]; |
| 111 | 111 | |
| 112 | - if(!in_array($color, $colorList)) { |
|
| 112 | + if (!in_array($color, $colorList)) { |
|
| 113 | 113 | throw new Exception('Color '.$color.' is not available in function.'); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if($type === 'txt') { |
|
| 116 | + if ($type === 'txt') { |
|
| 117 | 117 | return $colorList[$color] + 30; |
| 118 | 118 | } |
| 119 | - elseif($type === 'bg') { |
|
| 119 | + elseif ($type === 'bg') { |
|
| 120 | 120 | return $colorList[$color] + 40; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | 'not-reverse' => 27 |
| 141 | 141 | ]; |
| 142 | 142 | |
| 143 | - if(!in_array($style, $styleList)) { |
|
| 143 | + if (!in_array($style, $styleList)) { |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function getZone() |
| 93 | 93 | { |
| 94 | - return parent::format('P');; |
|
| 94 | + return parent::format('P'); ; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function modify($modify) |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $dateDepart = clone $this; |
| 100 | 100 | parent::modify($modify); |
| 101 | 101 | |
| 102 | - if($dateDepart == $this) { |
|
| 102 | + if ($dateDepart == $this) { |
|
| 103 | 103 | return $this; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $match = []; |
| 143 | 143 | |
| 144 | 144 | //Regex sur le paramètre pour récupéré le type de modification |
| 145 | - if(preg_match('#(\+|\-)([0-9]+) ([a-z]+)#i', $modify, $match) !== 1) { |
|
| 145 | + if (preg_match('#(\+|\-)([0-9]+) ([a-z]+)#i', $modify, $match) !== 1) { |
|
| 146 | 146 | throw new Exceptio('Date::modify pattern not match.'); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $dateDepart = clone $this; |
| 156 | 156 | parent::modify($match[1].$match[2].' '.$keyword); |
| 157 | 157 | |
| 158 | - if($dateDepart == $this) { |
|
| 158 | + if ($dateDepart == $this) { |
|
| 159 | 159 | throw new Exception('Parameter '.$match[3].' is unknown.'); |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $date = $this->format('Y-m-d'); |
| 176 | 176 | $heure = $this->format('H:i:s'); |
| 177 | 177 | |
| 178 | - if($returnArray) { |
|
| 178 | + if ($returnArray) { |
|
| 179 | 179 | return [$date, $heure]; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | $return = []; |
| 227 | 227 | |
| 228 | 228 | $pos = false; |
| 229 | - foreach($lst_all as $val) { |
|
| 229 | + foreach ($lst_all as $val) { |
|
| 230 | 230 | $pos = strpos($val, $continent); |
| 231 | 231 | |
| 232 | - if($pos !== false) { |
|
| 232 | + if ($pos !== false) { |
|
| 233 | 233 | $return[] = $val; |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | 'time' => '' |
| 248 | 248 | ]; |
| 249 | 249 | |
| 250 | - if($actual == $this) { |
|
| 250 | + if ($actual == $this) { |
|
| 251 | 251 | //A l'instant |
| 252 | 252 | |
| 253 | 253 | $returnTxt->date = self::$humainReadableI18n['now']; |
| 254 | - } elseif($actual->format('d') !== parent::format('d')) { |
|
| 254 | + } elseif ($actual->format('d') !== parent::format('d')) { |
|
| 255 | 255 | //Hier |
| 256 | 256 | |
| 257 | 257 | $returnTxt->date = self::$humainReadableI18n['yesterday']; |
@@ -260,21 +260,21 @@ discard block |
||
| 260 | 260 | .parent::format( |
| 261 | 261 | self::$humainReadableFormats['time'] |
| 262 | 262 | ); |
| 263 | - } elseif($diff->days === 0) { |
|
| 263 | + } elseif ($diff->days === 0) { |
|
| 264 | 264 | //Aujourd'hui |
| 265 | 265 | |
| 266 | 266 | $returnTxt->date = self::$humainReadableI18n['since']; |
| 267 | 267 | |
| 268 | - if($diff->h === 0 && $diff->m === 0) { |
|
| 268 | + if ($diff->h === 0 && $diff->m === 0) { |
|
| 269 | 269 | $returnTxt->date .= $diff->s.'s'; |
| 270 | - } elseif($diff->h === 0) { |
|
| 270 | + } elseif ($diff->h === 0) { |
|
| 271 | 271 | $returnTxt->date .= $diff->s.'min'; |
| 272 | 272 | } else { |
| 273 | 273 | $returnTxt->date .= $diff->h.'h'; |
| 274 | 274 | } |
| 275 | 275 | } else { |
| 276 | 276 | $dateFormat = self::$humainReadableFormats['dateDifferentYear']; |
| 277 | - if($actual->format('Y') === parent::format('Y')) { |
|
| 277 | + if ($actual->format('Y') === parent::format('Y')) { |
|
| 278 | 278 | $dateFormat = self::$humainReadableFormats['dateSameYear']; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | $txtReturn = $returnTxt->date; |
| 294 | - if($returnDateAndTime === true && $returnTxt->time !== '') { |
|
| 294 | + if ($returnDateAndTime === true && $returnTxt->time !== '') { |
|
| 295 | 295 | $txtReturn .= ' '.$returnTxt->time; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if($toLower === true) { |
|
| 298 | + if ($toLower === true) { |
|
| 299 | 299 | $txtReturn = mb_strtolower($txtReturn); |
| 300 | 300 | } |
| 301 | 301 | |
@@ -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 | |