Completed
Push — prado4-sauce ( 31ba42...77d75b )
by Fabio
16:20 queued 08:27
created
framework/Collections/TListItemCollection.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 	public function createListItem($index=-1)
39 39
 	{
40 40
 		$item=$this->createNewListItem();
41
-		if($index<0)
41
+		if($index < 0)
42 42
 			$this->add($item);
43 43
 		else
44
-			$this->insertAt($index,$item);
44
+			$this->insertAt($index, $item);
45 45
 		return $item;
46 46
 	}
47 47
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	protected function createNewListItem($text=null)
52 52
 	{
53
-		$item =  new TListItem;
53
+		$item=new TListItem;
54 54
 		if($text!==null)
55 55
 			$item->setText($text);
56 56
 		return $item;
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 	 * @param TListItem the item to be inserted.
64 64
 	 * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem
65 65
 	 */
66
-	public function insertAt($index,$item)
66
+	public function insertAt($index, $item)
67 67
 	{
68 68
 		if(is_string($item))
69
-			$item = $this->createNewListItem($item);
69
+			$item=$this->createNewListItem($item);
70 70
 		if(!($item instanceof TListItem))
71
-			throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this));
72
-		parent::insertAt($index,$item);
71
+			throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this));
72
+		parent::insertAt($index, $item);
73 73
 	}
74 74
 
75 75
 	/**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param boolean whether to look for disabled items also
79 79
 	 * @return integer the index of the item found, -1 if not found.
80 80
 	 */
81
-	public function findIndexByValue($value,$includeDisabled=true)
81
+	public function findIndexByValue($value, $includeDisabled=true)
82 82
 	{
83 83
 		$value=TPropertyValue::ensureString($value);
84 84
 		$index=0;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param boolean whether to look for disabled items also
98 98
 	 * @return integer the index of the item found, -1 if not found.
99 99
 	 */
100
-	public function findIndexByText($text,$includeDisabled=true)
100
+	public function findIndexByText($text, $includeDisabled=true)
101 101
 	{
102 102
 		$text=TPropertyValue::ensureString($text);
103 103
 		$index=0;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 * @param boolean whether to look for disabled items also
117 117
 	 * @return TListItem the item found, null if not found.
118 118
 	 */
119
-	public function findItemByValue($value,$includeDisabled=true)
119
+	public function findItemByValue($value, $includeDisabled=true)
120 120
 	{
121
-		if(($index=$this->findIndexByValue($value,$includeDisabled))>=0)
121
+		if(($index=$this->findIndexByValue($value, $includeDisabled)) >= 0)
122 122
 			return $this->itemAt($index);
123 123
 		else
124 124
 			return null;
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @param boolean whether to look for disabled items also
131 131
 	 * @return TListItem the item found, null if not found.
132 132
 	 */
133
-	public function findItemByText($text,$includeDisabled=true)
133
+	public function findItemByText($text, $includeDisabled=true)
134 134
 	{
135
-		if(($index=$this->findIndexByText($text,$includeDisabled))>=0)
135
+		if(($index=$this->findIndexByText($text, $includeDisabled)) >= 0)
136 136
 			return $this->itemAt($index);
137 137
 		else
138 138
 			return null;
@@ -157,6 +157,6 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function saveState()
159 159
 	{
160
-		return ($this->getCount()>0) ? $this->toArray() : null;
160
+		return ($this->getCount() > 0) ? $this->toArray() : null;
161 161
 	}
162 162
 }
Please login to merge, or discard this patch.
framework/TApplicationComponent.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
 	 * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this).
95 95
 	 * @return string URL to the asset path.
96 96
 	 */
97
-	public function publishAsset($assetPath,$className=null)
97
+	public function publishAsset($assetPath, $className=null)
98 98
 	{
99 99
 		if($className===null)
100 100
 			$className=get_class($this);
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	}
52 52
 
53 53
 	/**
54
-	 * @return THttpRequest the current user request
54
+	 * @return Web\THttpRequest the current user request
55 55
 	 */
56 56
 	public function getRequest()
57 57
 	{
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	}
60 60
 
61 61
 	/**
62
-	 * @return THttpResponse the response
62
+	 * @return Web\THttpResponse the response
63 63
 	 */
64 64
 	public function getResponse()
65 65
 	{
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	/**
70
-	 * @return THttpSession user session
70
+	 * @return Web\THttpSession user session
71 71
 	 */
72 72
 	public function getSession()
73 73
 	{
@@ -94,6 +94,7 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @param string path of the asset that is relative to the directory containing the specified class file.
96 96
 	 * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this).
97
+	 * @param string $assetPath
97 98
 	 * @return string URL to the asset path.
98 99
 	 */
99 100
 	public function publishAsset($assetPath,$className=null)
@@ -108,6 +109,7 @@  discard block
 block discarded – undo
108 109
 	/**
109 110
 	 * Publishes a file or directory and returns its URL.
110 111
 	 * @param string absolute path of the file or directory to be published
112
+	 * @param string $fullPath
111 113
 	 * @return string URL to the published file or directory
112 114
 	 */
113 115
 	public function publishFilePath($fullPath, $checkTimestamp=false)
Please login to merge, or discard this patch.
framework/Security/TDbUserManager.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -189,8 +189,7 @@  discard block
 block discarded – undo
189 189
 				return file_put_contents($fileName,file_get_contents($this->_localName))!==false;
190 190
 			else
191 191
 				return false;
192
-		}
193
-		else
192
+		} else
194 193
 			return false;
195 194
 	}
196 195
 
@@ -211,8 +210,7 @@  discard block
 block discarded – undo
211 210
 			$this->_errorCode=$_FILES[$key]['error'];
212 211
 			$this->_localName=$_FILES[$key]['tmp_name'];
213 212
 			return $this->_dataChanged=true;
214
-		}
215
-		else
213
+		} else
216 214
 			return false;
217 215
 	}
218 216
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,8 @@
 block discarded – undo
162 162
 	/**
163 163
 	 * Creates the DB connection.
164 164
 	 * @param string the module ID for TDataSourceConfig
165
-	 * @return TDbConnection the created DB connection
165
+	 * @param string $connectionID
166
+	 * @return \Prado\Data\TDbConnection the created DB connection
166 167
 	 * @throws TConfigurationException if module ID is invalid or empty
167 168
 	 */
168 169
 	protected function createDbConnection($connectionID)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	{
63 63
 		if($this->_userClass==='')
64 64
 			throw new TConfigurationException('dbusermanager_userclass_required');
65
-		$this->_userFactory=Prado::createComponent($this->_userClass,$this);
65
+		$this->_userFactory=Prado::createComponent($this->_userClass, $this);
66 66
 		if(!($this->_userFactory instanceof TDbUser))
67
-			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid',$this->_userClass);
67
+			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass);
68 68
 	}
69 69
 
70 70
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @param string password
106 106
 	 * @return boolean true if validation is successful, false otherwise.
107 107
 	 */
108
-	public function validateUser($username,$password)
108
+	public function validateUser($username, $password)
109 109
 	{
110
-		return $this->_userFactory->validateUser($username,$password);
110
+		return $this->_userFactory->validateUser($username, $password);
111 111
 	}
112 112
 
113 113
 	/**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	{
120 120
 		if($username===null)
121 121
 		{
122
-			$user=Prado::createComponent($this->_userClass,$this);
122
+			$user=Prado::createComponent($this->_userClass, $this);
123 123
 			$user->setIsGuest(true);
124 124
 			return $user;
125 125
 		}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			if($conn instanceof TDataSourceConfig)
174 174
 				return $conn->getDbConnection();
175 175
 			else
176
-				throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID);
176
+				throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID);
177 177
 		}
178 178
 		else
179 179
 			throw new TConfigurationException('dbusermanager_connectionid_required');
Please login to merge, or discard this patch.
framework/Security/IUserManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,6 +51,6 @@
 block discarded – undo
51 51
 	 * @param string password
52 52
 	 * @return boolean true if validation is successful, false otherwise.
53 53
 	 */
54
-	public function validateUser($username,$password);
54
+	public function validateUser($username, $password);
55 55
 }
56 56
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -37,6 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * Returns a user instance according to auth data stored in a cookie.
39 39
 	 * @param THttpCookie the cookie storing user authentication information
40
+	 * @param \Prado\Web\THttpCookie $cookie
40 41
 	 * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
41 42
 	 * @since 3.1.1
42 43
 	 */
@@ -44,7 +45,9 @@  discard block
 block discarded – undo
44 45
 	/**
45 46
 	 * Saves user auth data into a cookie.
46 47
 	 * @param THttpCookie the cookie to receive the user auth data.
48
+	 * @param \Prado\Web\THttpCookie $cookie
47 49
 	 * @since 3.1.1
50
+	 * @return void
48 51
 	 */
49 52
 	public function saveUserToCookie($cookie);
50 53
 	/**
Please login to merge, or discard this patch.
framework/I18N/TTranslateParameter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * To trim or not to trim the contents.
51 51
 	 * @var boolean
52 52
 	 */
53
-	protected $trim = true;
53
+	protected $trim=true;
54 54
 
55 55
 
56 56
 	/**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function setKey($value)
72 72
 	{
73
-		$this->key = $value;
73
+		$this->key=$value;
74 74
 	}
75 75
 
76 76
 	/**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function setTrim($value)
81 81
 	{
82
-		$this->trim = TPropertyValue::ensureBoolean($value);
82
+		$this->trim=TPropertyValue::ensureBoolean($value);
83 83
 	}
84 84
 
85 85
 	/**
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function getParameter()
108 108
 	{
109
-		$value = $this->getValue();
109
+		$value=$this->getValue();
110 110
 		if(strlen($value) > 0)
111 111
 			return $value;
112
-		$htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter());
112
+		$htmlWriter=Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter());
113 113
 		$this->renderControl($htmlWriter);
114 114
 		return $this->getTrim() ?
115 115
 			trim($htmlWriter->flush()) : $htmlWriter->flush();
Please login to merge, or discard this patch.
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.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
 		if ($this->sourcepath === NULL)
59 59
 		{
60 60
 			$this->sourcepath = $sourcepath;
61
-		}
62
-		else
61
+		} else
63 62
 		{
64 63
 			$this->sourcepath->append($sourcepath);
65 64
 		}
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.
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/MessageSource_SQLite.php 2 patches
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	function __construct($source)
56 56
 	{
57
-		$dsn = parseDSN((string)$source);
58
-		$this->source = $dsn['database'];
57
+		$dsn=parseDSN((string) $source);
58
+		$this->source=$dsn['database'];
59 59
 	}
60 60
 	
61 61
 	/**
@@ -66,26 +66,26 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	protected function &loadData($variant)
68 68
 	{
69
-		$variant = sqlite_escape_string($variant);
69
+		$variant=sqlite_escape_string($variant);
70 70
 		
71
-		$statement = 
71
+		$statement= 
72 72
 			"SELECT t.id, t.source, t.target, t.comments
73 73
 				FROM trans_unit t, catalogue c
74 74
  				WHERE c.cat_id =  t.cat_id
75 75
 					AND c.name = '{$variant}' 
76 76
 				ORDER BY id ASC";
77 77
 	
78
-		$db = sqlite_open($this->source);
79
-		$rs = sqlite_query($statement, $db);
78
+		$db=sqlite_open($this->source);
79
+		$rs=sqlite_query($statement, $db);
80 80
 			
81
-		$result = array();
81
+		$result=array();
82 82
 		
83
-		while($row = sqlite_fetch_array($rs,SQLITE_NUM))
83
+		while($row=sqlite_fetch_array($rs, SQLITE_NUM))
84 84
 		{
85
-			$source = $row[1];
86
-			$result[$source][] = $row[2]; //target
87
-			$result[$source][] = $row[0]; //id
88
-			$result[$source][] = $row[3]; //comments
85
+			$source=$row[1];
86
+			$result[$source][]=$row[2]; //target
87
+			$result[$source][]=$row[0]; //id
88
+			$result[$source][]=$row[3]; //comments
89 89
 		}
90 90
 
91 91
 		sqlite_close($db);
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 */	
102 102
 	protected function getLastModified($source)
103 103
 	{
104
-		$source = sqlite_escape_string($source);
104
+		$source=sqlite_escape_string($source);
105 105
 
106
-		$db = sqlite_open($this->source);
106
+		$db=sqlite_open($this->source);
107 107
 		
108
-		$rs = sqlite_query(
108
+		$rs=sqlite_query(
109 109
 			"SELECT date_modified FROM catalogue WHERE name = '{$source}'",
110 110
 			$db);
111 111
 			
112
-		$result = $rs ? (int)sqlite_fetch_single($rs) : 0;
112
+		$result=$rs ? (int) sqlite_fetch_single($rs) : 0;
113 113
 		
114 114
 		sqlite_close($db);		
115 115
 	
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	protected function isValidSource($variant)
126 126
 	{
127
-		$variant = sqlite_escape_string($variant);
128
-		$db = sqlite_open($this->source);
129
-		$rs = sqlite_query(
127
+		$variant=sqlite_escape_string($variant);
128
+		$db=sqlite_open($this->source);
129
+		$rs=sqlite_query(
130 130
 			"SELECT COUNT(*) FROM catalogue WHERE name = '{$variant}'",
131 131
 			$db);
132
-		$result = $rs && (int)sqlite_fetch_single($rs);	
132
+		$result=$rs && (int) sqlite_fetch_single($rs);	
133 133
 		sqlite_close($db);
134 134
 
135 135
 		return $result;
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	protected function getCatalogueList($catalogue)
144 144
 	{
145
-		$variants = explode('_',$this->culture);
145
+		$variants=explode('_', $this->culture);
146 146
 		
147
-		$catalogues = array($catalogue);
147
+		$catalogues=array($catalogue);
148 148
 
149
-		$variant = null;
149
+		$variant=null;
150 150
 				
151
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
151
+		for($i=0, $k=count($variants); $i < $k; ++$i)
152 152
 		{						
153 153
 			if(isset($variants[$i]{0}))
154 154
 			{
155
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
156
-				$catalogues[] = $catalogue.'.'.$variant;
155
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
156
+				$catalogues[]=$catalogue.'.'.$variant;
157 157
 			}
158 158
 		}
159 159
 		return array_reverse($catalogues);	
@@ -167,29 +167,29 @@  discard block
 block discarded – undo
167 167
 	private function getCatalogueDetails($catalogue='messages')
168 168
 	{
169 169
 		if(empty($catalogue))
170
-			$catalogue = 'messages';
170
+			$catalogue='messages';
171 171
 
172
-		$variant = $catalogue.'.'.$this->culture;
172
+		$variant=$catalogue.'.'.$this->culture;
173 173
 		
174
-		$name = sqlite_escape_string($this->getSource($variant));	
174
+		$name=sqlite_escape_string($this->getSource($variant));	
175 175
 			
176
-		$db = sqlite_open($this->source);
176
+		$db=sqlite_open($this->source);
177 177
 		
178
-		$rs = sqlite_query("SELECT cat_id
178
+		$rs=sqlite_query("SELECT cat_id
179 179
 					FROM catalogue WHERE name = '{$name}'", $db);
180 180
 		
181
-		if(sqlite_num_rows($rs) != 1)
181
+		if(sqlite_num_rows($rs)!=1)
182 182
 			return false;
183 183
 		
184
-		$cat_id = (int)sqlite_fetch_single($rs);
184
+		$cat_id=(int) sqlite_fetch_single($rs);
185 185
 		
186 186
 		//first get the catalogue ID
187
-		$rs = sqlite_query(
187
+		$rs=sqlite_query(
188 188
 			"SELECT count(msg_id)
189 189
 				FROM trans_unit
190 190
 				WHERE cat_id = {$cat_id}", $db);
191 191
 
192
-		$count = (int)sqlite_fetch_single($rs);
192
+		$count=(int) sqlite_fetch_single($rs);
193 193
 
194 194
 		sqlite_close($db);	
195 195
 		
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	private function updateCatalogueTime($cat_id, $variant, $db)
204 204
 	{
205
-		$time = time();
205
+		$time=time();
206 206
 		
207
-		$result = sqlite_query("UPDATE catalogue 
207
+		$result=sqlite_query("UPDATE catalogue 
208 208
 							SET date_modified = {$time}
209 209
 							WHERE cat_id = {$cat_id}", $db);
210 210
 
@@ -223,27 +223,27 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	function save($catalogue='messages')
225 225
 	{
226
-		$messages = $this->untranslated;
226
+		$messages=$this->untranslated;
227 227
 		
228 228
 		if(count($messages) <= 0) return false;				
229 229
 		
230
-		$details = $this->getCatalogueDetails($catalogue);	
230
+		$details=$this->getCatalogueDetails($catalogue);	
231 231
 		
232 232
 		if($details)
233
-			list($cat_id, $variant, $count) = $details;
233
+			list($cat_id, $variant, $count)=$details;
234 234
 		else
235 235
 			return false;
236 236
 		
237 237
 		if($cat_id <= 0) return false;
238
-		$inserted = 0;
238
+		$inserted=0;
239 239
 		
240
-		$db = sqlite_open($this->source);
241
-		$time = time();
240
+		$db=sqlite_open($this->source);
241
+		$time=time();
242 242
 
243 243
 		foreach($messages as $message)
244 244
 		{
245
-			$message = sqlite_escape_string($message);
246
-			$statement = "INSERT INTO trans_unit
245
+			$message=sqlite_escape_string($message);
246
+			$statement="INSERT INTO trans_unit
247 247
 				(cat_id,id,source,date_added) VALUES
248 248
 				({$cat_id}, {$count},'{$message}',$time)";
249 249
 			if(sqlite_query($statement, $db))
@@ -269,31 +269,31 @@  discard block
 block discarded – undo
269 269
 	 */	
270 270
 	function update($text, $target, $comments, $catalogue='messages')
271 271
 	{
272
-		$details = $this->getCatalogueDetails($catalogue);
272
+		$details=$this->getCatalogueDetails($catalogue);
273 273
 		if($details)
274
-			list($cat_id, $variant, $count) = $details;
274
+			list($cat_id, $variant, $count)=$details;
275 275
 		else
276 276
 			return false;
277 277
 		
278
-		$comments = sqlite_escape_string($comments);
279
-		$target = sqlite_escape_string($target);
280
-		$text = sqlite_escape_string($text);
278
+		$comments=sqlite_escape_string($comments);
279
+		$target=sqlite_escape_string($target);
280
+		$text=sqlite_escape_string($text);
281 281
 		
282
-		$time = time();
282
+		$time=time();
283 283
 		
284
-		$db = sqlite_open($this->source);
284
+		$db=sqlite_open($this->source);
285 285
 		
286
-		$statement = "UPDATE trans_unit SET
286
+		$statement="UPDATE trans_unit SET
287 287
 						target = '{$target}',
288 288
 						comments = '{$comments}',
289 289
 						date_modified = '{$time}'
290 290
 					WHERE cat_id = {$cat_id} 
291 291
 						AND source = '{$text}'";
292 292
 		
293
-		$updated = false;
293
+		$updated=false;
294 294
 		
295 295
 		if(sqlite_query($statement, $db))
296
-			$updated = $this->updateCatalogueTime($cat_id, $variant, $db);
296
+			$updated=$this->updateCatalogueTime($cat_id, $variant, $db);
297 297
 		
298 298
 		sqlite_close($db);			
299 299
 				
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
 	 */
309 309
 	function delete($message, $catalogue='messages')
310 310
 	{
311
-		$details = $this->getCatalogueDetails($catalogue);
311
+		$details=$this->getCatalogueDetails($catalogue);
312 312
 		if($details)
313
-			list($cat_id, $variant, $count) = $details;
313
+			list($cat_id, $variant, $count)=$details;
314 314
 		else
315 315
 			return false;
316 316
 			
317
-		$db = sqlite_open($this->source);
318
-		$text = sqlite_escape_string($message);
317
+		$db=sqlite_open($this->source);
318
+		$text=sqlite_escape_string($message);
319 319
 		
320
-		$statement = "DELETE FROM trans_unit WHERE
320
+		$statement="DELETE FROM trans_unit WHERE
321 321
 						cat_id = {$cat_id} AND source = '{$message}'";
322
-		$deleted = false;
322
+		$deleted=false;
323 323
 				
324 324
 		if(sqlite_query($statement, $db))
325
-			$deleted = $this->updateCatalogueTime($cat_id, $variant, $db);		
325
+			$deleted=$this->updateCatalogueTime($cat_id, $variant, $db);		
326 326
 			
327 327
 		sqlite_close($db);	
328 328
 				
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	function catalogues()
337 337
 	{
338
-		$db = sqlite_open($this->source);
339
-		$statement = 'SELECT name FROM catalogue ORDER BY name';
340
-		$rs = sqlite_query($statement, $db);
341
-		$result = array();
342
-		while($row = sqlite_fetch_array($rs,SQLITE_NUM))
338
+		$db=sqlite_open($this->source);
339
+		$statement='SELECT name FROM catalogue ORDER BY name';
340
+		$rs=sqlite_query($statement, $db);
341
+		$result=array();
342
+		while($row=sqlite_fetch_array($rs, SQLITE_NUM))
343 343
 		{
344
-			$details = explode('.',$row[0]);
345
-			if(!isset($details[1])) $details[1] = null;
344
+			$details=explode('.', $row[0]);
345
+			if(!isset($details[1])) $details[1]=null;
346 346
 			
347
-			$result[] = $details;
347
+			$result[]=$details;
348 348
 		}
349 349
 		sqlite_close($db);
350 350
 		return $result;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,9 @@
 block discarded – undo
198 198
 	
199 199
 	/**
200 200
 	 * Update the catalogue last modified time.
201
-	 * @return boolean true if updated, false otherwise. 
201
+	 * @param integer $cat_id
202
+	 * @param string $variant
203
+	 * @return \SQLiteResult true if updated, false otherwise. 
202 204
 	 */
203 205
 	private function updateCatalogueTime($cat_id, $variant, $db)
204 206
 	{
Please login to merge, or discard this patch.