Completed
Push — intl ( b391f2...20c33e )
by Fabio
08:04
created
framework/I18N/core/MessageFormat.php 3 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -63,25 +63,25 @@  discard block
 block discarded – undo
63 63
 	 * A list of loaded message catalogues.
64 64
 	 * @var array 
65 65
 	 */
66
-	protected $catagloues = array();
66
+	protected $catagloues=array();
67 67
 	
68 68
 	/**
69 69
 	 * The translation messages.
70 70
 	 * @var array 
71 71
 	 */
72
-	protected $messages = array();
72
+	protected $messages=array();
73 73
 	
74 74
 	/**
75 75
 	 * A list of untranslated messages.
76 76
 	 * @var array 
77 77
 	 */
78
-	protected $untranslated = array();
78
+	protected $untranslated=array();
79 79
 	
80 80
 	/**
81 81
 	 * The prefix and suffix to append to untranslated messages.
82 82
 	 * @var array 
83 83
 	 */
84
-	protected $postscript = array('','');
84
+	protected $postscript=array('', '');
85 85
 	
86 86
 	/**
87 87
 	 * Set the default catalogue.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * Output encoding charset
94 94
 	 * @var string
95 95
 	 */
96
-	protected $charset = 'UTF-8'; 
96
+	protected $charset='UTF-8'; 
97 97
 
98 98
 	/**
99 99
 	 * Constructor.
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	function __construct(IMessageSource $source, $charset='UTF-8')
106 106
 	{
107
-		$this->source = $source;	
107
+		$this->source=$source;	
108 108
 		$this->setCharset($charset);
109 109
 	}
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function setCharset($charset)
116 116
 	{
117
-		$this->charset = $charset;
117
+		$this->charset=$charset;
118 118
 	}
119 119
 
120 120
 	/**
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	protected function loadCatalogue($catalogue)
137 137
 	{
138
-		if(in_array($catalogue,$this->catagloues))
138
+		if(in_array($catalogue, $this->catagloues))
139 139
 			return;
140 140
 			
141 141
 		if($this->source->load($catalogue))
142 142
 		{
143
-			$this->messages[$catalogue] = $this->source->read();
144
-			$this->catagloues[] = $catalogue;						
143
+			$this->messages[$catalogue]=$this->source->read();
144
+			$this->catagloues[]=$catalogue;						
145 145
 		}
146 146
 	}
147 147
 
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 	 * catalogue.
159 159
 	 * @return string translated string.
160 160
 	 */
161
-	public function format($string,$args=array(), $catalogue=null, $charset=null) 
161
+	public function format($string, $args=array(), $catalogue=null, $charset=null) 
162 162
 	{
163
-		if(empty($charset)) $charset = $this->getCharset();
163
+		if(empty($charset)) $charset=$this->getCharset();
164 164
 		
165 165
 		//force args as UTF-8
166 166
 		foreach($args as $k => $v)
167
-			$args[$k] = I18N_toUTF8($v, $charset);
168
-		$s = $this->formatString(I18N_toUTF8($string, $charset),$args,$catalogue);
167
+			$args[$k]=I18N_toUTF8($v, $charset);
168
+		$s=$this->formatString(I18N_toUTF8($string, $charset), $args, $catalogue);
169 169
 		return I18N_toEncoding($s, $charset);
170 170
 	}
171 171
 
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 		if(empty($catalogue))
183 183
 		{
184 184
 			if(empty($this->Catalogue))
185
-				$catalogue = 'messages';
185
+				$catalogue='messages';
186 186
 			else 
187
-				$catalogue = $this->Catalogue;
187
+				$catalogue=$this->Catalogue;
188 188
 		}
189 189
 				
190 190
 		$this->loadCatalogue($catalogue);
191 191
 		
192 192
 		if(empty($args))
193
-			$args = array();		
193
+			$args=array();		
194 194
 		
195 195
 		foreach($this->messages[$catalogue] as $variant)
196 196
 		{
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
 			foreach($variant as $source => $result)
199 199
 			{ 
200 200
 				// we found it, so return the target translation
201
-				if($source == $string)
201
+				if($source==$string)
202 202
 				{
203 203
 					//check if it contains only strings.
204 204
 					if(is_string($result))
205
-						$target = $result;
205
+						$target=$result;
206 206
 					else
207 207
 					{
208
-						$target = $result[0];
208
+						$target=$result[0];
209 209
 					}
210 210
 					//found, but untranslated
211 211
 					if(empty($target))
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	function setUntranslatedPS($postscript)
247 247
 	{
248
-		if(is_array($postscript) && count($postscript)>=2)
248
+		if(is_array($postscript) && count($postscript) >= 2)
249 249
 		{
250
-			$this->postscript[0] = $postscript[0];
251
-			$this->postscript[1] = $postscript[1];
250
+			$this->postscript[0]=$postscript[0];
251
+			$this->postscript[1]=$postscript[1];
252 252
 		}
253 253
 	}
254 254
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
 						return 	$this->postscript[0].
214 214
 								strtr($string, $args).
215 215
 								$this->postscript[1];		
216
-					}
217
-					else
216
+					} else
218 217
 						return strtr($target, $args);
219 218
 				}
220 219
 			}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -111,6 +111,7 @@
 block discarded – undo
111 111
 	/** 
112 112
 	 * Sets the charset for message output.
113 113
 	 * @param string charset, default is UTF-8
114
+	 * @param string $charset
114 115
 	 */
115 116
 	public function setCharset($charset)
116 117
 	{
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_Database.php 3 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	function __construct($source)
43 43
 	{
44
-		$this->_connID= (string)$source;
44
+		$this->_connID=(string) $source;
45 45
 	}
46 46
 
47 47
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			if($conn instanceof TDataSourceConfig)
72 72
 				return $conn->getDbConnection();
73 73
 			else
74
-				throw new TConfigurationException('messagesource_connectionid_invalid',$connectionID);
74
+				throw new TConfigurationException('messagesource_connectionid_invalid', $connectionID);
75 75
 		}
76 76
 		else
77 77
 			throw new TConfigurationException('messagesource_connectionid_required');
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 				WHERE c.cat_id =  t.cat_id
92 92
 					AND c.name = :variant
93 93
 				ORDER BY id ASC');
94
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
94
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
95 95
 		$dataReader=$command->query();
96 96
 
97
-		$result = array();
97
+		$result=array();
98 98
 
99
-		foreach ($dataReader as $row)
100
-			$result[$row['source']] = array($row['target'],$row['id'],$row['comments']);
99
+		foreach($dataReader as $row)
100
+			$result[$row['source']]=array($row['target'], $row['id'], $row['comments']);
101 101
 
102 102
 		return $result;
103 103
 	}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	{
113 113
 		$command=$this->getDBConnection()->createCommand(
114 114
 			'SELECT date_modified FROM catalogue WHERE name = :source');
115
-		$command->bindParameter(':source',$source,PDO::PARAM_STR);
115
+		$command->bindParameter(':source', $source, PDO::PARAM_STR);
116 116
 		$result=$command->queryScalar();
117 117
 		return $result ? $result : 0;
118 118
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	{
129 129
 		$command=$this->getDBConnection()->createCommand(
130 130
 			'SELECT COUNT(*) FROM catalogue WHERE name = :variant');
131
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
131
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
132 132
 		return $command->queryScalar()==1;
133 133
 	}
134 134
 
@@ -139,18 +139,18 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function getCatalogueList($catalogue)
141 141
 	{
142
-		$variants = explode('_',$this->culture);
142
+		$variants=explode('_', $this->culture);
143 143
 
144
-		$catalogues = array($catalogue);
144
+		$catalogues=array($catalogue);
145 145
 
146
-		$variant = null;
146
+		$variant=null;
147 147
 
148
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
148
+		for($i=0, $k=count($variants); $i < $k; ++$i)
149 149
 		{
150 150
 			if(isset($variants[$i]{0}))
151 151
 			{
152
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
153
-				$catalogues[] = $catalogue.'.'.$variant;
152
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
153
+				$catalogues[]=$catalogue.'.'.$variant;
154 154
 			}
155 155
 		}
156 156
 		return array_reverse($catalogues);
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
 	private function getCatalogueDetails($catalogue='messages')
165 165
 	{
166 166
 		if(empty($catalogue))
167
-			$catalogue = 'messages';
167
+			$catalogue='messages';
168 168
 
169
-		$variant = $catalogue.'.'.$this->culture;
169
+		$variant=$catalogue.'.'.$this->culture;
170 170
 
171 171
 		$command=$this->getDBConnection()->createCommand(
172 172
 			'SELECT cat_id FROM catalogue WHERE name = :variant');
173
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
173
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
174 174
 		$cat_id=$command->queryScalar();
175 175
 
176
-		if ($cat_id===null) return false;
176
+		if($cat_id===null) return false;
177 177
 
178 178
 		$command=$this->getDBConnection()->createCommand(
179 179
 			'SELECT COUNT(msg_id) FROM trans_unit WHERE cat_id = :catid ');
180
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
180
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
181 181
 		$count=$command->queryScalar();
182 182
 
183 183
 		return array($cat_id, $variant, $count);
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	private function updateCatalogueTime($cat_id, $variant)
191 191
 	{
192
-		$time = time();
192
+		$time=time();
193 193
 		$command=$this->getDBConnection()->createCommand(
194 194
 			'UPDATE catalogue SET date_modified = :moddate WHERE cat_id = :catid');
195
-		$command->bindParameter(':moddate',$time,PDO::PARAM_INT);
196
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
195
+		$command->bindParameter(':moddate', $time, PDO::PARAM_INT);
196
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
197 197
 		$result=$command->execute();
198 198
 
199 199
 		if(!empty($this->cache))
@@ -211,31 +211,31 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
 	function save($catalogue='messages')
213 213
 	{
214
-		$messages = $this->untranslated;
214
+		$messages=$this->untranslated;
215 215
 
216 216
 		if(count($messages) <= 0) return false;
217 217
 
218
-		$details = $this->getCatalogueDetails($catalogue);
218
+		$details=$this->getCatalogueDetails($catalogue);
219 219
 
220 220
 		if($details)
221
-			list($cat_id, $variant, $count) = $details;
221
+			list($cat_id, $variant, $count)=$details;
222 222
 		else
223 223
 			return false;
224 224
 
225 225
 		if($cat_id <= 0) return false;
226
-		$inserted = 0;
226
+		$inserted=0;
227 227
 
228
-		$time = time();
228
+		$time=time();
229 229
 
230 230
 		$command=$this->getDBConnection()->createCommand(
231 231
 			'INSERT INTO trans_unit (cat_id,id,source,date_added) VALUES (:catid,:id,:source,:dateadded)');
232
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
233
-		$command->bindParameter(':id',$count,PDO::PARAM_INT);
234
-		$command->bindParameter(':source',$message,PDO::PARAM_STR);
235
-		$command->bindParameter(':dateadded',$time,PDO::PARAM_INT);
232
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
233
+		$command->bindParameter(':id', $count, PDO::PARAM_INT);
234
+		$command->bindParameter(':source', $message, PDO::PARAM_STR);
235
+		$command->bindParameter(':dateadded', $time, PDO::PARAM_INT);
236 236
 		foreach($messages as $message)
237 237
 		{
238
-			if (empty($message)) continue;
238
+			if(empty($message)) continue;
239 239
 			$count++; $inserted++;
240 240
 			$command->execute();
241 241
 		}
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	function delete($message, $catalogue='messages')
255 255
 	{
256
-		$details = $this->getCatalogueDetails($catalogue);
256
+		$details=$this->getCatalogueDetails($catalogue);
257 257
 		if($details)
258
-			list($cat_id, $variant, $count) = $details;
258
+			list($cat_id, $variant, $count)=$details;
259 259
 		else
260 260
 			return false;
261 261
 
262 262
 		$command=$this->getDBConnection()->createCommand(
263 263
 			'DELETE FROM trans_unit WHERE cat_id = :catid AND source = :message');
264
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
265
-		$command->bindParameter(':message',$message,PDO::PARAM_STR);
264
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
265
+		$command->bindParameter(':message', $message, PDO::PARAM_STR);
266 266
 
267 267
 		return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
268 268
 
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	function update($text, $target, $comments, $catalogue='messages')
280 280
 	{
281
-		$details = $this->getCatalogueDetails($catalogue);
281
+		$details=$this->getCatalogueDetails($catalogue);
282 282
 		if($details)
283
-			list($cat_id, $variant, $count) = $details;
283
+			list($cat_id, $variant, $count)=$details;
284 284
 		else
285 285
 			return false;
286 286
 
287
-		$time = time();
287
+		$time=time();
288 288
 		$command=$this->getDBConnection()->createCommand(
289 289
 			'UPDATE trans_unit SET target = :target, comments = :comments, date_modified = :datemod
290 290
 					WHERE cat_id = :catid AND source = :source');
291
-		$command->bindParameter(':target',$target,PDO::PARAM_STR);
292
-		$command->bindParameter(':comments',$comments,PDO::PARAM_STR);
293
-		$command->bindParameter(':datemod',$time,PDO::PARAM_INT);
294
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
295
-		$command->bindParameter(':source',$text,PDO::PARAM_STR);
291
+		$command->bindParameter(':target', $target, PDO::PARAM_STR);
292
+		$command->bindParameter(':comments', $comments, PDO::PARAM_STR);
293
+		$command->bindParameter(':datemod', $time, PDO::PARAM_INT);
294
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
295
+		$command->bindParameter(':source', $text, PDO::PARAM_STR);
296 296
 
297 297
 		return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
298 298
 	}
@@ -303,17 +303,17 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	function catalogues()
305 305
 	{
306
-		$command=$this->getDBConnection()->createCommand( 'SELECT name FROM catalogue ORDER BY name');
306
+		$command=$this->getDBConnection()->createCommand('SELECT name FROM catalogue ORDER BY name');
307 307
 		$dataReader=$command->query();
308 308
 
309
-		$result = array();
309
+		$result=array();
310 310
 
311
-		foreach ($dataReader as $row)
311
+		foreach($dataReader as $row)
312 312
 		{
313
-			$details = explode('.',$row[0]);
314
-			if(!isset($details[1])) $details[1] = null;
313
+			$details=explode('.', $row[0]);
314
+			if(!isset($details[1])) $details[1]=null;
315 315
 
316
-			$result[] = $details;
316
+			$result[]=$details;
317 317
 		}
318 318
 
319 319
 		return $result;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,8 @@  discard block
 block discarded – undo
67 67
 	/**
68 68
 	 * Creates the DB connection.
69 69
 	 * @param string the module ID for TDataSourceConfig
70
-	 * @return TDbConnection the created DB connection
70
+	 * @param string $connectionID
71
+	 * @return \Prado\Data\TDbConnection the created DB connection
71 72
 	 * @throws TConfigurationException if module ID is invalid or empty
72 73
 	 */
73 74
 	protected function createDbConnection($connectionID)
@@ -192,6 +193,7 @@  discard block
 block discarded – undo
192 193
 
193 194
 	/**
194 195
 	 * Update the catalogue last modified time.
196
+	 * @param string $variant
195 197
 	 * @return boolean true if updated, false otherwise.
196 198
 	 */
197 199
 	private function updateCatalogueTime($cat_id, $variant)
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@
 block discarded – undo
79 79
 				return $conn->getDbConnection();
80 80
 			else
81 81
 				throw new TConfigurationException('messagesource_connectionid_invalid',$connectionID);
82
-		}
83
-		else
82
+		} else
84 83
 			throw new TConfigurationException('messagesource_connectionid_required');
85 84
 	}
86 85
 
Please login to merge, or discard this patch.
framework/I18N/core/util.php 2 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
     function parseDSN($dsn)
41 41
     {
42
-        if (is_array($dsn)) {
42
+        if(is_array($dsn)) {
43 43
             return $dsn;
44 44
         }
45 45
 
46
-        $parsed = array(
46
+        $parsed=array(
47 47
             'phptype'  => false,
48 48
             'dbsyntax' => false,
49 49
             'username' => false,
@@ -56,94 +56,94 @@  discard block
 block discarded – undo
56 56
         );
57 57
 
58 58
         // Find phptype and dbsyntax
59
-        if (($pos = strpos($dsn, '://')) !== false) {
60
-            $str = substr($dsn, 0, $pos);
61
-            $dsn = substr($dsn, $pos + 3);
59
+        if(($pos=strpos($dsn, '://'))!==false) {
60
+            $str=substr($dsn, 0, $pos);
61
+            $dsn=substr($dsn, $pos + 3);
62 62
         } else {
63
-            $str = $dsn;
64
-            $dsn = null;
63
+            $str=$dsn;
64
+            $dsn=null;
65 65
         }
66 66
 
67 67
         // Get phptype and dbsyntax
68 68
         // $str => phptype(dbsyntax)
69
-        if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
70
-            $parsed['phptype']  = $arr[1];
71
-            $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
69
+        if(preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
70
+            $parsed['phptype']=$arr[1];
71
+            $parsed['dbsyntax']=(empty($arr[2])) ? $arr[1] : $arr[2];
72 72
         } else {
73
-            $parsed['phptype']  = $str;
74
-            $parsed['dbsyntax'] = $str;
73
+            $parsed['phptype']=$str;
74
+            $parsed['dbsyntax']=$str;
75 75
         }
76 76
 
77
-        if (empty($dsn)) {
77
+        if(empty($dsn)) {
78 78
             return $parsed;
79 79
         }
80 80
 
81 81
         // Get (if found): username and password
82 82
         // $dsn => username:password@protocol+hostspec/database
83
-        if (($at = strrpos($dsn,'@')) !== false) {
84
-            $str = substr($dsn, 0, $at);
85
-            $dsn = substr($dsn, $at + 1);
86
-            if (($pos = strpos($str, ':')) !== false) {
87
-                $parsed['username'] = rawurldecode(substr($str, 0, $pos));
88
-                $parsed['password'] = rawurldecode(substr($str, $pos + 1));
83
+        if(($at=strrpos($dsn, '@'))!==false) {
84
+            $str=substr($dsn, 0, $at);
85
+            $dsn=substr($dsn, $at + 1);
86
+            if(($pos=strpos($str, ':'))!==false) {
87
+                $parsed['username']=rawurldecode(substr($str, 0, $pos));
88
+                $parsed['password']=rawurldecode(substr($str, $pos + 1));
89 89
             } else {
90
-                $parsed['username'] = rawurldecode($str);
90
+                $parsed['username']=rawurldecode($str);
91 91
             }
92 92
         }
93 93
 
94 94
         // Find protocol and hostspec
95 95
 
96 96
         // $dsn => proto(proto_opts)/database
97
-        if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
98
-            $proto       = $match[1];
99
-            $proto_opts  = (!empty($match[2])) ? $match[2] : false;
100
-            $dsn         = $match[3];
97
+        if(preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
98
+            $proto=$match[1];
99
+            $proto_opts=(!empty($match[2])) ? $match[2] : false;
100
+            $dsn=$match[3];
101 101
 
102 102
         // $dsn => protocol+hostspec/database (old format)
103 103
         } else {
104
-            if (strpos($dsn, '+') !== false) {
105
-                list($proto, $dsn) = explode('+', $dsn, 2);
104
+            if(strpos($dsn, '+')!==false) {
105
+                list($proto, $dsn)=explode('+', $dsn, 2);
106 106
             }
107
-            if (strpos($dsn, '/') !== false) {
108
-                list($proto_opts, $dsn) = explode('/', $dsn, 2);
107
+            if(strpos($dsn, '/')!==false) {
108
+                list($proto_opts, $dsn)=explode('/', $dsn, 2);
109 109
             } else {
110
-                $proto_opts = $dsn;
111
-                $dsn = null;
110
+                $proto_opts=$dsn;
111
+                $dsn=null;
112 112
             }
113 113
         }
114 114
 
115 115
         // process the different protocol options
116
-        $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp';
117
-        $proto_opts = rawurldecode($proto_opts);
118
-        if ($parsed['protocol'] == 'tcp') {
119
-            if (strpos($proto_opts, ':') !== false) {
120
-                list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts);
116
+        $parsed['protocol']=(!empty($proto)) ? $proto : 'tcp';
117
+        $proto_opts=rawurldecode($proto_opts);
118
+        if($parsed['protocol']=='tcp') {
119
+            if(strpos($proto_opts, ':')!==false) {
120
+                list($parsed['hostspec'], $parsed['port'])=explode(':', $proto_opts);
121 121
             } else {
122
-                $parsed['hostspec'] = $proto_opts;
122
+                $parsed['hostspec']=$proto_opts;
123 123
             }
124
-        } elseif ($parsed['protocol'] == 'unix') {
125
-            $parsed['socket'] = $proto_opts;
124
+        } elseif($parsed['protocol']=='unix') {
125
+            $parsed['socket']=$proto_opts;
126 126
         }
127 127
 
128 128
         // Get dabase if any
129 129
         // $dsn => database
130
-        if (!empty($dsn)) {
130
+        if(!empty($dsn)) {
131 131
             // /database
132
-            if (($pos = strpos($dsn, '?')) === false) {
133
-                $parsed['database'] = $dsn;
132
+            if(($pos=strpos($dsn, '?'))===false) {
133
+                $parsed['database']=$dsn;
134 134
             // /database?param1=value1&param2=value2
135 135
             } else {
136
-                $parsed['database'] = substr($dsn, 0, $pos);
137
-                $dsn = substr($dsn, $pos + 1);
138
-                if (strpos($dsn, '&') !== false) {
139
-                    $opts = explode('&', $dsn);
136
+                $parsed['database']=substr($dsn, 0, $pos);
137
+                $dsn=substr($dsn, $pos + 1);
138
+                if(strpos($dsn, '&')!==false) {
139
+                    $opts=explode('&', $dsn);
140 140
                 } else { // database?param1=value1
141
-                    $opts = array($dsn);
141
+                    $opts=array($dsn);
142 142
                 }
143
-                foreach ($opts as $opt) {
144
-                    list($key, $value) = explode('=', $opt);
145
-                    if (!isset($parsed[$key])) { // don't allow params overwrite
146
-                        $parsed[$key] = rawurldecode($value);
143
+                foreach($opts as $opt) {
144
+                    list($key, $value)=explode('=', $opt);
145
+                    if(!isset($parsed[$key])) { // don't allow params overwrite
146
+                        $parsed[$key]=rawurldecode($value);
147 147
                     }
148 148
                 }
149 149
             }
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	function I18N_toUTF8($string, $from)
163 163
 	{
164
-		if($from != 'UTF-8')
164
+		if($from!='UTF-8')
165 165
 		{
166
-			$s = iconv($from,'UTF-8',$string); //to UTF-8
167
-			return $s !== false ? $s : $string; //it could return false
166
+			$s=iconv($from, 'UTF-8', $string); //to UTF-8
167
+			return $s!==false ? $s : $string; //it could return false
168 168
 		}
169 169
 		return $string;
170 170
 	}
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	function I18N_toEncoding($string, $to)
179 179
 	{
180
-		if($to != 'UTF-8')
180
+		if($to!='UTF-8')
181 181
 		{
182
-			$s = iconv('UTF-8', $to, $string);
183
-			return $s !== false ? $s : $string;
182
+			$s=iconv('UTF-8', $to, $string);
183
+			return $s!==false ? $s : $string;
184 184
 		}
185 185
 		return $string;
186 186
 	} 
Please login to merge, or discard this patch.
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * For a given DSN (database connection string), return some information
24 24
 	 * about the DSN. This function comes from PEAR's DB package.
25
-  	 *
25
+	 *
26 26
 	 * LICENSE: This source file is subject to version 3.0 of the PHP license
27 27
 	 * that is available through the world-wide-web at the following URI:
28 28
 	 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
@@ -38,120 +38,120 @@  discard block
 block discarded – undo
38 38
 	 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
39 39
 	 * @link       http://pear.php.net/package/DB
40 40
 	 */
41
-    function parseDSN($dsn)
42
-    {
43
-        if (is_array($dsn)) {
44
-            return $dsn;
45
-        }
46
-
47
-        $parsed = array(
48
-            'phptype'  => false,
49
-            'dbsyntax' => false,
50
-            'username' => false,
51
-            'password' => false,
52
-            'protocol' => false,
53
-            'hostspec' => false,
54
-            'port'     => false,
55
-            'socket'   => false,
56
-            'database' => false
57
-        );
58
-
59
-        // Find phptype and dbsyntax
60
-        if (($pos = strpos($dsn, '://')) !== false) {
61
-            $str = substr($dsn, 0, $pos);
62
-            $dsn = substr($dsn, $pos + 3);
63
-        } else {
64
-            $str = $dsn;
65
-            $dsn = null;
66
-        }
67
-
68
-        // Get phptype and dbsyntax
69
-        // $str => phptype(dbsyntax)
70
-        if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
71
-            $parsed['phptype']  = $arr[1];
72
-            $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
73
-        } else {
74
-            $parsed['phptype']  = $str;
75
-            $parsed['dbsyntax'] = $str;
76
-        }
77
-
78
-        if (empty($dsn)) {
79
-            return $parsed;
80
-        }
81
-
82
-        // Get (if found): username and password
83
-        // $dsn => username:password@protocol+hostspec/database
84
-        if (($at = strrpos($dsn,'@')) !== false) {
85
-            $str = substr($dsn, 0, $at);
86
-            $dsn = substr($dsn, $at + 1);
87
-            if (($pos = strpos($str, ':')) !== false) {
88
-                $parsed['username'] = rawurldecode(substr($str, 0, $pos));
89
-                $parsed['password'] = rawurldecode(substr($str, $pos + 1));
90
-            } else {
91
-                $parsed['username'] = rawurldecode($str);
92
-            }
93
-        }
94
-
95
-        // Find protocol and hostspec
96
-
97
-        // $dsn => proto(proto_opts)/database
98
-        if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
99
-            $proto       = $match[1];
100
-            $proto_opts  = (!empty($match[2])) ? $match[2] : false;
101
-            $dsn         = $match[3];
102
-
103
-        // $dsn => protocol+hostspec/database (old format)
104
-        } else {
105
-            if (strpos($dsn, '+') !== false) {
106
-                list($proto, $dsn) = explode('+', $dsn, 2);
107
-            }
108
-            if (strpos($dsn, '/') !== false) {
109
-                list($proto_opts, $dsn) = explode('/', $dsn, 2);
110
-            } else {
111
-                $proto_opts = $dsn;
112
-                $dsn = null;
113
-            }
114
-        }
115
-
116
-        // process the different protocol options
117
-        $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp';
118
-        $proto_opts = rawurldecode($proto_opts);
119
-        if ($parsed['protocol'] == 'tcp') {
120
-            if (strpos($proto_opts, ':') !== false) {
121
-                list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts);
122
-            } else {
123
-                $parsed['hostspec'] = $proto_opts;
124
-            }
125
-        } elseif ($parsed['protocol'] == 'unix') {
126
-            $parsed['socket'] = $proto_opts;
127
-        }
128
-
129
-        // Get dabase if any
130
-        // $dsn => database
131
-        if (!empty($dsn)) {
132
-            // /database
133
-            if (($pos = strpos($dsn, '?')) === false) {
134
-                $parsed['database'] = $dsn;
135
-            // /database?param1=value1&param2=value2
136
-            } else {
137
-                $parsed['database'] = substr($dsn, 0, $pos);
138
-                $dsn = substr($dsn, $pos + 1);
139
-                if (strpos($dsn, '&') !== false) {
140
-                    $opts = explode('&', $dsn);
141
-                } else { // database?param1=value1
142
-                    $opts = array($dsn);
143
-                }
144
-                foreach ($opts as $opt) {
145
-                    list($key, $value) = explode('=', $opt);
146
-                    if (!isset($parsed[$key])) { // don't allow params overwrite
147
-                        $parsed[$key] = rawurldecode($value);
148
-                    }
149
-                }
150
-            }
151
-        }
152
-
153
-        return $parsed;
154
-    }
41
+	function parseDSN($dsn)
42
+	{
43
+		if (is_array($dsn)) {
44
+			return $dsn;
45
+		}
46
+
47
+		$parsed = array(
48
+			'phptype'  => false,
49
+			'dbsyntax' => false,
50
+			'username' => false,
51
+			'password' => false,
52
+			'protocol' => false,
53
+			'hostspec' => false,
54
+			'port'     => false,
55
+			'socket'   => false,
56
+			'database' => false
57
+		);
58
+
59
+		// Find phptype and dbsyntax
60
+		if (($pos = strpos($dsn, '://')) !== false) {
61
+			$str = substr($dsn, 0, $pos);
62
+			$dsn = substr($dsn, $pos + 3);
63
+		} else {
64
+			$str = $dsn;
65
+			$dsn = null;
66
+		}
67
+
68
+		// Get phptype and dbsyntax
69
+		// $str => phptype(dbsyntax)
70
+		if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
71
+			$parsed['phptype']  = $arr[1];
72
+			$parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
73
+		} else {
74
+			$parsed['phptype']  = $str;
75
+			$parsed['dbsyntax'] = $str;
76
+		}
77
+
78
+		if (empty($dsn)) {
79
+			return $parsed;
80
+		}
81
+
82
+		// Get (if found): username and password
83
+		// $dsn => username:password@protocol+hostspec/database
84
+		if (($at = strrpos($dsn,'@')) !== false) {
85
+			$str = substr($dsn, 0, $at);
86
+			$dsn = substr($dsn, $at + 1);
87
+			if (($pos = strpos($str, ':')) !== false) {
88
+				$parsed['username'] = rawurldecode(substr($str, 0, $pos));
89
+				$parsed['password'] = rawurldecode(substr($str, $pos + 1));
90
+			} else {
91
+				$parsed['username'] = rawurldecode($str);
92
+			}
93
+		}
94
+
95
+		// Find protocol and hostspec
96
+
97
+		// $dsn => proto(proto_opts)/database
98
+		if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
99
+			$proto       = $match[1];
100
+			$proto_opts  = (!empty($match[2])) ? $match[2] : false;
101
+			$dsn         = $match[3];
102
+
103
+		// $dsn => protocol+hostspec/database (old format)
104
+		} else {
105
+			if (strpos($dsn, '+') !== false) {
106
+				list($proto, $dsn) = explode('+', $dsn, 2);
107
+			}
108
+			if (strpos($dsn, '/') !== false) {
109
+				list($proto_opts, $dsn) = explode('/', $dsn, 2);
110
+			} else {
111
+				$proto_opts = $dsn;
112
+				$dsn = null;
113
+			}
114
+		}
115
+
116
+		// process the different protocol options
117
+		$parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp';
118
+		$proto_opts = rawurldecode($proto_opts);
119
+		if ($parsed['protocol'] == 'tcp') {
120
+			if (strpos($proto_opts, ':') !== false) {
121
+				list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts);
122
+			} else {
123
+				$parsed['hostspec'] = $proto_opts;
124
+			}
125
+		} elseif ($parsed['protocol'] == 'unix') {
126
+			$parsed['socket'] = $proto_opts;
127
+		}
128
+
129
+		// Get dabase if any
130
+		// $dsn => database
131
+		if (!empty($dsn)) {
132
+			// /database
133
+			if (($pos = strpos($dsn, '?')) === false) {
134
+				$parsed['database'] = $dsn;
135
+			// /database?param1=value1&param2=value2
136
+			} else {
137
+				$parsed['database'] = substr($dsn, 0, $pos);
138
+				$dsn = substr($dsn, $pos + 1);
139
+				if (strpos($dsn, '&') !== false) {
140
+					$opts = explode('&', $dsn);
141
+				} else { // database?param1=value1
142
+					$opts = array($dsn);
143
+				}
144
+				foreach ($opts as $opt) {
145
+					list($key, $value) = explode('=', $opt);
146
+					if (!isset($parsed[$key])) { // don't allow params overwrite
147
+						$parsed[$key] = rawurldecode($value);
148
+					}
149
+				}
150
+			}
151
+		}
152
+
153
+		return $parsed;
154
+	}
155 155
     
156 156
    
157 157
 	/**
Please login to merge, or discard this patch.
framework/I18N/core/ChoiceFormat.php 3 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 	 * The pattern to validate a set notation
83 83
 	 * @var string
84 84
 	 */
85
-	protected $validate = '/[\(\[\{]|[-Inf\d:\s]+|,|[\+Inf\d\s:\?\-=!><%\|&\(\)]+|[\)\]\}]/ms';
85
+	protected $validate='/[\(\[\{]|[-Inf\d:\s]+|,|[\+Inf\d\s:\?\-=!><%\|&\(\)]+|[\)\]\}]/ms';
86 86
 
87 87
 	/**
88 88
 	 * The pattern to parse the formatting string.
89 89
 	 * @var string
90 90
 	 */
91
-	protected $parse = '/\s*\|?([\(\[\{]([-Inf\d:\s]+,?[\+Inf\d\s:\?\-=!><%\|&\(\)]*)+[\)\]\}])\s*/';
91
+	protected $parse='/\s*\|?([\(\[\{]([-Inf\d:\s]+,?[\+Inf\d\s:\?\-=!><%\|&\(\)]*)+[\)\]\}])\s*/';
92 92
 
93 93
 	/**
94 94
 	 * The value for positive infinity.
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	function __construct()
104 104
 	{
105
-		$this->inf = -log(0);
105
+		$this->inf=-log(0);
106 106
 	}
107 107
 
108 108
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	function isValid($number, $set)
116 116
 	{
117
-		$n = preg_match_all($this->validate,$set,$matches,PREG_SET_ORDER);
117
+		$n=preg_match_all($this->validate, $set, $matches, PREG_SET_ORDER);
118 118
 
119 119
 		if($n < 3) throw new Exception("Invalid set \"{$set}\"");
120 120
 
@@ -123,42 +123,42 @@  discard block
 block discarded – undo
123 123
 			return $this->isValidSetNotation($number, $def[1]);
124 124
 		}
125 125
 
126
-		$leftBracket = $matches[0][0];
127
-		$rightBracket = $matches[$n-1][0];
126
+		$leftBracket=$matches[0][0];
127
+		$rightBracket=$matches[$n - 1][0];
128 128
 
129
-		$i = 0;
130
-		$elements = array();
129
+		$i=0;
130
+		$elements=array();
131 131
 		foreach($matches as $match)
132 132
 		{
133
-			$string = $match[0];
134
-			if($i != 0 && $i != $n-1 && $string !== ',')
133
+			$string=$match[0];
134
+			if($i!=0 && $i!=$n - 1 && $string!==',')
135 135
 			{
136
-				if($string == '-Inf')
137
-					$elements[] = -1*$this->inf;
138
-				else if ($string == '+Inf' || $string == 'Inf')
139
-					$elements[] = $this->inf;
136
+				if($string=='-Inf')
137
+					$elements[]=-1 * $this->inf;
138
+				else if($string=='+Inf' || $string=='Inf')
139
+					$elements[]=$this->inf;
140 140
 				else
141
-					$elements[] = floatval($string);
141
+					$elements[]=floatval($string);
142 142
 			}
143 143
 			$i++;
144 144
 		}
145
-		$total = count($elements);
146
-		$number = floatval($number);
145
+		$total=count($elements);
146
+		$number=floatval($number);
147 147
 
148
-		if($leftBracket == '{' && $rightBracket == '}')
148
+		if($leftBracket=='{' && $rightBracket=='}')
149 149
 			return in_array($number, $elements);
150 150
 
151
-		$left = false;
152
-		if($leftBracket == '[')
153
-			$left = $number >= $elements[0];
154
-		else if ($leftBracket == '(')
155
-			$left = $number > $elements[0];
151
+		$left=false;
152
+		if($leftBracket=='[')
153
+			$left=$number >= $elements[0];
154
+		else if($leftBracket=='(')
155
+			$left=$number > $elements[0];
156 156
 
157
-		$right = false;
157
+		$right=false;
158 158
 		if($rightBracket==']')
159
-			$right = $number <= $elements[$total-1];
160
-		else if($rightBracket == ')')
161
-			$right = $number < $elements[$total-1];
159
+			$right=$number <= $elements[$total - 1];
160
+		else if($rightBracket==')')
161
+			$right=$number < $elements[$total - 1];
162 162
 
163 163
 		if($left && $right) return true;
164 164
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 	protected function isValidSetNotation($number, $set)
169 169
 	{
170
-		$str = '$result = '.str_replace('n', '$number', $set).';';
170
+		$str='$result = '.str_replace('n', '$number', $set).';';
171 171
 		try
172 172
 		{
173 173
 			eval($str);
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	function parse($string)
189 189
 	{
190
-		$n = preg_match_all($this->parse,$string,$matches, PREG_OFFSET_CAPTURE);
191
-		$sets = array();
190
+		$n=preg_match_all($this->parse, $string, $matches, PREG_OFFSET_CAPTURE);
191
+		$sets=array();
192 192
 		foreach($matches[1] as $match)
193
-			$sets[] = $match[0];
194
-		$offset = $matches[0];
195
-		$strings = array();
196
-		for($i = 0; $i < $n; $i++)
193
+			$sets[]=$match[0];
194
+		$offset=$matches[0];
195
+		$strings=array();
196
+		for($i=0; $i < $n; $i++)
197 197
 		{
198
-			$len = strlen($offset[$i][0]);
199
-			$begin = $i == 0? $len : $offset[$i][1] + $len;
200
-			$end = $i == $n-1 ? strlen($string) : $offset[$i+1][1];
201
-			$strings[] = substr($string, $begin, $end - $begin);
198
+			$len=strlen($offset[$i][0]);
199
+			$begin=$i==0 ? $len : $offset[$i][1] + $len;
200
+			$end=$i==$n - 1 ? strlen($string) : $offset[$i + 1][1];
201
+			$strings[]=substr($string, $begin, $end - $begin);
202 202
 		}
203 203
 		return array($sets, $strings);
204 204
 	}
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function format($string, $number)
214 214
 	{
215
-		list($sets, $strings) = $this->parse($string);
216
-		$total = count($sets);
217
-		for($i = 0; $i < $total; $i++)
215
+		list($sets, $strings)=$this->parse($string);
216
+		$total=count($sets);
217
+		for($i=0; $i < $total; $i++)
218 218
 		{
219 219
 			if($this->isValid($number, $sets[$i]))
220 220
 				return $strings[$i];
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,6 +165,9 @@  discard block
 block discarded – undo
165 165
 		return false;
166 166
 	}
167 167
 
168
+	/**
169
+	 * @param string $set
170
+	 */
168 171
 	protected function isValidSetNotation($number, $set)
169 172
 	{
170 173
 		$str = '$result = '.str_replace('n', '$number', $set).';';
@@ -206,8 +209,9 @@  discard block
 block discarded – undo
206 209
 	/**
207 210
 	 * For the choice string, and a number, find and return the
208 211
 	 * string that satisfied the set within the choices.
209
-	 * @param string the choices string.
212
+	 * @param string string choices string.
210 213
 	 * @param float the number to test.
214
+	 * @param double $number
211 215
 	 * @return string the choosen string.
212 216
 	 */
213 217
 	public function format($string, $number)
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -172,8 +172,7 @@
 block discarded – undo
172 172
 		{
173 173
 			eval($str);
174 174
 			return $result;
175
-		}
176
-		catch(Exception $e)
175
+		} catch(Exception $e)
177 176
 		{
178 177
 			return false;
179 178
 		}
Please login to merge, or discard this patch.
framework/I18N/TI18NControl.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
framework/I18N/TChoiceFormat.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
 namespace Prado\I18N;
13 13
 
14 14
  /**
15
- * Get the ChoiceFormat class.
16
- */
15
+  * Get the ChoiceFormat class.
16
+  */
17 17
 use Prado\I18N\core\ChoiceFormat;
18 18
 use Prado\Prado;
19 19
 
Please login to merge, or discard this patch.
framework/I18N/TTranslate.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
framework/I18N/TNumberFormat.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -24,48 +24,48 @@
 block discarded – undo
24 24
  */
25 25
 
26 26
 /**
27
-  * To format numbers in locale sensitive manner use
28
-  * <code>
29
-  * <com:TNumberFormat Pattern="0.##" value="2.0" />
30
-  * </code>
31
-  *
32
-  * Numbers can be formatted as currency, percentage, decimal or scientific
33
-  * numbers by specifying the Type attribute. The known types are
34
-  * "currency", "percentage", "decimal" and "scientific".
35
-  *
36
-  * If someone from US want to see sales figures from a store in
37
-  * Germany (say using the EURO currency), formatted using the german
38
-  * currency, you would need to use the attribute Culture="de_DE" to get
39
-  * the currency right, e.g. 100,00. The decimal and grouping separator is
40
-  * then also from the de_DE locale. This may lead to some confusion because
41
-  * people from US know the "," as thousand separator. Therefore a "Currency"
42
-  * attribute is available, so that the output from the following example
43
-  * results in 100.00.
44
-  * <code>
45
-  * <com:TNumberFormat Type="currency" Culture="en_US" Currency="EUR" Value="100" />
46
-  * </code>
47
-  *
48
-  * Namespace: System.I18N
49
-  *
50
-  * Properties
51
-  * - <b>Value</b>, number,
52
-  *   <br>Gets or sets the number to format. The tag content is used as Value
53
-  *   if the Value property is not specified.
54
-  * - <b>Type</b>, string,
55
-  *   <br>Gets or sets the formatting type. The valid types are
56
-  *    'decimal', 'currency', 'percentage' and 'scientific'.
57
-  * - <b>Currency</b>, string,
58
-  *   <br>Gets or sets the currency symbol for the currency format.
59
-  *   The default is 'USD' if the Currency property is not specified.
60
-  * - <b>Pattern</b>, string,
61
-  *   <br>Gets or sets the custom number formatting pattern.
62
-  * - <b>DefaultText</b>, string,
63
-  * <br>Gets or sets the default text. If Value is not set, DefaultText will be
64
-  * shown instead of the default currency Value/Pattern.
65
-  *
66
-  * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
67
-  * @package Prado\I18N
68
-  */
27
+ * To format numbers in locale sensitive manner use
28
+ * <code>
29
+ * <com:TNumberFormat Pattern="0.##" value="2.0" />
30
+ * </code>
31
+ *
32
+ * Numbers can be formatted as currency, percentage, decimal or scientific
33
+ * numbers by specifying the Type attribute. The known types are
34
+ * "currency", "percentage", "decimal" and "scientific".
35
+ *
36
+ * If someone from US want to see sales figures from a store in
37
+ * Germany (say using the EURO currency), formatted using the german
38
+ * currency, you would need to use the attribute Culture="de_DE" to get
39
+ * the currency right, e.g. 100,00. The decimal and grouping separator is
40
+ * then also from the de_DE locale. This may lead to some confusion because
41
+ * people from US know the "," as thousand separator. Therefore a "Currency"
42
+ * attribute is available, so that the output from the following example
43
+ * results in 100.00.
44
+ * <code>
45
+ * <com:TNumberFormat Type="currency" Culture="en_US" Currency="EUR" Value="100" />
46
+ * </code>
47
+ *
48
+ * Namespace: System.I18N
49
+ *
50
+ * Properties
51
+ * - <b>Value</b>, number,
52
+ *   <br>Gets or sets the number to format. The tag content is used as Value
53
+ *   if the Value property is not specified.
54
+ * - <b>Type</b>, string,
55
+ *   <br>Gets or sets the formatting type. The valid types are
56
+ *    'decimal', 'currency', 'percentage' and 'scientific'.
57
+ * - <b>Currency</b>, string,
58
+ *   <br>Gets or sets the currency symbol for the currency format.
59
+ *   The default is 'USD' if the Currency property is not specified.
60
+ * - <b>Pattern</b>, string,
61
+ *   <br>Gets or sets the custom number formatting pattern.
62
+ * - <b>DefaultText</b>, string,
63
+ * <br>Gets or sets the default text. If Value is not set, DefaultText will be
64
+ * shown instead of the default currency Value/Pattern.
65
+ *
66
+ * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
67
+ * @package Prado\I18N
68
+ */
69 69
 class TNumberFormat extends TI18NControl implements \Prado\IDataRenderer
70 70
 {
71 71
 	/**
Please login to merge, or discard this patch.
framework/Web/UI/ActiveControls/TActiveRadioButton.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function setText($value)
89 89
 	{
90
-		if(parent::getText() === $value)
90
+		if(parent::getText()===$value)
91 91
 			return;
92 92
 
93 93
 		parent::setText($value);
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function setChecked($value)
106 106
 	{
107
-		$value = TPropertyValue::ensureBoolean($value);
108
-		if(parent::getChecked() === $value)
107
+		$value=TPropertyValue::ensureBoolean($value);
108
+		if(parent::getChecked()===$value)
109 109
 			return;
110 110
 
111 111
 		parent::setChecked($value);
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	 * Since 3.1.4, the javascript code is not rendered if {@link setAutoPostBack AutoPostBack} is false
128 128
 	 *
129 129
 	 */
130
-	protected function renderInputTag($writer,$clientID,$onclick)
130
+	protected function renderInputTag($writer, $clientID, $onclick)
131 131
 	{
132
-		parent::renderInputTag($writer,$clientID,$onclick);
133
-		if ($this->getAutoPostBack())
132
+		parent::renderInputTag($writer, $clientID, $onclick);
133
+		if($this->getAutoPostBack())
134 134
 			$this->getActiveControl()->registerCallbackClientScript(
135 135
 				$this->getClientClassName(), $this->getPostBackOptions());
136 136
 	}
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function getLabelAttributes()
151 151
 	{
152
-		$attributes = parent::getLabelAttributes();
153
-		$attributes['id'] = $this->getDefaultLabelID();
152
+		$attributes=parent::getLabelAttributes();
153
+		$attributes['id']=$this->getDefaultLabelID();
154 154
 		return $attributes;
155 155
 	}
156 156
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @param string radio button id
161 161
 	 * @param string label text
162 162
 	 */
163
-	protected function renderLabel($writer,$clientID,$text)
163
+	protected function renderLabel($writer, $clientID, $text)
164 164
 	{
165 165
 		$writer->addAttribute('id', $this->getDefaultLabelID());
166 166
 		parent::renderLabel($writer, $clientID, $text);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	protected function getDefaultLabelID()
173 173
 	{
174
-		if($attributes=$this->getViewState('LabelAttributes',null))
174
+		if($attributes=$this->getViewState('LabelAttributes', null))
175 175
 			return $this->getLabelAttributes()->itemAt('id');
176 176
 		else
177 177
 			return $this->getClientID().'_label';
Please login to merge, or discard this patch.