@@ -173,9 +173,10 @@ discard block |
||
173 | 173 | { |
174 | 174 | if($this->_elements) |
175 | 175 | { |
176 | - foreach($this->_elements as $element) |
|
177 | - if($element->_tagName === $tagName) |
|
176 | + foreach($this->_elements as $element) { |
|
177 | + if($element->_tagName === $tagName) |
|
178 | 178 | return $element; |
179 | + } |
|
179 | 180 | } |
180 | 181 | return null; |
181 | 182 | } |
@@ -188,9 +189,10 @@ discard block |
||
188 | 189 | $list = new TList; |
189 | 190 | if($this->_elements) |
190 | 191 | { |
191 | - foreach($this->_elements as $element) |
|
192 | - if($element->_tagName === $tagName) |
|
192 | + foreach($this->_elements as $element) { |
|
193 | + if($element->_tagName === $tagName) |
|
193 | 194 | $list->add($element); |
195 | + } |
|
194 | 196 | } |
195 | 197 | return $list; |
196 | 198 | } |
@@ -213,17 +215,16 @@ discard block |
||
213 | 215 | if($this->getHasElement()) |
214 | 216 | { |
215 | 217 | $str = $prefix . "<{$this->_tagName}$attr>\n"; |
216 | - foreach($this->getElements() as $element) |
|
217 | - $str .= $element->toString($indent + 1) . "\n"; |
|
218 | + foreach($this->getElements() as $element) { |
|
219 | + $str .= $element->toString($indent + 1) . "\n"; |
|
220 | + } |
|
218 | 221 | $str .= $prefix . "</{$this->_tagName}>"; |
219 | 222 | return $str; |
220 | - } |
|
221 | - elseif(($value = $this->getValue()) !== '') |
|
223 | + } elseif(($value = $this->getValue()) !== '') |
|
222 | 224 | { |
223 | 225 | $value = $this->xmlEncode($value); |
224 | 226 | return $prefix . "<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
225 | - } |
|
226 | - else |
|
227 | + } else |
|
227 | 228 | return $prefix . "<{$this->_tagName}$attr />"; |
228 | 229 | } |
229 | 230 |
@@ -212,8 +212,7 @@ discard block |
||
212 | 212 | $config['source']); |
213 | 213 | chmod($config['source'], PRADO_CHMOD); //make it deletable |
214 | 214 | } |
215 | - } |
|
216 | - else |
|
215 | + } else |
|
217 | 216 | { |
218 | 217 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
219 | 218 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | $config['cache']); |
229 | 228 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
230 | 229 | } |
231 | - } |
|
232 | - else |
|
230 | + } else |
|
233 | 231 | { |
234 | 232 | unset($config['cache']); |
235 | 233 | } |
@@ -263,8 +261,9 @@ discard block |
||
263 | 261 | if($culture === null) $culture = $this->getCulture(); |
264 | 262 | $variants = explode('_', $culture); |
265 | 263 | $result = []; |
266 | - for(; count($variants) > 0; array_pop($variants)) |
|
267 | - $result[] = implode('_', $variants); |
|
264 | + for(; count($variants) > 0; array_pop($variants)) { |
|
265 | + $result[] = implode('_', $variants); |
|
266 | + } |
|
268 | 267 | return $result; |
269 | 268 | } |
270 | 269 | |
@@ -292,11 +291,13 @@ discard block |
||
292 | 291 | $files = []; |
293 | 292 | $variants = $this->getCultureVariants($culture); |
294 | 293 | $path = pathinfo($file); |
295 | - foreach($variants as $variant) |
|
296 | - $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename']; |
|
294 | + foreach($variants as $variant) { |
|
295 | + $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename']; |
|
296 | + } |
|
297 | 297 | $filename = substr($path['basename'], 0, strrpos($path['basename'], '.')); |
298 | - foreach($variants as $variant) |
|
299 | - $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension']; |
|
298 | + foreach($variants as $variant) { |
|
299 | + $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension']; |
|
300 | + } |
|
300 | 301 | $files[] = $file; |
301 | 302 | return $files; |
302 | 303 | } |
@@ -82,11 +82,11 @@ |
||
82 | 82 | if($config !== null) |
83 | 83 | { |
84 | 84 | if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
85 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
85 | + $translation = isset($config['translate']) ? $config['translate'] : null; |
|
86 | 86 | else |
87 | 87 | { |
88 | 88 | $t = $config->getElementByTagName('translation'); |
89 | - $translation = ($t)?$t->getAttributes():null; |
|
89 | + $translation = ($t) ? $t->getAttributes() : null; |
|
90 | 90 | } |
91 | 91 | if($translation) |
92 | 92 | $this->setTranslationConfiguration($translation); |
@@ -208,8 +208,9 @@ |
||
208 | 208 | { |
209 | 209 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
210 | 210 | $subs = []; |
211 | - foreach($this->getParameters() as $key => $value) |
|
212 | - $subs['{' . $key . '}'] = $value; |
|
211 | + foreach($this->getParameters() as $key => $value) { |
|
212 | + $subs['{' . $key . '}'] = $value; |
|
213 | + } |
|
213 | 214 | foreach($this->getControls() as $control) |
214 | 215 | { |
215 | 216 | if($control instanceof TTranslateParameter) |
@@ -246,7 +246,7 @@ |
||
246 | 246 | $catalogue = $this->getCatalogue(); |
247 | 247 | if(empty($catalogue) && isset($config['catalogue'])) |
248 | 248 | $catalogue = $config['catalogue']; |
249 | - if (empty($catalogue)) $catalogue = 'messages'; |
|
249 | + if(empty($catalogue)) $catalogue = 'messages'; |
|
250 | 250 | Translation::init($catalogue); |
251 | 251 | |
252 | 252 | $key = $this->getKey(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | //mark untranslated text |
66 | 66 | if($ps = $config['marker']) |
67 | - self::$formatters[$catalogue]->setUntranslatedPS([$ps,$ps]); |
|
67 | + self::$formatters[$catalogue]->setUntranslatedPS([$ps, $ps]); |
|
68 | 68 | |
69 | 69 | //save the message on end request |
70 | 70 | // Do it only once ! |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | if($onceonly) |
98 | 98 | { |
99 | - foreach (self::$formatters as $catalogue => $formatter) |
|
99 | + foreach(self::$formatters as $catalogue => $formatter) |
|
100 | 100 | { |
101 | 101 | $app = Prado::getApplication()->getGlobalization(); |
102 | 102 | $config = $app->getTranslationConfiguration(); |
@@ -233,13 +233,13 @@ |
||
233 | 233 | if(!empty($culture) && $app->getCulture() != $culture) |
234 | 234 | { |
235 | 235 | $formatter = new NumberFormat($culture); |
236 | - return $formatter->format($this->getValue(),$pattern, |
|
236 | + return $formatter->format($this->getValue(), $pattern, |
|
237 | 237 | $this->getCurrency(), |
238 | 238 | $this->getCharset()); |
239 | 239 | } |
240 | 240 | |
241 | 241 | //return the application wide culture formatted number. |
242 | - return self::$formatter->format($this->getValue(),$pattern, |
|
242 | + return self::$formatter->format($this->getValue(), $pattern, |
|
243 | 243 | $this->getCurrency(), |
244 | 244 | $this->getCharset()); |
245 | 245 | } |
@@ -158,8 +158,9 @@ discard block |
||
158 | 158 | if(empty($charset)) $charset = $this->getCharset(); |
159 | 159 | |
160 | 160 | //force args as UTF-8 |
161 | - foreach($args as $k => $v) |
|
162 | - $args[$k] = I18N_toUTF8($v, $charset); |
|
161 | + foreach($args as $k => $v) { |
|
162 | + $args[$k] = I18N_toUTF8($v, $charset); |
|
163 | + } |
|
163 | 164 | $s = $this->formatString(I18N_toUTF8($string, $charset), $args, $catalogue); |
164 | 165 | return I18N_toEncoding($s, $charset); |
165 | 166 | } |
@@ -208,8 +209,7 @@ discard block |
||
208 | 209 | return $this->postscript[0] . |
209 | 210 | strtr($string, $args) . |
210 | 211 | $this->postscript[1]; |
211 | - } |
|
212 | - else |
|
212 | + } else |
|
213 | 213 | return strtr($target, $args); |
214 | 214 | } |
215 | 215 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | * The prefix and suffix to append to untranslated messages. |
77 | 77 | * @var array |
78 | 78 | */ |
79 | - protected $postscript = ['','']; |
|
79 | + protected $postscript = ['', '']; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Set the default catalogue. |
@@ -173,8 +173,7 @@ discard block |
||
173 | 173 | { |
174 | 174 | eval($str); |
175 | 175 | return $result; |
176 | - } |
|
177 | - catch(Exception $e) |
|
176 | + } catch(Exception $e) |
|
178 | 177 | { |
179 | 178 | return false; |
180 | 179 | } |
@@ -190,8 +189,9 @@ discard block |
||
190 | 189 | { |
191 | 190 | $n = preg_match_all($this->parse, $string, $matches, PREG_OFFSET_CAPTURE); |
192 | 191 | $sets = []; |
193 | - foreach($matches[1] as $match) |
|
194 | - $sets[] = $match[0]; |
|
192 | + foreach($matches[1] as $match) { |
|
193 | + $sets[] = $match[0]; |
|
194 | + } |
|
195 | 195 | $offset = $matches[0]; |
196 | 196 | $strings = []; |
197 | 197 | for($i = 0; $i < $n; $i++) |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | { |
137 | 137 | if($string == '-Inf') |
138 | 138 | $elements[] = -1 * $this->inf; |
139 | - elseif ($string == '+Inf' || $string == 'Inf') |
|
139 | + elseif($string == '+Inf' || $string == 'Inf') |
|
140 | 140 | $elements[] = $this->inf; |
141 | 141 | else |
142 | 142 | $elements[] = floatval($string); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $left = false; |
153 | 153 | if($leftBracket == '[') |
154 | 154 | $left = $number >= $elements[0]; |
155 | - elseif ($leftBracket == '(') |
|
155 | + elseif($leftBracket == '(') |
|
156 | 156 | $left = $number > $elements[0]; |
157 | 157 | |
158 | 158 | $right = false; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | eval($str); |
175 | 175 | return $result; |
176 | 176 | } |
177 | - catch(Exception $e) |
|
177 | + catch (Exception $e) |
|
178 | 178 | { |
179 | 179 | return false; |
180 | 180 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | for($i = 0; $i < $n; $i++) |
198 | 198 | { |
199 | 199 | $len = strlen($offset[$i][0]); |
200 | - $begin = $i == 0? $len : $offset[$i][1] + $len; |
|
200 | + $begin = $i == 0 ? $len : $offset[$i][1] + $len; |
|
201 | 201 | $end = $i == $n - 1 ? strlen($string) : $offset[$i + 1][1]; |
202 | 202 | $strings[] = substr($string, $begin, $end - $begin); |
203 | 203 | } |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | return $conn->getDbConnection(); |
75 | 75 | else |
76 | 76 | throw new TConfigurationException('messagesource_connectionid_invalid', $connectionID); |
77 | - } |
|
78 | - else |
|
77 | + } else |
|
79 | 78 | throw new TConfigurationException('messagesource_connectionid_required'); |
80 | 79 | } |
81 | 80 | |
@@ -98,8 +97,9 @@ discard block |
||
98 | 97 | |
99 | 98 | $result = []; |
100 | 99 | |
101 | - foreach ($dataReader as $row) |
|
102 | - $result[$row['source']] = [$row['target'],$row['id'],$row['comments']]; |
|
100 | + foreach ($dataReader as $row) { |
|
101 | + $result[$row['source']] = [$row['target'],$row['id'],$row['comments']]; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | return $result; |
105 | 105 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct($source) |
45 | 45 | { |
46 | - $this->_connID = (string)$source; |
|
46 | + $this->_connID = (string) $source; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | |
99 | 99 | $result = []; |
100 | 100 | |
101 | - foreach ($dataReader as $row) |
|
102 | - $result[$row['source']] = [$row['target'],$row['id'],$row['comments']]; |
|
101 | + foreach($dataReader as $row) |
|
102 | + $result[$row['source']] = [$row['target'], $row['id'], $row['comments']]; |
|
103 | 103 | |
104 | 104 | return $result; |
105 | 105 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | if(isset($variants[$i]{0})) |
153 | 153 | { |
154 | - $variant .= ($variant)?'_' . $variants[$i]:$variants[$i]; |
|
154 | + $variant .= ($variant) ? '_' . $variants[$i] : $variants[$i]; |
|
155 | 155 | $catalogues[] = $catalogue . '.' . $variant; |
156 | 156 | } |
157 | 157 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $command->bindParameter(':variant', $variant, PDO::PARAM_STR); |
176 | 176 | $cat_id = $command->queryScalar(); |
177 | 177 | |
178 | - if ($cat_id === null) return false; |
|
178 | + if($cat_id === null) return false; |
|
179 | 179 | |
180 | 180 | $command = $this->getDBConnection()->createCommand( |
181 | 181 | 'SELECT COUNT(msg_id) FROM trans_unit WHERE cat_id = :catid '); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $command->bindParameter(':dateadded', $time, PDO::PARAM_INT); |
238 | 238 | foreach($messages as $message) |
239 | 239 | { |
240 | - if (empty($message)) continue; |
|
240 | + if(empty($message)) continue; |
|
241 | 241 | $count++; $inserted++; |
242 | 242 | $command->execute(); |
243 | 243 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | $result = []; |
312 | 312 | |
313 | - foreach ($dataReader as $row) |
|
313 | + foreach($dataReader as $row) |
|
314 | 314 | { |
315 | 315 | $details = explode('.', $row[0]); |
316 | 316 | if(!isset($details[1])) $details[1] = null; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function parseDSN($dsn) |
42 | 42 | { |
43 | - if (is_array($dsn)) { |
|
43 | + if(is_array($dsn)) { |
|
44 | 44 | return $dsn; |
45 | 45 | } |
46 | 46 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | ]; |
58 | 58 | |
59 | 59 | // Find phptype and dbsyntax |
60 | - if (($pos = strpos($dsn, '://')) !== false) { |
|
60 | + if(($pos = strpos($dsn, '://')) !== false) { |
|
61 | 61 | $str = substr($dsn, 0, $pos); |
62 | 62 | $dsn = substr($dsn, $pos + 3); |
63 | 63 | } else { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | // Get phptype and dbsyntax |
69 | 69 | // $str => phptype(dbsyntax) |
70 | - if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
|
70 | + if(preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
|
71 | 71 | $parsed['phptype'] = $arr[1]; |
72 | 72 | $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; |
73 | 73 | } else { |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | $parsed['dbsyntax'] = $str; |
76 | 76 | } |
77 | 77 | |
78 | - if (empty($dsn)) { |
|
78 | + if(empty($dsn)) { |
|
79 | 79 | return $parsed; |
80 | 80 | } |
81 | 81 | |
82 | 82 | // Get (if found): username and password |
83 | 83 | // $dsn => username:password@protocol+hostspec/database |
84 | - if (($at = strrpos($dsn, '@')) !== false) { |
|
84 | + if(($at = strrpos($dsn, '@')) !== false) { |
|
85 | 85 | $str = substr($dsn, 0, $at); |
86 | 86 | $dsn = substr($dsn, $at + 1); |
87 | - if (($pos = strpos($str, ':')) !== false) { |
|
87 | + if(($pos = strpos($str, ':')) !== false) { |
|
88 | 88 | $parsed['username'] = rawurldecode(substr($str, 0, $pos)); |
89 | 89 | $parsed['password'] = rawurldecode(substr($str, $pos + 1)); |
90 | 90 | } else { |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | // Find protocol and hostspec |
96 | 96 | |
97 | 97 | // $dsn => proto(proto_opts)/database |
98 | - if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
|
98 | + if(preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
|
99 | 99 | $proto = $match[1]; |
100 | 100 | $proto_opts = (!empty($match[2])) ? $match[2] : false; |
101 | 101 | $dsn = $match[3]; |
102 | 102 | |
103 | 103 | // $dsn => protocol+hostspec/database (old format) |
104 | 104 | } else { |
105 | - if (strpos($dsn, '+') !== false) { |
|
105 | + if(strpos($dsn, '+') !== false) { |
|
106 | 106 | list($proto, $dsn) = explode('+', $dsn, 2); |
107 | 107 | } |
108 | - if (strpos($dsn, '/') !== false) { |
|
108 | + if(strpos($dsn, '/') !== false) { |
|
109 | 109 | list($proto_opts, $dsn) = explode('/', $dsn, 2); |
110 | 110 | } else { |
111 | 111 | $proto_opts = $dsn; |
@@ -116,34 +116,34 @@ discard block |
||
116 | 116 | // process the different protocol options |
117 | 117 | $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; |
118 | 118 | $proto_opts = rawurldecode($proto_opts); |
119 | - if ($parsed['protocol'] == 'tcp') { |
|
120 | - if (strpos($proto_opts, ':') !== false) { |
|
119 | + if($parsed['protocol'] == 'tcp') { |
|
120 | + if(strpos($proto_opts, ':') !== false) { |
|
121 | 121 | list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts); |
122 | 122 | } else { |
123 | 123 | $parsed['hostspec'] = $proto_opts; |
124 | 124 | } |
125 | - } elseif ($parsed['protocol'] == 'unix') { |
|
125 | + } elseif($parsed['protocol'] == 'unix') { |
|
126 | 126 | $parsed['socket'] = $proto_opts; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Get dabase if any |
130 | 130 | // $dsn => database |
131 | - if (!empty($dsn)) { |
|
131 | + if(!empty($dsn)) { |
|
132 | 132 | // /database |
133 | - if (($pos = strpos($dsn, '?')) === false) { |
|
133 | + if(($pos = strpos($dsn, '?')) === false) { |
|
134 | 134 | $parsed['database'] = $dsn; |
135 | 135 | // /database?param1=value1¶m2=value2 |
136 | 136 | } else { |
137 | 137 | $parsed['database'] = substr($dsn, 0, $pos); |
138 | 138 | $dsn = substr($dsn, $pos + 1); |
139 | - if (strpos($dsn, '&') !== false) { |
|
139 | + if(strpos($dsn, '&') !== false) { |
|
140 | 140 | $opts = explode('&', $dsn); |
141 | 141 | } else { // database?param1=value1 |
142 | 142 | $opts = [$dsn]; |
143 | 143 | } |
144 | - foreach ($opts as $opt) { |
|
144 | + foreach($opts as $opt) { |
|
145 | 145 | list($key, $value) = explode('=', $opt); |
146 | - if (!isset($parsed[$key])) { // don't allow params overwrite |
|
146 | + if(!isset($parsed[$key])) { // don't allow params overwrite |
|
147 | 147 | $parsed[$key] = rawurldecode($value); |
148 | 148 | } |
149 | 149 | } |