@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | interface ResponseInterface |
32 | 32 | { |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * translate the content |
35 | 35 | * |
36 | 36 | * @access public |
@@ -34,61 +34,61 @@ |
||
34 | 34 | */ |
35 | 35 | private $_sLanguage = LANGUAGE; |
36 | 36 | |
37 | - /** |
|
38 | - * set the language if you don't want take the default language of the configuration file |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @param int $iImageUri |
|
42 | - * @param int $iWidth |
|
43 | - * @param int $iHeight |
|
44 | - * @param bool $bKeepDimension |
|
45 | - * @return void |
|
46 | - */ |
|
37 | + /** |
|
38 | + * set the language if you don't want take the default language of the configuration file |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @param int $iImageUri |
|
42 | + * @param int $iWidth |
|
43 | + * @param int $iHeight |
|
44 | + * @param bool $bKeepDimension |
|
45 | + * @return void |
|
46 | + */ |
|
47 | 47 | public static function showImageInSize(int $iImageUri, int $iWidth, int $iHeight, bool $bKeepDimension = false) |
48 | 48 | { |
49 | - $aSize = getimagesize($iImageUri); |
|
50 | - $rActualImage = imagecreatefromjpeg($iImageUri); |
|
49 | + $aSize = getimagesize($iImageUri); |
|
50 | + $rActualImage = imagecreatefromjpeg($iImageUri); |
|
51 | 51 | |
52 | - $ImageChoisie = imagecreatefromjpeg($_FILES['ImageNews']['tmp_name']); |
|
53 | - $TailleImageChoisie = getimagesize($_FILES['ImageNews']['tmp_name']); |
|
52 | + $ImageChoisie = imagecreatefromjpeg($_FILES['ImageNews']['tmp_name']); |
|
53 | + $TailleImageChoisie = getimagesize($_FILES['ImageNews']['tmp_name']); |
|
54 | 54 | |
55 | - $rNewImage = imagecreatetruecolor($iWidth , $iHeight); |
|
55 | + $rNewImage = imagecreatetruecolor($iWidth , $iHeight); |
|
56 | 56 | |
57 | - if ($bKeepDimension === false) { |
|
57 | + if ($bKeepDimension === false) { |
|
58 | 58 | |
59 | - imagecopyresampled($rNewImage, $rActualImage, 0, 0, 0, 0, $iWidth, $iHeight, $aSize[0], $aSize[1]); |
|
60 | - } |
|
61 | - else { |
|
59 | + imagecopyresampled($rNewImage, $rActualImage, 0, 0, 0, 0, $iWidth, $iHeight, $aSize[0], $aSize[1]); |
|
60 | + } |
|
61 | + else { |
|
62 | 62 | |
63 | - if ($aSize[0] > $aSize[1]) { |
|
63 | + if ($aSize[0] > $aSize[1]) { |
|
64 | 64 | |
65 | - $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
|
66 | - imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
|
67 | - $fCoef = $aSize[1] / $aSize[0]; |
|
68 | - $iHeight = round($iWidth * $fCoef); |
|
69 | - $iDestY = round(($iWidth - $iHeight) / 2); |
|
70 | - $iDestX = 0; |
|
71 | - } |
|
72 | - else { |
|
65 | + $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
|
66 | + imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
|
67 | + $fCoef = $aSize[1] / $aSize[0]; |
|
68 | + $iHeight = round($iWidth * $fCoef); |
|
69 | + $iDestY = round(($iWidth - $iHeight) / 2); |
|
70 | + $iDestX = 0; |
|
71 | + } |
|
72 | + else { |
|
73 | 73 | |
74 | - $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
|
75 | - imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
|
76 | - $fCoef = $aSize[0] / $aSize[1]; |
|
77 | - $iWidth = round($iHeight * $fCoef); |
|
78 | - $iDestX = round(($iHeight - $iWidth) / 2); |
|
79 | - $iDestY = 0; |
|
80 | - } |
|
74 | + $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
|
75 | + imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
|
76 | + $fCoef = $aSize[0] / $aSize[1]; |
|
77 | + $iWidth = round($iHeight * $fCoef); |
|
78 | + $iDestX = round(($iHeight - $iWidth) / 2); |
|
79 | + $iDestY = 0; |
|
80 | + } |
|
81 | 81 | |
82 | - $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
|
83 | - imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
|
84 | - imagecopyresampled($rNewImage, $rActualImage, $iDestX, $iDestY, 0, 0, $iWidth, $iHeight, $aSize[0], $aSize[1]); |
|
85 | - } |
|
82 | + $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
|
83 | + imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
|
84 | + imagecopyresampled($rNewImage, $rActualImage, $iDestX, $iDestY, 0, 0, $iWidth, $iHeight, $aSize[0], $aSize[1]); |
|
85 | + } |
|
86 | 86 | |
87 | - imagedestroy($rActualImage); |
|
88 | - $NomImageChoisie = explode('.', $rNewImage); |
|
89 | - $NomImageExploitable = time(); |
|
87 | + imagedestroy($rActualImage); |
|
88 | + $NomImageChoisie = explode('.', $rNewImage); |
|
89 | + $NomImageExploitable = time(); |
|
90 | 90 | |
91 | - header('Content-Type: image/jpeg'); |
|
92 | - imagejpeg($rNewImage , null, 100); |
|
91 | + header('Content-Type: image/jpeg'); |
|
92 | + imagejpeg($rNewImage , null, 100); |
|
93 | 93 | } |
94 | 94 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $ImageChoisie = imagecreatefromjpeg($_FILES['ImageNews']['tmp_name']); |
53 | 53 | $TailleImageChoisie = getimagesize($_FILES['ImageNews']['tmp_name']); |
54 | 54 | |
55 | - $rNewImage = imagecreatetruecolor($iWidth , $iHeight); |
|
55 | + $rNewImage = imagecreatetruecolor($iWidth, $iHeight); |
|
56 | 56 | |
57 | 57 | if ($bKeepDimension === false) { |
58 | 58 | |
@@ -89,6 +89,6 @@ discard block |
||
89 | 89 | $NomImageExploitable = time(); |
90 | 90 | |
91 | 91 | header('Content-Type: image/jpeg'); |
92 | - imagejpeg($rNewImage , null, 100); |
|
92 | + imagejpeg($rNewImage, null, 100); |
|
93 | 93 | } |
94 | 94 | } |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | if ($bKeepDimension === false) { |
58 | 58 | |
59 | 59 | imagecopyresampled($rNewImage, $rActualImage, 0, 0, 0, 0, $iWidth, $iHeight, $aSize[0], $aSize[1]); |
60 | - } |
|
61 | - else { |
|
60 | + } else { |
|
62 | 61 | |
63 | 62 | if ($aSize[0] > $aSize[1]) { |
64 | 63 | |
@@ -68,8 +67,7 @@ discard block |
||
68 | 67 | $iHeight = round($iWidth * $fCoef); |
69 | 68 | $iDestY = round(($iWidth - $iHeight) / 2); |
70 | 69 | $iDestX = 0; |
71 | - } |
|
72 | - else { |
|
70 | + } else { |
|
73 | 71 | |
74 | 72 | $rWhite = imagecolorallocate($rNewImage, 255, 255, 255); |
75 | 73 | imagefilledrectangle($rNewImage, 0, 0, $iWidth, $iHeight, $rWhite); |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | |
138 | 138 | if (!isset(self::$_aCache['memcache'])) { |
139 | 139 | |
140 | - $oDbConf = Config::get('Memcache')->configuration; |
|
140 | + $oDbConf = Config::get('Memcache')->configuration; |
|
141 | 141 | |
142 | - if (isset($oDbConf->port)) { $sPort = $oDbConf->port; } |
|
143 | - else { $sPort = null; } |
|
142 | + if (isset($oDbConf->port)) { $sPort = $oDbConf->port; } |
|
143 | + else { $sPort = null; } |
|
144 | 144 | |
145 | - if (isset($oDbConf->timeout)) { $iTimeout = $oDbConf->timeout; } |
|
146 | - else { $iTimeout = null; } |
|
145 | + if (isset($oDbConf->timeout)) { $iTimeout = $oDbConf->timeout; } |
|
146 | + else { $iTimeout = null; } |
|
147 | 147 | |
148 | - self::$_aCache['memcache'] = new CacheMemcache($oDbConf->host, $sPort, $iTimeout); |
|
148 | + self::$_aCache['memcache'] = new CacheMemcache($oDbConf->host, $sPort, $iTimeout); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return self::$_aCache['memcache']; |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | |
161 | 161 | if (!isset(self::$_aCache['redis'])) { |
162 | 162 | |
163 | - $oDbConf = Config::get('Redis')->configuration; |
|
164 | - self::$_aCache['memcache'] = new Redis($oDbConf); |
|
163 | + $oDbConf = Config::get('Redis')->configuration; |
|
164 | + self::$_aCache['memcache'] = new Redis($oDbConf); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return self::$_aCache['redis']; |
@@ -91,7 +91,7 @@ |
||
91 | 91 | * @param int $iTimeout expiration of cache |
92 | 92 | * @return bool |
93 | 93 | */ |
94 | - public static function get(string $sName, int &$iFlags = null, int $iTimeout = 0) : bool |
|
94 | + public static function get(string $sName, int&$iFlags = null, int $iTimeout = 0) : bool |
|
95 | 95 | { |
96 | 96 | return self::_getCacheObject()->get($sName, $iFlags, $iTimeout); |
97 | 97 | } |
@@ -60,11 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function setCacheType(string $sCacheName) |
62 | 62 | { |
63 | - if ($sCacheName === 'file') { self::$_sTypeOfCache = 'file'; } |
|
64 | - else if ($sCacheName === 'memcache') { self::$_sTypeOfCache = 'memcache'; } |
|
65 | - else if ($sCacheName === 'apc') { self::$_sTypeOfCache = 'apc'; } |
|
66 | - else if ($sCacheName === 'redis') { self::$_sTypeOfCache = 'redis'; } |
|
67 | - else { self::$_sTypeOfCache = 'mock'; } |
|
63 | + if ($sCacheName === 'file') { self::$_sTypeOfCache = 'file'; } else if ($sCacheName === 'memcache') { self::$_sTypeOfCache = 'memcache'; } else if ($sCacheName === 'apc') { self::$_sTypeOfCache = 'apc'; } else if ($sCacheName === 'redis') { self::$_sTypeOfCache = 'redis'; } else { self::$_sTypeOfCache = 'mock'; } |
|
68 | 64 | } |
69 | 65 | |
70 | 66 | /** |
@@ -132,31 +128,26 @@ discard block |
||
132 | 128 | if (!isset(self::$_aCache['file'])) { self::$_aCache['file'] = new CacheFile; } |
133 | 129 | |
134 | 130 | return self::$_aCache['file']; |
135 | - } |
|
136 | - else if (self::$_sTypeOfCache === 'memcache') { |
|
131 | + } else if (self::$_sTypeOfCache === 'memcache') { |
|
137 | 132 | |
138 | 133 | if (!isset(self::$_aCache['memcache'])) { |
139 | 134 | |
140 | 135 | $oDbConf = Config::get('Memcache')->configuration; |
141 | 136 | |
142 | - if (isset($oDbConf->port)) { $sPort = $oDbConf->port; } |
|
143 | - else { $sPort = null; } |
|
137 | + if (isset($oDbConf->port)) { $sPort = $oDbConf->port; } else { $sPort = null; } |
|
144 | 138 | |
145 | - if (isset($oDbConf->timeout)) { $iTimeout = $oDbConf->timeout; } |
|
146 | - else { $iTimeout = null; } |
|
139 | + if (isset($oDbConf->timeout)) { $iTimeout = $oDbConf->timeout; } else { $iTimeout = null; } |
|
147 | 140 | |
148 | 141 | self::$_aCache['memcache'] = new CacheMemcache($oDbConf->host, $sPort, $iTimeout); |
149 | 142 | } |
150 | 143 | |
151 | 144 | return self::$_aCache['memcache']; |
152 | - } |
|
153 | - else if (self::$_sTypeOfCache === 'apc') { |
|
145 | + } else if (self::$_sTypeOfCache === 'apc') { |
|
154 | 146 | |
155 | 147 | if (!isset(self::$_aCache['apc'])) { self::$_aCache['apc'] = new Apc; } |
156 | 148 | |
157 | 149 | return self::$_aCache['apc']; |
158 | - } |
|
159 | - else if (self::$_sTypeOfCache === 'redis') { |
|
150 | + } else if (self::$_sTypeOfCache === 'redis') { |
|
160 | 151 | |
161 | 152 | if (!isset(self::$_aCache['redis'])) { |
162 | 153 | |
@@ -165,8 +156,7 @@ discard block |
||
165 | 156 | } |
166 | 157 | |
167 | 158 | return self::$_aCache['redis']; |
168 | - } |
|
169 | - else if (self::$_sTypeOfCache === 'mock') { |
|
159 | + } else if (self::$_sTypeOfCache === 'mock') { |
|
170 | 160 | |
171 | 161 | if (!isset(self::$_aCache['mock'])) { self::$_aCache['mock'] = new Mock; } |
172 | 162 |
@@ -40,28 +40,28 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function javascripts() : array { |
42 | 42 | |
43 | - $sDefaultPath = 'http://'.$_SERVER['HTTP_HOST'].'/getJs?'; |
|
44 | - $aJavascript = func_get_args(); |
|
45 | - $aReturns = array(); |
|
43 | + $sDefaultPath = 'http://'.$_SERVER['HTTP_HOST'].'/getJs?'; |
|
44 | + $aJavascript = func_get_args(); |
|
45 | + $aReturns = array(); |
|
46 | 46 | |
47 | - foreach($aJavascript as $aJsCombination) { |
|
47 | + foreach($aJavascript as $aJsCombination) { |
|
48 | 48 | |
49 | - $sJsPath = $sDefaultPath; |
|
49 | + $sJsPath = $sDefaultPath; |
|
50 | 50 | |
51 | - foreach ($aJsCombination as $sJsToAdd) { |
|
51 | + foreach ($aJsCombination as $sJsToAdd) { |
|
52 | 52 | |
53 | - $sJsPath = $sJsToAdd.'&'; |
|
54 | - } |
|
53 | + $sJsPath = $sJsToAdd.'&'; |
|
54 | + } |
|
55 | 55 | |
56 | - if (defined('ASSET_VERSION') && ASSET_VERSION) { |
|
56 | + if (defined('ASSET_VERSION') && ASSET_VERSION) { |
|
57 | 57 | |
58 | - $sJsPath = ASSET_VERSION; |
|
59 | - } |
|
58 | + $sJsPath = ASSET_VERSION; |
|
59 | + } |
|
60 | 60 | |
61 | - $aReturns[] = $sJsPath; |
|
62 | - } |
|
61 | + $aReturns[] = $sJsPath; |
|
62 | + } |
|
63 | 63 | |
64 | - return $aReturns; |
|
64 | + return $aReturns; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function stylesheets() : array { |
77 | 77 | |
78 | - $sDefaultPath = 'http://'.$_SERVER['HTTP_HOST'].'/getCss?'; |
|
79 | - $aCss = func_get_args(); |
|
80 | - $aReturns = array(); |
|
78 | + $sDefaultPath = 'http://'.$_SERVER['HTTP_HOST'].'/getCss?'; |
|
79 | + $aCss = func_get_args(); |
|
80 | + $aReturns = array(); |
|
81 | 81 | |
82 | - foreach($aCss as $aCssCombination) { |
|
82 | + foreach($aCss as $aCssCombination) { |
|
83 | 83 | |
84 | - $sCssPath = $sDefaultPath; |
|
84 | + $sCssPath = $sDefaultPath; |
|
85 | 85 | |
86 | - foreach ($aCssCombination as $sCssToAdd) { |
|
86 | + foreach ($aCssCombination as $sCssToAdd) { |
|
87 | 87 | |
88 | - $sCssPath = $sCssToAdd.'&'; |
|
89 | - } |
|
88 | + $sCssPath = $sCssToAdd.'&'; |
|
89 | + } |
|
90 | 90 | |
91 | - if (defined('ASSET_VERSION') && ASSET_VERSION) { |
|
91 | + if (defined('ASSET_VERSION') && ASSET_VERSION) { |
|
92 | 92 | |
93 | - $sJsPath = ASSET_VERSION; |
|
94 | - } |
|
93 | + $sJsPath = ASSET_VERSION; |
|
94 | + } |
|
95 | 95 | |
96 | - $aReturns[] = $sCssPath; |
|
97 | - } |
|
96 | + $aReturns[] = $sCssPath; |
|
97 | + } |
|
98 | 98 | |
99 | - return $aReturns; |
|
99 | + return $aReturns; |
|
100 | 100 | } |
101 | 101 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $aJavascript = func_get_args(); |
45 | 45 | $aReturns = array(); |
46 | 46 | |
47 | - foreach($aJavascript as $aJsCombination) { |
|
47 | + foreach ($aJavascript as $aJsCombination) { |
|
48 | 48 | |
49 | 49 | $sJsPath = $sDefaultPath; |
50 | 50 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $aCss = func_get_args(); |
80 | 80 | $aReturns = array(); |
81 | 81 | |
82 | - foreach($aCss as $aCssCombination) { |
|
82 | + foreach ($aCss as $aCssCombination) { |
|
83 | 83 | |
84 | 84 | $sCssPath = $sDefaultPath; |
85 | 85 |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | class Debug extends AbstractLogger |
36 | 36 | { |
37 | 37 | /** |
38 | - * variable to activate or not the debug |
|
39 | - * @var boolean |
|
40 | - */ |
|
38 | + * variable to activate or not the debug |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | 41 | private static $_bActivateDebug = false; |
42 | 42 | |
43 | 43 | /** |
44 | - * variable to activate or not the error |
|
44 | + * variable to activate or not the error |
|
45 | 45 | * @var boolean |
46 | 46 | */ |
47 | 47 | private static $_bActivateError = false; |
@@ -76,37 +76,37 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private static $_oInstance; |
78 | 78 | |
79 | - /** |
|
80 | - * Send back the isntance or create it |
|
81 | - * |
|
82 | - * @access public |
|
83 | - * @return \Venus\lib\Debug |
|
84 | - */ |
|
85 | - public static function getInstance() : Debug |
|
86 | - { |
|
87 | - if (!(self::$_oInstance instanceof self)) { self::$_oInstance = new self(); } |
|
79 | + /** |
|
80 | + * Send back the isntance or create it |
|
81 | + * |
|
82 | + * @access public |
|
83 | + * @return \Venus\lib\Debug |
|
84 | + */ |
|
85 | + public static function getInstance() : Debug |
|
86 | + { |
|
87 | + if (!(self::$_oInstance instanceof self)) { self::$_oInstance = new self(); } |
|
88 | 88 | |
89 | - return self::$_oInstance; |
|
90 | - } |
|
89 | + return self::$_oInstance; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * activate debug |
94 | 94 | * |
95 | 95 | * @access public |
96 | 96 | * @return void |
97 | - */ |
|
97 | + */ |
|
98 | 98 | public static function activateDebug() |
99 | 99 | { |
100 | 100 | if (self::$_bFirstActivation === true) { |
101 | 101 | |
102 | 102 | self::_setFileNameInErrorFile(); |
103 | 103 | self::$_bFirstActivation = false; |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | - self::_initLogFile(); |
|
107 | - self::$_bActivateDebug = true; |
|
108 | - self::activateError(E_ALL); |
|
109 | - self::activateException(E_ALL); |
|
106 | + self::_initLogFile(); |
|
107 | + self::$_bActivateDebug = true; |
|
108 | + self::activateError(E_ALL); |
|
109 | + self::activateException(E_ALL); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public static function deactivateDebug() |
119 | 119 | { |
120 | - self::$_bActivateDebug = false; |
|
120 | + self::$_bActivateDebug = false; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,54 +125,54 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @access public |
127 | 127 | * @return boolean |
128 | - */ |
|
128 | + */ |
|
129 | 129 | public static function isDebug() : bool |
130 | 130 | { |
131 | 131 | return self::$_bActivateDebug; |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * activate error reporting |
|
136 | - * |
|
137 | - * @access public |
|
138 | - * @param int $iLevel level of error |
|
139 | - * @return void |
|
140 | - */ |
|
135 | + * activate error reporting |
|
136 | + * |
|
137 | + * @access public |
|
138 | + * @param int $iLevel level of error |
|
139 | + * @return void |
|
140 | + */ |
|
141 | 141 | public static function activateError($iLevel) |
142 | 142 | { |
143 | - if (self::$_bFirstActivation === true) { |
|
143 | + if (self::$_bFirstActivation === true) { |
|
144 | 144 | |
145 | - self::_setFileNameInErrorFile(); |
|
146 | - self::$_bFirstActivation = false; |
|
147 | - } |
|
145 | + self::_setFileNameInErrorFile(); |
|
146 | + self::$_bFirstActivation = false; |
|
147 | + } |
|
148 | 148 | |
149 | - self::_initLogFile(); |
|
150 | - self::$_bActivateError = true; |
|
149 | + self::_initLogFile(); |
|
150 | + self::$_bActivateError = true; |
|
151 | 151 | |
152 | - error_reporting($iLevel); |
|
152 | + error_reporting($iLevel); |
|
153 | 153 | |
154 | - set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
155 | - { |
|
154 | + set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
155 | + { |
|
156 | 156 | $aContext = array('file' => $sErrFile, 'line' => $iErrLine); |
157 | 157 | |
158 | 158 | $sType = self::getTranslateErrorCode($iErrNo); |
159 | 159 | |
160 | - self::getInstance()->$sType($sErrStr, $aContext); |
|
160 | + self::getInstance()->$sType($sErrStr, $aContext); |
|
161 | 161 | |
162 | - return true; |
|
162 | + return true; |
|
163 | 163 | }, $iLevel); |
164 | 164 | |
165 | - register_shutdown_function(function() |
|
166 | - { |
|
165 | + register_shutdown_function(function() |
|
166 | + { |
|
167 | 167 | if (null !== ($aLastError = error_get_last())) { |
168 | 168 | |
169 | - $aContext = array('file' => $aLastError['file'], 'line' => $aLastError['line']); |
|
169 | + $aContext = array('file' => $aLastError['file'], 'line' => $aLastError['line']); |
|
170 | 170 | |
171 | - $sType = self::getTranslateErrorCode($aLastError['type']); |
|
171 | + $sType = self::getTranslateErrorCode($aLastError['type']); |
|
172 | 172 | |
173 | - self::getInstance()->$sType($aLastError['message'], $aContext); |
|
174 | - } |
|
175 | - }); |
|
173 | + self::getInstance()->$sType($aLastError['message'], $aContext); |
|
174 | + } |
|
175 | + }); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @access public |
182 | 182 | * @return void |
183 | - */ |
|
183 | + */ |
|
184 | 184 | public static function deactivateError() |
185 | 185 | { |
186 | - self::$_bActivateError = false; |
|
186 | + self::$_bActivateError = false; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public static function isError() : bool |
196 | 196 | { |
197 | - return self::$_bActivateError; |
|
197 | + return self::$_bActivateError; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function emergency($message, array $context = array()) |
297 | 297 | { |
298 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
298 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * @param string $message |
308 | 308 | * @param array $context |
309 | 309 | * @return null |
310 | - */ |
|
310 | + */ |
|
311 | 311 | public function alert($message, array $context = array()) |
312 | 312 | { |
313 | - $this->log(LogLevel::ALERT, $message, $context); |
|
313 | + $this->log(LogLevel::ALERT, $message, $context); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | * @param string $message |
322 | 322 | * @param array $context |
323 | 323 | * @return null |
324 | - */ |
|
324 | + */ |
|
325 | 325 | public function critical($message, array $context = array()) |
326 | 326 | { |
327 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
327 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | * @param string $message |
335 | 335 | * @param array $context |
336 | 336 | * @return null |
337 | - */ |
|
337 | + */ |
|
338 | 338 | public function error($message, array $context = array()) |
339 | 339 | { |
340 | - $this->log(LogLevel::ERROR, $message, $context); |
|
340 | + $this->log(LogLevel::ERROR, $message, $context); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | * @param string $message |
350 | 350 | * @param array $context |
351 | 351 | * @return null |
352 | - */ |
|
352 | + */ |
|
353 | 353 | public function warning($message, array $context = array()) |
354 | 354 | { |
355 | - $this->log(LogLevel::WARNING, $message, $context); |
|
355 | + $this->log(LogLevel::WARNING, $message, $context); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -361,10 +361,10 @@ discard block |
||
361 | 361 | * @param string $message |
362 | 362 | * @param array $context |
363 | 363 | * @return null |
364 | - */ |
|
364 | + */ |
|
365 | 365 | public function notice($message, array $context = array()) |
366 | 366 | { |
367 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
367 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | * @param string $message |
376 | 376 | * @param array $context |
377 | 377 | * @return null |
378 | - */ |
|
378 | + */ |
|
379 | 379 | public function info($message, array $context = array()) |
380 | 380 | { |
381 | - $this->log(LogLevel::INFO, $message, $context); |
|
381 | + $this->log(LogLevel::INFO, $message, $context); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @param string $message |
388 | 388 | * @param array $context |
389 | 389 | * @return null |
390 | - */ |
|
390 | + */ |
|
391 | 391 | public function debug($message, array $context = array()) |
392 | 392 | { |
393 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
393 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -398,40 +398,40 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @access public |
400 | 400 | * @return void |
401 | - */ |
|
401 | + */ |
|
402 | 402 | private static function _setFileNameInErrorFile() |
403 | 403 | { |
404 | - /** |
|
405 | - * We see if it's a cli call or a web call |
|
406 | - */ |
|
404 | + /** |
|
405 | + * We see if it's a cli call or a web call |
|
406 | + */ |
|
407 | 407 | |
408 | - if (defined('BASH_CALLED')) { |
|
408 | + if (defined('BASH_CALLED')) { |
|
409 | 409 | |
410 | - error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); |
|
411 | - } |
|
412 | - else { |
|
410 | + error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); |
|
411 | + } |
|
412 | + else { |
|
413 | 413 | |
414 | - if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
|
415 | - error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
416 | - } |
|
417 | - } |
|
414 | + if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
|
415 | + error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
416 | + } |
|
417 | + } |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
421 | - * init the log file (error_log) |
|
421 | + * init the log file (error_log) |
|
422 | 422 | * |
423 | - * @access private |
|
423 | + * @access private |
|
424 | 424 | * @return void |
425 | - */ |
|
425 | + */ |
|
426 | 426 | private static function _initLogFile() |
427 | 427 | { |
428 | - self::$_sFileLog = str_replace(DIRECTORY_SEPARATOR.'bundles'.DIRECTORY_SEPARATOR.'lib', '', __DIR__).DIRECTORY_SEPARATOR. |
|
429 | - "data".DIRECTORY_SEPARATOR."log".DIRECTORY_SEPARATOR."php-error.log"; |
|
428 | + self::$_sFileLog = str_replace(DIRECTORY_SEPARATOR.'bundles'.DIRECTORY_SEPARATOR.'lib', '', __DIR__).DIRECTORY_SEPARATOR. |
|
429 | + "data".DIRECTORY_SEPARATOR."log".DIRECTORY_SEPARATOR."php-error.log"; |
|
430 | 430 | |
431 | - ini_set("log_errors", 1); |
|
432 | - ini_set("error_log", self::$_sFileLog); |
|
431 | + ini_set("log_errors", 1); |
|
432 | + ini_set("error_log", self::$_sFileLog); |
|
433 | 433 | |
434 | - if (file_exists(self::$_sFileLog) === false) { file_put_contents(self::$_sFileLog, ''); } |
|
434 | + if (file_exists(self::$_sFileLog) === false) { file_put_contents(self::$_sFileLog, ''); } |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -254,8 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public static function setKindOfReportLog(string $sKindOfReportLog) |
256 | 256 | { |
257 | - if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } |
|
258 | - else { self::$_sKindOfReportLog = 'error_log'; } |
|
257 | + if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } else { self::$_sKindOfReportLog = 'error_log'; } |
|
259 | 258 | } |
260 | 259 | |
261 | 260 | /** |
@@ -278,12 +277,9 @@ discard block |
||
278 | 277 | */ |
279 | 278 | public static function getTranslateErrorCode(int $iCode) : string |
280 | 279 | { |
281 | - if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } |
|
282 | - else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } |
|
283 | - else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } |
|
284 | - else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } |
|
285 | - else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } |
|
286 | - else return LogLevel::DEBUG; |
|
280 | + if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } else { |
|
281 | + return LogLevel::DEBUG; |
|
282 | + } |
|
287 | 283 | } |
288 | 284 | |
289 | 285 | /** |
@@ -408,8 +404,7 @@ discard block |
||
408 | 404 | if (defined('BASH_CALLED')) { |
409 | 405 | |
410 | 406 | error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); |
411 | - } |
|
412 | - else { |
|
407 | + } else { |
|
413 | 408 | |
414 | 409 | if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
415 | 410 | error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | error_reporting($iLevel); |
153 | 153 | |
154 | - set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
154 | + set_error_handler(function($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
155 | 155 | { |
156 | 156 | $aContext = array('file' => $sErrFile, 'line' => $iErrLine); |
157 | 157 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | self::_initLogFile(); |
217 | 217 | self::$_bActivateException = true; |
218 | 218 | |
219 | - set_exception_handler(function (\Exception $oException) |
|
219 | + set_exception_handler(function(\Exception $oException) |
|
220 | 220 | { |
221 | 221 | $aContext = array('file' => $oException->getFile(), 'line' => $oException->getLine()); |
222 | 222 | self::getInstance()->critical($oException->getMessage(), $aContext); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | else { |
413 | 413 | |
414 | 414 | if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
415 | - error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
415 | + error_log(Bash::setColor('############### '.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].' ###############', 'cyan')); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | } |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Response constructor. |
200 | - */ |
|
200 | + */ |
|
201 | 201 | public function __construct() |
202 | 202 | { |
203 | 203 | /** |
204 | 204 | * @return \Venus\lib\Request |
205 | - */ |
|
205 | + */ |
|
206 | 206 | $this->headers = function() { $request = new Request(); return $request->headers; }; |
207 | 207 | } |
208 | 208 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | /** |
236 | 236 | * @return string |
237 | - */ |
|
237 | + */ |
|
238 | 238 | public function getContent() : string |
239 | 239 | { |
240 | 240 | return $this->content; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | /** |
244 | 244 | * @param string $content |
245 | 245 | * @return Response |
246 | - */ |
|
246 | + */ |
|
247 | 247 | public function setContent(string $content) : Response |
248 | 248 | { |
249 | 249 | $this->content = $content; |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @return int |
255 | - */ |
|
255 | + */ |
|
256 | 256 | public function getStatusCode() : int |
257 | 257 | { |
258 | 258 | return $this->statusCode; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | /** |
262 | 262 | * @param int $statusCode |
263 | 263 | * @return Response |
264 | - */ |
|
264 | + */ |
|
265 | 265 | public function setStatusCode(int $statusCode) : Response |
266 | 266 | { |
267 | 267 | $this->statusCode = $statusCode; |
@@ -227,9 +227,7 @@ |
||
227 | 227 | */ |
228 | 228 | public function translate($mContent) |
229 | 229 | { |
230 | - if (self::$_sKindOfReturn === 'yaml') { return Yaml::translate($mContent); } |
|
231 | - else if (self::$_sKindOfReturn === 'mock') { return Mock::translate($mContent); } |
|
232 | - else { return Json::translate($mContent); } |
|
230 | + if (self::$_sKindOfReturn === 'yaml') { return Yaml::translate($mContent); } else if (self::$_sKindOfReturn === 'mock') { return Mock::translate($mContent); } else { return Json::translate($mContent); } |
|
233 | 231 | } |
234 | 232 | |
235 | 233 | /** |
@@ -30,11 +30,11 @@ |
||
30 | 30 | */ |
31 | 31 | class Memory implements CacheInterface |
32 | 32 | { |
33 | - /** |
|
34 | - * A static variable to keep the cache |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - private static $_aMemories = array(); |
|
33 | + /** |
|
34 | + * A static variable to keep the cache |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + private static $_aMemories = array(); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * set a value |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * @param int $iTimeout expiration of cache |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
64 | + public function get(string $sName, int&$iFlags = null, int $iTimeout = 0) |
|
65 | 65 | { |
66 | 66 | return parent::get($sName); |
67 | 67 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @param int $iFlags flags |
50 | 50 | * @param int $iTimeout expiration of cache |
51 | 51 | */ |
52 | - public function get(string $sName, int &$iFlags = null, int $iTimeout = 0); |
|
52 | + public function get(string $sName, int&$iFlags = null, int $iTimeout = 0); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * delete a value |
@@ -31,44 +31,44 @@ |
||
31 | 31 | */ |
32 | 32 | class I18n extends CoreI18n |
33 | 33 | { |
34 | - /** |
|
35 | - * constructor |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @return \Venus\lib\I18n |
|
39 | - */ |
|
40 | - public function __construct() |
|
41 | - { |
|
42 | - $this->setI18nDirectory(__DIR__.DIRECTORY_SEPARATOR.I18N_DIRECTORY) |
|
43 | - ->setI18nDomain(I18N_DOMAIN) |
|
44 | - ->setIntermediaiteDirectory(DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR); |
|
34 | + /** |
|
35 | + * constructor |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @return \Venus\lib\I18n |
|
39 | + */ |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + $this->setI18nDirectory(__DIR__.DIRECTORY_SEPARATOR.I18N_DIRECTORY) |
|
43 | + ->setI18nDomain(I18N_DOMAIN) |
|
44 | + ->setIntermediaiteDirectory(DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR); |
|
45 | 45 | |
46 | - foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
46 | + foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
47 | 47 | |
48 | - if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'i18n'.DIRECTORY_SEPARATOR.$this->getLanguage().$this->getIntermediaiteDirectory().$sPlugin.'.json')) { |
|
48 | + if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'i18n'.DIRECTORY_SEPARATOR.$this->getLanguage().$this->getIntermediaiteDirectory().$sPlugin.'.json')) { |
|
49 | 49 | |
50 | - $oJson = json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'i18n'.DIRECTORY_SEPARATOR.$this->getLanguage().$this->getIntermediaiteDirectory().$sPlugin.'.json')); |
|
50 | + $oJson = json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'i18n'.DIRECTORY_SEPARATOR.$this->getLanguage().$this->getIntermediaiteDirectory().$sPlugin.'.json')); |
|
51 | 51 | |
52 | - $fCallBack = function($sValue) use ($oJson) |
|
53 | - { |
|
54 | - if (isset($oJson->$sValue)) { return $oJson->$sValue; } |
|
55 | - else { return ''; } |
|
56 | - }; |
|
57 | - } |
|
52 | + $fCallBack = function($sValue) use ($oJson) |
|
53 | + { |
|
54 | + if (isset($oJson->$sValue)) { return $oJson->$sValue; } |
|
55 | + else { return ''; } |
|
56 | + }; |
|
57 | + } |
|
58 | 58 | |
59 | - CoreI18n::addCallback($sPlugin, $fCallBack); |
|
60 | - } |
|
61 | - } |
|
59 | + CoreI18n::addCallback($sPlugin, $fCallBack); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Hilight to add the plugin I18N |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @param string $sValue value of text to traduct |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function _(string $sValue) : string |
|
71 | - { |
|
72 | - return $this->getText($sValue); |
|
73 | - } |
|
63 | + /** |
|
64 | + * Hilight to add the plugin I18N |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @param string $sValue value of text to traduct |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function _(string $sValue) : string |
|
71 | + { |
|
72 | + return $this->getText($sValue); |
|
73 | + } |
|
74 | 74 | } |
@@ -51,8 +51,7 @@ |
||
51 | 51 | |
52 | 52 | $fCallBack = function($sValue) use ($oJson) |
53 | 53 | { |
54 | - if (isset($oJson->$sValue)) { return $oJson->$sValue; } |
|
55 | - else { return ''; } |
|
54 | + if (isset($oJson->$sValue)) { return $oJson->$sValue; } else { return ''; } |
|
56 | 55 | }; |
57 | 56 | } |
58 | 57 |