@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function getCharset() |
43 | 43 | { |
44 | - $app = $this->getApplication()->getGlobalization(false); |
|
44 | + $app=$this->getApplication()->getGlobalization(false); |
|
45 | 45 | |
46 | 46 | //instance charset |
47 | - $charset = $this->getViewState('Charset',''); |
|
47 | + $charset=$this->getViewState('Charset', ''); |
|
48 | 48 | |
49 | 49 | //fall back to globalization charset |
50 | 50 | if(empty($charset)) |
51 | - $charset = ($app===null) ? '' : $app->getCharset(); |
|
51 | + $charset=($app===null) ? '' : $app->getCharset(); |
|
52 | 52 | |
53 | 53 | //fall back to default charset |
54 | 54 | if(empty($charset)) |
55 | - $charset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
55 | + $charset=($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
56 | 56 | |
57 | 57 | return $charset; |
58 | 58 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function setCharset($value) |
65 | 65 | { |
66 | - $this->setViewState('Charset',$value,''); |
|
66 | + $this->setViewState('Charset', $value, ''); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getCulture() |
76 | 76 | { |
77 | - return $this->getViewState('Culture',''); |
|
77 | + return $this->getViewState('Culture', ''); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function setCulture($culture) |
85 | 85 | { |
86 | - $this->setViewState('Culture',$culture,''); |
|
86 | + $this->setViewState('Culture', $culture, ''); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getValue() |
82 | 82 | { |
83 | - return $this->getViewState('Value',''); |
|
83 | + return $this->getViewState('Value', ''); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setValue($value) |
91 | 91 | { |
92 | - $this->setViewState('Value',$value,''); |
|
92 | + $this->setViewState('Value', $value, ''); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function translateText($text, $subs) |
101 | 101 | { |
102 | - $text = parent::translateText($text, $subs); |
|
103 | - $choice = new ChoiceFormat(); |
|
104 | - $value = $this->getValue(); |
|
105 | - $string = $choice->format($text, $value); |
|
102 | + $text=parent::translateText($text, $subs); |
|
103 | + $choice=new ChoiceFormat(); |
|
104 | + $value=$this->getValue(); |
|
105 | + $string=$choice->format($text, $value); |
|
106 | 106 | if($string) |
107 | 107 | return strtr($string, array('{Value}'=> $value)); |
108 | 108 | } |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | * Default character set is 'UTF-8'. |
30 | 30 | * @var string |
31 | 31 | */ |
32 | - private $_defaultCharset = 'UTF-8'; |
|
32 | + private $_defaultCharset='UTF-8'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Default culture is 'en'. |
36 | 36 | * @var string |
37 | 37 | */ |
38 | - private $_defaultCulture = 'en'; |
|
38 | + private $_defaultCulture='en'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * The current charset. |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | if($config!==null) |
78 | 78 | { |
79 | 79 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
80 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
80 | + $translation=isset($config['translate']) ? $config['translate'] : null; |
|
81 | 81 | else |
82 | 82 | { |
83 | - $t = $config->getElementByTagName('translation'); |
|
84 | - $translation = ($t)?$t->getAttributes():null; |
|
83 | + $t=$config->getElementByTagName('translation'); |
|
84 | + $translation=($t) ? $t->getAttributes() : null; |
|
85 | 85 | } |
86 | 86 | if($translation) |
87 | 87 | $this->setTranslationConfiguration($translation); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function setTranslateDefaultCulture($value) |
104 | 104 | { |
105 | - $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value); |
|
105 | + $this->_translateDefaultCulture=TPropertyValue::ensureBoolean($value); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function setDefaultCulture($culture) |
120 | 120 | { |
121 | - $this->_defaultCulture = str_replace('-','_',$culture); |
|
121 | + $this->_defaultCulture=str_replace('-', '_', $culture); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function setDefaultCharset($charset) |
136 | 136 | { |
137 | - $this->_defaultCharset = $charset; |
|
137 | + $this->_defaultCharset=$charset; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function setCulture($culture) |
152 | 152 | { |
153 | - $this->_culture = str_replace('-','_',$culture); |
|
153 | + $this->_culture=str_replace('-', '_', $culture); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function setCharset($charset) |
168 | 168 | { |
169 | - $this->_charset = $charset; |
|
169 | + $this->_charset=$charset; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function getTranslationConfiguration() |
176 | 176 | { |
177 | - return (!$this->_translateDefaultCulture && ($this->getDefaultCulture() == $this->getCulture())) |
|
177 | + return (!$this->_translateDefaultCulture && ($this->getDefaultCulture()==$this->getCulture())) |
|
178 | 178 | ? null |
179 | 179 | : $this->_translation; |
180 | 180 | } |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function setTranslationConfiguration($config) |
198 | 198 | { |
199 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext') |
|
199 | + if($config['type']=='XLIFF' || $config['type']=='gettext') |
|
200 | 200 | { |
201 | 201 | if($config['source']) |
202 | 202 | { |
203 | - $config['source'] = Prado::getPathOfNamespace($config['source']); |
|
203 | + $config['source']=Prado::getPathOfNamespace($config['source']); |
|
204 | 204 | if(!is_dir($config['source'])) |
205 | 205 | { |
206 | 206 | if(@mkdir($config['source'])===false) |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | if($config['cache']) |
218 | 218 | { |
219 | - $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
219 | + $config['cache']=$this->getApplication()->getRunTimePath().'/i18n'; |
|
220 | 220 | if(!is_dir($config['cache'])) |
221 | 221 | { |
222 | 222 | if(@mkdir($config['cache'])===false) |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
226 | 226 | } |
227 | 227 | } |
228 | - $this->_translation = $config; |
|
228 | + $this->_translation=$config; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function setTranslationCatalogue($value) |
243 | 243 | { |
244 | - $this->_translation['catalogue'] = $value; |
|
244 | + $this->_translation['catalogue']=$value; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function getCultureVariants($culture=null) |
254 | 254 | { |
255 | - if($culture===null) $culture = $this->getCulture(); |
|
256 | - $variants = explode('_', $culture); |
|
257 | - $result = array(); |
|
255 | + if($culture===null) $culture=$this->getCulture(); |
|
256 | + $variants=explode('_', $culture); |
|
257 | + $result=array(); |
|
258 | 258 | for(; count($variants) > 0; array_pop($variants)) |
259 | - $result[] = implode('_', $variants); |
|
259 | + $result[]=implode('_', $variants); |
|
260 | 260 | return $result; |
261 | 261 | } |
262 | 262 | |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | * @param string culture string, null to use current culture |
280 | 280 | * @return array list of possible localized resource files. |
281 | 281 | */ |
282 | - public function getLocalizedResource($file,$culture=null) |
|
282 | + public function getLocalizedResource($file, $culture=null) |
|
283 | 283 | { |
284 | - $files = array(); |
|
285 | - $variants = $this->getCultureVariants($culture); |
|
286 | - $path = pathinfo($file); |
|
284 | + $files=array(); |
|
285 | + $variants=$this->getCultureVariants($culture); |
|
286 | + $path=pathinfo($file); |
|
287 | 287 | foreach($variants as $variant) |
288 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
289 | - $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
|
288 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
289 | + $filename=substr($path['basename'], 0, strrpos($path['basename'], '.')); |
|
290 | 290 | foreach($variants as $variant) |
291 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
292 | - $files[] = $file; |
|
291 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
292 | + $files[]=$file; |
|
293 | 293 | return $files; |
294 | 294 | } |
295 | 295 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getText() |
68 | 68 | { |
69 | - return $this->getViewState('Text',''); |
|
69 | + return $this->getViewState('Text', ''); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function setText($value) |
77 | 77 | { |
78 | - $this->setViewState('Text',$value,''); |
|
78 | + $this->setViewState('Text', $value, ''); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setKey($value) |
86 | 86 | { |
87 | - $this->setViewState('Key',$value,''); |
|
87 | + $this->setViewState('Key', $value, ''); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getKey() |
95 | 95 | { |
96 | - return $this->getViewState('Key',''); |
|
96 | + return $this->getViewState('Key', ''); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function getCatalogue() |
104 | 104 | { |
105 | - return $this->getViewState('Catalogue',''); |
|
105 | + return $this->getViewState('Catalogue', ''); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setCatalogue($value) |
113 | 113 | { |
114 | - $this->setViewState('Catalogue',$value,''); |
|
114 | + $this->setViewState('Catalogue', $value, ''); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function setTrim($value) |
122 | 122 | { |
123 | - $this->setViewState('Trim',TPropertyValue::ensureBoolean($value),true); |
|
123 | + $this->setViewState('Trim', TPropertyValue::ensureBoolean($value), true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getTrim() |
131 | 131 | { |
132 | - return $this->getViewState('Trim',true); |
|
132 | + return $this->getViewState('Trim', true); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function getParameters() |
142 | 142 | { |
143 | - if($parameters=$this->getViewState('Parameters',null)) |
|
143 | + if($parameters=$this->getViewState('Parameters', null)) |
|
144 | 144 | return $parameters; |
145 | 145 | else |
146 | 146 | { |
147 | 147 | $parameters=new TAttributeCollection; |
148 | 148 | $parameters->setCaseSensitive(true); |
149 | - $this->setViewState('Parameters',$parameters,null); |
|
149 | + $this->setViewState('Parameters', $parameters, null); |
|
150 | 150 | return $parameters; |
151 | 151 | } |
152 | 152 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function hasParameter($name) |
158 | 158 | { |
159 | - if($parameters=$this->getViewState('Parameters',null)) |
|
159 | + if($parameters=$this->getViewState('Parameters', null)) |
|
160 | 160 | return $parameters->contains($name); |
161 | 161 | else |
162 | 162 | return false; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getParameter($name) |
169 | 169 | { |
170 | - if($parameters=$this->getViewState('Parameters',null)) |
|
170 | + if($parameters=$this->getViewState('Parameters', null)) |
|
171 | 171 | return $parameters->itemAt($name); |
172 | 172 | else |
173 | 173 | return null; |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | * @param string parameter name |
178 | 178 | * @param string value of the parameter |
179 | 179 | */ |
180 | - public function setParameter($name,$value) |
|
180 | + public function setParameter($name, $value) |
|
181 | 181 | { |
182 | - $this->getParameters()->add($name,$value); |
|
182 | + $this->getParameters()->add($name, $value); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function removeParameter($name) |
191 | 191 | { |
192 | - if($parameters=$this->getViewState('Parameters',null)) |
|
192 | + if($parameters=$this->getViewState('Parameters', null)) |
|
193 | 193 | return $parameters->remove($name); |
194 | 194 | else |
195 | 195 | return null; |
@@ -200,25 +200,25 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function render($writer) |
202 | 202 | { |
203 | - $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
204 | - $subs = array(); |
|
203 | + $htmlWriter=Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
204 | + $subs=array(); |
|
205 | 205 | foreach($this->getParameters() as $key => $value) |
206 | - $subs['{'.$key.'}'] = $value; |
|
206 | + $subs['{'.$key.'}']=$value; |
|
207 | 207 | foreach($this->getControls() as $control) |
208 | 208 | { |
209 | 209 | if($control instanceof TTranslateParameter) |
210 | - $subs['{'.$control->getKey().'}'] = $control->getParameter(); |
|
210 | + $subs['{'.$control->getKey().'}']=$control->getParameter(); |
|
211 | 211 | elseif($control instanceof TControl) |
212 | 212 | $control->render($htmlWriter); |
213 | 213 | elseif(is_string($control)) |
214 | 214 | $htmlWriter->write($control); |
215 | 215 | } |
216 | 216 | |
217 | - $text = $this->getText(); |
|
217 | + $text=$this->getText(); |
|
218 | 218 | if(strlen($text)==0) |
219 | - $text = $htmlWriter->flush(); |
|
219 | + $text=$htmlWriter->flush(); |
|
220 | 220 | if($this->getTrim()) |
221 | - $text = trim($text); |
|
221 | + $text=trim($text); |
|
222 | 222 | |
223 | 223 | $writer->write($this->translateText($text, $subs)); |
224 | 224 | } |
@@ -231,20 +231,20 @@ discard block |
||
231 | 231 | */ |
232 | 232 | protected function translateText($text, $subs) |
233 | 233 | { |
234 | - $app = $this->getApplication()->getGlobalization(); |
|
234 | + $app=$this->getApplication()->getGlobalization(); |
|
235 | 235 | |
236 | 236 | //no translation handler provided |
237 | - if(($config = $app->getTranslationConfiguration())===null) |
|
237 | + if(($config=$app->getTranslationConfiguration())===null) |
|
238 | 238 | return strtr($text, $subs); |
239 | 239 | |
240 | - $catalogue = $this->getCatalogue(); |
|
240 | + $catalogue=$this->getCatalogue(); |
|
241 | 241 | if(empty($catalogue) && isset($config['catalogue'])) |
242 | - $catalogue = $config['catalogue']; |
|
243 | - if (empty($catalogue)) $catalogue='messages'; |
|
242 | + $catalogue=$config['catalogue']; |
|
243 | + if(empty($catalogue)) $catalogue='messages'; |
|
244 | 244 | Translation::init($catalogue); |
245 | 245 | |
246 | - $key = $this->getKey(); |
|
247 | - if(!empty($key)) $text = $key; |
|
246 | + $key=$this->getKey(); |
|
247 | + if(!empty($key)) $text=$key; |
|
248 | 248 | |
249 | 249 | //translate it |
250 | 250 | return Translation::formatter($catalogue)->format($text, |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * A set of pattern presets and their respective formatting shorthand. |
71 | 71 | * @var array |
72 | 72 | */ |
73 | - static private $_patternPresets = array( |
|
74 | - 'fulldate'=>'P','full'=>'P', |
|
75 | - 'longdate'=>'D','long'=>'d', |
|
76 | - 'mediumdate'=>'p','medium'=>'p', |
|
77 | - 'shortdate'=>'d','short'=>'d', |
|
73 | + static private $_patternPresets=array( |
|
74 | + 'fulldate'=>'P', 'full'=>'P', |
|
75 | + 'longdate'=>'D', 'long'=>'d', |
|
76 | + 'mediumdate'=>'p', 'medium'=>'p', |
|
77 | + 'shortdate'=>'d', 'short'=>'d', |
|
78 | 78 | 'fulltime'=>'Q', 'longtime'=>'T', |
79 | 79 | 'mediumtime'=>'q', 'shorttime'=>'t'); |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setPattern($value) |
86 | 86 | { |
87 | - $this->setViewState('Pattern',$value,''); |
|
87 | + $this->setViewState('Pattern', $value, ''); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -93,35 +93,35 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getPattern() |
95 | 95 | { |
96 | - $string = $this->getViewState('Pattern',''); |
|
96 | + $string=$this->getViewState('Pattern', ''); |
|
97 | 97 | |
98 | - $pattern = null; |
|
98 | + $pattern=null; |
|
99 | 99 | |
100 | 100 | //try the subpattern of "date time" presets |
101 | - $subpatterns = explode(' ',$string,2); |
|
102 | - $datetime = array(); |
|
101 | + $subpatterns=explode(' ', $string, 2); |
|
102 | + $datetime=array(); |
|
103 | 103 | if(count($subpatterns)==2) |
104 | 104 | { |
105 | - $datetime[] = $this->getPreset($subpatterns[0]); |
|
106 | - $datetime[] = $this->getPreset($subpatterns[1]); |
|
105 | + $datetime[]=$this->getPreset($subpatterns[0]); |
|
106 | + $datetime[]=$this->getPreset($subpatterns[1]); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //we have a good subpattern |
110 | - if(count($datetime) == 2 |
|
111 | - && strlen($datetime[0]) == 1 |
|
112 | - && strlen($datetime[1]) == 1) |
|
110 | + if(count($datetime)==2 |
|
111 | + && strlen($datetime[0])==1 |
|
112 | + && strlen($datetime[1])==1) |
|
113 | 113 | { |
114 | - $pattern = $datetime; |
|
114 | + $pattern=$datetime; |
|
115 | 115 | } |
116 | 116 | else //no subpattern, try the presets |
117 | - $pattern = $this->getPreset($string); |
|
117 | + $pattern=$this->getPreset($string); |
|
118 | 118 | |
119 | 119 | //no presets found, use the string as the pattern |
120 | 120 | //and let the DateFormat handle it. |
121 | 121 | if($pattern===null) |
122 | - $pattern = $string; |
|
123 | - if (!is_array($pattern) && strlen($pattern) == 0) |
|
124 | - $pattern = null; |
|
122 | + $pattern=$string; |
|
123 | + if(!is_array($pattern) && strlen($pattern)==0) |
|
124 | + $pattern=null; |
|
125 | 125 | return $pattern; |
126 | 126 | } |
127 | 127 | |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function getPreset($string) |
134 | 134 | { |
135 | - $string = strtolower($string); |
|
135 | + $string=strtolower($string); |
|
136 | 136 | foreach(self::$_patternPresets as $pattern => $preset) |
137 | 137 | { |
138 | - if($string == $pattern) |
|
138 | + if($string==$pattern) |
|
139 | 139 | return $preset; |
140 | 140 | } |
141 | 141 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getValue() |
148 | 148 | { |
149 | - $value = $this->getViewState('Value',''); |
|
149 | + $value=$this->getViewState('Value', ''); |
|
150 | 150 | if(empty($value)) |
151 | 151 | { |
152 | - $defaultText = $this->getDefaultText(); |
|
152 | + $defaultText=$this->getDefaultText(); |
|
153 | 153 | if(empty($defaultText)) |
154 | 154 | return time(); |
155 | 155 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function setValue($value) |
164 | 164 | { |
165 | - $this->setViewState('Value',$value,''); |
|
165 | + $this->setViewState('Value', $value, ''); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function getDefaultText() |
173 | 173 | { |
174 | - return $this->getViewState('DefaultText',''); |
|
174 | + return $this->getViewState('DefaultText', ''); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function setDefaultText($value) |
182 | 182 | { |
183 | - $this->setViewState('DefaultText',$value,''); |
|
183 | + $this->setViewState('DefaultText', $value, ''); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -217,29 +217,29 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function getFormattedDate() |
219 | 219 | { |
220 | - $value = $this->getValue(); |
|
221 | - $defaultText = $this->getDefaultText(); |
|
220 | + $value=$this->getValue(); |
|
221 | + $defaultText=$this->getDefaultText(); |
|
222 | 222 | if(empty($value) && !empty($defaultText)) |
223 | 223 | return $this->getDefaultText(); |
224 | 224 | |
225 | - $app = $this->getApplication()->getGlobalization(); |
|
225 | + $app=$this->getApplication()->getGlobalization(); |
|
226 | 226 | |
227 | 227 | //initialized the default class wide formatter |
228 | 228 | if(self::$formatter===null) |
229 | - self::$formatter = new DateFormat($app->getCulture()); |
|
229 | + self::$formatter=new DateFormat($app->getCulture()); |
|
230 | 230 | |
231 | - $culture = $this->getCulture(); |
|
231 | + $culture=$this->getCulture(); |
|
232 | 232 | |
233 | 233 | //return the specific cultural formatted date time |
234 | - if(strlen($culture) && $app->getCulture() !== $culture) |
|
234 | + if(strlen($culture) && $app->getCulture()!==$culture) |
|
235 | 235 | { |
236 | - $formatter = new DateFormat($culture); |
|
236 | + $formatter=new DateFormat($culture); |
|
237 | 237 | return $formatter->format($value, |
238 | 238 | $this->getPattern(), |
239 | 239 | $this->getCharset()); |
240 | 240 | } |
241 | 241 | //return the application wide culture formatted date time. |
242 | - $result = self::$formatter->format($value, |
|
242 | + $result=self::$formatter->format($value, |
|
243 | 243 | $this->getPattern(), |
244 | 244 | $this->getCharset()); |
245 | 245 | return $result; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getPattern() |
79 | 79 | { |
80 | - return $this->getViewState('Pattern',''); |
|
80 | + return $this->getViewState('Pattern', ''); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function setPattern($pattern) |
88 | 88 | { |
89 | - $this->setViewState('Pattern',$pattern,''); |
|
89 | + $this->setViewState('Pattern', $pattern, ''); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getValue() |
97 | 97 | { |
98 | - return $this->getViewState('Value',''); |
|
98 | + return $this->getViewState('Value', ''); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function setValue($value) |
106 | 106 | { |
107 | - $this->setViewState('Value',$value,''); |
|
107 | + $this->setViewState('Value', $value, ''); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getDefaultText() |
115 | 115 | { |
116 | - return $this->getViewState('DefaultText',''); |
|
116 | + return $this->getViewState('DefaultText', ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setDefaultText($value) |
124 | 124 | { |
125 | - $this->setViewState('DefaultText',$value,''); |
|
125 | + $this->setViewState('DefaultText', $value, ''); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function getType() |
159 | 159 | { |
160 | - return $this->getViewState('Type','d'); |
|
160 | + return $this->getViewState('Type', 'd'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -168,20 +168,20 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function setType($type) |
170 | 170 | { |
171 | - $type = strtolower($type); |
|
171 | + $type=strtolower($type); |
|
172 | 172 | |
173 | 173 | switch($type) |
174 | 174 | { |
175 | 175 | case 'decimal': |
176 | - $this->setViewState('Type','d',''); break; |
|
176 | + $this->setViewState('Type', 'd', ''); break; |
|
177 | 177 | case 'currency': |
178 | - $this->setViewState('Type','c',''); break; |
|
178 | + $this->setViewState('Type', 'c', ''); break; |
|
179 | 179 | case 'percentage': |
180 | - $this->setViewState('Type','p',''); break; |
|
180 | + $this->setViewState('Type', 'p', ''); break; |
|
181 | 181 | case 'scientific': |
182 | - $this->setViewState('Type','e',''); break; |
|
182 | + $this->setViewState('Type', 'e', ''); break; |
|
183 | 183 | default: |
184 | - throw new TInvalidDataValueException('numberformat_type_invalid',$type); |
|
184 | + throw new TInvalidDataValueException('numberformat_type_invalid', $type); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function getCurrency() |
193 | 193 | { |
194 | - return $this->getViewState('Currency','USD'); |
|
194 | + return $this->getViewState('Currency', 'USD'); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setCurrency($currency) |
203 | 203 | { |
204 | - $this->setViewState('Currency', $currency,''); |
|
204 | + $this->setViewState('Currency', $currency, ''); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -212,31 +212,31 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function getFormattedValue() |
214 | 214 | { |
215 | - $value = $this->getValue(); |
|
216 | - $defaultText = $this->getDefaultText(); |
|
215 | + $value=$this->getValue(); |
|
216 | + $defaultText=$this->getDefaultText(); |
|
217 | 217 | if(empty($value) && !empty($defaultText)) |
218 | 218 | return $this->getDefaultText(); |
219 | 219 | |
220 | - $app = $this->getApplication()->getGlobalization(); |
|
220 | + $app=$this->getApplication()->getGlobalization(); |
|
221 | 221 | //initialized the default class wide formatter |
222 | 222 | if(self::$formatter===null) |
223 | - self::$formatter = new NumberFormat($app->getCulture()); |
|
223 | + self::$formatter=new NumberFormat($app->getCulture()); |
|
224 | 224 | |
225 | - $pattern = strlen($this->getPattern()) > 0 |
|
225 | + $pattern=strlen($this->getPattern()) > 0 |
|
226 | 226 | ? $this->getPattern() : $this->getType(); |
227 | 227 | |
228 | - $culture = $this->getCulture(); |
|
228 | + $culture=$this->getCulture(); |
|
229 | 229 | //return the specific cultural formatted number |
230 | - if(!empty($culture) && $app->getCulture() != $culture) |
|
230 | + if(!empty($culture) && $app->getCulture()!=$culture) |
|
231 | 231 | { |
232 | - $formatter = new NumberFormat($culture); |
|
233 | - return $formatter->format($this->getValue(),$pattern, |
|
232 | + $formatter=new NumberFormat($culture); |
|
233 | + return $formatter->format($this->getValue(), $pattern, |
|
234 | 234 | $this->getCurrency(), |
235 | 235 | $this->getCharset()); |
236 | 236 | } |
237 | 237 | |
238 | 238 | //return the application wide culture formatted number. |
239 | - return self::$formatter->format($this->getValue(),$pattern, |
|
239 | + return self::$formatter->format($this->getValue(), $pattern, |
|
240 | 240 | $this->getCurrency(), |
241 | 241 | $this->getCharset()); |
242 | 242 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
99 | 99 | $this->_templatePath=$templatePath; |
100 | 100 | else |
101 | - throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
|
101 | + throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param mixed sender of the event |
111 | 111 | * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance) |
112 | 112 | */ |
113 | - public function handleError($sender,$param) |
|
113 | + public function handleError($sender, $param) |
|
114 | 114 | { |
115 | 115 | static $handling=false; |
116 | 116 | // We need to restore error and exception handlers, |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | if(!headers_sent()) |
130 | 130 | header('Content-Type: text/html; charset=UTF-8'); |
131 | 131 | if($param instanceof THttpException) |
132 | - $this->handleExternalError($param->getStatusCode(),$param); |
|
132 | + $this->handleExternalError($param->getStatusCode(), $param); |
|
133 | 133 | else if($this->getApplication()->getMode()===TApplicationMode::Debug) |
134 | 134 | $this->displayException($param); |
135 | 135 | else |
136 | - $this->handleExternalError(500,$param); |
|
136 | + $this->handleExternalError(500, $param); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -146,21 +146,21 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected static function hideSecurityRelated($value, $exception=null) |
148 | 148 | { |
149 | - $aRpl = array(); |
|
150 | - if($exception !== null && $exception instanceof Exception) |
|
149 | + $aRpl=array(); |
|
150 | + if($exception!==null && $exception instanceof Exception) |
|
151 | 151 | { |
152 | - $aTrace = $exception->getTrace(); |
|
152 | + $aTrace=$exception->getTrace(); |
|
153 | 153 | foreach($aTrace as $item) |
154 | 154 | { |
155 | 155 | if(isset($item['file'])) |
156 | - $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
|
156 | + $aRpl[dirname($item['file']).DIRECTORY_SEPARATOR]='<hidden>'.DIRECTORY_SEPARATOR; |
|
157 | 157 | } |
158 | 158 | } |
159 | - $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
|
160 | - $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
|
161 | - $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
|
159 | + $aRpl[$_SERVER['DOCUMENT_ROOT']]='${DocumentRoot}'; |
|
160 | + $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])]='${DocumentRoot}'; |
|
161 | + $aRpl[PRADO_DIR.DIRECTORY_SEPARATOR]='${PradoFramework}'.DIRECTORY_SEPARATOR; |
|
162 | 162 | if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
163 | - $aRpl = array_reverse($aRpl, true); |
|
163 | + $aRpl=array_reverse($aRpl, true); |
|
164 | 164 | |
165 | 165 | return str_replace(array_keys($aRpl), $aRpl, $value); |
166 | 166 | } |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | * @param integer response status code |
173 | 173 | * @param Exception exception instance |
174 | 174 | */ |
175 | - protected function handleExternalError($statusCode,$exception) |
|
175 | + protected function handleExternalError($statusCode, $exception) |
|
176 | 176 | { |
177 | 177 | if(!($exception instanceof THttpException)) |
178 | 178 | error_log($exception->__toString()); |
179 | 179 | |
180 | - $content=$this->getErrorTemplate($statusCode,$exception); |
|
180 | + $content=$this->getErrorTemplate($statusCode, $exception); |
|
181 | 181 | |
182 | - $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
182 | + $serverAdmin=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
183 | 183 | |
184 | - $isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug; |
|
184 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
185 | 185 | |
186 | - $errorMessage = $exception->getMessage(); |
|
186 | + $errorMessage=$exception->getMessage(); |
|
187 | 187 | if($isDebug) |
188 | 188 | $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
189 | 189 | else |
190 | 190 | { |
191 | 191 | $version=''; |
192 | - $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
|
192 | + $errorMessage=self::hideSecurityRelated($errorMessage, $exception); |
|
193 | 193 | } |
194 | 194 | $tokens=array( |
195 | 195 | '%%StatusCode%%' => "$statusCode", |
196 | 196 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
197 | 197 | '%%ServerAdmin%%' => $serverAdmin, |
198 | 198 | '%%Version%%' => $version, |
199 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
199 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
200 | 200 | ); |
201 | 201 | |
202 | 202 | $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null); |
203 | 203 | |
204 | - echo strtr($content,$tokens); |
|
204 | + echo strtr($content, $tokens); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | if($exception instanceof TTemplateException) |
247 | 247 | { |
248 | 248 | $fileName=$exception->getTemplateFile(); |
249 | - $lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName); |
|
250 | - $source=$this->getSourceCode($lines,$exception->getLineNumber()); |
|
249 | + $lines=empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
250 | + $source=$this->getSourceCode($lines, $exception->getLineNumber()); |
|
251 | 251 | if($fileName==='') |
252 | 252 | $fileName='---embedded template---'; |
253 | 253 | $errorLine=$exception->getLineNumber(); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $fileName=$exception->getFile(); |
265 | 265 | $errorLine=$exception->getLine(); |
266 | 266 | } |
267 | - $source=$this->getSourceCode(@file($fileName),$errorLine); |
|
267 | + $source=$this->getSourceCode(@file($fileName), $errorLine); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | '%%SourceCode%%' => $source, |
280 | 280 | '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), |
281 | 281 | '%%Version%%' => $version, |
282 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
282 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
283 | 283 | ); |
284 | 284 | |
285 | 285 | $content=$this->getExceptionTemplate($exception); |
286 | 286 | |
287 | - echo strtr($content,$tokens); |
|
287 | + echo strtr($content, $tokens); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param Exception the exception to be displayed |
322 | 322 | * @return string the template content |
323 | 323 | */ |
324 | - protected function getErrorTemplate($statusCode,$exception) |
|
324 | + protected function getErrorTemplate($statusCode, $exception) |
|
325 | 325 | { |
326 | 326 | $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
327 | 327 | $lang=Prado::getPreferredLanguage(); |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | else if($exception instanceof TInvalidOperationException) |
355 | 355 | { |
356 | 356 | // in case of getter or setter error, find out the exact file and row |
357 | - if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
|
358 | - $result=$this->getPropertyAccessTrace($trace,'__set'); |
|
357 | + if(($result=$this->getPropertyAccessTrace($trace, '__get'))===null) |
|
358 | + $result=$this->getPropertyAccessTrace($trace, '__set'); |
|
359 | 359 | } |
360 | - if($result!==null && strpos($result['file'],': eval()\'d code')!==false) |
|
360 | + if($result!==null && strpos($result['file'], ': eval()\'d code')!==false) |
|
361 | 361 | return null; |
362 | 362 | |
363 | 363 | return $result; |
364 | 364 | } |
365 | 365 | |
366 | - private function getPropertyAccessTrace($trace,$pattern) |
|
366 | + private function getPropertyAccessTrace($trace, $pattern) |
|
367 | 367 | { |
368 | 368 | $result=null; |
369 | 369 | foreach($trace as $t) |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | return $result; |
377 | 377 | } |
378 | 378 | |
379 | - private function getSourceCode($lines,$errorLine) |
|
379 | + private function getSourceCode($lines, $errorLine) |
|
380 | 380 | { |
381 | - $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; |
|
382 | - $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); |
|
381 | + $beginLine=$errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
382 | + $endLine=$errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
383 | 383 | |
384 | 384 | $source=''; |
385 | - for($i=$beginLine;$i<$endLine;++$i) |
|
385 | + for($i=$beginLine; $i < $endLine; ++$i) |
|
386 | 386 | { |
387 | - if($i===$errorLine-1) |
|
387 | + if($i===$errorLine - 1) |
|
388 | 388 | { |
389 | - $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
389 | + $line=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
390 | 390 | $source.="<div class=\"error\">".$line."</div>"; |
391 | 391 | } |
392 | 392 | else |
393 | - $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
393 | + $source.=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
394 | 394 | } |
395 | 395 | return $source; |
396 | 396 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | private function addLink($message) |
399 | 399 | { |
400 | 400 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
401 | - return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message); |
|
401 | + return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | array_shift($args); |
51 | 51 | $n=count($args); |
52 | 52 | $tokens=array(); |
53 | - for($i=0;$i<$n;++$i) |
|
53 | + for($i=0; $i < $n; ++$i) |
|
54 | 54 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
55 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
55 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | $msgFile=$this->getErrorMessageFile(); |
66 | 66 | |
67 | 67 | // Cache messages |
68 | - if (!isset(self::$_messageCache[$msgFile])) |
|
68 | + if(!isset(self::$_messageCache[$msgFile])) |
|
69 | 69 | { |
70 | 70 | if(($entries=@file($msgFile))!==false) |
71 | 71 | { |
72 | 72 | foreach($entries as $entry) |
73 | 73 | { |
74 | - @list($code,$message)=explode('=',$entry,2); |
|
74 | + @list($code, $message)=explode('=', $entry, 2); |
|
75 | 75 | self::$_messageCache[$msgFile][trim($code)]=trim($message); |
76 | 76 | } |
77 | 77 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param string error file |
339 | 339 | * @param integer error line number |
340 | 340 | */ |
341 | - public function __construct($errno,$errstr,$errfile,$errline) |
|
341 | + public function __construct($errno, $errstr, $errfile, $errline) |
|
342 | 342 | { |
343 | 343 | static $errorTypes=array( |
344 | 344 | E_ERROR => "Error", |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | E_USER_NOTICE => "User Notice", |
355 | 355 | E_STRICT => "Runtime Notice" |
356 | 356 | ); |
357 | - $errorType=isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; |
|
357 | + $errorType=isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error'; |
|
358 | 358 | parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); |
359 | 359 | } |
360 | 360 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * will be used as the error message. Any rest parameters will be used |
395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
396 | 396 | */ |
397 | - public function __construct($statusCode,$errorMessage) |
|
397 | + public function __construct($statusCode, $errorMessage) |
|
398 | 398 | { |
399 | 399 | $this->_statusCode=$statusCode; |
400 | 400 | $this->setErrorCode($errorMessage); |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | array_shift($args); |
405 | 405 | $n=count($args); |
406 | 406 | $tokens=array(); |
407 | - for($i=0;$i<$n;++$i) |
|
407 | + for($i=0; $i < $n; ++$i) |
|
408 | 408 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
409 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
409 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @var array List of requirements (required or not, check item, hint) |
29 | 29 | */ |
30 | -$requirements = array( |
|
30 | +$requirements=array( |
|
31 | 31 | array( |
32 | 32 | true, |
33 | - version_compare(PHP_VERSION,"5.3.3",">="), |
|
34 | - 'PHP version check','PHP 5.3.3 or higher required'), |
|
33 | + version_compare(PHP_VERSION, "5.3.3", ">="), |
|
34 | + 'PHP version check', 'PHP 5.3.3 or higher required'), |
|
35 | 35 | array( |
36 | 36 | true, |
37 | 37 | isset($_SERVER["HTTP_ACCEPT"]), |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | 'REQUEST_URI required'), |
50 | 50 | array( |
51 | 51 | true, |
52 | - isset($_SERVER["PATH_INFO"]) || strpos($_SERVER["PHP_SELF"],$_SERVER["SCRIPT_NAME"])===0, |
|
52 | + isset($_SERVER["PATH_INFO"]) || strpos($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"])===0, |
|
53 | 53 | '$_SERVER["PATH_INFO"] check', |
54 | 54 | 'PATH_INFO required'), |
55 | 55 | array( |
56 | 56 | true, |
57 | - class_exists('Reflection',false), |
|
57 | + class_exists('Reflection', false), |
|
58 | 58 | 'Reflection extension check', |
59 | 59 | 'Reflection extension required'), |
60 | 60 | array( |
61 | 61 | true, |
62 | - class_exists("DOMDocument",false), |
|
62 | + class_exists("DOMDocument", false), |
|
63 | 63 | 'DOM extension check', |
64 | 64 | 'DOM extension required'), |
65 | 65 | array( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'JSON extension required'), |
85 | 85 | array( |
86 | 86 | false, |
87 | - class_exists("PDO",false), |
|
87 | + class_exists("PDO", false), |
|
88 | 88 | 'PDO extension check', |
89 | 89 | 'PDO extension optional'), |
90 | 90 | array( |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | 'SOAP extension optional'), |
150 | 150 | ); |
151 | 151 | |
152 | -$results = "<table class=\"result\">\n"; |
|
153 | -$conclusion = 0; |
|
152 | +$results="<table class=\"result\">\n"; |
|
153 | +$conclusion=0; |
|
154 | 154 | foreach($requirements as $requirement) |
155 | 155 | { |
156 | - list($required,$expression,$aspect,$hint)=$requirement; |
|
156 | + list($required, $expression, $aspect, $hint)=$requirement; |
|
157 | 157 | //eval('$ret='.$expression.';'); |
158 | 158 | $ret=$expression; |
159 | 159 | if($required) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | $results.="<tr class=\"$ret\"><td class=\"$ret\">".lmessage($aspect)."</td><td class=\"$ret\">".lmessage($hint)."</td></tr>\n"; |
181 | 181 | } |
182 | -$results .= '</table>'; |
|
182 | +$results.='</table>'; |
|
183 | 183 | if($conclusion===0) |
184 | 184 | $conclusion=lmessage('all passed'); |
185 | 185 | else if($conclusion===1) |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | else |
188 | 188 | $conclusion=lmessage('passed with warnings'); |
189 | 189 | |
190 | -$tokens = array( |
|
190 | +$tokens=array( |
|
191 | 191 | '%%Conclusion%%' => $conclusion, |
192 | 192 | '%%Details%%' => $results, |
193 | 193 | '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.getPradoVersion(), |
194 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%m',time()), |
|
194 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%m', time()), |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | $lang=getPreferredLanguage(); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | die("Unable to open template file '$templateFile'."); |
203 | 203 | |
204 | 204 | header('Content-Type: text/html; charset=UTF-8'); |
205 | -echo strtr($content,$tokens); |
|
205 | +echo strtr($content, $tokens); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Returns a localized message according to user preferred language. |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | static $messages=null; |
215 | 215 | if($messages===null) |
216 | 216 | { |
217 | - $lang = getPreferredLanguage(); |
|
217 | + $lang=getPreferredLanguage(); |
|
218 | 218 | $msgFile=dirname(__FILE__)."/messages-$lang.txt"; |
219 | 219 | if(!is_file($msgFile)) |
220 | 220 | $msgFile=dirname(__FILE__).'/messages.txt'; |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | { |
223 | 223 | foreach($entries as $entry) |
224 | 224 | { |
225 | - @list($code,$message)=explode('=',$entry,2); |
|
225 | + @list($code, $message)=explode('=', $entry, 2); |
|
226 | 226 | $messages[trim($code)]=trim($message); |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | - return isset($messages[$token])?$messages[$token]:$token; |
|
230 | + return isset($messages[$token]) ? $messages[$token] : $token; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | if($languages===null) |
244 | 244 | { |
245 | 245 | $languages=array(); |
246 | - foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
246 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
247 | 247 | { |
248 | - $array=explode(';q=',trim($language)); |
|
249 | - $languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0; |
|
248 | + $array=explode(';q=', trim($language)); |
|
249 | + $languages[trim($array[0])]=isset($array[1]) ? (float) $array[1] : 1.0; |
|
250 | 250 | } |
251 | 251 | arsort($languages); |
252 | 252 | $languages=array_keys($languages); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | if($language===null) |
267 | 267 | { |
268 | 268 | $langs=getUserLanguages(); |
269 | - $lang=explode('-',$langs[0]); |
|
269 | + $lang=explode('-', $langs[0]); |
|
270 | 270 | if(empty($lang[0]) || !function_exists('ctype_alpha') || !ctype_alpha($lang[0])) |
271 | 271 | $language='en'; |
272 | 272 | else |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | { |
286 | 286 | $contents=file_get_contents($coreFile); |
287 | 287 | $matches=array(); |
288 | - if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms',$contents,$matches)>0) |
|
288 | + if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms', $contents, $matches) > 0) |
|
289 | 289 | return $matches[1]; |
290 | 290 | } |
291 | 291 | return ''; |