@@ -105,7 +105,7 @@ |
||
105 | 105 | $choice = new ChoiceFormat(); |
106 | 106 | $value = $this->getValue(); |
107 | 107 | $string = $choice->format($text, $value); |
108 | - if($string) |
|
108 | + if ($string) |
|
109 | 109 | return strtr($string, ['{Value}' => $value]); |
110 | 110 | } |
111 | 111 | } |
@@ -105,7 +105,8 @@ |
||
105 | 105 | $choice = new ChoiceFormat(); |
106 | 106 | $value = $this->getValue(); |
107 | 107 | $string = $choice->format($text, $value); |
108 | - if($string) |
|
109 | - return strtr($string, ['{Value}' => $value]); |
|
108 | + if($string) { |
|
109 | + return strtr($string, ['{Value}' => $value]); |
|
110 | + } |
|
110 | 111 | } |
111 | 112 | } |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @var array |
74 | 74 | */ |
75 | 75 | private static $_patternPresets = [ |
76 | - 'fulldate' => 'P','full' => 'P', |
|
77 | - 'longdate' => 'D','long' => 'd', |
|
78 | - 'mediumdate' => 'p','medium' => 'p', |
|
79 | - 'shortdate' => 'd','short' => 'd', |
|
76 | + 'fulldate' => 'P', 'full' => 'P', |
|
77 | + 'longdate' => 'D', 'long' => 'd', |
|
78 | + 'mediumdate' => 'p', 'medium' => 'p', |
|
79 | + 'shortdate' => 'd', 'short' => 'd', |
|
80 | 80 | 'fulltime' => 'Q', 'longtime' => 'T', |
81 | 81 | 'mediumtime' => 'q', 'shorttime' => 't']; |
82 | 82 | |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | //try the subpattern of "date time" presets |
103 | 103 | $subpatterns = explode(' ', $string, 2); |
104 | 104 | $datetime = []; |
105 | - if(count($subpatterns) == 2) |
|
105 | + if (count($subpatterns) == 2) |
|
106 | 106 | { |
107 | 107 | $datetime[] = $this->getPreset($subpatterns[0]); |
108 | 108 | $datetime[] = $this->getPreset($subpatterns[1]); |
109 | 109 | } |
110 | 110 | |
111 | 111 | //we have a good subpattern |
112 | - if(count($datetime) == 2 |
|
112 | + if (count($datetime) == 2 |
|
113 | 113 | && strlen($datetime[0]) == 1 |
114 | 114 | && strlen($datetime[1]) == 1) |
115 | 115 | { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | //no presets found, use the string as the pattern |
122 | 122 | //and let the DateFormat handle it. |
123 | - if($pattern === null) |
|
123 | + if ($pattern === null) |
|
124 | 124 | $pattern = $string; |
125 | 125 | if (!is_array($pattern) && strlen($pattern) == 0) |
126 | 126 | $pattern = null; |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | protected function getPreset($string) |
136 | 136 | { |
137 | 137 | $string = strtolower($string); |
138 | - foreach(self::$_patternPresets as $pattern => $preset) |
|
138 | + foreach (self::$_patternPresets as $pattern => $preset) |
|
139 | 139 | { |
140 | - if($string == $pattern) |
|
140 | + if ($string == $pattern) |
|
141 | 141 | return $preset; |
142 | 142 | } |
143 | 143 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | public function getValue() |
150 | 150 | { |
151 | 151 | $value = $this->getViewState('Value', ''); |
152 | - if(empty($value)) |
|
152 | + if (empty($value)) |
|
153 | 153 | { |
154 | 154 | $defaultText = $this->getDefaultText(); |
155 | - if(empty($defaultText)) |
|
155 | + if (empty($defaultText)) |
|
156 | 156 | return time(); |
157 | 157 | } |
158 | 158 | return $value; |
@@ -221,19 +221,19 @@ discard block |
||
221 | 221 | { |
222 | 222 | $value = $this->getValue(); |
223 | 223 | $defaultText = $this->getDefaultText(); |
224 | - if(empty($value) && !empty($defaultText)) |
|
224 | + if (empty($value) && !empty($defaultText)) |
|
225 | 225 | return $this->getDefaultText(); |
226 | 226 | |
227 | 227 | $app = $this->getApplication()->getGlobalization(); |
228 | 228 | |
229 | 229 | //initialized the default class wide formatter |
230 | - if(self::$formatter === null) |
|
230 | + if (self::$formatter === null) |
|
231 | 231 | self::$formatter = new DateFormat($app->getCulture()); |
232 | 232 | |
233 | 233 | $culture = $this->getCulture(); |
234 | 234 | |
235 | 235 | //return the specific cultural formatted date time |
236 | - if(strlen($culture) && $app->getCulture() !== $culture) |
|
236 | + if (strlen($culture) && $app->getCulture() !== $culture) |
|
237 | 237 | { |
238 | 238 | $formatter = new DateFormat($culture); |
239 | 239 | return $formatter->format($value, |
@@ -114,16 +114,19 @@ discard block |
||
114 | 114 | && strlen($datetime[1]) == 1) |
115 | 115 | { |
116 | 116 | $pattern = $datetime; |
117 | - } |
|
118 | - else //no subpattern, try the presets |
|
117 | + } else { |
|
118 | + //no subpattern, try the presets |
|
119 | 119 | $pattern = $this->getPreset($string); |
120 | + } |
|
120 | 121 | |
121 | 122 | //no presets found, use the string as the pattern |
122 | 123 | //and let the DateFormat handle it. |
123 | - if($pattern === null) |
|
124 | - $pattern = $string; |
|
125 | - if (!is_array($pattern) && strlen($pattern) == 0) |
|
126 | - $pattern = null; |
|
124 | + if($pattern === null) { |
|
125 | + $pattern = $string; |
|
126 | + } |
|
127 | + if (!is_array($pattern) && strlen($pattern) == 0) { |
|
128 | + $pattern = null; |
|
129 | + } |
|
127 | 130 | return $pattern; |
128 | 131 | } |
129 | 132 | |
@@ -137,8 +140,9 @@ discard block |
||
137 | 140 | $string = strtolower($string); |
138 | 141 | foreach(self::$_patternPresets as $pattern => $preset) |
139 | 142 | { |
140 | - if($string == $pattern) |
|
141 | - return $preset; |
|
143 | + if($string == $pattern) { |
|
144 | + return $preset; |
|
145 | + } |
|
142 | 146 | } |
143 | 147 | } |
144 | 148 | |
@@ -152,8 +156,9 @@ discard block |
||
152 | 156 | if(empty($value)) |
153 | 157 | { |
154 | 158 | $defaultText = $this->getDefaultText(); |
155 | - if(empty($defaultText)) |
|
156 | - return time(); |
|
159 | + if(empty($defaultText)) { |
|
160 | + return time(); |
|
161 | + } |
|
157 | 162 | } |
158 | 163 | return $value; |
159 | 164 | } |
@@ -221,14 +226,16 @@ discard block |
||
221 | 226 | { |
222 | 227 | $value = $this->getValue(); |
223 | 228 | $defaultText = $this->getDefaultText(); |
224 | - if(empty($value) && !empty($defaultText)) |
|
225 | - return $this->getDefaultText(); |
|
229 | + if(empty($value) && !empty($defaultText)) { |
|
230 | + return $this->getDefaultText(); |
|
231 | + } |
|
226 | 232 | |
227 | 233 | $app = $this->getApplication()->getGlobalization(); |
228 | 234 | |
229 | 235 | //initialized the default class wide formatter |
230 | - if(self::$formatter === null) |
|
231 | - self::$formatter = new DateFormat($app->getCulture()); |
|
236 | + if(self::$formatter === null) { |
|
237 | + self::$formatter = new DateFormat($app->getCulture()); |
|
238 | + } |
|
232 | 239 | |
233 | 240 | $culture = $this->getCulture(); |
234 | 241 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | static $saveEventHandlerAttached = false; |
48 | 48 | |
49 | 49 | //initialized the default class wide formatter |
50 | - if(!isset(self::$formatters[$catalogue])) |
|
50 | + if (!isset(self::$formatters[$catalogue])) |
|
51 | 51 | { |
52 | 52 | $app = Prado::getApplication()->getGlobalization(); |
53 | 53 | $config = $app->getTranslationConfiguration(); |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | |
58 | 58 | $source->setCulture($app->getCulture()); |
59 | 59 | |
60 | - if(isset($config['cache'])) |
|
60 | + if (isset($config['cache'])) |
|
61 | 61 | $source->setCache(new MessageCache($config['cache'])); |
62 | 62 | |
63 | 63 | self::$formatters[$catalogue] = new MessageFormat($source, $app->getCharset()); |
64 | 64 | |
65 | 65 | //mark untranslated text |
66 | - if($ps = $config['marker']) |
|
67 | - self::$formatters[$catalogue]->setUntranslatedPS([$ps,$ps]); |
|
66 | + if ($ps = $config['marker']) |
|
67 | + self::$formatters[$catalogue]->setUntranslatedPS([$ps, $ps]); |
|
68 | 68 | |
69 | 69 | //save the message on end request |
70 | 70 | // Do it only once ! |
71 | - if(!$saveEventHandlerAttached && TPropertyValue::ensureBoolean($config['autosave'])) |
|
71 | + if (!$saveEventHandlerAttached && TPropertyValue::ensureBoolean($config['autosave'])) |
|
72 | 72 | { |
73 | 73 | Prado::getApplication()->attachEventHandler( |
74 | 74 | 'OnEndRequest', ['Translation', 'saveMessages']); |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | { |
95 | 95 | static $onceonly = true; |
96 | 96 | |
97 | - if($onceonly) |
|
97 | + if ($onceonly) |
|
98 | 98 | { |
99 | 99 | foreach (self::$formatters as $catalogue => $formatter) |
100 | 100 | { |
101 | 101 | $app = Prado::getApplication()->getGlobalization(); |
102 | 102 | $config = $app->getTranslationConfiguration(); |
103 | - if(isset($config['autosave'])) |
|
103 | + if (isset($config['autosave'])) |
|
104 | 104 | { |
105 | 105 | $formatter->getSource()->setCulture($app->getCulture()); |
106 | 106 | $formatter->getSource()->save($catalogue); |
@@ -57,14 +57,16 @@ |
||
57 | 57 | |
58 | 58 | $source->setCulture($app->getCulture()); |
59 | 59 | |
60 | - if(isset($config['cache'])) |
|
61 | - $source->setCache(new MessageCache($config['cache'])); |
|
60 | + if(isset($config['cache'])) { |
|
61 | + $source->setCache(new MessageCache($config['cache'])); |
|
62 | + } |
|
62 | 63 | |
63 | 64 | self::$formatters[$catalogue] = new MessageFormat($source, $app->getCharset()); |
64 | 65 | |
65 | 66 | //mark untranslated text |
66 | - if($ps = $config['marker']) |
|
67 | - self::$formatters[$catalogue]->setUntranslatedPS([$ps,$ps]); |
|
67 | + if($ps = $config['marker']) { |
|
68 | + self::$formatters[$catalogue]->setUntranslatedPS([$ps,$ps]); |
|
69 | + } |
|
68 | 70 | |
69 | 71 | //save the message on end request |
70 | 72 | // Do it only once ! |
@@ -74,21 +74,21 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function init($config) |
76 | 76 | { |
77 | - if($this->_charset === null) |
|
77 | + if ($this->_charset === null) |
|
78 | 78 | $this->_charset = $this->getDefaultCharset(); |
79 | - if($this->_culture === null) |
|
79 | + if ($this->_culture === null) |
|
80 | 80 | $this->_culture = $this->getDefaultCulture(); |
81 | 81 | |
82 | - if($config !== null) |
|
82 | + if ($config !== null) |
|
83 | 83 | { |
84 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
85 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
84 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
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 | - if($translation) |
|
91 | + if ($translation) |
|
92 | 92 | $this->setTranslationConfiguration($translation); |
93 | 93 | } |
94 | 94 | $this->getApplication()->setGlobalization($this); |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function setTranslationConfiguration($config) |
202 | 202 | { |
203 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext' || $config['type'] == 'PHP') |
|
203 | + if ($config['type'] == 'XLIFF' || $config['type'] == 'gettext' || $config['type'] == 'PHP') |
|
204 | 204 | { |
205 | - if($config['source']) |
|
205 | + if ($config['source']) |
|
206 | 206 | { |
207 | 207 | $config['source'] = Prado::getPathOfNamespace($config['source']); |
208 | - if(!is_dir($config['source'])) |
|
208 | + if (!is_dir($config['source'])) |
|
209 | 209 | { |
210 | - if(@mkdir($config['source']) === false) |
|
210 | + if (@mkdir($config['source']) === false) |
|
211 | 211 | throw new TConfigurationException('globalization_source_path_failed', |
212 | 212 | $config['source']); |
213 | 213 | chmod($config['source'], PRADO_CHMOD); //make it deletable |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
219 | 219 | } |
220 | 220 | } |
221 | - if(isset($config['cache']) && TPropertyValue::ensureBoolean($config['cache'])) |
|
221 | + if (isset($config['cache']) && TPropertyValue::ensureBoolean($config['cache'])) |
|
222 | 222 | { |
223 | - $config['cache'] = $this->getApplication()->getRunTimePath() . '/i18n'; |
|
224 | - if(!is_dir($config['cache'])) |
|
223 | + $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
224 | + if (!is_dir($config['cache'])) |
|
225 | 225 | { |
226 | - if(@mkdir($config['cache']) === false) |
|
226 | + if (@mkdir($config['cache']) === false) |
|
227 | 227 | throw new TConfigurationException('globalization_cache_path_failed', |
228 | 228 | $config['cache']); |
229 | 229 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function getCultureVariants($culture = null) |
262 | 262 | { |
263 | - if($culture === null) $culture = $this->getCulture(); |
|
263 | + if ($culture === null) $culture = $this->getCulture(); |
|
264 | 264 | $variants = explode('_', $culture); |
265 | 265 | $result = []; |
266 | - for(; count($variants) > 0; array_pop($variants)) |
|
266 | + for (; count($variants) > 0; array_pop($variants)) |
|
267 | 267 | $result[] = implode('_', $variants); |
268 | 268 | return $result; |
269 | 269 | } |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | $files = []; |
293 | 293 | $variants = $this->getCultureVariants($culture); |
294 | 294 | $path = pathinfo($file); |
295 | - foreach($variants as $variant) |
|
296 | - $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename']; |
|
295 | + foreach ($variants as $variant) |
|
296 | + $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
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 | $files[] = $file; |
301 | 301 | return $files; |
302 | 302 | } |
@@ -74,22 +74,25 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function init($config) |
76 | 76 | { |
77 | - if($this->_charset === null) |
|
78 | - $this->_charset = $this->getDefaultCharset(); |
|
79 | - if($this->_culture === null) |
|
80 | - $this->_culture = $this->getDefaultCulture(); |
|
77 | + if($this->_charset === null) { |
|
78 | + $this->_charset = $this->getDefaultCharset(); |
|
79 | + } |
|
80 | + if($this->_culture === null) { |
|
81 | + $this->_culture = $this->getDefaultCulture(); |
|
82 | + } |
|
81 | 83 | |
82 | 84 | if($config !== null) |
83 | 85 | { |
84 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
85 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
86 | - else |
|
86 | + if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { |
|
87 | + $translation = isset($config['translate'])?$config['translate']:null; |
|
88 | + } else |
|
87 | 89 | { |
88 | 90 | $t = $config->getElementByTagName('translation'); |
89 | 91 | $translation = ($t)?$t->getAttributes():null; |
90 | 92 | } |
91 | - if($translation) |
|
92 | - $this->setTranslationConfiguration($translation); |
|
93 | + if($translation) { |
|
94 | + $this->setTranslationConfiguration($translation); |
|
95 | + } |
|
93 | 96 | } |
94 | 97 | $this->getApplication()->setGlobalization($this); |
95 | 98 | } |
@@ -207,13 +210,13 @@ discard block |
||
207 | 210 | $config['source'] = Prado::getPathOfNamespace($config['source']); |
208 | 211 | if(!is_dir($config['source'])) |
209 | 212 | { |
210 | - if(@mkdir($config['source']) === false) |
|
211 | - throw new TConfigurationException('globalization_source_path_failed', |
|
213 | + if(@mkdir($config['source']) === false) { |
|
214 | + throw new TConfigurationException('globalization_source_path_failed', |
|
212 | 215 | $config['source']); |
216 | + } |
|
213 | 217 | chmod($config['source'], PRADO_CHMOD); //make it deletable |
214 | 218 | } |
215 | - } |
|
216 | - else |
|
219 | + } else |
|
217 | 220 | { |
218 | 221 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
219 | 222 | } |
@@ -223,13 +226,13 @@ discard block |
||
223 | 226 | $config['cache'] = $this->getApplication()->getRunTimePath() . '/i18n'; |
224 | 227 | if(!is_dir($config['cache'])) |
225 | 228 | { |
226 | - if(@mkdir($config['cache']) === false) |
|
227 | - throw new TConfigurationException('globalization_cache_path_failed', |
|
229 | + if(@mkdir($config['cache']) === false) { |
|
230 | + throw new TConfigurationException('globalization_cache_path_failed', |
|
228 | 231 | $config['cache']); |
232 | + } |
|
229 | 233 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
230 | 234 | } |
231 | - } |
|
232 | - else |
|
235 | + } else |
|
233 | 236 | { |
234 | 237 | unset($config['cache']); |
235 | 238 | } |
@@ -260,11 +263,14 @@ discard block |
||
260 | 263 | */ |
261 | 264 | public function getCultureVariants($culture = null) |
262 | 265 | { |
263 | - if($culture === null) $culture = $this->getCulture(); |
|
266 | + if($culture === null) { |
|
267 | + $culture = $this->getCulture(); |
|
268 | + } |
|
264 | 269 | $variants = explode('_', $culture); |
265 | 270 | $result = []; |
266 | - for(; count($variants) > 0; array_pop($variants)) |
|
267 | - $result[] = implode('_', $variants); |
|
271 | + for(; count($variants) > 0; array_pop($variants)) { |
|
272 | + $result[] = implode('_', $variants); |
|
273 | + } |
|
268 | 274 | return $result; |
269 | 275 | } |
270 | 276 | |
@@ -292,11 +298,13 @@ discard block |
||
292 | 298 | $files = []; |
293 | 299 | $variants = $this->getCultureVariants($culture); |
294 | 300 | $path = pathinfo($file); |
295 | - foreach($variants as $variant) |
|
296 | - $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename']; |
|
301 | + foreach($variants as $variant) { |
|
302 | + $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename']; |
|
303 | + } |
|
297 | 304 | $filename = substr($path['basename'], 0, strrpos($path['basename'], '.')); |
298 | - foreach($variants as $variant) |
|
299 | - $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension']; |
|
305 | + foreach($variants as $variant) { |
|
306 | + $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension']; |
|
307 | + } |
|
300 | 308 | $files[] = $file; |
301 | 309 | return $files; |
302 | 310 | } |
@@ -49,11 +49,11 @@ |
||
49 | 49 | $charset = $this->getViewState('Charset', ''); |
50 | 50 | |
51 | 51 | //fall back to globalization charset |
52 | - if(empty($charset)) |
|
52 | + if (empty($charset)) |
|
53 | 53 | $charset = ($app === null) ? '' : $app->getCharset(); |
54 | 54 | |
55 | 55 | //fall back to default charset |
56 | - if(empty($charset)) |
|
56 | + if (empty($charset)) |
|
57 | 57 | $charset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
58 | 58 | |
59 | 59 | return $charset; |
@@ -49,12 +49,14 @@ |
||
49 | 49 | $charset = $this->getViewState('Charset', ''); |
50 | 50 | |
51 | 51 | //fall back to globalization charset |
52 | - if(empty($charset)) |
|
53 | - $charset = ($app === null) ? '' : $app->getCharset(); |
|
52 | + if(empty($charset)) { |
|
53 | + $charset = ($app === null) ? '' : $app->getCharset(); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | //fall back to default charset |
56 | - if(empty($charset)) |
|
57 | - $charset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
57 | + if(empty($charset)) { |
|
58 | + $charset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | return $charset; |
60 | 62 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | { |
174 | 174 | $type = strtolower($type); |
175 | 175 | |
176 | - switch($type) |
|
176 | + switch ($type) |
|
177 | 177 | { |
178 | 178 | case 'decimal': |
179 | 179 | $this->setViewState('Type', 'd', ''); break; |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | { |
218 | 218 | $value = $this->getValue(); |
219 | 219 | $defaultText = $this->getDefaultText(); |
220 | - if(empty($value) && !empty($defaultText)) |
|
220 | + if (empty($value) && !empty($defaultText)) |
|
221 | 221 | return $this->getDefaultText(); |
222 | 222 | |
223 | 223 | $app = $this->getApplication()->getGlobalization(); |
224 | 224 | //initialized the default class wide formatter |
225 | - if(self::$formatter === null) |
|
225 | + if (self::$formatter === null) |
|
226 | 226 | self::$formatter = new NumberFormat($app->getCulture()); |
227 | 227 | |
228 | 228 | $pattern = strlen($this->getPattern()) > 0 |
@@ -230,16 +230,16 @@ discard block |
||
230 | 230 | |
231 | 231 | $culture = $this->getCulture(); |
232 | 232 | //return the specific cultural formatted number |
233 | - if(!empty($culture) && $app->getCulture() != $culture) |
|
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 | } |
@@ -217,13 +217,15 @@ |
||
217 | 217 | { |
218 | 218 | $value = $this->getValue(); |
219 | 219 | $defaultText = $this->getDefaultText(); |
220 | - if(empty($value) && !empty($defaultText)) |
|
221 | - return $this->getDefaultText(); |
|
220 | + if(empty($value) && !empty($defaultText)) { |
|
221 | + return $this->getDefaultText(); |
|
222 | + } |
|
222 | 223 | |
223 | 224 | $app = $this->getApplication()->getGlobalization(); |
224 | 225 | //initialized the default class wide formatter |
225 | - if(self::$formatter === null) |
|
226 | - self::$formatter = new NumberFormat($app->getCulture()); |
|
226 | + if(self::$formatter === null) { |
|
227 | + self::$formatter = new NumberFormat($app->getCulture()); |
|
228 | + } |
|
227 | 229 | |
228 | 230 | $pattern = strlen($this->getPattern()) > 0 |
229 | 231 | ? $this->getPattern() : $this->getType(); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getParameters() |
148 | 148 | { |
149 | - if($parameters = $this->getViewState('Parameters', null)) |
|
149 | + if ($parameters = $this->getViewState('Parameters', null)) |
|
150 | 150 | return $parameters; |
151 | 151 | else |
152 | 152 | { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function hasParameter($name) |
164 | 164 | { |
165 | - if($parameters = $this->getViewState('Parameters', null)) |
|
165 | + if ($parameters = $this->getViewState('Parameters', null)) |
|
166 | 166 | return $parameters->contains($name); |
167 | 167 | else |
168 | 168 | return false; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function getParameter($name) |
175 | 175 | { |
176 | - if($parameters = $this->getViewState('Parameters', null)) |
|
176 | + if ($parameters = $this->getViewState('Parameters', null)) |
|
177 | 177 | return $parameters->itemAt($name); |
178 | 178 | else |
179 | 179 | return null; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function removeParameter($name) |
197 | 197 | { |
198 | - if($parameters = $this->getViewState('Parameters', null)) |
|
198 | + if ($parameters = $this->getViewState('Parameters', null)) |
|
199 | 199 | return $parameters->remove($name); |
200 | 200 | else |
201 | 201 | return null; |
@@ -208,22 +208,22 @@ discard block |
||
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; |
|
213 | - foreach($this->getControls() as $control) |
|
211 | + foreach ($this->getParameters() as $key => $value) |
|
212 | + $subs['{'.$key.'}'] = $value; |
|
213 | + foreach ($this->getControls() as $control) |
|
214 | 214 | { |
215 | - if($control instanceof TTranslateParameter) |
|
216 | - $subs['{' . $control->getKey() . '}'] = $control->getParameter(); |
|
217 | - elseif($control instanceof TControl) |
|
215 | + if ($control instanceof TTranslateParameter) |
|
216 | + $subs['{'.$control->getKey().'}'] = $control->getParameter(); |
|
217 | + elseif ($control instanceof TControl) |
|
218 | 218 | $control->render($htmlWriter); |
219 | - elseif(is_string($control)) |
|
219 | + elseif (is_string($control)) |
|
220 | 220 | $htmlWriter->write($control); |
221 | 221 | } |
222 | 222 | |
223 | 223 | $text = $this->getText(); |
224 | - if(strlen($text) == 0) |
|
224 | + if (strlen($text) == 0) |
|
225 | 225 | $text = $htmlWriter->flush(); |
226 | - if($this->getTrim()) |
|
226 | + if ($this->getTrim()) |
|
227 | 227 | $text = trim($text); |
228 | 228 | |
229 | 229 | $writer->write($this->translateText($text, $subs)); |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | $app = $this->getApplication()->getGlobalization(); |
241 | 241 | |
242 | 242 | //no translation handler provided |
243 | - if(($config = $app->getTranslationConfiguration()) === null) |
|
243 | + if (($config = $app->getTranslationConfiguration()) === null) |
|
244 | 244 | return strtr($text, $subs); |
245 | 245 | |
246 | 246 | $catalogue = $this->getCatalogue(); |
247 | - if(empty($catalogue) && isset($config['catalogue'])) |
|
247 | + if (empty($catalogue) && isset($config['catalogue'])) |
|
248 | 248 | $catalogue = $config['catalogue']; |
249 | 249 | if (empty($catalogue)) $catalogue = 'messages'; |
250 | 250 | Translation::init($catalogue); |
251 | 251 | |
252 | 252 | $key = $this->getKey(); |
253 | - if(!empty($key)) $text = $key; |
|
253 | + if (!empty($key)) $text = $key; |
|
254 | 254 | |
255 | 255 | //translate it |
256 | 256 | return Translation::formatter($catalogue)->format($text, |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getParameters() |
148 | 148 | { |
149 | - if($parameters = $this->getViewState('Parameters', null)) |
|
150 | - return $parameters; |
|
151 | - else |
|
149 | + if($parameters = $this->getViewState('Parameters', null)) { |
|
150 | + return $parameters; |
|
151 | + } else |
|
152 | 152 | { |
153 | 153 | $parameters = new TAttributeCollection; |
154 | 154 | $parameters->setCaseSensitive(true); |
@@ -162,10 +162,11 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function hasParameter($name) |
164 | 164 | { |
165 | - if($parameters = $this->getViewState('Parameters', null)) |
|
166 | - return $parameters->contains($name); |
|
167 | - else |
|
168 | - return false; |
|
165 | + if($parameters = $this->getViewState('Parameters', null)) { |
|
166 | + return $parameters->contains($name); |
|
167 | + } else { |
|
168 | + return false; |
|
169 | + } |
|
169 | 170 | } |
170 | 171 | |
171 | 172 | /** |
@@ -173,10 +174,11 @@ discard block |
||
173 | 174 | */ |
174 | 175 | public function getParameter($name) |
175 | 176 | { |
176 | - if($parameters = $this->getViewState('Parameters', null)) |
|
177 | - return $parameters->itemAt($name); |
|
178 | - else |
|
179 | - return null; |
|
177 | + if($parameters = $this->getViewState('Parameters', null)) { |
|
178 | + return $parameters->itemAt($name); |
|
179 | + } else { |
|
180 | + return null; |
|
181 | + } |
|
180 | 182 | } |
181 | 183 | |
182 | 184 | /** |
@@ -195,10 +197,11 @@ discard block |
||
195 | 197 | */ |
196 | 198 | public function removeParameter($name) |
197 | 199 | { |
198 | - if($parameters = $this->getViewState('Parameters', null)) |
|
199 | - return $parameters->remove($name); |
|
200 | - else |
|
201 | - return null; |
|
200 | + if($parameters = $this->getViewState('Parameters', null)) { |
|
201 | + return $parameters->remove($name); |
|
202 | + } else { |
|
203 | + return null; |
|
204 | + } |
|
202 | 205 | } |
203 | 206 | |
204 | 207 | /** |
@@ -208,23 +211,27 @@ discard block |
||
208 | 211 | { |
209 | 212 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
210 | 213 | $subs = []; |
211 | - foreach($this->getParameters() as $key => $value) |
|
212 | - $subs['{' . $key . '}'] = $value; |
|
214 | + foreach($this->getParameters() as $key => $value) { |
|
215 | + $subs['{' . $key . '}'] = $value; |
|
216 | + } |
|
213 | 217 | foreach($this->getControls() as $control) |
214 | 218 | { |
215 | - if($control instanceof TTranslateParameter) |
|
216 | - $subs['{' . $control->getKey() . '}'] = $control->getParameter(); |
|
217 | - elseif($control instanceof TControl) |
|
218 | - $control->render($htmlWriter); |
|
219 | - elseif(is_string($control)) |
|
220 | - $htmlWriter->write($control); |
|
219 | + if($control instanceof TTranslateParameter) { |
|
220 | + $subs['{' . $control->getKey() . '}'] = $control->getParameter(); |
|
221 | + } elseif($control instanceof TControl) { |
|
222 | + $control->render($htmlWriter); |
|
223 | + } elseif(is_string($control)) { |
|
224 | + $htmlWriter->write($control); |
|
225 | + } |
|
221 | 226 | } |
222 | 227 | |
223 | 228 | $text = $this->getText(); |
224 | - if(strlen($text) == 0) |
|
225 | - $text = $htmlWriter->flush(); |
|
226 | - if($this->getTrim()) |
|
227 | - $text = trim($text); |
|
229 | + if(strlen($text) == 0) { |
|
230 | + $text = $htmlWriter->flush(); |
|
231 | + } |
|
232 | + if($this->getTrim()) { |
|
233 | + $text = trim($text); |
|
234 | + } |
|
228 | 235 | |
229 | 236 | $writer->write($this->translateText($text, $subs)); |
230 | 237 | } |
@@ -240,17 +247,23 @@ discard block |
||
240 | 247 | $app = $this->getApplication()->getGlobalization(); |
241 | 248 | |
242 | 249 | //no translation handler provided |
243 | - if(($config = $app->getTranslationConfiguration()) === null) |
|
244 | - return strtr($text, $subs); |
|
250 | + if(($config = $app->getTranslationConfiguration()) === null) { |
|
251 | + return strtr($text, $subs); |
|
252 | + } |
|
245 | 253 | |
246 | 254 | $catalogue = $this->getCatalogue(); |
247 | - if(empty($catalogue) && isset($config['catalogue'])) |
|
248 | - $catalogue = $config['catalogue']; |
|
249 | - if (empty($catalogue)) $catalogue = 'messages'; |
|
255 | + if(empty($catalogue) && isset($config['catalogue'])) { |
|
256 | + $catalogue = $config['catalogue']; |
|
257 | + } |
|
258 | + if (empty($catalogue)) { |
|
259 | + $catalogue = 'messages'; |
|
260 | + } |
|
250 | 261 | Translation::init($catalogue); |
251 | 262 | |
252 | 263 | $key = $this->getKey(); |
253 | - if(!empty($key)) $text = $key; |
|
264 | + if(!empty($key)) { |
|
265 | + $text = $key; |
|
266 | + } |
|
254 | 267 | |
255 | 268 | //translate it |
256 | 269 | return Translation::formatter($catalogue)->format($text, |
@@ -29,7 +29,7 @@ |
||
29 | 29 | //set the culture according to browser language settings |
30 | 30 | $http = new core\HTTPNegotiator(); |
31 | 31 | $languages = $http->getLanguages(); |
32 | - if(count($languages) > 0) |
|
32 | + if (count($languages) > 0) |
|
33 | 33 | { |
34 | 34 | $this->_detectedLanguage = $languages[0]; |
35 | 35 | $this->setCulture($languages[0]); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @license PHP License |
39 | 39 | */ |
40 | 40 | |
41 | -require_once dirname(__FILE__) . '/TGettext.php'; |
|
41 | +require_once dirname(__FILE__).'/TGettext.php'; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * File_Gettext_PO |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // match all msgid/msgstr entries |
86 | 86 | $matched = preg_match_all( |
87 | - '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' . |
|
87 | + '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+'. |
|
88 | 88 | '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/', |
89 | 89 | $contents, $matches |
90 | 90 | ); |
@@ -137,17 +137,17 @@ discard block |
||
137 | 137 | } |
138 | 138 | // write meta info |
139 | 139 | if (count($this->meta)) { |
140 | - $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n"; |
|
140 | + $meta = 'msgid ""'."\nmsgstr ".'""'."\n"; |
|
141 | 141 | foreach ($this->meta as $k => $v) { |
142 | - $meta .= '"' . $k . ': ' . $v . '\n"' . "\n"; |
|
142 | + $meta .= '"'.$k.': '.$v.'\n"'."\n"; |
|
143 | 143 | } |
144 | - fwrite($fh, $meta . "\n"); |
|
144 | + fwrite($fh, $meta."\n"); |
|
145 | 145 | } |
146 | 146 | // write strings |
147 | 147 | foreach ($this->strings as $o => $t) { |
148 | 148 | fwrite($fh, |
149 | - 'msgid "' . parent::prepare($o, true) . '"' . "\n" . |
|
150 | - 'msgstr "' . parent::prepare($t, true) . '"' . "\n\n" |
|
149 | + 'msgid "'.parent::prepare($o, true).'"'."\n". |
|
150 | + 'msgstr "'.parent::prepare($t, true).'"'."\n\n" |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 |