@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | self::$_objects = []; |
49 | 49 | self::$_depth = $depth; |
50 | 50 | self::dumpInternal($var, 0); |
51 | - if($highlight) |
|
51 | + if ($highlight) |
|
52 | 52 | { |
53 | - $result = highlight_string("<?php\n" . self::$_output, true); |
|
53 | + $result = highlight_string("<?php\n".self::$_output, true); |
|
54 | 54 | return preg_replace('/<\\?php<br \\/>/', '', $result, 1); |
55 | 55 | } |
56 | 56 | else |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | |
60 | 60 | private static function dumpInternal($var, $level) |
61 | 61 | { |
62 | - switch(gettype($var)) |
|
62 | + switch (gettype($var)) |
|
63 | 63 | { |
64 | 64 | case 'boolean': |
65 | - self::$_output .= $var?'true':'false'; |
|
65 | + self::$_output .= $var ? 'true' : 'false'; |
|
66 | 66 | break; |
67 | 67 | case 'integer': |
68 | 68 | self::$_output .= "$var"; |
@@ -83,43 +83,43 @@ discard block |
||
83 | 83 | self::$_output .= '{unknown}'; |
84 | 84 | break; |
85 | 85 | case 'array': |
86 | - if(self::$_depth <= $level) |
|
86 | + if (self::$_depth <= $level) |
|
87 | 87 | self::$_output .= 'array(...)'; |
88 | - elseif(empty($var)) |
|
88 | + elseif (empty($var)) |
|
89 | 89 | self::$_output .= 'array()'; |
90 | 90 | else |
91 | 91 | { |
92 | 92 | $keys = array_keys($var); |
93 | 93 | $spaces = str_repeat(' ', $level * 4); |
94 | - self::$_output .= "array\n" . $spaces . '('; |
|
95 | - foreach($keys as $key) |
|
94 | + self::$_output .= "array\n".$spaces.'('; |
|
95 | + foreach ($keys as $key) |
|
96 | 96 | { |
97 | - self::$_output .= "\n" . $spaces . " [$key] => "; |
|
97 | + self::$_output .= "\n".$spaces." [$key] => "; |
|
98 | 98 | self::$_output .= self::dumpInternal($var[$key], $level + 1); |
99 | 99 | } |
100 | - self::$_output .= "\n" . $spaces . ')'; |
|
100 | + self::$_output .= "\n".$spaces.')'; |
|
101 | 101 | } |
102 | 102 | break; |
103 | 103 | case 'object': |
104 | - if(($id = array_search($var, self::$_objects, true)) !== false) |
|
105 | - self::$_output .= get_class($var) . '#' . ($id + 1) . '(...)'; |
|
106 | - elseif(self::$_depth <= $level) |
|
107 | - self::$_output .= get_class($var) . '(...)'; |
|
104 | + if (($id = array_search($var, self::$_objects, true)) !== false) |
|
105 | + self::$_output .= get_class($var).'#'.($id + 1).'(...)'; |
|
106 | + elseif (self::$_depth <= $level) |
|
107 | + self::$_output .= get_class($var).'(...)'; |
|
108 | 108 | else |
109 | 109 | { |
110 | 110 | $id = array_push(self::$_objects, $var); |
111 | 111 | $className = get_class($var); |
112 | - $members = (array)$var; |
|
112 | + $members = (array) $var; |
|
113 | 113 | $keys = array_keys($members); |
114 | 114 | $spaces = str_repeat(' ', $level * 4); |
115 | - self::$_output .= "$className#$id\n" . $spaces . '('; |
|
116 | - foreach($keys as $key) |
|
115 | + self::$_output .= "$className#$id\n".$spaces.'('; |
|
116 | + foreach ($keys as $key) |
|
117 | 117 | { |
118 | 118 | $keyDisplay = strtr(trim($key), ["\0" => ':']); |
119 | - self::$_output .= "\n" . $spaces . " [$keyDisplay] => "; |
|
119 | + self::$_output .= "\n".$spaces." [$keyDisplay] => "; |
|
120 | 120 | self::$_output .= self::dumpInternal($members[$key], $level + 1); |
121 | 121 | } |
122 | - self::$_output .= "\n" . $spaces . ')'; |
|
122 | + self::$_output .= "\n".$spaces.')'; |
|
123 | 123 | } |
124 | 124 | break; |
125 | 125 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | { |
53 | 53 | $result = highlight_string("<?php\n" . self::$_output, true); |
54 | 54 | return preg_replace('/<\\?php<br \\/>/', '', $result, 1); |
55 | + } else { |
|
56 | + return self::$_output; |
|
55 | 57 | } |
56 | - else |
|
57 | - return self::$_output; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | private static function dumpInternal($var, $level) |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | self::$_output .= '{unknown}'; |
84 | 84 | break; |
85 | 85 | case 'array': |
86 | - if(self::$_depth <= $level) |
|
87 | - self::$_output .= 'array(...)'; |
|
88 | - elseif(empty($var)) |
|
89 | - self::$_output .= 'array()'; |
|
90 | - else |
|
86 | + if(self::$_depth <= $level) { |
|
87 | + self::$_output .= 'array(...)'; |
|
88 | + } elseif(empty($var)) { |
|
89 | + self::$_output .= 'array()'; |
|
90 | + } else |
|
91 | 91 | { |
92 | 92 | $keys = array_keys($var); |
93 | 93 | $spaces = str_repeat(' ', $level * 4); |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | } |
102 | 102 | break; |
103 | 103 | case 'object': |
104 | - if(($id = array_search($var, self::$_objects, true)) !== false) |
|
105 | - self::$_output .= get_class($var) . '#' . ($id + 1) . '(...)'; |
|
106 | - elseif(self::$_depth <= $level) |
|
107 | - self::$_output .= get_class($var) . '(...)'; |
|
108 | - else |
|
104 | + if(($id = array_search($var, self::$_objects, true)) !== false) { |
|
105 | + self::$_output .= get_class($var) . '#' . ($id + 1) . '(...)'; |
|
106 | + } elseif(self::$_depth <= $level) { |
|
107 | + self::$_output .= get_class($var) . '(...)'; |
|
108 | + } else |
|
109 | 109 | { |
110 | 110 | $id = array_push(self::$_objects, $var); |
111 | 111 | $className = get_class($var); |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | { |
58 | 58 | try |
59 | 59 | { |
60 | - if(is_array($data) || ($data instanceof \ArrayAccess)) |
|
60 | + if (is_array($data) || ($data instanceof \ArrayAccess)) |
|
61 | 61 | { |
62 | - if(isset($data[$field])) |
|
62 | + if (isset($data[$field])) |
|
63 | 63 | return $data[$field]; |
64 | 64 | |
65 | 65 | $tmp = $data; |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | $tmp = $tmp[$f]; |
68 | 68 | return $tmp; |
69 | 69 | } |
70 | - elseif(is_object($data)) |
|
70 | + elseif (is_object($data)) |
|
71 | 71 | { |
72 | - if(strpos($field, '.') === false) // simple field |
|
72 | + if (strpos($field, '.') === false) // simple field |
|
73 | 73 | { |
74 | - if(method_exists($data, 'get' . $field)) |
|
75 | - return call_user_func([$data,'get' . $field]); |
|
74 | + if (method_exists($data, 'get'.$field)) |
|
75 | + return call_user_func([$data, 'get'.$field]); |
|
76 | 76 | else |
77 | 77 | return $data->{$field}; |
78 | 78 | } |
79 | 79 | else // field in the format of xxx.yyy.zzz |
80 | 80 | { |
81 | 81 | $object = $data; |
82 | - foreach(explode('.', $field) as $f) |
|
82 | + foreach (explode('.', $field) as $f) |
|
83 | 83 | $object = TDataFieldAccessor::getDataFieldValue($object, $f); |
84 | 84 | return $object; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
88 | - catch(Exception $e) |
|
88 | + catch (Exception $e) |
|
89 | 89 | { |
90 | 90 | throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage()); |
91 | 91 | } |
@@ -59,33 +59,35 @@ |
||
59 | 59 | { |
60 | 60 | if(is_array($data) || ($data instanceof \ArrayAccess)) |
61 | 61 | { |
62 | - if(isset($data[$field])) |
|
63 | - return $data[$field]; |
|
62 | + if(isset($data[$field])) { |
|
63 | + return $data[$field]; |
|
64 | + } |
|
64 | 65 | |
65 | 66 | $tmp = $data; |
66 | - foreach (explode(".", $field) as $f) |
|
67 | - $tmp = $tmp[$f]; |
|
67 | + foreach (explode(".", $field) as $f) { |
|
68 | + $tmp = $tmp[$f]; |
|
69 | + } |
|
68 | 70 | return $tmp; |
69 | - } |
|
70 | - elseif(is_object($data)) |
|
71 | + } elseif(is_object($data)) |
|
71 | 72 | { |
72 | - if(strpos($field, '.') === false) // simple field |
|
73 | + if(strpos($field, '.') === false) { |
|
74 | + // simple field |
|
73 | 75 | { |
74 | 76 | if(method_exists($data, 'get' . $field)) |
75 | 77 | return call_user_func([$data,'get' . $field]); |
76 | - else |
|
77 | - return $data->{$field}; |
|
78 | - } |
|
79 | - else // field in the format of xxx.yyy.zzz |
|
78 | + } else { |
|
79 | + return $data->{$field}; |
|
80 | + } |
|
81 | + } else // field in the format of xxx.yyy.zzz |
|
80 | 82 | { |
81 | 83 | $object = $data; |
82 | - foreach(explode('.', $field) as $f) |
|
83 | - $object = TDataFieldAccessor::getDataFieldValue($object, $f); |
|
84 | + foreach(explode('.', $field) as $f) { |
|
85 | + $object = TDataFieldAccessor::getDataFieldValue($object, $f); |
|
86 | + } |
|
84 | 87 | return $object; |
85 | 88 | } |
86 | 89 | } |
87 | - } |
|
88 | - catch(Exception $e) |
|
90 | + } catch(Exception $e) |
|
89 | 91 | { |
90 | 92 | throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage()); |
91 | 93 | } |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function log($message, $level, $category = 'Uncategorized', $ctl = null) |
71 | 71 | { |
72 | - if($ctl) { |
|
73 | - if($ctl instanceof TControl) |
|
72 | + if ($ctl) { |
|
73 | + if ($ctl instanceof TControl) |
|
74 | 74 | $ctl = $ctl->ClientId; |
75 | - elseif(!is_string($ctl)) |
|
75 | + elseif (!is_string($ctl)) |
|
76 | 76 | $ctl = null; |
77 | 77 | } else |
78 | 78 | $ctl = null; |
79 | - $this->_logs[] = [$message,$level,$category,microtime(true),memory_get_usage(),$ctl]; |
|
79 | + $this->_logs[] = [$message, $level, $category, microtime(true), memory_get_usage(), $ctl]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | $this->_categories = $categories; |
119 | 119 | $this->_controls = $controls; |
120 | 120 | $this->_timestamp = $timestamp; |
121 | - if(empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
121 | + if (empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
122 | 122 | return $this->_logs; |
123 | 123 | $logs = $this->_logs; |
124 | - if(!empty($levels)) |
|
125 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByLevels']))); |
|
126 | - if(!empty($categories)) |
|
127 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByCategories']))); |
|
128 | - if(!empty($controls)) |
|
129 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByControl']))); |
|
130 | - if(null !== $timestamp) |
|
131 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByTimeStamp']))); |
|
124 | + if (!empty($levels)) |
|
125 | + $logs = array_values(array_filter(array_filter($logs, [$this, 'filterByLevels']))); |
|
126 | + if (!empty($categories)) |
|
127 | + $logs = array_values(array_filter(array_filter($logs, [$this, 'filterByCategories']))); |
|
128 | + if (!empty($controls)) |
|
129 | + $logs = array_values(array_filter(array_filter($logs, [$this, 'filterByControl']))); |
|
130 | + if (null !== $timestamp) |
|
131 | + $logs = array_values(array_filter(array_filter($logs, [$this, 'filterByTimeStamp']))); |
|
132 | 132 | return $logs; |
133 | 133 | } |
134 | 134 | |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | $this->_categories = $categories; |
163 | 163 | $this->_controls = $controls; |
164 | 164 | $this->_timestamp = $timestamp; |
165 | - if(empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
165 | + if (empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
166 | 166 | { |
167 | 167 | $this->_logs = []; |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | $logs = $this->_logs; |
171 | - if(!empty($levels)) |
|
172 | - $logs = array_filter(array_filter($logs, [$this,'filterByLevels'])); |
|
173 | - if(!empty($categories)) |
|
174 | - $logs = array_filter(array_filter($logs, [$this,'filterByCategories'])); |
|
175 | - if(!empty($controls)) |
|
176 | - $logs = array_filter(array_filter($logs, [$this,'filterByControl'])); |
|
177 | - if(null !== $timestamp) |
|
178 | - $logs = array_filter(array_filter($logs, [$this,'filterByTimeStamp'])); |
|
171 | + if (!empty($levels)) |
|
172 | + $logs = array_filter(array_filter($logs, [$this, 'filterByLevels'])); |
|
173 | + if (!empty($categories)) |
|
174 | + $logs = array_filter(array_filter($logs, [$this, 'filterByCategories'])); |
|
175 | + if (!empty($controls)) |
|
176 | + $logs = array_filter(array_filter($logs, [$this, 'filterByControl'])); |
|
177 | + if (null !== $timestamp) |
|
178 | + $logs = array_filter(array_filter($logs, [$this, 'filterByTimeStamp'])); |
|
179 | 179 | $this->_logs = array_values(array_diff_key($this->_logs, $logs)); |
180 | 180 | } |
181 | 181 | |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | */ |
186 | 186 | private function filterByCategories($value) |
187 | 187 | { |
188 | - foreach($this->_categories as $category) |
|
188 | + foreach ($this->_categories as $category) |
|
189 | 189 | { |
190 | 190 | // element 2 is the category |
191 | - if($value[2] === $category || strpos($value[2], $category . '.') === 0) |
|
191 | + if ($value[2] === $category || strpos($value[2], $category.'.') === 0) |
|
192 | 192 | return $value; |
193 | 193 | } |
194 | 194 | return false; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | private function filterByLevels($value) |
202 | 202 | { |
203 | 203 | // element 1 are the levels |
204 | - if($value[1] & $this->_levels) |
|
204 | + if ($value[1] & $this->_levels) |
|
205 | 205 | return $value; |
206 | 206 | else |
207 | 207 | return false; |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | private function filterByControl($value) |
215 | 215 | { |
216 | 216 | // element 5 are the control client ids |
217 | - foreach($this->_controls as $control) |
|
217 | + foreach ($this->_controls as $control) |
|
218 | 218 | { |
219 | - if($value[5] === $control || strpos($value[5], $control) === 0) |
|
219 | + if ($value[5] === $control || strpos($value[5], $control) === 0) |
|
220 | 220 | return $value; |
221 | 221 | } |
222 | 222 | return false; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | private function filterByTimeStamp($value) |
230 | 230 | { |
231 | 231 | // element 3 is the timestamp |
232 | - if($value[3] <= $this->_timestamp) |
|
232 | + if ($value[3] <= $this->_timestamp) |
|
233 | 233 | return $value; |
234 | 234 | else |
235 | 235 | return false; |
@@ -70,12 +70,14 @@ discard block |
||
70 | 70 | public function log($message, $level, $category = 'Uncategorized', $ctl = null) |
71 | 71 | { |
72 | 72 | if($ctl) { |
73 | - if($ctl instanceof TControl) |
|
74 | - $ctl = $ctl->ClientId; |
|
75 | - elseif(!is_string($ctl)) |
|
76 | - $ctl = null; |
|
77 | - } else |
|
78 | - $ctl = null; |
|
73 | + if($ctl instanceof TControl) { |
|
74 | + $ctl = $ctl->ClientId; |
|
75 | + } elseif(!is_string($ctl)) { |
|
76 | + $ctl = null; |
|
77 | + } |
|
78 | + } else { |
|
79 | + $ctl = null; |
|
80 | + } |
|
79 | 81 | $this->_logs[] = [$message,$level,$category,microtime(true),memory_get_usage(),$ctl]; |
80 | 82 | } |
81 | 83 | |
@@ -118,17 +120,22 @@ discard block |
||
118 | 120 | $this->_categories = $categories; |
119 | 121 | $this->_controls = $controls; |
120 | 122 | $this->_timestamp = $timestamp; |
121 | - if(empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
122 | - return $this->_logs; |
|
123 | + if(empty($levels) && empty($categories) && empty($controls) && null === $timestamp) { |
|
124 | + return $this->_logs; |
|
125 | + } |
|
123 | 126 | $logs = $this->_logs; |
124 | - if(!empty($levels)) |
|
125 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByLevels']))); |
|
126 | - if(!empty($categories)) |
|
127 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByCategories']))); |
|
128 | - if(!empty($controls)) |
|
129 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByControl']))); |
|
130 | - if(null !== $timestamp) |
|
131 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByTimeStamp']))); |
|
127 | + if(!empty($levels)) { |
|
128 | + $logs = array_values(array_filter(array_filter($logs, [$this,'filterByLevels']))); |
|
129 | + } |
|
130 | + if(!empty($categories)) { |
|
131 | + $logs = array_values(array_filter(array_filter($logs, [$this,'filterByCategories']))); |
|
132 | + } |
|
133 | + if(!empty($controls)) { |
|
134 | + $logs = array_values(array_filter(array_filter($logs, [$this,'filterByControl']))); |
|
135 | + } |
|
136 | + if(null !== $timestamp) { |
|
137 | + $logs = array_values(array_filter(array_filter($logs, [$this,'filterByTimeStamp']))); |
|
138 | + } |
|
132 | 139 | return $logs; |
133 | 140 | } |
134 | 141 | |
@@ -168,14 +175,18 @@ discard block |
||
168 | 175 | return; |
169 | 176 | } |
170 | 177 | $logs = $this->_logs; |
171 | - if(!empty($levels)) |
|
172 | - $logs = array_filter(array_filter($logs, [$this,'filterByLevels'])); |
|
173 | - if(!empty($categories)) |
|
174 | - $logs = array_filter(array_filter($logs, [$this,'filterByCategories'])); |
|
175 | - if(!empty($controls)) |
|
176 | - $logs = array_filter(array_filter($logs, [$this,'filterByControl'])); |
|
177 | - if(null !== $timestamp) |
|
178 | - $logs = array_filter(array_filter($logs, [$this,'filterByTimeStamp'])); |
|
178 | + if(!empty($levels)) { |
|
179 | + $logs = array_filter(array_filter($logs, [$this,'filterByLevels'])); |
|
180 | + } |
|
181 | + if(!empty($categories)) { |
|
182 | + $logs = array_filter(array_filter($logs, [$this,'filterByCategories'])); |
|
183 | + } |
|
184 | + if(!empty($controls)) { |
|
185 | + $logs = array_filter(array_filter($logs, [$this,'filterByControl'])); |
|
186 | + } |
|
187 | + if(null !== $timestamp) { |
|
188 | + $logs = array_filter(array_filter($logs, [$this,'filterByTimeStamp'])); |
|
189 | + } |
|
179 | 190 | $this->_logs = array_values(array_diff_key($this->_logs, $logs)); |
180 | 191 | } |
181 | 192 | |
@@ -188,8 +199,9 @@ discard block |
||
188 | 199 | foreach($this->_categories as $category) |
189 | 200 | { |
190 | 201 | // element 2 is the category |
191 | - if($value[2] === $category || strpos($value[2], $category . '.') === 0) |
|
192 | - return $value; |
|
202 | + if($value[2] === $category || strpos($value[2], $category . '.') === 0) { |
|
203 | + return $value; |
|
204 | + } |
|
193 | 205 | } |
194 | 206 | return false; |
195 | 207 | } |
@@ -201,10 +213,11 @@ discard block |
||
201 | 213 | private function filterByLevels($value) |
202 | 214 | { |
203 | 215 | // element 1 are the levels |
204 | - if($value[1] & $this->_levels) |
|
205 | - return $value; |
|
206 | - else |
|
207 | - return false; |
|
216 | + if($value[1] & $this->_levels) { |
|
217 | + return $value; |
|
218 | + } else { |
|
219 | + return false; |
|
220 | + } |
|
208 | 221 | } |
209 | 222 | |
210 | 223 | /** |
@@ -216,8 +229,9 @@ discard block |
||
216 | 229 | // element 5 are the control client ids |
217 | 230 | foreach($this->_controls as $control) |
218 | 231 | { |
219 | - if($value[5] === $control || strpos($value[5], $control) === 0) |
|
220 | - return $value; |
|
232 | + if($value[5] === $control || strpos($value[5], $control) === 0) { |
|
233 | + return $value; |
|
234 | + } |
|
221 | 235 | } |
222 | 236 | return false; |
223 | 237 | } |
@@ -229,10 +243,11 @@ discard block |
||
229 | 243 | private function filterByTimeStamp($value) |
230 | 244 | { |
231 | 245 | // element 3 is the timestamp |
232 | - if($value[3] <= $this->_timestamp) |
|
233 | - return $value; |
|
234 | - else |
|
235 | - return false; |
|
246 | + if($value[3] <= $this->_timestamp) { |
|
247 | + return $value; |
|
248 | + } else { |
|
249 | + return false; |
|
250 | + } |
|
236 | 251 | } |
237 | 252 | } |
238 | 253 |
@@ -127,31 +127,31 @@ discard block |
||
127 | 127 | |
128 | 128 | public function getMonthPattern() |
129 | 129 | { |
130 | - if(is_int(strpos($this->pattern, 'MMMM'))) |
|
130 | + if (is_int(strpos($this->pattern, 'MMMM'))) |
|
131 | 131 | return 'MMMM'; |
132 | - if(is_int(strpos($this->pattern, 'MMM'))) |
|
132 | + if (is_int(strpos($this->pattern, 'MMM'))) |
|
133 | 133 | return 'MMM'; |
134 | - if(is_int(strpos($this->pattern, 'MM'))) |
|
134 | + if (is_int(strpos($this->pattern, 'MM'))) |
|
135 | 135 | return 'MM'; |
136 | - if(is_int(strpos($this->pattern, 'M'))) |
|
136 | + if (is_int(strpos($this->pattern, 'M'))) |
|
137 | 137 | return 'M'; |
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function getDayPattern() |
142 | 142 | { |
143 | - if(is_int(strpos($this->pattern, 'dd'))) |
|
143 | + if (is_int(strpos($this->pattern, 'dd'))) |
|
144 | 144 | return 'dd'; |
145 | - if(is_int(strpos($this->pattern, 'd'))) |
|
145 | + if (is_int(strpos($this->pattern, 'd'))) |
|
146 | 146 | return 'd'; |
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function getYearPattern() |
151 | 151 | { |
152 | - if(is_int(strpos($this->pattern, 'yyyy'))) |
|
152 | + if (is_int(strpos($this->pattern, 'yyyy'))) |
|
153 | 153 | return 'yyyy'; |
154 | - if(is_int(strpos($this->pattern, 'yy'))) |
|
154 | + if (is_int(strpos($this->pattern, 'yy'))) |
|
155 | 155 | return 'yy'; |
156 | 156 | return false; |
157 | 157 | } |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | public function getDayMonthYearOrdering() |
160 | 160 | { |
161 | 161 | $ordering = []; |
162 | - if(is_int($day = strpos($this->pattern, 'd'))) |
|
162 | + if (is_int($day = strpos($this->pattern, 'd'))) |
|
163 | 163 | $ordering['day'] = $day; |
164 | - if(is_int($month = strpos($this->pattern, 'M'))) |
|
164 | + if (is_int($month = strpos($this->pattern, 'M'))) |
|
165 | 165 | $ordering['month'] = $month; |
166 | - if(is_int($year = strpos($this->pattern, 'yy'))) |
|
166 | + if (is_int($year = strpos($this->pattern, 'yy'))) |
|
167 | 167 | $ordering['year'] = $year; |
168 | 168 | asort($ordering); |
169 | 169 | return array_keys($ordering); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function getDate($value) |
178 | 178 | { |
179 | - if(is_numeric($value)) |
|
179 | + if (is_numeric($value)) |
|
180 | 180 | { |
181 | 181 | $date = new \DateTime; |
182 | 182 | $date->setTimeStamp($value); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function isValidDate($value) |
193 | 193 | { |
194 | - if($value === null) { |
|
194 | + if ($value === null) { |
|
195 | 195 | return false; |
196 | 196 | } else { |
197 | 197 | return $this->parse($value, false) !== null; |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function parse($value, $defaultToCurrentTime = true) |
208 | 208 | { |
209 | - if(is_int($value) || is_float($value)) |
|
209 | + if (is_int($value) || is_float($value)) |
|
210 | 210 | return $value; |
211 | - elseif(!is_string($value)) |
|
211 | + elseif (!is_string($value)) |
|
212 | 212 | throw new TInvalidDataValueException('date_to_parse_must_be_string', $value); |
213 | 213 | |
214 | - if(empty($this->pattern)) return time(); |
|
214 | + if (empty($this->pattern)) return time(); |
|
215 | 215 | |
216 | 216 | $date = time(); |
217 | 217 | |
218 | - if($this->length(trim($value)) < 1) |
|
218 | + if ($this->length(trim($value)) < 1) |
|
219 | 219 | return $defaultToCurrentTime ? $date : null; |
220 | 220 | |
221 | 221 | $pattern = $this->pattern; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $x = null; $y = null; |
229 | 229 | |
230 | 230 | |
231 | - if($defaultToCurrentTime) |
|
231 | + if ($defaultToCurrentTime) |
|
232 | 232 | { |
233 | 233 | $year = "{$date['year']}"; |
234 | 234 | $month = $date['mon']; |
@@ -253,30 +253,30 @@ discard block |
||
253 | 253 | |
254 | 254 | if ($token == 'yyyy' || $token == 'yy' || $token == 'y') |
255 | 255 | { |
256 | - if ($token == 'yyyy') { $x = 4;$y = 4; } |
|
257 | - if ($token == 'yy') { $x = 2;$y = 2; } |
|
258 | - if ($token == 'y') { $x = 2;$y = 4; } |
|
256 | + if ($token == 'yyyy') { $x = 4; $y = 4; } |
|
257 | + if ($token == 'yy') { $x = 2; $y = 2; } |
|
258 | + if ($token == 'y') { $x = 2; $y = 4; } |
|
259 | 259 | $year = $this->getInteger($value, $i_val, $x, $y); |
260 | - if($year === null) |
|
260 | + if ($year === null) |
|
261 | 261 | return null; |
262 | 262 | //throw new TInvalidDataValueException('Invalid year', $value); |
263 | 263 | $i_val += strlen($year); |
264 | - if(strlen($year) == 2) |
|
264 | + if (strlen($year) == 2) |
|
265 | 265 | { |
266 | - $iYear = (int)$year; |
|
267 | - if($iYear > 70) |
|
266 | + $iYear = (int) $year; |
|
267 | + if ($iYear > 70) |
|
268 | 268 | $year = $iYear + 1900; |
269 | 269 | else |
270 | 270 | $year = $iYear + 2000; |
271 | 271 | } |
272 | - $year = (int)$year; |
|
272 | + $year = (int) $year; |
|
273 | 273 | } |
274 | - elseif($token == 'MM' || $token == 'M') |
|
274 | + elseif ($token == 'MM' || $token == 'M') |
|
275 | 275 | { |
276 | - $month = $this->getInteger($value,$i_val, |
|
276 | + $month = $this->getInteger($value, $i_val, |
|
277 | 277 | $this->length($token), 2); |
278 | - $iMonth = (int)$month; |
|
279 | - if($month === null || $iMonth < 1 || $iMonth > 12) |
|
278 | + $iMonth = (int) $month; |
|
279 | + if ($month === null || $iMonth < 1 || $iMonth > 12) |
|
280 | 280 | return null; |
281 | 281 | //throw new TInvalidDataValueException('Invalid month', $value); |
282 | 282 | $i_val += strlen($month); |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | } |
285 | 285 | elseif ($token == 'dd' || $token == 'd') |
286 | 286 | { |
287 | - $day = $this->getInteger($value,$i_val, |
|
287 | + $day = $this->getInteger($value, $i_val, |
|
288 | 288 | $this->length($token), 2); |
289 | - $iDay = (int)$day; |
|
290 | - if($day === null || $iDay < 1 || $iDay > 31) |
|
289 | + $iDay = (int) $day; |
|
290 | + if ($day === null || $iDay < 1 || $iDay > 31) |
|
291 | 291 | return null; |
292 | 292 | //throw new TInvalidDataValueException('Invalid day', $value); |
293 | 293 | $i_val += strlen($day); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
298 | + if ($this->substring($value, $i_val, $this->length($token)) != $token) |
|
299 | 299 | return null; |
300 | 300 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
301 | 301 | else |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | if ($i_val != $this->length($value)) |
306 | 306 | return null; |
307 | 307 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
308 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
308 | + if (!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
309 | 309 | return null; |
310 | 310 | else |
311 | 311 | { |
312 | - if(empty($year)) { |
|
312 | + if (empty($year)) { |
|
313 | 313 | $year = date('Y'); |
314 | 314 | } |
315 | - $day = (int)$day <= 0 ? 1 : (int)$day; |
|
316 | - $month = (int)$month <= 0 ? 1 : (int)$month; |
|
315 | + $day = (int) $day <= 0 ? 1 : (int) $day; |
|
316 | + $month = (int) $month <= 0 ? 1 : (int) $month; |
|
317 | 317 | |
318 | 318 | $s = new \DateTime; |
319 | 319 | $s->setDate($year, $month, $day); |
@@ -127,44 +127,55 @@ discard block |
||
127 | 127 | |
128 | 128 | public function getMonthPattern() |
129 | 129 | { |
130 | - if(is_int(strpos($this->pattern, 'MMMM'))) |
|
131 | - return 'MMMM'; |
|
132 | - if(is_int(strpos($this->pattern, 'MMM'))) |
|
133 | - return 'MMM'; |
|
134 | - if(is_int(strpos($this->pattern, 'MM'))) |
|
135 | - return 'MM'; |
|
136 | - if(is_int(strpos($this->pattern, 'M'))) |
|
137 | - return 'M'; |
|
130 | + if(is_int(strpos($this->pattern, 'MMMM'))) { |
|
131 | + return 'MMMM'; |
|
132 | + } |
|
133 | + if(is_int(strpos($this->pattern, 'MMM'))) { |
|
134 | + return 'MMM'; |
|
135 | + } |
|
136 | + if(is_int(strpos($this->pattern, 'MM'))) { |
|
137 | + return 'MM'; |
|
138 | + } |
|
139 | + if(is_int(strpos($this->pattern, 'M'))) { |
|
140 | + return 'M'; |
|
141 | + } |
|
138 | 142 | return false; |
139 | 143 | } |
140 | 144 | |
141 | 145 | public function getDayPattern() |
142 | 146 | { |
143 | - if(is_int(strpos($this->pattern, 'dd'))) |
|
144 | - return 'dd'; |
|
145 | - if(is_int(strpos($this->pattern, 'd'))) |
|
146 | - return 'd'; |
|
147 | + if(is_int(strpos($this->pattern, 'dd'))) { |
|
148 | + return 'dd'; |
|
149 | + } |
|
150 | + if(is_int(strpos($this->pattern, 'd'))) { |
|
151 | + return 'd'; |
|
152 | + } |
|
147 | 153 | return false; |
148 | 154 | } |
149 | 155 | |
150 | 156 | public function getYearPattern() |
151 | 157 | { |
152 | - if(is_int(strpos($this->pattern, 'yyyy'))) |
|
153 | - return 'yyyy'; |
|
154 | - if(is_int(strpos($this->pattern, 'yy'))) |
|
155 | - return 'yy'; |
|
158 | + if(is_int(strpos($this->pattern, 'yyyy'))) { |
|
159 | + return 'yyyy'; |
|
160 | + } |
|
161 | + if(is_int(strpos($this->pattern, 'yy'))) { |
|
162 | + return 'yy'; |
|
163 | + } |
|
156 | 164 | return false; |
157 | 165 | } |
158 | 166 | |
159 | 167 | public function getDayMonthYearOrdering() |
160 | 168 | { |
161 | 169 | $ordering = []; |
162 | - if(is_int($day = strpos($this->pattern, 'd'))) |
|
163 | - $ordering['day'] = $day; |
|
164 | - if(is_int($month = strpos($this->pattern, 'M'))) |
|
165 | - $ordering['month'] = $month; |
|
166 | - if(is_int($year = strpos($this->pattern, 'yy'))) |
|
167 | - $ordering['year'] = $year; |
|
170 | + if(is_int($day = strpos($this->pattern, 'd'))) { |
|
171 | + $ordering['day'] = $day; |
|
172 | + } |
|
173 | + if(is_int($month = strpos($this->pattern, 'M'))) { |
|
174 | + $ordering['month'] = $month; |
|
175 | + } |
|
176 | + if(is_int($year = strpos($this->pattern, 'yy'))) { |
|
177 | + $ordering['year'] = $year; |
|
178 | + } |
|
168 | 179 | asort($ordering); |
169 | 180 | return array_keys($ordering); |
170 | 181 | } |
@@ -206,17 +217,21 @@ discard block |
||
206 | 217 | */ |
207 | 218 | public function parse($value, $defaultToCurrentTime = true) |
208 | 219 | { |
209 | - if(is_int($value) || is_float($value)) |
|
210 | - return $value; |
|
211 | - elseif(!is_string($value)) |
|
212 | - throw new TInvalidDataValueException('date_to_parse_must_be_string', $value); |
|
220 | + if(is_int($value) || is_float($value)) { |
|
221 | + return $value; |
|
222 | + } elseif(!is_string($value)) { |
|
223 | + throw new TInvalidDataValueException('date_to_parse_must_be_string', $value); |
|
224 | + } |
|
213 | 225 | |
214 | - if(empty($this->pattern)) return time(); |
|
226 | + if(empty($this->pattern)) { |
|
227 | + return time(); |
|
228 | + } |
|
215 | 229 | |
216 | 230 | $date = time(); |
217 | 231 | |
218 | - if($this->length(trim($value)) < 1) |
|
219 | - return $defaultToCurrentTime ? $date : null; |
|
232 | + if($this->length(trim($value)) < 1) { |
|
233 | + return $defaultToCurrentTime ? $date : null; |
|
234 | + } |
|
220 | 235 | |
221 | 236 | $pattern = $this->pattern; |
222 | 237 | |
@@ -233,8 +248,7 @@ discard block |
||
233 | 248 | $year = "{$date['year']}"; |
234 | 249 | $month = $date['mon']; |
235 | 250 | $day = $date['mday']; |
236 | - } |
|
237 | - else |
|
251 | + } else |
|
238 | 252 | { |
239 | 253 | $year = null; |
240 | 254 | $month = null; |
@@ -257,57 +271,61 @@ discard block |
||
257 | 271 | if ($token == 'yy') { $x = 2;$y = 2; } |
258 | 272 | if ($token == 'y') { $x = 2;$y = 4; } |
259 | 273 | $year = $this->getInteger($value, $i_val, $x, $y); |
260 | - if($year === null) |
|
261 | - return null; |
|
274 | + if($year === null) { |
|
275 | + return null; |
|
276 | + } |
|
262 | 277 | //throw new TInvalidDataValueException('Invalid year', $value); |
263 | 278 | $i_val += strlen($year); |
264 | 279 | if(strlen($year) == 2) |
265 | 280 | { |
266 | 281 | $iYear = (int)$year; |
267 | - if($iYear > 70) |
|
268 | - $year = $iYear + 1900; |
|
269 | - else |
|
270 | - $year = $iYear + 2000; |
|
282 | + if($iYear > 70) { |
|
283 | + $year = $iYear + 1900; |
|
284 | + } else { |
|
285 | + $year = $iYear + 2000; |
|
286 | + } |
|
271 | 287 | } |
272 | 288 | $year = (int)$year; |
273 | - } |
|
274 | - elseif($token == 'MM' || $token == 'M') |
|
289 | + } elseif($token == 'MM' || $token == 'M') |
|
275 | 290 | { |
276 | 291 | $month = $this->getInteger($value,$i_val, |
277 | 292 | $this->length($token), 2); |
278 | 293 | $iMonth = (int)$month; |
279 | - if($month === null || $iMonth < 1 || $iMonth > 12) |
|
280 | - return null; |
|
294 | + if($month === null || $iMonth < 1 || $iMonth > 12) { |
|
295 | + return null; |
|
296 | + } |
|
281 | 297 | //throw new TInvalidDataValueException('Invalid month', $value); |
282 | 298 | $i_val += strlen($month); |
283 | 299 | $month = $iMonth; |
284 | - } |
|
285 | - elseif ($token == 'dd' || $token == 'd') |
|
300 | + } elseif ($token == 'dd' || $token == 'd') |
|
286 | 301 | { |
287 | 302 | $day = $this->getInteger($value,$i_val, |
288 | 303 | $this->length($token), 2); |
289 | 304 | $iDay = (int)$day; |
290 | - if($day === null || $iDay < 1 || $iDay > 31) |
|
291 | - return null; |
|
305 | + if($day === null || $iDay < 1 || $iDay > 31) { |
|
306 | + return null; |
|
307 | + } |
|
292 | 308 | //throw new TInvalidDataValueException('Invalid day', $value); |
293 | 309 | $i_val += strlen($day); |
294 | 310 | $day = $iDay; |
295 | - } |
|
296 | - else |
|
311 | + } else |
|
297 | 312 | { |
298 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
299 | - return null; |
|
313 | + if($this->substring($value, $i_val, $this->length($token)) != $token) { |
|
314 | + return null; |
|
315 | + } |
|
300 | 316 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
301 | - else |
|
302 | - $i_val += $this->length($token); |
|
317 | + else { |
|
318 | + $i_val += $this->length($token); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | - if ($i_val != $this->length($value)) |
|
306 | - return null; |
|
322 | + if ($i_val != $this->length($value)) { |
|
323 | + return null; |
|
324 | + } |
|
307 | 325 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
308 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
309 | - return null; |
|
310 | - else |
|
326 | + if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) { |
|
327 | + return null; |
|
328 | + } else |
|
311 | 329 | { |
312 | 330 | if(empty($year)) { |
313 | 331 | $year = date('Y'); |
@@ -369,10 +387,12 @@ discard block |
||
369 | 387 | for ($x = $maxlength; $x >= $minlength; $x--) |
370 | 388 | { |
371 | 389 | $token = $this->substring($str, $i, $x); |
372 | - if ($this->length($token) < $minlength) |
|
373 | - return null; |
|
374 | - if (preg_match('/^\d+$/', $token)) |
|
375 | - return $token; |
|
390 | + if ($this->length($token) < $minlength) { |
|
391 | + return null; |
|
392 | + } |
|
393 | + if (preg_match('/^\d+$/', $token)) { |
|
394 | + return $token; |
|
395 | + } |
|
376 | 396 | } |
377 | 397 | return null; |
378 | 398 | } |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | |
37 | 37 | public function processLogs($logs) |
38 | 38 | { |
39 | - if(empty($logs) || $this->getApplication()->getMode() === 'Performance') |
|
39 | + if (empty($logs) || $this->getApplication()->getMode() === 'Performance') |
|
40 | 40 | return; |
41 | 41 | |
42 | - if(headers_sent()) { |
|
42 | + if (headers_sent()) { |
|
43 | 43 | echo ' |
44 | 44 | <div style="width:100%; background-color:darkred; color:#FFF; padding:2px"> |
45 | - TFirePhpLogRoute.GroupLabel "<i>' . $this -> getGroupLabel() . '</i>" - |
|
45 | + TFirePhpLogRoute.GroupLabel "<i>' . $this -> getGroupLabel().'</i>" - |
|
46 | 46 | Routing to FirePHP impossible, because headers already sent! |
47 | 47 | </div> |
48 | 48 | '; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $first = $logs[0][3]; |
60 | 60 | $c = count($logs); |
61 | - for($i = 0,$n = $c;$i < $n;++$i) |
|
61 | + for ($i = 0, $n = $c; $i < $n; ++$i) |
|
62 | 62 | { |
63 | 63 | $message = $logs[$i][0]; |
64 | 64 | $level = $logs[$i][1]; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected static function translateLogLevel($level) |
91 | 91 | { |
92 | - switch($level) |
|
92 | + switch ($level) |
|
93 | 93 | { |
94 | 94 | case TLogger::INFO: |
95 | 95 | return FirePHP::INFO; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function getGroupLabel() |
114 | 114 | { |
115 | - if($this->_groupLabel === null) |
|
115 | + if ($this->_groupLabel === null) |
|
116 | 116 | $this->_groupLabel = self::DEFAULT_LABEL; |
117 | 117 | |
118 | 118 | return $this->_groupLabel; |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | public function processLogs($logs) |
38 | 38 | { |
39 | - if(empty($logs) || $this->getApplication()->getMode() === 'Performance') |
|
40 | - return; |
|
39 | + if(empty($logs) || $this->getApplication()->getMode() === 'Performance') { |
|
40 | + return; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | if(headers_sent()) { |
43 | 44 | echo ' |
@@ -68,8 +69,7 @@ discard block |
||
68 | 69 | { |
69 | 70 | $delta = $logs[$i + 1][3] - $logs[$i][3]; |
70 | 71 | $total = $logs[$i + 1][3] - $first; |
71 | - } |
|
72 | - else |
|
72 | + } else |
|
73 | 73 | { |
74 | 74 | $delta = '?'; |
75 | 75 | $total = $logs[$i][3] - $first; |
@@ -112,8 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function getGroupLabel() |
114 | 114 | { |
115 | - if($this->_groupLabel === null) |
|
116 | - $this->_groupLabel = self::DEFAULT_LABEL; |
|
115 | + if($this->_groupLabel === null) { |
|
116 | + $this->_groupLabel = self::DEFAULT_LABEL; |
|
117 | + } |
|
117 | 118 | |
118 | 119 | return $this->_groupLabel; |
119 | 120 | } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | public function processLogs($logs) |
34 | 34 | { |
35 | - if(empty($logs) || $this->getApplication()->getMode() === 'Performance') return; |
|
35 | + if (empty($logs) || $this->getApplication()->getMode() === 'Performance') return; |
|
36 | 36 | $first = $logs[0][3]; |
37 | 37 | $even = true; |
38 | 38 | $response = $this->getApplication()->getResponse(); |
39 | 39 | $response->write($this->renderHeader()); |
40 | - for($i = 0,$n = count($logs);$i < $n;++$i) |
|
40 | + for ($i = 0, $n = count($logs); $i < $n; ++$i) |
|
41 | 41 | { |
42 | 42 | if ($i < $n - 1) |
43 | 43 | { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function renderHeader() |
75 | 75 | { |
76 | 76 | $string = ''; |
77 | - if($className = $this->getCssClass()) |
|
77 | + if ($className = $this->getCssClass()) |
|
78 | 78 | { |
79 | 79 | $string = <<<EOD |
80 | 80 | <table class="$className"> |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $delta = sprintf('%0.6f', $info['delta']); |
113 | 113 | $msg = preg_replace('/\(line[^\)]+\)$/', '', $log[0]); //remove line number info |
114 | 114 | $msg = THttpUtility::htmlEncode($msg); |
115 | - if($this->getCssClass()) |
|
115 | + if ($this->getCssClass()) |
|
116 | 116 | { |
117 | 117 | $colorCssClass = $log[1]; |
118 | 118 | $messageCssClass = $info['even'] ? 'even' : 'odd'; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | protected function getColorLevel($level) |
147 | 147 | { |
148 | - switch($level) |
|
148 | + switch ($level) |
|
149 | 149 | { |
150 | 150 | case TLogger::DEBUG: return 'green'; |
151 | 151 | case TLogger::INFO: return 'black'; |
@@ -161,21 +161,21 @@ discard block |
||
161 | 161 | protected function renderFooter() |
162 | 162 | { |
163 | 163 | $string = ''; |
164 | - if($this->getCssClass()) |
|
164 | + if ($this->getCssClass()) |
|
165 | 165 | { |
166 | 166 | $string .= '<tr class="footer"><td colspan="5">'; |
167 | - foreach(self::$_levelValues as $name => $level) |
|
167 | + foreach (self::$_levelValues as $name => $level) |
|
168 | 168 | { |
169 | - $string .= '<span class="level' . $level . '">' . strtoupper($name) . "</span>"; |
|
169 | + $string .= '<span class="level'.$level.'">'.strtoupper($name)."</span>"; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | else |
173 | 173 | { |
174 | 174 | $string .= "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">"; |
175 | - foreach(self::$_levelValues as $name => $level) |
|
175 | + foreach (self::$_levelValues as $name => $level) |
|
176 | 176 | { |
177 | - $string .= "<span style=\"color:white; border:1px solid white; background-color:" . $this->getColorLevel($level); |
|
178 | - $string .= ";margin: 0.5em; padding:0.01em;\">" . strtoupper($name) . "</span>"; |
|
177 | + $string .= "<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level); |
|
178 | + $string .= ";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>"; |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | $string .= '</td></tr></table>'; |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | public function processLogs($logs) |
34 | 34 | { |
35 | - if(empty($logs) || $this->getApplication()->getMode() === 'Performance') return; |
|
35 | + if(empty($logs) || $this->getApplication()->getMode() === 'Performance') { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | $first = $logs[0][3]; |
37 | 39 | $even = true; |
38 | 40 | $response = $this->getApplication()->getResponse(); |
@@ -43,8 +45,7 @@ discard block |
||
43 | 45 | { |
44 | 46 | $timing['delta'] = $logs[$i + 1][3] - $logs[$i][3]; |
45 | 47 | $timing['total'] = $logs[$i + 1][3] - $first; |
46 | - } |
|
47 | - else |
|
48 | + } else |
|
48 | 49 | { |
49 | 50 | $timing['delta'] = '?'; |
50 | 51 | $timing['total'] = $logs[$i][3] - $first; |
@@ -87,8 +88,7 @@ discard block |
||
87 | 88 | <th>Category</th><th>Message</th><th>Time Spent (s)</th><th>Cumulated Time Spent (s)</th> |
88 | 89 | </tr> |
89 | 90 | EOD; |
90 | - } |
|
91 | - else |
|
91 | + } else |
|
92 | 92 | { |
93 | 93 | $string = <<<EOD |
94 | 94 | <table cellspacing="0" cellpadding="2" border="0" width="100%" style="table-layout:auto"> |
@@ -125,8 +125,7 @@ discard block |
||
125 | 125 | <td class="cumulatedtime">{$total}</td> |
126 | 126 | </tr> |
127 | 127 | EOD; |
128 | - } |
|
129 | - else |
|
128 | + } else |
|
130 | 129 | { |
131 | 130 | $bgcolor = $info['even'] ? "#fff" : "#eee"; |
132 | 131 | $color = $this->getColorLevel($log[1]); |
@@ -168,8 +167,7 @@ discard block |
||
168 | 167 | { |
169 | 168 | $string .= '<span class="level' . $level . '">' . strtoupper($name) . "</span>"; |
170 | 169 | } |
171 | - } |
|
172 | - else |
|
170 | + } else |
|
173 | 171 | { |
174 | 172 | $string .= "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">"; |
175 | 173 | foreach(self::$_levelValues as $name => $level) |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | public function init($config) |
67 | 67 | { |
68 | 68 | $this->loadParameters($config); |
69 | - if($this->_paramFile !== null) |
|
69 | + if ($this->_paramFile !== null) |
|
70 | 70 | { |
71 | 71 | $configFile = null; |
72 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML && ($cache = $this->getApplication()->getCache()) !== null) |
|
72 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML && ($cache = $this->getApplication()->getCache()) !== null) |
|
73 | 73 | { |
74 | - $cacheKey = 'TParameterModule:' . $this->_paramFile; |
|
75 | - if(($configFile = $cache->get($cacheKey)) === false) |
|
74 | + $cacheKey = 'TParameterModule:'.$this->_paramFile; |
|
75 | + if (($configFile = $cache->get($cacheKey)) === false) |
|
76 | 76 | { |
77 | 77 | $configFile = new TXmlDocument; |
78 | 78 | $configFile->loadFromFile($this->_paramFile); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | else |
83 | 83 | { |
84 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
84 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
85 | 85 | { |
86 | 86 | $configFile = include $this->_paramFile; |
87 | 87 | } |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | protected function loadParameters($config) |
105 | 105 | { |
106 | 106 | $parameters = []; |
107 | - if(is_array($config)) |
|
107 | + if (is_array($config)) |
|
108 | 108 | { |
109 | - foreach($config as $id => $parameter) |
|
109 | + foreach ($config as $id => $parameter) |
|
110 | 110 | { |
111 | - if(is_array($parameter) && isset($parameter['class'])) |
|
111 | + if (is_array($parameter) && isset($parameter['class'])) |
|
112 | 112 | { |
113 | - $properties = isset($parameter['properties'])?$parameter['properties']:[]; |
|
114 | - $parameters[$id] = [$parameter['class'],$properties]; |
|
113 | + $properties = isset($parameter['properties']) ? $parameter['properties'] : []; |
|
114 | + $parameters[$id] = [$parameter['class'], $properties]; |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -119,32 +119,32 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
122 | - elseif($config instanceof TXmlElement) |
|
122 | + elseif ($config instanceof TXmlElement) |
|
123 | 123 | { |
124 | - foreach($config->getElementsByTagName('parameter') as $node) |
|
124 | + foreach ($config->getElementsByTagName('parameter') as $node) |
|
125 | 125 | { |
126 | 126 | $properties = $node->getAttributes(); |
127 | - if(($id = $properties->remove('id')) === null) |
|
127 | + if (($id = $properties->remove('id')) === null) |
|
128 | 128 | throw new TConfigurationException('parametermodule_parameterid_required'); |
129 | - if(($type = $properties->remove('class')) === null) |
|
129 | + if (($type = $properties->remove('class')) === null) |
|
130 | 130 | { |
131 | - if(($value = $properties->remove('value')) === null) |
|
131 | + if (($value = $properties->remove('value')) === null) |
|
132 | 132 | $parameters[$id] = $node; |
133 | 133 | else |
134 | 134 | $parameters[$id] = $value; |
135 | 135 | } |
136 | 136 | else |
137 | - $parameters[$id] = [$type,$properties->toArray()]; |
|
137 | + $parameters[$id] = [$type, $properties->toArray()]; |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | 141 | $appParams = $this->getApplication()->getParameters(); |
142 | - foreach($parameters as $id => $parameter) |
|
142 | + foreach ($parameters as $id => $parameter) |
|
143 | 143 | { |
144 | - if(is_array($parameter)) |
|
144 | + if (is_array($parameter)) |
|
145 | 145 | { |
146 | 146 | $component = Prado::createComponent($parameter[0]); |
147 | - foreach($parameter[1] as $name => $value) |
|
147 | + foreach ($parameter[1] as $name => $value) |
|
148 | 148 | $component->setSubProperty($name, $value); |
149 | 149 | $appParams->add($id, $component); |
150 | 150 | } |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function setParameterFile($value) |
171 | 171 | { |
172 | - if($this->_initialized) |
|
172 | + if ($this->_initialized) |
|
173 | 173 | throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable'); |
174 | - elseif(($this->_paramFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null || !is_file($this->_paramFile)) |
|
174 | + elseif (($this->_paramFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null || !is_file($this->_paramFile)) |
|
175 | 175 | throw new TConfigurationException('parametermodule_parameterfile_invalid', $value); |
176 | 176 | } |
177 | 177 | } |
@@ -78,14 +78,12 @@ discard block |
||
78 | 78 | $configFile->loadFromFile($this->_paramFile); |
79 | 79 | $cache->set($cacheKey, $configFile, 0, new TFileCacheDependency($this->_paramFile)); |
80 | 80 | } |
81 | - } |
|
82 | - else |
|
81 | + } else |
|
83 | 82 | { |
84 | 83 | if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
85 | 84 | { |
86 | 85 | $configFile = include $this->_paramFile; |
87 | - } |
|
88 | - else |
|
86 | + } else |
|
89 | 87 | { |
90 | 88 | $configFile = new TXmlDocument; |
91 | 89 | $configFile->loadFromFile($this->_paramFile); |
@@ -112,29 +110,29 @@ discard block |
||
112 | 110 | { |
113 | 111 | $properties = isset($parameter['properties'])?$parameter['properties']:[]; |
114 | 112 | $parameters[$id] = [$parameter['class'],$properties]; |
115 | - } |
|
116 | - else |
|
113 | + } else |
|
117 | 114 | { |
118 | 115 | $parameters[$id] = $parameter; |
119 | 116 | } |
120 | 117 | } |
121 | - } |
|
122 | - elseif($config instanceof TXmlElement) |
|
118 | + } elseif($config instanceof TXmlElement) |
|
123 | 119 | { |
124 | 120 | foreach($config->getElementsByTagName('parameter') as $node) |
125 | 121 | { |
126 | 122 | $properties = $node->getAttributes(); |
127 | - if(($id = $properties->remove('id')) === null) |
|
128 | - throw new TConfigurationException('parametermodule_parameterid_required'); |
|
123 | + if(($id = $properties->remove('id')) === null) { |
|
124 | + throw new TConfigurationException('parametermodule_parameterid_required'); |
|
125 | + } |
|
129 | 126 | if(($type = $properties->remove('class')) === null) |
130 | 127 | { |
131 | - if(($value = $properties->remove('value')) === null) |
|
132 | - $parameters[$id] = $node; |
|
133 | - else |
|
134 | - $parameters[$id] = $value; |
|
128 | + if(($value = $properties->remove('value')) === null) { |
|
129 | + $parameters[$id] = $node; |
|
130 | + } else { |
|
131 | + $parameters[$id] = $value; |
|
132 | + } |
|
133 | + } else { |
|
134 | + $parameters[$id] = [$type,$properties->toArray()]; |
|
135 | 135 | } |
136 | - else |
|
137 | - $parameters[$id] = [$type,$properties->toArray()]; |
|
138 | 136 | } |
139 | 137 | } |
140 | 138 | |
@@ -144,12 +142,13 @@ discard block |
||
144 | 142 | if(is_array($parameter)) |
145 | 143 | { |
146 | 144 | $component = Prado::createComponent($parameter[0]); |
147 | - foreach($parameter[1] as $name => $value) |
|
148 | - $component->setSubProperty($name, $value); |
|
145 | + foreach($parameter[1] as $name => $value) { |
|
146 | + $component->setSubProperty($name, $value); |
|
147 | + } |
|
149 | 148 | $appParams->add($id, $component); |
149 | + } else { |
|
150 | + $appParams->add($id, $parameter); |
|
150 | 151 | } |
151 | - else |
|
152 | - $appParams->add($id, $parameter); |
|
153 | 152 | } |
154 | 153 | } |
155 | 154 | |
@@ -169,10 +168,11 @@ discard block |
||
169 | 168 | */ |
170 | 169 | public function setParameterFile($value) |
171 | 170 | { |
172 | - if($this->_initialized) |
|
173 | - throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable'); |
|
174 | - elseif(($this->_paramFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null || !is_file($this->_paramFile)) |
|
175 | - throw new TConfigurationException('parametermodule_parameterfile_invalid', $value); |
|
171 | + if($this->_initialized) { |
|
172 | + throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable'); |
|
173 | + } elseif(($this->_paramFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null || !is_file($this->_paramFile)) { |
|
174 | + throw new TConfigurationException('parametermodule_parameterfile_invalid', $value); |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function __destruct() |
69 | 69 | { |
70 | - if($this->_db !== null) |
|
70 | + if ($this->_db !== null) |
|
71 | 71 | $this->_db->setActive(false); |
72 | 72 | } |
73 | 73 | |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | $db = $this->getDbConnection(); |
84 | 84 | $db->setActive(true); |
85 | 85 | |
86 | - $sql = 'SELECT * FROM ' . $this->_logTable . ' WHERE 0=1'; |
|
86 | + $sql = 'SELECT * FROM '.$this->_logTable.' WHERE 0=1'; |
|
87 | 87 | try |
88 | 88 | { |
89 | 89 | $db->createCommand($sql)->query()->close(); |
90 | 90 | } |
91 | - catch(Exception $e) |
|
91 | + catch (Exception $e) |
|
92 | 92 | { |
93 | 93 | // DB table not exists |
94 | - if($this->_autoCreate) |
|
94 | + if ($this->_autoCreate) |
|
95 | 95 | $this->createDbTable(); |
96 | 96 | else |
97 | 97 | throw new TConfigurationException('db_logtable_inexistent', $this->_logTable); |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function processLogs($logs) |
108 | 108 | { |
109 | - $sql = 'INSERT INTO ' . $this->_logTable . '(level, category, logtime, message) VALUES (:level, :category, :logtime, :message)'; |
|
109 | + $sql = 'INSERT INTO '.$this->_logTable.'(level, category, logtime, message) VALUES (:level, :category, :logtime, :message)'; |
|
110 | 110 | $command = $this->getDbConnection()->createCommand($sql); |
111 | - foreach($logs as $log) |
|
111 | + foreach ($logs as $log) |
|
112 | 112 | { |
113 | 113 | $command->bindValue(':message', $log[0]); |
114 | 114 | $command->bindValue(':level', $log[1]); |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | $db = $this->getDbConnection(); |
128 | 128 | $driver = $db->getDriverName(); |
129 | 129 | $autoidAttributes = ''; |
130 | - if($driver === 'mysql') |
|
130 | + if ($driver === 'mysql') |
|
131 | 131 | $autoidAttributes = 'AUTO_INCREMENT'; |
132 | 132 | |
133 | - $sql = 'CREATE TABLE ' . $this->_logTable . ' ( |
|
134 | - log_id INTEGER NOT NULL PRIMARY KEY ' . $autoidAttributes . ', |
|
133 | + $sql = 'CREATE TABLE '.$this->_logTable.' ( |
|
134 | + log_id INTEGER NOT NULL PRIMARY KEY ' . $autoidAttributes.', |
|
135 | 135 | level INTEGER, |
136 | 136 | category VARCHAR(128), |
137 | 137 | logtime VARCHAR(20), |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function createDbConnection() |
149 | 149 | { |
150 | - if($this->_connID !== '') |
|
150 | + if ($this->_connID !== '') |
|
151 | 151 | { |
152 | 152 | $config = $this->getApplication()->getModule($this->_connID); |
153 | - if($config instanceof TDataSourceConfig) |
|
153 | + if ($config instanceof TDataSourceConfig) |
|
154 | 154 | return $config->getDbConnection(); |
155 | 155 | else |
156 | 156 | throw new TConfigurationException('dblogroute_connectionid_invalid', $this->_connID); |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | { |
160 | 160 | $db = new TDbConnection; |
161 | 161 | // default to SQLite3 database |
162 | - $dbFile = $this->getApplication()->getRuntimePath() . '/sqlite3.log'; |
|
163 | - $db->setConnectionString('sqlite:' . $dbFile); |
|
162 | + $dbFile = $this->getApplication()->getRuntimePath().'/sqlite3.log'; |
|
163 | + $db->setConnectionString('sqlite:'.$dbFile); |
|
164 | 164 | return $db; |
165 | 165 | } |
166 | 166 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function getDbConnection() |
172 | 172 | { |
173 | - if($this->_db === null) |
|
173 | + if ($this->_db === null) |
|
174 | 174 | $this->_db = $this->createDbConnection(); |
175 | 175 | return $this->_db; |
176 | 176 | } |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function __destruct() |
69 | 69 | { |
70 | - if($this->_db !== null) |
|
71 | - $this->_db->setActive(false); |
|
70 | + if($this->_db !== null) { |
|
71 | + $this->_db->setActive(false); |
|
72 | + } |
|
72 | 73 | } |
73 | 74 | |
74 | 75 | /** |
@@ -87,14 +88,14 @@ discard block |
||
87 | 88 | try |
88 | 89 | { |
89 | 90 | $db->createCommand($sql)->query()->close(); |
90 | - } |
|
91 | - catch(Exception $e) |
|
91 | + } catch(Exception $e) |
|
92 | 92 | { |
93 | 93 | // DB table not exists |
94 | - if($this->_autoCreate) |
|
95 | - $this->createDbTable(); |
|
96 | - else |
|
97 | - throw new TConfigurationException('db_logtable_inexistent', $this->_logTable); |
|
94 | + if($this->_autoCreate) { |
|
95 | + $this->createDbTable(); |
|
96 | + } else { |
|
97 | + throw new TConfigurationException('db_logtable_inexistent', $this->_logTable); |
|
98 | + } |
|
98 | 99 | } |
99 | 100 | |
100 | 101 | parent::init($config); |
@@ -127,8 +128,9 @@ discard block |
||
127 | 128 | $db = $this->getDbConnection(); |
128 | 129 | $driver = $db->getDriverName(); |
129 | 130 | $autoidAttributes = ''; |
130 | - if($driver === 'mysql') |
|
131 | - $autoidAttributes = 'AUTO_INCREMENT'; |
|
131 | + if($driver === 'mysql') { |
|
132 | + $autoidAttributes = 'AUTO_INCREMENT'; |
|
133 | + } |
|
132 | 134 | |
133 | 135 | $sql = 'CREATE TABLE ' . $this->_logTable . ' ( |
134 | 136 | log_id INTEGER NOT NULL PRIMARY KEY ' . $autoidAttributes . ', |
@@ -150,12 +152,12 @@ discard block |
||
150 | 152 | if($this->_connID !== '') |
151 | 153 | { |
152 | 154 | $config = $this->getApplication()->getModule($this->_connID); |
153 | - if($config instanceof TDataSourceConfig) |
|
154 | - return $config->getDbConnection(); |
|
155 | - else |
|
156 | - throw new TConfigurationException('dblogroute_connectionid_invalid', $this->_connID); |
|
157 | - } |
|
158 | - else |
|
155 | + if($config instanceof TDataSourceConfig) { |
|
156 | + return $config->getDbConnection(); |
|
157 | + } else { |
|
158 | + throw new TConfigurationException('dblogroute_connectionid_invalid', $this->_connID); |
|
159 | + } |
|
160 | + } else |
|
159 | 161 | { |
160 | 162 | $db = new TDbConnection; |
161 | 163 | // default to SQLite3 database |
@@ -170,8 +172,9 @@ discard block |
||
170 | 172 | */ |
171 | 173 | public function getDbConnection() |
172 | 174 | { |
173 | - if($this->_db === null) |
|
174 | - $this->_db = $this->createDbConnection(); |
|
175 | + if($this->_db === null) { |
|
176 | + $this->_db = $this->createDbConnection(); |
|
177 | + } |
|
175 | 178 | return $this->_db; |
176 | 179 | } |
177 | 180 |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | |
145 | 145 | // ----- Look if a local copy need to be done |
146 | 146 | if ($this->_temp_tarname == '') { |
147 | - $this->_temp_tarname = uniqid('tar') . '.tmp'; |
|
147 | + $this->_temp_tarname = uniqid('tar').'.tmp'; |
|
148 | 148 | if (!$v_file_from = @fopen($this->_tarname, 'rb')) { |
149 | 149 | $this->_error('Unable to open in read mode \'' |
150 | - . $this->_tarname . '\''); |
|
150 | + . $this->_tarname.'\''); |
|
151 | 151 | $this->_temp_tarname = ''; |
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
155 | 155 | $this->_error('Unable to open in write mode \'' |
156 | - . $this->_temp_tarname . '\''); |
|
156 | + . $this->_temp_tarname.'\''); |
|
157 | 157 | $this->_temp_tarname = ''; |
158 | 158 | return false; |
159 | 159 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $this->_file = @fopen($v_filename, "rb"); |
174 | 174 | |
175 | 175 | if ($this->_file == 0) { |
176 | - $this->_error('Unable to open in read mode \'' . $v_filename . '\''); |
|
176 | + $this->_error('Unable to open in read mode \''.$v_filename.'\''); |
|
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | if (strlen($v_binary_data) != 512) { |
248 | 248 | $v_header['filename'] = ''; |
249 | - $this->_error('Invalid block size : ' . strlen($v_binary_data)); |
|
249 | + $this->_error('Invalid block size : '.strlen($v_binary_data)); |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
277 | 277 | return true; |
278 | 278 | |
279 | - $this->_error('Invalid checksum for file "' . $v_data['filename'] |
|
280 | - . '" : ' . $v_checksum . ' calculated, ' |
|
281 | - . $v_header['checksum'] . ' expected'); |
|
279 | + $this->_error('Invalid checksum for file "'.$v_data['filename'] |
|
280 | + . '" : '.$v_checksum.' calculated, ' |
|
281 | + . $v_header['checksum'].' expected'); |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $p_path = $this->_translateWinPath($p_path, false); |
331 | 331 | if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
332 | 332 | && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
333 | - $p_path = "./" . $p_path; |
|
333 | + $p_path = "./".$p_path; |
|
334 | 334 | } |
335 | 335 | $p_remove_path = $this->_translateWinPath($p_remove_path); |
336 | 336 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $v_listing = true; |
354 | 354 | break; |
355 | 355 | default : |
356 | - $this->_error('Invalid extract mode (' . $p_mode . ')'); |
|
356 | + $this->_error('Invalid extract mode ('.$p_mode.')'); |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
@@ -416,25 +416,25 @@ discard block |
||
416 | 416 | $p_path = substr($p_path, 0, strlen($p_path) - 1); |
417 | 417 | |
418 | 418 | if (substr($v_header['filename'], 0, 1) == '/') |
419 | - $v_header['filename'] = $p_path . $v_header['filename']; |
|
419 | + $v_header['filename'] = $p_path.$v_header['filename']; |
|
420 | 420 | else |
421 | - $v_header['filename'] = $p_path . '/' . $v_header['filename']; |
|
421 | + $v_header['filename'] = $p_path.'/'.$v_header['filename']; |
|
422 | 422 | } |
423 | 423 | if (file_exists($v_header['filename'])) { |
424 | 424 | if ((@is_dir($v_header['filename'])) |
425 | 425 | && ($v_header['typeflag'] == '')) { |
426 | - $this->_error('File ' . $v_header['filename'] |
|
426 | + $this->_error('File '.$v_header['filename'] |
|
427 | 427 | . ' already exists as a directory'); |
428 | 428 | return false; |
429 | 429 | } |
430 | 430 | if (($this->_isArchive($v_header['filename'])) |
431 | 431 | && ($v_header['typeflag'] == "5")) { |
432 | - $this->_error('Directory ' . $v_header['filename'] |
|
432 | + $this->_error('Directory '.$v_header['filename'] |
|
433 | 433 | . ' already exists as a file'); |
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | if (!is_writable($v_header['filename'])) { |
437 | - $this->_error('File ' . $v_header['filename'] |
|
437 | + $this->_error('File '.$v_header['filename'] |
|
438 | 438 | . ' already exists and is write protected'); |
439 | 439 | return false; |
440 | 440 | } |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | // ----- Check the directory availability and create it if necessary |
447 | 447 | elseif (($v_result |
448 | 448 | = $this->_dirCheck(($v_header['typeflag'] == "5" |
449 | - ?$v_header['filename'] |
|
449 | + ? $v_header['filename'] |
|
450 | 450 | :dirname($v_header['filename'])))) != 1) { |
451 | - $this->_error('Unable to create path for ' . $v_header['filename']); |
|
451 | + $this->_error('Unable to create path for '.$v_header['filename']); |
|
452 | 452 | return false; |
453 | 453 | } |
454 | 454 | |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | if (!@file_exists($v_header['filename'])) { |
458 | 458 | if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
459 | 459 | $this->_error('Unable to create directory {' |
460 | - . $v_header['filename'] . '}'); |
|
460 | + . $v_header['filename'].'}'); |
|
461 | 461 | return false; |
462 | 462 | } |
463 | 463 | chmod($v_header['filename'], PRADO_CHMOD); |
464 | 464 | } |
465 | 465 | } else { |
466 | 466 | if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
467 | - $this->_error('Error while opening {' . $v_header['filename'] |
|
467 | + $this->_error('Error while opening {'.$v_header['filename'] |
|
468 | 468 | . '} in write binary mode'); |
469 | 469 | return false; |
470 | 470 | } else { |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | // ----- Check the file size |
490 | 490 | clearstatcache(); |
491 | 491 | if (filesize($v_header['filename']) != $v_header['size']) { |
492 | - $this->_error('Extracted file ' . $v_header['filename'] |
|
492 | + $this->_error('Extracted file '.$v_header['filename'] |
|
493 | 493 | . ' does not have the correct file size \'' |
494 | 494 | . filesize($v_header['filename']) |
495 | - . '\' (' . $v_header['size'] |
|
495 | + . '\' ('.$v_header['size'] |
|
496 | 496 | . ' expected). Archive may be corrupted.'); |
497 | 497 | return false; |
498 | 498 | } |
@@ -69,8 +69,9 @@ discard block |
||
69 | 69 | { |
70 | 70 | $this->_close(); |
71 | 71 | // ----- Look for a local copy to delete |
72 | - if ($this->_temp_tarname != '') |
|
73 | - @unlink($this->_temp_tarname); |
|
72 | + if ($this->_temp_tarname != '') { |
|
73 | + @unlink($this->_temp_tarname); |
|
74 | + } |
|
74 | 75 | } |
75 | 76 | |
76 | 77 | public function extract($p_path = '') |
@@ -157,8 +158,9 @@ discard block |
||
157 | 158 | $this->_temp_tarname = ''; |
158 | 159 | return false; |
159 | 160 | } |
160 | - while ($v_data = @fread($v_file_from, 1024)) |
|
161 | - @fwrite($v_file_to, $v_data); |
|
161 | + while ($v_data = @fread($v_file_from, 1024)) { |
|
162 | + @fwrite($v_file_to, $v_data); |
|
163 | + } |
|
162 | 164 | @fclose($v_file_from); |
163 | 165 | @fclose($v_file_to); |
164 | 166 | } |
@@ -166,9 +168,10 @@ discard block |
||
166 | 168 | // ----- File to open if the local copy |
167 | 169 | $v_filename = $this->_temp_tarname; |
168 | 170 | |
169 | - } else |
|
170 | - // ----- File to open if the normal Tar file |
|
171 | + } else { |
|
172 | + // ----- File to open if the normal Tar file |
|
171 | 173 | $v_filename = $this->_tarname; |
174 | + } |
|
172 | 175 | |
173 | 176 | $this->_file = @fopen($v_filename, "rb"); |
174 | 177 | |
@@ -229,8 +232,9 @@ discard block |
||
229 | 232 | private function _jumpBlock($p_len = null) |
230 | 233 | { |
231 | 234 | if (is_resource($this->_file)) { |
232 | - if ($p_len === null) |
|
233 | - $p_len = 1; |
|
235 | + if ($p_len === null) { |
|
236 | + $p_len = 1; |
|
237 | + } |
|
234 | 238 | |
235 | 239 | @fseek($this->_file, @ftell($this->_file) + ($p_len * 512)); |
236 | 240 | } |
@@ -253,14 +257,17 @@ discard block |
||
253 | 257 | // ----- Calculate the checksum |
254 | 258 | $v_checksum = 0; |
255 | 259 | // ..... First part of the header |
256 | - for ($i = 0; $i < 148; $i++) |
|
257 | - $v_checksum += ord(substr($v_binary_data, $i, 1)); |
|
260 | + for ($i = 0; $i < 148; $i++) { |
|
261 | + $v_checksum += ord(substr($v_binary_data, $i, 1)); |
|
262 | + } |
|
258 | 263 | // ..... Ignore the checksum value and replace it by ' ' (space) |
259 | - for ($i = 148; $i < 156; $i++) |
|
260 | - $v_checksum += ord(' '); |
|
264 | + for ($i = 148; $i < 156; $i++) { |
|
265 | + $v_checksum += ord(' '); |
|
266 | + } |
|
261 | 267 | // ..... Last part of the header |
262 | - for ($i = 156; $i < 512; $i++) |
|
263 | - $v_checksum += ord(substr($v_binary_data, $i, 1)); |
|
268 | + for ($i = 156; $i < 512; $i++) { |
|
269 | + $v_checksum += ord(substr($v_binary_data, $i, 1)); |
|
270 | + } |
|
264 | 271 | |
265 | 272 | $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
266 | 273 | . "a8checksum/a1typeflag/a100link/a6magic/a2version/" |
@@ -273,8 +280,9 @@ discard block |
||
273 | 280 | $v_header['filename'] = ''; |
274 | 281 | |
275 | 282 | // ----- Look for last block (empty block) |
276 | - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
277 | - return true; |
|
283 | + if (($v_checksum == 256) && ($v_header['checksum'] == 0)) { |
|
284 | + return true; |
|
285 | + } |
|
278 | 286 | |
279 | 287 | $this->_error('Invalid checksum for file "' . $v_data['filename'] |
280 | 288 | . '" : ' . $v_checksum . ' calculated, ' |
@@ -311,8 +319,9 @@ discard block |
||
311 | 319 | // ----- Read the next header |
312 | 320 | $v_binary_data = $this->_readBlock(); |
313 | 321 | |
314 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
315 | - return false; |
|
322 | + if (!$this->_readHeader($v_binary_data, $v_header)) { |
|
323 | + return false; |
|
324 | + } |
|
316 | 325 | |
317 | 326 | $v_header['filename'] = $v_filename; |
318 | 327 | |
@@ -335,8 +344,9 @@ discard block |
||
335 | 344 | $p_remove_path = $this->_translateWinPath($p_remove_path); |
336 | 345 | |
337 | 346 | // ----- Look for path to remove format (should end by /) |
338 | - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
339 | - $p_remove_path .= '/'; |
|
347 | + if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) { |
|
348 | + $p_remove_path .= '/'; |
|
349 | + } |
|
340 | 350 | $p_remove_path_size = strlen($p_remove_path); |
341 | 351 | |
342 | 352 | switch ($p_mode) { |
@@ -364,8 +374,9 @@ discard block |
||
364 | 374 | $v_extract_file = false; |
365 | 375 | $v_extraction_stopped = 0; |
366 | 376 | |
367 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
368 | - return false; |
|
377 | + if (!$this->_readHeader($v_binary_data, $v_header)) { |
|
378 | + return false; |
|
379 | + } |
|
369 | 380 | |
370 | 381 | if ($v_header['filename'] == '') { |
371 | 382 | continue; |
@@ -373,8 +384,9 @@ discard block |
||
373 | 384 | |
374 | 385 | // ----- Look for long filename |
375 | 386 | if ($v_header['typeflag'] == 'L') { |
376 | - if (!$this->_readLongHeader($v_header)) |
|
377 | - return false; |
|
387 | + if (!$this->_readLongHeader($v_header)) { |
|
388 | + return false; |
|
389 | + } |
|
378 | 390 | } |
379 | 391 | |
380 | 392 | if ((!$v_extract_all) && (is_array($p_file_list))) { |
@@ -408,17 +420,20 @@ discard block |
||
408 | 420 | { |
409 | 421 | if (($p_remove_path != '') |
410 | 422 | && (substr($v_header['filename'], 0, $p_remove_path_size) |
411 | - == $p_remove_path)) |
|
412 | - $v_header['filename'] = substr($v_header['filename'], |
|
423 | + == $p_remove_path)) { |
|
424 | + $v_header['filename'] = substr($v_header['filename'], |
|
413 | 425 | $p_remove_path_size); |
426 | + } |
|
414 | 427 | if (($p_path != './') && ($p_path != '/')) { |
415 | - while (substr($p_path, -1) == '/') |
|
416 | - $p_path = substr($p_path, 0, strlen($p_path) - 1); |
|
428 | + while (substr($p_path, -1) == '/') { |
|
429 | + $p_path = substr($p_path, 0, strlen($p_path) - 1); |
|
430 | + } |
|
417 | 431 | |
418 | - if (substr($v_header['filename'], 0, 1) == '/') |
|
419 | - $v_header['filename'] = $p_path . $v_header['filename']; |
|
420 | - else |
|
421 | - $v_header['filename'] = $p_path . '/' . $v_header['filename']; |
|
432 | + if (substr($v_header['filename'], 0, 1) == '/') { |
|
433 | + $v_header['filename'] = $p_path . $v_header['filename']; |
|
434 | + } else { |
|
435 | + $v_header['filename'] = $p_path . '/' . $v_header['filename']; |
|
436 | + } |
|
422 | 437 | } |
423 | 438 | if (file_exists($v_header['filename'])) { |
424 | 439 | if ((@is_dir($v_header['filename'])) |
@@ -514,10 +529,12 @@ discard block |
||
514 | 529 | if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
515 | 530 | // ----- Log extracted files |
516 | 531 | if (($v_file_dir = dirname($v_header['filename'])) |
517 | - == $v_header['filename']) |
|
518 | - $v_file_dir = ''; |
|
519 | - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
520 | - $v_file_dir = '/'; |
|
532 | + == $v_header['filename']) { |
|
533 | + $v_file_dir = ''; |
|
534 | + } |
|
535 | + if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) { |
|
536 | + $v_file_dir = '/'; |
|
537 | + } |
|
521 | 538 | |
522 | 539 | $p_list_detail[$v_nb++] = $v_header; |
523 | 540 | } |
@@ -536,15 +553,17 @@ discard block |
||
536 | 553 | */ |
537 | 554 | protected function _dirCheck($p_dir) |
538 | 555 | { |
539 | - if ((@is_dir($p_dir)) || ($p_dir == '')) |
|
540 | - return true; |
|
556 | + if ((@is_dir($p_dir)) || ($p_dir == '')) { |
|
557 | + return true; |
|
558 | + } |
|
541 | 559 | |
542 | 560 | $p_parent_dir = dirname($p_dir); |
543 | 561 | |
544 | 562 | if (($p_parent_dir != $p_dir) && |
545 | 563 | ($p_parent_dir != '') && |
546 | - (!$this->_dirCheck($p_parent_dir))) |
|
547 | - return false; |
|
564 | + (!$this->_dirCheck($p_parent_dir))) { |
|
565 | + return false; |
|
566 | + } |
|
548 | 567 | |
549 | 568 | if (!@mkdir($p_dir, PRADO_CHMOD)) { |
550 | 569 | $this->_error("Unable to create directory '$p_dir'"); |