Completed
Push — autoload ( 4808d1...dcd67f )
by Fabio
60:18 queued 50:52
created
framework/Collections/TPagedDataSource.php 2 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -63,6 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 	/**
65 65
 	 * @param mixed original data source
66
+	 * @param Traversable $value
66 67
 	 */
67 68
 	public function setDataSource($value)
68 69
 	{
@@ -88,6 +89,7 @@  discard block
 block discarded – undo
88 89
 
89 90
 	/**
90 91
 	 * @param integer number of items in each page
92
+	 * @param integer $value
91 93
 	 */
92 94
 	public function setPageSize($value)
93 95
 	{
@@ -107,6 +109,7 @@  discard block
 block discarded – undo
107 109
 
108 110
 	/**
109 111
 	 * @param integer current page index
112
+	 * @param integer $value
110 113
 	 */
111 114
 	public function setCurrentPageIndex($value)
112 115
 	{
@@ -125,6 +128,7 @@  discard block
 block discarded – undo
125 128
 
126 129
 	/**
127 130
 	 * @param boolean whether to allow paging
131
+	 * @param boolean $value
128 132
 	 */
129 133
 	public function setAllowPaging($value)
130 134
 	{
@@ -141,6 +145,7 @@  discard block
 block discarded – undo
141 145
 
142 146
 	/**
143 147
 	 * @param boolean whether to allow custom paging
148
+	 * @param boolean $value
144 149
 	 */
145 150
 	public function setAllowCustomPaging($value)
146 151
 	{
@@ -157,6 +162,7 @@  discard block
 block discarded – undo
157 162
 
158 163
 	/**
159 164
 	 * @param integer user-assigned number of items in data source
165
+	 * @param integer $value
160 166
 	 */
161 167
 	public function setVirtualItemCount($value)
162 168
 	{
@@ -290,6 +296,8 @@  discard block
 block discarded – undo
290 296
 	 * @param TList the data to be iterated through
291 297
 	 * @param integer start index
292 298
 	 * @param integer number of items to be iterated through
299
+	 * @param integer $startIndex
300
+	 * @param integer $count
293 301
 	 */
294 302
 	public function __construct(TList $list,$startIndex,$count)
295 303
 	{
@@ -374,6 +382,8 @@  discard block
 block discarded – undo
374 382
 	/**
375 383
 	 * Constructor.
376 384
 	 * @param array the data to be iterated through
385
+	 * @param integer $startIndex
386
+	 * @param integer $count
377 387
 	 */
378 388
 	public function __construct(TMap $map,$startIndex,$count)
379 389
 	{
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @package System.Collections
27 27
  * @since 3.0
28 28
  */
29
-class TPagedDataSource extends TComponent implements IteratorAggregate,Countable
29
+class TPagedDataSource extends TComponent implements IteratorAggregate, Countable
30 30
 {
31 31
 	/**
32 32
 	 * @var mixed original data source
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function setPageSize($value)
93 93
 	{
94
-		if(($value=TPropertyValue::ensureInteger($value))>0)
94
+		if(($value=TPropertyValue::ensureInteger($value)) > 0)
95 95
 			$this->_pageSize=$value;
96 96
 		else
97 97
 			throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function setCurrentPageIndex($value)
112 112
 	{
113
-		if(($value=TPropertyValue::ensureInteger($value))<0)
113
+		if(($value=TPropertyValue::ensureInteger($value)) < 0)
114 114
 			$value=0;
115 115
 		$this->_currentPageIndex=$value;
116 116
 	}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function setVirtualItemCount($value)
162 162
 	{
163
-		if(($value=TPropertyValue::ensureInteger($value))>=0)
163
+		if(($value=TPropertyValue::ensureInteger($value)) >= 0)
164 164
 			$this->_virtualCount=$value;
165 165
 		else
166 166
 			throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		if(!$this->_allowPaging)
177 177
 			return $this->getDataSourceCount();
178 178
 		if(!$this->_allowCustomPaging && $this->getIsLastPage())
179
-			return $this->getDataSourceCount()-$this->getFirstIndexInPage();
179
+			return $this->getDataSourceCount() - $this->getFirstIndexInPage();
180 180
 		return $this->_pageSize;
181 181
 	}
182 182
 
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 		if($this->_dataSource===null)
199 199
 			return 0;
200 200
 		$count=$this->getDataSourceCount();
201
-		if(!$this->_allowPaging || $count<=0)
201
+		if(!$this->_allowPaging || $count <= 0)
202 202
 			return 1;
203
-		return (int)(($count+$this->_pageSize-1)/$this->_pageSize);
203
+		return (int) (($count + $this->_pageSize - 1) / $this->_pageSize);
204 204
 	}
205 205
 
206 206
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	public function getIsLastPage()
221 221
 	{
222 222
 		if($this->_allowPaging)
223
-			return $this->_currentPageIndex===$this->getPageCount()-1;
223
+			return $this->_currentPageIndex===$this->getPageCount() - 1;
224 224
 		else
225 225
 			return true;
226 226
 	}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	public function getFirstIndexInPage()
233 233
 	{
234 234
 		if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging)
235
-			return $this->_currentPageIndex*$this->_pageSize;
235
+			return $this->_currentPageIndex * $this->_pageSize;
236 236
 		else
237 237
 			return 0;
238 238
 	}
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	public function getIterator()
257 257
 	{
258 258
 		if($this->_dataSource instanceof TList)
259
-			return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
259
+			return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
260 260
 		else if($this->_dataSource instanceof TMap)
261
-			return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
261
+			return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
262 262
 		else
263 263
 			return null;
264 264
 	}
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
 	 * @param integer start index
292 292
 	 * @param integer number of items to be iterated through
293 293
 	 */
294
-	public function __construct(TList $list,$startIndex,$count)
294
+	public function __construct(TList $list, $startIndex, $count)
295 295
 	{
296 296
 		$this->_list=$list;
297 297
 		$this->_index=0;
298 298
 		$this->_startIndex=$startIndex;
299
-		if($startIndex+$count>$list->getCount())
300
-			$this->_count=$list->getCount()-$startIndex;
299
+		if($startIndex + $count > $list->getCount())
300
+			$this->_count=$list->getCount() - $startIndex;
301 301
 		else
302 302
 			$this->_count=$count;
303 303
 	}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 */
329 329
 	public function current()
330 330
 	{
331
-		return $this->_list->itemAt($this->_startIndex+$this->_index);
331
+		return $this->_list->itemAt($this->_startIndex + $this->_index);
332 332
 	}
333 333
 
334 334
 	/**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 */
348 348
 	public function valid()
349 349
 	{
350
-		return $this->_index<$this->_count;
350
+		return $this->_index < $this->_count;
351 351
 	}
352 352
 }
353 353
 
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
 	 * Constructor.
376 376
 	 * @param array the data to be iterated through
377 377
 	 */
378
-	public function __construct(TMap $map,$startIndex,$count)
378
+	public function __construct(TMap $map, $startIndex, $count)
379 379
 	{
380 380
 		$this->_map=$map;
381 381
 		$this->_index=0;
382 382
 		$this->_startIndex=$startIndex;
383
-		if($startIndex+$count>$map->getCount())
384
-			$this->_count=$map->getCount()-$startIndex;
383
+		if($startIndex + $count > $map->getCount())
384
+			$this->_count=$map->getCount() - $startIndex;
385 385
 		else
386 386
 			$this->_count=$count;
387 387
 		$this->_iterator=$map->getIterator();
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	public function rewind()
395 395
 	{
396 396
 		$this->_iterator->rewind();
397
-		for($i=0;$i<$this->_startIndex;++$i)
397
+		for($i=0; $i < $this->_startIndex; ++$i)
398 398
 			$this->_iterator->next();
399 399
 		$this->_index=0;
400 400
 	}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 */
437 437
 	public function valid()
438 438
 	{
439
-		return $this->_index<$this->_count;
439
+		return $this->_index < $this->_count;
440 440
 	}
441 441
 }
442 442
 
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -208,6 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param string active record class name.
209 209
 	 * @param array row data
210 210
 	 * @param array foreign key column names
211
+	 * @param string $type
211 212
 	 * @return TActiveRecord
212 213
 	 */
213 214
 	protected function createFkObject($type,$row,$foreignKeys)
@@ -227,6 +228,7 @@  discard block
 block discarded – undo
227 228
 	 * @param TTableInfo association table info
228 229
 	 * @param array field names
229 230
 	 * @param array field values
231
+	 * @param TActiveRecordCriteria $criteria
230 232
 	 */
231 233
 	public function createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys)
232 234
 	{
@@ -341,6 +343,10 @@  discard block
 block discarded – undo
341 343
 		return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0;
342 344
 	}
343 345
 
346
+	/**
347
+	 * @param TActiveRecord $obj
348
+	 * @param TDbCommandBuilder $builder
349
+	 */
344 350
 	private function updateAssociationTable($obj,$fkObjects, $builder)
345 351
 	{
346 352
 		$source = $this->getSourceRecordValues($obj);
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,10 +90,10 @@
 block discarded – undo
90 90
 	private $_association_columns=array();
91 91
 
92 92
 	/**
93
-	* Get the foreign key index values from the results and make calls to the
94
-	* database to find the corresponding foreign objects using association table.
95
-	* @param array original results.
96
-	*/
93
+	 * Get the foreign key index values from the results and make calls to the
94
+	 * database to find the corresponding foreign objects using association table.
95
+	 * @param array original results.
96
+	 */
97 97
 	protected function collectForeignObjects(&$results)
98 98
 	{
99 99
 		list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys();
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	*/
97 97
 	protected function collectForeignObjects(&$results)
98 98
 	{
99
-		list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys();
100
-		$properties = array_values($sourceKeys);
101
-		$indexValues = $this->getIndexValues($properties, $results);
102
-		$this->fetchForeignObjects($results, $foreignKeys,$indexValues,$sourceKeys);
99
+		list($sourceKeys, $foreignKeys)=$this->getRelationForeignKeys();
100
+		$properties=array_values($sourceKeys);
101
+		$indexValues=$this->getIndexValues($properties, $results);
102
+		$this->fetchForeignObjects($results, $foreignKeys, $indexValues, $sourceKeys);
103 103
 	}
104 104
 
105 105
 	/**
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getRelationForeignKeys()
109 109
 	{
110
-		$association = $this->getAssociationTable();
111
-		$sourceKeys = $this->findForeignKeys($association, $this->getSourceRecord(), true);
112
-		$fkObject = $this->getContext()->getForeignRecordFinder();
113
-		$foreignKeys = $this->findForeignKeys($association, $fkObject);
110
+		$association=$this->getAssociationTable();
111
+		$sourceKeys=$this->findForeignKeys($association, $this->getSourceRecord(), true);
112
+		$fkObject=$this->getContext()->getForeignRecordFinder();
113
+		$foreignKeys=$this->findForeignKeys($association, $fkObject);
114 114
 		return array($sourceKeys, $foreignKeys);
115 115
 	}
116 116
 
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	{
122 122
 		if($this->_association===null)
123 123
 		{
124
-			$gateway = $this->getSourceRecord()->getRecordGateway();
125
-			$conn = $this->getSourceRecord()->getDbConnection();
124
+			$gateway=$this->getSourceRecord()->getRecordGateway();
125
+			$conn=$this->getSourceRecord()->getDbConnection();
126 126
 			//table name may include the fk column name separated with a dot.
127
-			$table = explode('.', $this->getContext()->getAssociationTable());
128
-			if(count($table)>1)
127
+			$table=explode('.', $this->getContext()->getAssociationTable());
128
+			if(count($table) > 1)
129 129
 			{
130
-				$columns = preg_replace('/^\((.*)\)/', '\1', $table[1]);
131
-				$this->_association_columns = preg_split('/\s*[, ]\*/',$columns);
130
+				$columns=preg_replace('/^\((.*)\)/', '\1', $table[1]);
131
+				$this->_association_columns=preg_split('/\s*[, ]\*/', $columns);
132 132
 			}
133
-			$this->_association = $gateway->getTableInfo($conn, $table[0]);
133
+			$this->_association=$gateway->getTableInfo($conn, $table[0]);
134 134
 		}
135 135
 		return $this->_association;
136 136
 	}
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	{
143 143
 		if($this->_sourceTable===null)
144 144
 		{
145
-			$gateway = $this->getSourceRecord()->getRecordGateway();
146
-			$this->_sourceTable = $gateway->getRecordTableInfo($this->getSourceRecord());
145
+			$gateway=$this->getSourceRecord()->getRecordGateway();
146
+			$this->_sourceTable=$gateway->getRecordTableInfo($this->getSourceRecord());
147 147
 		}
148 148
 		return $this->_sourceTable;
149 149
 	}
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		if($this->_foreignTable===null)
157 157
 		{
158
-			$gateway = $this->getSourceRecord()->getRecordGateway();
159
-			$fkObject = $this->getContext()->getForeignRecordFinder();
160
-			$this->_foreignTable = $gateway->getRecordTableInfo($fkObject);
158
+			$gateway=$this->getSourceRecord()->getRecordGateway();
159
+			$fkObject=$this->getContext()->getForeignRecordFinder();
160
+			$this->_foreignTable=$gateway->getRecordTableInfo($fkObject);
161 161
 		}
162 162
 		return $this->_foreignTable;
163 163
 	}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function getForeignCommandBuilder()
177 177
 	{
178
-		$obj = $this->getContext()->getForeignRecordFinder();
178
+		$obj=$this->getContext()->getForeignRecordFinder();
179 179
 		return $this->getSourceRecord()->getRecordGateway()->getCommand($obj);
180 180
 	}
181 181
 
@@ -185,21 +185,21 @@  discard block
 block discarded – undo
185 185
 	 * @param array field names
186 186
 	 * @param array foreign key index values.
187 187
 	 */
188
-	protected function fetchForeignObjects(&$results,$foreignKeys,$indexValues,$sourceKeys)
188
+	protected function fetchForeignObjects(&$results, $foreignKeys, $indexValues, $sourceKeys)
189 189
 	{
190
-		$criteria = $this->getCriteria();
191
-		$finder = $this->getContext()->getForeignRecordFinder();
192
-		$type = get_class($finder);
193
-		$command = $this->createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys);
194
-		$srcProps = array_keys($sourceKeys);
190
+		$criteria=$this->getCriteria();
191
+		$finder=$this->getContext()->getForeignRecordFinder();
192
+		$type=get_class($finder);
193
+		$command=$this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys);
194
+		$srcProps=array_keys($sourceKeys);
195 195
 		$collections=array();
196 196
 		foreach($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row)
197 197
 		{
198
-			$hash = $this->getObjectHash($row, $srcProps);
198
+			$hash=$this->getObjectHash($row, $srcProps);
199 199
 			foreach($srcProps as $column)
200 200
 				unset($row[$column]);
201
-			$obj = $this->createFkObject($type,$row,$foreignKeys);
202
-			$collections[$hash][] = $obj;
201
+			$obj=$this->createFkObject($type, $row, $foreignKeys);
202
+			$collections[$hash][]=$obj;
203 203
 		}
204 204
 		$this->setResultCollection($results, $collections, array_values($sourceKeys));
205 205
 	}
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * @param array foreign key column names
211 211
 	 * @return TActiveRecord
212 212
 	 */
213
-	protected function createFkObject($type,$row,$foreignKeys)
213
+	protected function createFkObject($type, $row, $foreignKeys)
214 214
 	{
215
-		$obj = TActiveRecord::createRecord($type, $row);
215
+		$obj=TActiveRecord::createRecord($type, $row);
216 216
 		if(count($this->_association_columns) > 0)
217 217
 		{
218 218
 			$i=0;
@@ -228,22 +228,22 @@  discard block
 block discarded – undo
228 228
 	 * @param array field names
229 229
 	 * @param array field values
230 230
 	 */
231
-	public function createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys)
231
+	public function createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys)
232 232
 	{
233
-		$innerJoin = $this->getAssociationJoin($foreignKeys,$indexValues,$sourceKeys);
234
-		$fkTable = $this->getForeignTable()->getTableFullName();
235
-		$srcColumns = $this->getSourceColumns($sourceKeys);
233
+		$innerJoin=$this->getAssociationJoin($foreignKeys, $indexValues, $sourceKeys);
234
+		$fkTable=$this->getForeignTable()->getTableFullName();
235
+		$srcColumns=$this->getSourceColumns($sourceKeys);
236 236
 		if(($where=$criteria->getCondition())===null)
237 237
 			$where='1=1';
238
-		$sql = "SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}";
238
+		$sql="SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}";
239 239
 
240
-		$parameters = $criteria->getParameters()->toArray();
241
-		$ordering = $criteria->getOrdersBy();
242
-		$limit = $criteria->getLimit();
243
-		$offset = $criteria->getOffset();
240
+		$parameters=$criteria->getParameters()->toArray();
241
+		$ordering=$criteria->getOrdersBy();
242
+		$limit=$criteria->getLimit();
243
+		$offset=$criteria->getOffset();
244 244
 
245
-		$builder = $this->getForeignCommandBuilder()->getBuilder();
246
-		$command = $builder->applyCriterias($sql,$parameters,$ordering,$limit,$offset);
245
+		$builder=$this->getForeignCommandBuilder()->getBuilder();
246
+		$command=$builder->applyCriterias($sql, $parameters, $ordering, $limit, $offset);
247 247
 		$this->getCommandBuilder()->onCreateCommand($command, $criteria);
248 248
 		return $command;
249 249
 	}
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	protected function getSourceColumns($sourceKeys)
256 256
 	{
257 257
 		$columns=array();
258
-		$table = $this->getAssociationTable();
259
-		$tableName = $table->getTableFullName();
260
-		$columnNames = array_merge(array_keys($sourceKeys),$this->_association_columns);
258
+		$table=$this->getAssociationTable();
259
+		$tableName=$table->getTableFullName();
260
+		$columnNames=array_merge(array_keys($sourceKeys), $this->_association_columns);
261 261
 		foreach($columnNames as $name)
262
-			$columns[] = $tableName.'.'.$table->getColumn($name)->getColumnName();
262
+			$columns[]=$tableName.'.'.$table->getColumn($name)->getColumnName();
263 263
 		return implode(', ', $columns);
264 264
 	}
265 265
 
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
 	 * @param array source table column names.
271 271
 	 * @return string inner join condition for M-N relationship via association table.
272 272
 	 */
273
-	protected function getAssociationJoin($foreignKeys,$indexValues,$sourceKeys)
273
+	protected function getAssociationJoin($foreignKeys, $indexValues, $sourceKeys)
274 274
 	{
275
-		$refInfo= $this->getAssociationTable();
276
-		$fkInfo = $this->getForeignTable();
275
+		$refInfo=$this->getAssociationTable();
276
+		$fkInfo=$this->getForeignTable();
277 277
 
278
-		$refTable = $refInfo->getTableFullName();
279
-		$fkTable = $fkInfo->getTableFullName();
278
+		$refTable=$refInfo->getTableFullName();
279
+		$fkTable=$fkInfo->getTableFullName();
280 280
 
281
-		$joins = array();
282
-		$hasAssociationColumns = count($this->_association_columns) > 0;
281
+		$joins=array();
282
+		$hasAssociationColumns=count($this->_association_columns) > 0;
283 283
 		$i=0;
284 284
 		foreach($foreignKeys as $ref=>$fk)
285 285
 		{
286 286
 			if($hasAssociationColumns)
287
-				$refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
287
+				$refField=$refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
288 288
 			else
289
-				$refField = $refInfo->getColumn($ref)->getColumnName();
290
-			$fkField = $fkInfo->getColumn($fk)->getColumnName();
291
-			$joins[] = "{$fkTable}.{$fkField} = {$refTable}.{$refField}";
289
+				$refField=$refInfo->getColumn($ref)->getColumnName();
290
+			$fkField=$fkInfo->getColumn($fk)->getColumnName();
291
+			$joins[]="{$fkTable}.{$fkField} = {$refTable}.{$refField}";
292 292
 		}
293
-		$joinCondition = implode(' AND ', $joins);
294
-		$index = $this->getCommandBuilder()->getIndexKeyCondition($refInfo,array_keys($sourceKeys), $indexValues);
293
+		$joinCondition=implode(' AND ', $joins);
294
+		$index=$this->getCommandBuilder()->getIndexKeyCondition($refInfo, array_keys($sourceKeys), $indexValues);
295 295
 		return "INNER JOIN {$refTable} ON ({$joinCondition}) AND {$index}";
296 296
 	}
297 297
 
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
 	 */
302 302
 	public function updateAssociatedRecords()
303 303
 	{
304
-		$obj = $this->getContext()->getSourceRecord();
305
-		$fkObjects = &$obj->{$this->getContext()->getProperty()};
304
+		$obj=$this->getContext()->getSourceRecord();
305
+		$fkObjects=&$obj->{$this->getContext()->getProperty()};
306 306
 		$success=true;
307
-		if(($total = count($fkObjects))> 0)
307
+		if(($total=count($fkObjects)) > 0)
308 308
 		{
309
-			$source = $this->getSourceRecord();
310
-			$builder = $this->getAssociationTableCommandBuilder();
311
-			for($i=0;$i<$total;$i++)
312
-				$success = $fkObjects[$i]->save() && $success;
309
+			$source=$this->getSourceRecord();
310
+			$builder=$this->getAssociationTableCommandBuilder();
311
+			for($i=0; $i < $total; $i++)
312
+				$success=$fkObjects[$i]->save() && $success;
313 313
 			return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success;
314 314
 		}
315 315
 		return $success;
@@ -320,57 +320,57 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	protected function getAssociationTableCommandBuilder()
322 322
 	{
323
-		$conn = $this->getContext()->getSourceRecord()->getDbConnection();
323
+		$conn=$this->getContext()->getSourceRecord()->getDbConnection();
324 324
 		return $this->getAssociationTable()->createCommandBuilder($conn);
325 325
 	}
326 326
 
327
-	private function hasAssociationData($builder,$data)
327
+	private function hasAssociationData($builder, $data)
328 328
 	{
329 329
 		$condition=array();
330
-		$table = $this->getAssociationTable();
330
+		$table=$this->getAssociationTable();
331 331
 		foreach($data as $name=>$value)
332
-			$condition[] = $table->getColumn($name)->getColumnName().' = ?';
333
-		$command = $builder->createCountCommand(implode(' AND ', $condition),array_values($data));
334
-		$result = $this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar()));
332
+			$condition[]=$table->getColumn($name)->getColumnName().' = ?';
333
+		$command=$builder->createCountCommand(implode(' AND ', $condition), array_values($data));
334
+		$result=$this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar()));
335 335
 		return intval($result) > 0;
336 336
 	}
337 337
 
338
-	private function addAssociationData($builder,$data)
338
+	private function addAssociationData($builder, $data)
339 339
 	{
340
-		$command = $builder->createInsertCommand($data);
340
+		$command=$builder->createInsertCommand($data);
341 341
 		return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0;
342 342
 	}
343 343
 
344
-	private function updateAssociationTable($obj,$fkObjects, $builder)
344
+	private function updateAssociationTable($obj, $fkObjects, $builder)
345 345
 	{
346
-		$source = $this->getSourceRecordValues($obj);
347
-		$foreignKeys = $this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]);
346
+		$source=$this->getSourceRecordValues($obj);
347
+		$foreignKeys=$this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]);
348 348
 		$success=true;
349 349
 		foreach($fkObjects as $fkObject)
350 350
 		{
351
-			$data = array_merge($source, $this->getForeignObjectValues($foreignKeys,$fkObject));
352
-			if(!$this->hasAssociationData($builder,$data))
353
-				$success = $this->addAssociationData($builder,$data) && $success;
351
+			$data=array_merge($source, $this->getForeignObjectValues($foreignKeys, $fkObject));
352
+			if(!$this->hasAssociationData($builder, $data))
353
+				$success=$this->addAssociationData($builder, $data) && $success;
354 354
 		}
355 355
 		return $success;
356 356
 	}
357 357
 
358 358
 	private function getSourceRecordValues($obj)
359 359
 	{
360
-		$sourceKeys = $this->findForeignKeys($this->getAssociationTable(), $obj);
361
-		$indexValues = $this->getIndexValues(array_values($sourceKeys), $obj);
362
-		$data = array();
360
+		$sourceKeys=$this->findForeignKeys($this->getAssociationTable(), $obj);
361
+		$indexValues=$this->getIndexValues(array_values($sourceKeys), $obj);
362
+		$data=array();
363 363
 		$i=0;
364 364
 		foreach($sourceKeys as $name=>$srcKey)
365
-			$data[$name] = $indexValues[0][$i++];
365
+			$data[$name]=$indexValues[0][$i++];
366 366
 		return $data;
367 367
 	}
368 368
 
369
-	private function getForeignObjectValues($foreignKeys,$fkObject)
369
+	private function getForeignObjectValues($foreignKeys, $fkObject)
370 370
 	{
371 371
 		$data=array();
372 372
 		foreach($foreignKeys as $name=>$fKey)
373
-			$data[$name] = $fkObject->getColumnValue($fKey);
373
+			$data[$name]=$fkObject->getColumnValue($fKey);
374 374
 		return $data;
375 375
 	}
376 376
 }
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,6 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 	/**
94 94
 	 * Fetch results for current relationship.
95
+	 * @param TActiveRecord $obj
95 96
 	 * @return boolean always true.
96 97
 	 */
97 98
 	public function fetchResultsInto($obj)
@@ -104,7 +105,6 @@  discard block
 block discarded – undo
104 105
 	 * Returns foreign keys in $fromRecord with source column names as key
105 106
 	 * and foreign column names in the corresponding $matchesRecord as value.
106 107
 	 * The method returns the first matching foreign key between these 2 records.
107
-	 * @param TActiveRecord $fromRecord
108 108
 	 * @param TActiveRecord $matchesRecord
109 109
 	 * @return array foreign keys with source column names as key and foreign column names as value.
110 110
 	 */
@@ -212,6 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @param array source property names
213 213
 	 * @param array foreign objects
214 214
 	 * @param array foreign object field names.
215
+	 * @param TActiveRecord[] $fkObjects
215 216
 	 */
216 217
 	protected function populateResult(&$results,$properties,&$fkObjects,$fields)
217 218
 	{
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 
31 31
 	public function __construct(TActiveRecordRelationContext $context, $criteria)
32 32
 	{
33
-		$this->_context = $context;
34
-		$this->_criteria = $criteria;
33
+		$this->_context=$context;
34
+		$this->_criteria=$criteria;
35 35
 	}
36 36
 
37 37
 	/**
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * @param array method arguments
72 72
 	 * @return mixed TActiveRecord or array of TActiveRecord results depending on the method called.
73 73
 	 */
74
-	public function __call($method,$args)
74
+	public function __call($method, $args)
75 75
 	{
76 76
 		static $stack=array();
77 77
 
78
-		$results = call_user_func_array(array($this->getSourceRecord(),$method),$args);
79
-		$validArray = is_array($results) && count($results) > 0;
78
+		$results=call_user_func_array(array($this->getSourceRecord(), $method), $args);
79
+		$validArray=is_array($results) && count($results) > 0;
80 80
 		if($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
81 81
 		{
82 82
 			$this->collectForeignObjects($results);
83
-			while($obj = array_pop($stack))
83
+			while($obj=array_pop($stack))
84 84
 				$obj->collectForeignObjects($results);
85 85
 		}
86 86
 		else if($results instanceof TActiveRecordRelation)
87
-			$stack[] = $this; //call it later
88
-		else if($results === null || !$validArray)
89
-			$stack = array();
87
+			$stack[]=$this; //call it later
88
+		else if($results===null || !$validArray)
89
+			$stack=array();
90 90
 		return $results;
91 91
 	}
92 92
 
@@ -110,28 +110,28 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function findForeignKeys($from, $matchesRecord, $loose=false)
112 112
 	{
113
-		$gateway = $matchesRecord->getRecordGateway();
114
-		$recordTableInfo = $gateway->getRecordTableInfo($matchesRecord);
115
-		$matchingTableName = strtolower($recordTableInfo->getTableName());
116
-		$matchingFullTableName = strtolower($recordTableInfo->getTableFullName());
113
+		$gateway=$matchesRecord->getRecordGateway();
114
+		$recordTableInfo=$gateway->getRecordTableInfo($matchesRecord);
115
+		$matchingTableName=strtolower($recordTableInfo->getTableName());
116
+		$matchingFullTableName=strtolower($recordTableInfo->getTableFullName());
117 117
 		$tableInfo=$from;
118 118
 		if($from instanceof TActiveRecord)
119
-			$tableInfo = $gateway->getRecordTableInfo($from);
119
+			$tableInfo=$gateway->getRecordTableInfo($from);
120 120
 		//find first non-empty FK
121 121
 		foreach($tableInfo->getForeignKeys() as $fkeys)
122 122
 		{
123
-			$fkTable = strtolower($fkeys['table']);
123
+			$fkTable=strtolower($fkeys['table']);
124 124
 			if($fkTable===$matchingTableName || $fkTable===$matchingFullTableName)
125 125
 			{
126
-				$hasFkField = !$loose && $this->getContext()->hasFkField();
127
-				$key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
126
+				$hasFkField=!$loose && $this->getContext()->hasFkField();
127
+				$key=$hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
128 128
 				if(!empty($key))
129 129
 					return $key;
130 130
 			}
131 131
 		}
132 132
 
133 133
 		//none found
134
-		$matching = $gateway->getRecordTableInfo($matchesRecord)->getTableFullName();
134
+		$matching=$gateway->getRecordTableInfo($matchesRecord)->getTableFullName();
135 135
 		throw new TActiveRecordException('ar_relations_missing_fk',
136 136
 			$tableInfo->getTableFullName(), $matching);
137 137
 	}
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	private function getFkFields($fkeys)
151 151
 	{
152
-		$matching = array();
152
+		$matching=array();
153 153
 		preg_match_all('/\s*(\S+\.)?([\w-]+)\s*/', $this->getContext()->getFkField(), $matching);
154
-		$fields = array();
154
+		$fields=array();
155 155
 		foreach($fkeys as $fkName => $field)
156 156
 		{
157 157
 			if(in_array($fkName, $matching[2]))
158
-				$fields[$fkName] = $field;
158
+				$fields[$fkName]=$field;
159 159
 		}
160 160
 		return $fields;
161 161
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	{
170 170
 		$ids=array();
171 171
 		foreach($properties as $property)
172
-			$ids[] = is_object($obj) ? (string)$obj->getColumnValue($property) : (string)$obj[$property];
172
+			$ids[]=is_object($obj) ? (string) $obj->getColumnValue($property) : (string) $obj[$property];
173 173
 		return serialize($ids);
174 174
 	}
175 175
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	protected function findForeignObjects($fields, $indexValues)
183 183
 	{
184
-		$finder = $this->getContext()->getForeignRecordFinder();
184
+		$finder=$this->getContext()->getForeignRecordFinder();
185 185
 		return $finder->findAllByIndex($this->_criteria, $fields, $indexValues);
186 186
 	}
187 187
 
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 	protected function getIndexValues($keys, $results)
195 195
 	{
196 196
 		if(!is_array($results) && !$results instanceof ArrayAccess)
197
-			$results = array($results);
197
+			$results=array($results);
198 198
 		$values=array();
199 199
 		foreach($results as $result)
200 200
 		{
201
-			$value = array();
201
+			$value=array();
202 202
 			foreach($keys as $name)
203
-				$value[] = $result->getColumnValue($name);
204
-			$values[] = $value;
203
+				$value[]=$result->getColumnValue($name);
204
+			$values[]=$value;
205 205
 		}
206 206
 		return $values;
207 207
 	}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @param array foreign objects
214 214
 	 * @param array foreign object field names.
215 215
 	 */
216
-	protected function populateResult(&$results,$properties,&$fkObjects,$fields)
216
+	protected function populateResult(&$results, $properties, &$fkObjects, $fields)
217 217
 	{
218 218
 		$collections=array();
219 219
 		foreach($fkObjects as $fkObject)
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	{
232 232
 		if(is_array($results) || $results instanceof ArrayAccess)
233 233
 		{
234
-			for($i=0,$k=count($results);$i<$k;$i++)
234
+			for($i=0, $k=count($results); $i < $k; $i++)
235 235
 				$this->setObjectProperty($results[$i], $properties, $collections);
236 236
 		}
237 237
 		else
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	protected function setObjectProperty($source, $properties, &$collections)
248 248
 	{
249
-		$hash = $this->getObjectHash($source, $properties);
250
-		$prop = $this->getContext()->getProperty();
249
+		$hash=$this->getObjectHash($source, $properties);
250
+		$prop=$this->getContext()->getProperty();
251 251
 		$source->$prop=isset($collections[$hash]) ? $collections[$hash] : array();
252 252
 	}
253 253
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 		if($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
81 81
 		{
82 82
 			$this->collectForeignObjects($results);
83
-			while($obj = array_pop($stack))
84
-				$obj->collectForeignObjects($results);
85
-		}
86
-		else if($results instanceof TActiveRecordRelation)
83
+			while($obj = array_pop($stack)) {
84
+							$obj->collectForeignObjects($results);
85
+			}
86
+		} else if($results instanceof TActiveRecordRelation)
87 87
 			$stack[] = $this; //call it later
88 88
 		else if($results === null || !$validArray)
89 89
 			$stack = array();
@@ -233,8 +233,7 @@  discard block
 block discarded – undo
233 233
 		{
234 234
 			for($i=0,$k=count($results);$i<$k;$i++)
235 235
 				$this->setObjectProperty($results[$i], $properties, $collections);
236
-		}
237
-		else
236
+		} else
238 237
 			$this->setObjectProperty($results, $properties, $collections);
239 238
 	}
240 239
 
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php 2 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
30 30
 	private $_relation; //data from an entry of TActiveRecord::$RELATION
31 31
 	private $_fkeys;
32 32
 
33
+	/**
34
+	 * @param TActiveRecord $record
35
+	 */
33 36
 	public function __construct($record, $property=null, $relation=null)
34 37
 	{
35 38
 		$this->_record=$record;
@@ -163,6 +166,7 @@  discard block
 block discarded – undo
163 166
 	 * An instance of TActiveRecordHasOne, TActiveRecordBelongsTo, TActiveRecordHasMany,
164 167
 	 * or TActiveRecordHasManyAssocation will be returned.
165 168
 	 * @param TActiveRecordCriteria search criteria
169
+	 * @param TSqlCriteria $criteria
166 170
 	 * @return TActiveRecordRelation record relationship handler instnace.
167 171
 	 * @throws TActiveRecordException if property is not defined or missing.
168 172
 	 */
@@ -195,7 +199,7 @@  discard block
 block discarded – undo
195 199
 	}
196 200
 
197 201
 	/**
198
-	 * @return TActiveRecordRelationCommand
202
+	 * @return boolean
199 203
 	 */
200 204
 	public function updateAssociatedRecords($updateBelongsTo=false)
201 205
 	{
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 	public function getPropertyValue()
50 50
 	{
51
-		$obj = $this->getSourceRecord();
51
+		$obj=$this->getSourceRecord();
52 52
 		return $obj->getColumnValue($this->getProperty());
53 53
 	}
54 54
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function getCondition()
113 113
 	{
114
-		return isset($this->_relation[3])?$this->_relation[3]:null;
114
+		return isset($this->_relation[3]) ? $this->_relation[3] : null;
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function getParameters()
122 122
 	{
123
-		return isset($this->_relation[4])?$this->_relation[4]:array();
123
+		return isset($this->_relation[4]) ? $this->_relation[4] : array();
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function hasFkField()
131 131
 	{
132
-		$notManyToMany = $this->getRelationType() !== TActiveRecord::MANY_TO_MANY;
132
+		$notManyToMany=$this->getRelationType()!==TActiveRecord::MANY_TO_MANY;
133 133
 		return $notManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]);
134 134
 	}
135 135
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function hasAssociationTable()
148 148
 	{
149
-		$isManyToMany = $this->getRelationType() === TActiveRecord::MANY_TO_MANY;
149
+		$isManyToMany=$this->getRelationType()===TActiveRecord::MANY_TO_MANY;
150 150
 		return $isManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]);
151 151
 	}
152 152
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				$this->_property, get_class($this->_record), 'RELATIONS');
175 175
 		}
176 176
 		if($criteria===null)
177
-			$criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
177
+			$criteria=new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
178 178
 		switch($this->getRelationType())
179 179
 		{
180 180
 			case TActiveRecord::HAS_MANY:
@@ -202,15 +202,15 @@  discard block
 block discarded – undo
202 202
 		$success=true;
203 203
 		foreach($this->_record->getRecordRelations() as $data)
204 204
 		{
205
-			list($property, $relation) = $data;
206
-			$belongsTo = $relation[0]==TActiveRecord::BELONGS_TO;
205
+			list($property, $relation)=$data;
206
+			$belongsTo=$relation[0]==TActiveRecord::BELONGS_TO;
207 207
 			if(($updateBelongsTo && $belongsTo) || (!$updateBelongsTo && !$belongsTo))
208 208
 			{
209
-				$obj = $this->getSourceRecord();
209
+				$obj=$this->getSourceRecord();
210 210
 				if(!$this->isEmptyFkObject($obj->getColumnValue($property)))
211 211
 				{
212
-					$context = new TActiveRecordRelationContext($this->getSourceRecord(),$property,$relation);
213
-					$success = $context->getRelationHandler()->updateAssociatedRecords() && $success;
212
+					$context=new TActiveRecordRelationContext($this->getSourceRecord(), $property, $relation);
213
+					$success=$context->getRelationHandler()->updateAssociatedRecords() && $success;
214 214
 				}
215 215
 			}
216 216
 		}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	protected function isEmptyFkObject($obj)
221 221
 	{
222 222
 		if(is_object($obj))
223
-			return $obj instanceof TList ? $obj->count() === 0 : false;
223
+			return $obj instanceof TList ? $obj->count()===0 : false;
224 224
 		else if(is_array($obj))
225 225
 			return count($obj)===0;
226 226
 		else
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -46,6 +46,10 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 	}
48 48
 
49
+	/**
50
+	 * @param TScaffoldEditView $parent
51
+	 * @param TActiveRecord $record
52
+	 */
49 53
 	public function createScaffoldInput($parent, $item, $column, $record)
50 54
 	{
51 55
 		$this->_parent=$parent;
@@ -62,6 +66,11 @@  discard block
 block discarded – undo
62 66
 		$label->setForControl(self::DEFAULT_ID);
63 67
 	}
64 68
 
69
+	/**
70
+	 * @param TScaffoldEditView $parent
71
+	 * @param TDbTableColumn $column
72
+	 * @param TActiveRecord $record
73
+	 */
65 74
 	public function loadScaffoldInput($parent, $item, $column, $record)
66 75
 	{
67 76
 		$this->_parent=$parent;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class TScaffoldInputBase
11 11
 {
12
-	const DEFAULT_ID = 'scaffold_input';
12
+	const DEFAULT_ID='scaffold_input';
13 13
 	private $_parent;
14 14
 
15 15
 	protected function getParent()
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	public static function createInputBuilder($record)
21 21
 	{
22 22
 		$record->getDbConnection()->setActive(true); //must be connected before retrieving driver name!
23
-		$driver = $record->getDbConnection()->getDriverName();
23
+		$driver=$record->getDbConnection()->getDriverName();
24 24
 		switch(strtolower($driver))
25 25
 		{
26 26
 			case 'sqlite': //sqlite 3
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 				return new TIbmScaffoldInput($conn);
43 43
 			default:
44 44
 				throw new TConfigurationException(
45
-					'scaffold_invalid_database_driver',$driver);
45
+					'scaffold_invalid_database_driver', $driver);
46 46
 		}
47 47
 	}
48 48
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	protected function createControlLabel($label, $column, $record)
59 59
 	{
60
-		$fieldname = ucwords(str_replace('_', ' ', $column->getColumnId())).':';
60
+		$fieldname=ucwords(str_replace('_', ' ', $column->getColumnId())).':';
61 61
 		$label->setText($fieldname);
62 62
 		$label->setForControl(self::DEFAULT_ID);
63 63
 	}
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
 		$this->_parent=$parent;
68 68
 		if($this->getIsEnabled($column, $record))
69 69
 		{
70
-			$prop = $column->getColumnId();
70
+			$prop=$column->getColumnId();
71 71
 			$record->setColumnValue($prop, $this->getControlValue($item->_input, $column, $record));
72 72
 		}
73 73
 	}
74 74
 
75 75
 	protected function getIsEnabled($column, $record)
76 76
 	{
77
-		return !($this->getParent()->getRecordPk() !== null
77
+		return !($this->getParent()->getRecordPk()!==null
78 78
 				&& $column->getIsPrimaryKey() || $column->hasSequence());
79 79
 	}
80 80
 
81 81
 	protected function getRecordPropertyValue($column, $record)
82 82
 	{
83
-		$value = $record->getColumnValue($column->getColumnId());
83
+		$value=$record->getColumnValue($column->getColumnId());
84 84
 		if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null)
85 85
 			return $column->getDefaultValue();
86 86
 		else
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -47,6 +47,9 @@
 block discarded – undo
47 47
 		return $control;
48 48
 	}
49 49
 
50
+	/**
51
+	 * @return string
52
+	 */
50 53
 	protected function getDefaultControlValue($container,$column, $record)
51 54
 	{
52 55
 		$control = $container->findControl(self::DEFAULT_ID);
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	{
16 16
 		$control->setID(self::DEFAULT_ID);
17 17
 		$control->setEnabled($this->getIsEnabled($column, $record));
18
-		$container->Controls[] = $control;
18
+		$container->Controls[]=$control;
19 19
 	}
20 20
 
21 21
 	protected function setNotNullProperty($container, $control, $column, $record)
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
 	protected function createBooleanControl($container, $column, $record)
29 29
 	{
30
-		$value = $this->getRecordPropertyValue($column, $record);
31
-		$control = new TCheckBox();
30
+		$value=$this->getRecordPropertyValue($column, $record);
31
+		$control=new TCheckBox();
32 32
 		$control->setChecked(TPropertyValue::ensureBoolean($value));
33 33
 		$control->setCssClass('boolean-checkbox');
34 34
 		$this->setDefaultProperty($container, $control, $column, $record);
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 	protected function createDefaultControl($container, $column, $record)
39 39
 	{
40
-		$value = $this->getRecordPropertyValue($column, $record);
41
-		$control = new TTextBox();
40
+		$value=$this->getRecordPropertyValue($column, $record);
41
+		$control=new TTextBox();
42 42
 		$control->setText($value);
43 43
 		$control->setCssClass('default-textbox scaffold_input');
44 44
 		if(($len=$column->getColumnSize())!==null)
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 		return $control;
48 48
 	}
49 49
 
50
-	protected function getDefaultControlValue($container,$column, $record)
50
+	protected function getDefaultControlValue($container, $column, $record)
51 51
 	{
52
-		$control = $container->findControl(self::DEFAULT_ID);
52
+		$control=$container->findControl(self::DEFAULT_ID);
53 53
 		if($control instanceof TCheckBox)
54 54
 			return $control->getChecked();
55 55
 		else if($control instanceof TControl)
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 
59 59
 	protected function createMultiLineControl($container, $column, $record)
60 60
 	{
61
-		$value = $this->getRecordPropertyValue($column, $record);
62
-		$control = new TTextBox();
61
+		$value=$this->getRecordPropertyValue($column, $record);
62
+		$control=new TTextBox();
63 63
 		$control->setText($value);
64 64
 		$control->setTextMode(TTextBoxMode::MultiLine);
65 65
 		$control->setCssClass('multiline-textbox scaffold_input');
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 
70 70
 	protected function createYearControl($container, $column, $record)
71 71
 	{
72
-		$value = $this->getRecordPropertyValue($column, $record);
73
-		$control = new TDropDownList();
74
-		$years = array();
75
-		$current = intval(@date('Y'));
76
-		$from = $current-10; $to=$current+10;
77
-		for($i = $from; $i <= $to; $i++)
78
-			$years[$i] = $i;
72
+		$value=$this->getRecordPropertyValue($column, $record);
73
+		$control=new TDropDownList();
74
+		$years=array();
75
+		$current=intval(@date('Y'));
76
+		$from=$current - 10; $to=$current + 10;
77
+		for($i=$from; $i <= $to; $i++)
78
+			$years[$i]=$i;
79 79
 		$control->setDataSource($years);
80 80
 		$control->setSelectedValue(empty($value) ? $current : $value);
81 81
 		$control->setCssClass('year-dropdown');
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
 	protected function createIntegerControl($container, $column, $record)
87 87
 	{
88
-		$control = $this->createDefaultControl($container, $column, $record);
89
-		$val = $this->createTypeValidator($container, $column, $record);
88
+		$control=$this->createDefaultControl($container, $column, $record);
89
+		$val=$this->createTypeValidator($container, $column, $record);
90 90
 		$val->setDataType(TValidationDataType::Integer);
91 91
 		$val->setErrorMessage('Please entery an integer.');
92 92
 		return $control;
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 
95 95
 	protected function createFloatControl($container, $column, $record)
96 96
 	{
97
-		$control = $this->createDefaultControl($container, $column, $record);
98
-		$val = $this->createTypeValidator($container, $column, $record);
97
+		$control=$this->createDefaultControl($container, $column, $record);
98
+		$val=$this->createTypeValidator($container, $column, $record);
99 99
 		$val->setDataType(TValidationDataType::Float);
100 100
 		$val->setErrorMessage('Please entery a decimal number.');
101
-		if(($max= $column->getMaxiumNumericConstraint())!==null)
101
+		if(($max=$column->getMaxiumNumericConstraint())!==null)
102 102
 		{
103
-			$val = $this->createRangeValidator($container,$column,$record);
103
+			$val=$this->createRangeValidator($container, $column, $record);
104 104
 			$val->setDataType(TValidationDataType::Float);
105 105
 			$val->setMaxValue($max);
106 106
 			$val->setStrictComparison(true);
@@ -111,99 +111,99 @@  discard block
 block discarded – undo
111 111
 
112 112
 	protected function createRequiredValidator($container, $column, $record)
113 113
 	{
114
-		$val = new TRequiredFieldValidator();
114
+		$val=new TRequiredFieldValidator();
115 115
 		$val->setErrorMessage('*');
116 116
 		$val->setControlCssClass('required-input');
117 117
 		$val->setCssClass('required');
118 118
 		$val->setControlToValidate(self::DEFAULT_ID);
119 119
 		$val->setValidationGroup($this->getParent()->getValidationGroup());
120 120
 		$val->setDisplay(TValidatorDisplayStyle::Dynamic);
121
-		$container->Controls[] = $val;
121
+		$container->Controls[]=$val;
122 122
 		return $val;
123 123
 	}
124 124
 
125 125
 	protected function createTypeValidator($container, $column, $record)
126 126
 	{
127
-		$val = new TDataTypeValidator();
127
+		$val=new TDataTypeValidator();
128 128
 		$val->setControlCssClass('required-input2');
129 129
 		$val->setCssClass('required');
130 130
 		$val->setControlToValidate(self::DEFAULT_ID);
131 131
 		$val->setValidationGroup($this->getParent()->getValidationGroup());
132 132
 		$val->setDisplay(TValidatorDisplayStyle::Dynamic);
133
-		$container->Controls[] = $val;
133
+		$container->Controls[]=$val;
134 134
 		return $val;
135 135
 	}
136 136
 
137 137
 	protected function createRangeValidator($container, $column, $record)
138 138
 	{
139
-		$val = new TRangeValidator();
139
+		$val=new TRangeValidator();
140 140
 		$val->setControlCssClass('required-input3');
141 141
 		$val->setCssClass('required');
142 142
 		$val->setControlToValidate(self::DEFAULT_ID);
143 143
 		$val->setValidationGroup($this->getParent()->getValidationGroup());
144 144
 		$val->setDisplay(TValidatorDisplayStyle::Dynamic);
145
-		$container->Controls[] = $val;
145
+		$container->Controls[]=$val;
146 146
 		return $val;
147 147
 	}
148 148
 
149 149
 	protected function createTimeControl($container, $column, $record)
150 150
 	{
151
-		$value = $this->getRecordPropertyValue($column, $record);
151
+		$value=$this->getRecordPropertyValue($column, $record);
152 152
 		$hours=array();
153
-		for($i=0;$i<24;$i++) $hours[] = str_pad($i,2,'0',STR_PAD_LEFT);
153
+		for($i=0; $i < 24; $i++) $hours[]=str_pad($i, 2, '0', STR_PAD_LEFT);
154 154
 		$mins=array();
155
-		for($i=0;$i<60;$i++) $mins[] = str_pad($i,2,'0',STR_PAD_LEFT);
156
-		$hour = intval(@date('H'));
157
-		$min = intval(@date('i'));
158
-		$sec = intval(@date('s'));
155
+		for($i=0; $i < 60; $i++) $mins[]=str_pad($i, 2, '0', STR_PAD_LEFT);
156
+		$hour=intval(@date('H'));
157
+		$min=intval(@date('i'));
158
+		$sec=intval(@date('s'));
159 159
 		if(!empty($value))
160 160
 		{
161 161
 			$match=array();
162 162
 			if(preg_match('/(\d+):(\d+):?(\d+)?/', $value, $match))
163 163
 			{
164
-				$hour = $match[1];
165
-				$min = $match[2];
164
+				$hour=$match[1];
165
+				$min=$match[2];
166 166
 				if(isset($match[3]))
167 167
 					$sec=$match[3];
168 168
 			}
169 169
 		}
170 170
 
171
-		$hcontrol = new TDropDownList();
171
+		$hcontrol=new TDropDownList();
172 172
 		$hcontrol->setDataSource($hours);
173 173
 		$hcontrol->setID(self::DEFAULT_ID);
174 174
 		$hcontrol->dataBind();
175 175
 		$hcontrol->setSelectedValue(intval($hour));
176
-		$container->Controls[] = $hcontrol;
177
-		$container->Controls[] = ' : ';
176
+		$container->Controls[]=$hcontrol;
177
+		$container->Controls[]=' : ';
178 178
 
179
-		$mcontrol = new TDropDownList();
179
+		$mcontrol=new TDropDownList();
180 180
 		$mcontrol->setDataSource($mins);
181 181
 		$mcontrol->dataBind();
182 182
 		$mcontrol->setID('scaffold_time_min');
183 183
 		$mcontrol->setSelectedValue(intval($min));
184
-		$container->Controls[] = $mcontrol;
185
-		$container->Controls[] = ' : ';
184
+		$container->Controls[]=$mcontrol;
185
+		$container->Controls[]=' : ';
186 186
 
187
-		$scontrol = new TDropDownList();
187
+		$scontrol=new TDropDownList();
188 188
 		$scontrol->setDataSource($mins);
189 189
 		$scontrol->dataBind();
190 190
 		$scontrol->setID('scaffold_time_sec');
191 191
 		$scontrol->setSelectedValue(intval($sec));
192
-		$container->Controls[] = $scontrol;
192
+		$container->Controls[]=$scontrol;
193 193
 
194
-		return array($hcontrol,$mcontrol,$scontrol);
194
+		return array($hcontrol, $mcontrol, $scontrol);
195 195
 	}
196 196
 
197 197
 
198 198
 	protected function createDateControl($container, $column, $record)
199 199
 	{
200
-		$value = $this->getRecordPropertyValue($column, $record);
201
-		$control = new TDatePicker();
200
+		$value=$this->getRecordPropertyValue($column, $record);
201
+		$control=new TDatePicker();
202 202
 		$control->setFromYear(1900);
203 203
 		$control->setInputMode(TDatePickerInputMode::DropDownList);
204 204
 		$control->setDateFormat('yyyy-MM-dd');
205 205
 		if(!empty($value))
206
-			$control->setDate(substr($value,0,10));
206
+			$control->setDate(substr($value, 0, 10));
207 207
 		$control->setCssClass('date-dropdown');
208 208
 		$this->setNotNullProperty($container, $control, $column, $record);
209 209
 		return $control;
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 
212 212
 	protected function createDateTimeControl($container, $column, $record)
213 213
 	{
214
-		$value = $this->getRecordPropertyValue($column, $record);
215
-		$control = $this->createDateControl($container, $column, $record);
216
-		$container->Controls[] = ' @ ';
217
-		$time = $this->createTimeControl($container, $column, $record);
214
+		$value=$this->getRecordPropertyValue($column, $record);
215
+		$control=$this->createDateControl($container, $column, $record);
216
+		$container->Controls[]=' @ ';
217
+		$time=$this->createTimeControl($container, $column, $record);
218 218
 		if(!empty($value))
219 219
 		{
220 220
 			$match=array();
@@ -232,30 +232,30 @@  discard block
 block discarded – undo
232 232
 
233 233
 	protected function getDateTimeValue($container, $column, $record)
234 234
 	{
235
-		$date = $container->findControl(self::DEFAULT_ID)->getDate();
236
-		$hour = $container->findControl('scaffold_time_hour')->getSelectedValue();
237
-		$mins = $container->findControl('scaffold_time_min')->getSelectedValue();
238
-		$secs = $container->findControl('scaffold_time_sec')->getSelectedValue();
235
+		$date=$container->findControl(self::DEFAULT_ID)->getDate();
236
+		$hour=$container->findControl('scaffold_time_hour')->getSelectedValue();
237
+		$mins=$container->findControl('scaffold_time_min')->getSelectedValue();
238
+		$secs=$container->findControl('scaffold_time_sec')->getSelectedValue();
239 239
 		return "{$date} {$hour}:{$mins}:{$secs}";
240 240
 	}
241 241
 
242 242
 	protected function getTimeValue($container, $column, $record)
243 243
 	{
244
-		$hour = $container->findControl(self::DEFAULT_ID)->getSelectedValue();
245
-		$mins = $container->findControl('scaffold_time_min')->getSelectedValue();
246
-		$secs = $container->findControl('scaffold_time_sec')->getSelectedValue();
244
+		$hour=$container->findControl(self::DEFAULT_ID)->getSelectedValue();
245
+		$mins=$container->findControl('scaffold_time_min')->getSelectedValue();
246
+		$secs=$container->findControl('scaffold_time_sec')->getSelectedValue();
247 247
 		return "{$hour}:{$mins}:{$secs}";
248 248
 	}
249 249
 
250 250
 	protected function createSetControl($container, $column, $record)
251 251
 	{
252
-		$value = $this->getRecordPropertyValue($column, $record);
253
-		$selectedValues = preg_split('/\s*,\s*/', $value);
254
-		$control = new TCheckBoxList();
255
-		$values = $column->getDbTypeValues();
252
+		$value=$this->getRecordPropertyValue($column, $record);
253
+		$selectedValues=preg_split('/\s*,\s*/', $value);
254
+		$control=new TCheckBoxList();
255
+		$values=$column->getDbTypeValues();
256 256
 		$control->setDataSource($values);
257 257
 		$control->dataBind();
258
-		$control->setSelectedIndices($this->getMatchingIndices($values,$selectedValues));
258
+		$control->setSelectedIndices($this->getMatchingIndices($values, $selectedValues));
259 259
 		$control->setID(self::DEFAULT_ID);
260 260
 		$control->setCssClass('set-checkboxes');
261 261
 		$this->setNotNullProperty($container, $control, $column, $record);
@@ -265,23 +265,23 @@  discard block
 block discarded – undo
265 265
 	protected function getMatchingIndices($checks, $values)
266 266
 	{
267 267
 		$index=array();
268
-		for($i=0, $k=count($checks); $i<$k; $i++)
268
+		for($i=0, $k=count($checks); $i < $k; $i++)
269 269
 		{
270 270
 			if(in_array($checks[$i], $values))
271
-				$index[] = $i;
271
+				$index[]=$i;
272 272
 		}
273 273
 		return $index;
274 274
 	}
275 275
 
276 276
 	protected function createEnumControl($container, $column, $record)
277 277
 	{
278
-		$value = $this->getRecordPropertyValue($column, $record);
279
-		$selectedValues = preg_split('/\s*,\s*/', $value);
280
-		$control = new TRadioButtonList();
281
-		$values = $column->getDbTypeValues();
278
+		$value=$this->getRecordPropertyValue($column, $record);
279
+		$selectedValues=preg_split('/\s*,\s*/', $value);
280
+		$control=new TRadioButtonList();
281
+		$values=$column->getDbTypeValues();
282 282
 		$control->setDataSource($values);
283 283
 		$control->dataBind();
284
-		$index = $this->getMatchingIndices($values,$selectedValues);
284
+		$index=$this->getMatchingIndices($values, $selectedValues);
285 285
 		if(count($index) > 0)
286 286
 			$control->setSelectedIndex($index[0]);
287 287
 		$control->setID(self::DEFAULT_ID);
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		foreach($container->findControl(self::DEFAULT_ID)->getItems() as $item)
297 297
 		{
298 298
 			if($item->getSelected())
299
-				$value[] = $item->getText();
299
+				$value[]=$item->getText();
300 300
 		}
301 301
 		return implode(',', $value);
302 302
 	}
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php 3 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	private $_record;
37 37
 
38 38
 	/**
39
-	 * @return TDbMetaData table/view information
39
+	 * @return TDbTableInfo table/view information
40 40
 	 */
41 41
 	protected function getTableInfo()
42 42
 	{
@@ -84,6 +84,7 @@  discard block
 block discarded – undo
84 84
 	/**
85 85
 	 * Name of the Active Record class to be viewed or scaffolded.
86 86
 	 * @param string Active Record class name.
87
+	 * @param string $value
87 88
 	 */
88 89
 	public function setRecordClass($value)
89 90
 	{
@@ -183,6 +184,7 @@  discard block
 block discarded – undo
183 184
 
184 185
 	/**
185 186
 	 * @param boolean enable default stylesheet, default is true.
187
+	 * @param boolean $value
186 188
 	 */
187 189
 	public function setEnableDefaultStyle($value)
188 190
 	{
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected function getTableInfo()
42 42
 	{
43
-		$finder = $this->getRecordFinder();
44
-		$gateway = $finder->getRecordManager()->getRecordGateWay();
43
+		$finder=$this->getRecordFinder();
44
+		$gateway=$finder->getRecordManager()->getRecordGateWay();
45 45
 		return $gateway->getRecordTableInfo($finder);
46 46
 	}
47 47
 
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	protected function getRecordPropertyValues($record)
53 53
 	{
54
-		$data = array();
54
+		$data=array();
55 55
 		foreach($this->getTableInfo()->getColumns() as $name=>$column)
56
-			$data[] = $record->getColumnValue($name);
56
+			$data[]=$record->getColumnValue($name);
57 57
 		return $data;
58 58
 	}
59 59
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		foreach($this->getTableInfo()->getColumns() as $name=>$column)
68 68
 		{
69 69
 			if($column->getIsPrimaryKey())
70
-				$data[] = $record->getColumnValue($name);
70
+				$data[]=$record->getColumnValue($name);
71 71
 		}
72 72
 		return $data;
73 73
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	protected function copyFrom(TScaffoldBase $obj)
98 98
 	{
99
-		$this->_record = $obj->_record;
99
+		$this->_record=$obj->_record;
100 100
 		$this->setRecordClass($obj->getRecordClass());
101 101
 		$this->setEnableDefaultStyle($obj->getEnableDefaultStyle());
102 102
 	}
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 			}
129 129
 			else
130 130
 			{
131
-				$class = $this->getRecordClass();
131
+				$class=$this->getRecordClass();
132 132
 				if($class!==null)
133 133
 					$this->_record=Prado::createComponent($class);
134 134
 				else
135 135
 				{
136 136
 					throw new TConfigurationException('scaffold_invalid_record_class',
137
-						$this->getRecordClass(),$this->getID());
137
+						$this->getRecordClass(), $this->getID());
138 138
 				}
139 139
 			}
140 140
 		}
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 		parent::onPreRender($param);
198 198
 		if($this->getEnableDefaultStyle())
199 199
 		{
200
-			$url = $this->publishAsset($this->getDefaultStyle().'.css');
201
-			$this->getPage()->getClientScript()->registerStyleSheetFile($url,$url);
200
+			$url=$this->publishAsset($this->getDefaultStyle().'.css');
201
+			$this->getPage()->getClientScript()->registerStyleSheetFile($url, $url);
202 202
 		}
203 203
 	}
204 204
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,8 +158,7 @@
 block discarded – undo
158 158
 				$e->setAttribute('maxOccurs','unbounded');
159 159
 				$sequence->appendChild($e);
160 160
 				$complexType->appendChild($sequence);
161
-			}
162
-			else
161
+			} else
163 162
 			{
164 163
 				$all = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all');
165 164
 				foreach($elements as $elem)
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -129,6 +129,8 @@  discard block
 block discarded – undo
129 129
 	 * Instantiate the external edit renderer.
130 130
 	 * @param TActiveRecord record to be edited
131 131
 	 * @param string external edit renderer class name.
132
+	 * @param TActiveRecord $record
133
+	 * @param string $classPath
132 134
 	 * @throws TConfigurationException raised when renderer is not an
133 135
 	 * instance of IScaffoldEditRenderer.
134 136
 	 */
@@ -260,6 +262,7 @@  discard block
 block discarded – undo
260 262
 	/**
261 263
 	 * Create the default scaffold editor control factory.
262 264
 	 * @param TActiveRecord record instance.
265
+	 * @param TActiveRecord $record
263 266
 	 * @return TScaffoldInputBase scaffold editor control factory.
264 267
 	 */
265 268
 	protected function getScaffoldInputBuilder($record)
@@ -300,6 +303,7 @@  discard block
 block discarded – undo
300 303
 	/**
301 304
 	 * This method should update the record with the user input data.
302 305
 	 * @param TActiveRecord record to be saved.
306
+	 * @param TActiveRecord $record
303 307
 	 */
304 308
 	public function updateRecord($record);
305 309
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@  discard block
 block discarded – undo
115 115
 			$columns = $this->getTableInfo()->getColumns();
116 116
 			$this->getInputRepeater()->setDataSource($columns);
117 117
 			$this->getInputRepeater()->dataBind();
118
-		}
119
-		else
118
+		} else
120 119
 		{
121 120
 			if($this->_editRenderer===null)
122 121
 				$this->createEditRenderer($record, $classPath);
@@ -140,8 +139,7 @@  discard block
 block discarded – undo
140 139
 			$index = $this->getControls()->remove($this->getInputRepeater());
141 140
 			$this->getControls()->insertAt($index,$this->_editRenderer);
142 141
 			$this->_editRenderer->setData($record);
143
-		}
144
-		else
142
+		} else
145 143
 		{
146 144
 			throw new TConfigurationException(
147 145
 				'scaffold_invalid_edit_renderer', $this->getID(), get_class($record));
@@ -204,15 +202,13 @@  discard block
 block discarded – undo
204 202
 					$column = $table->getColumn($item->getCustomData());
205 203
 					$builder->loadScaffoldInput($this, $item, $column, $record);
206 204
 				}
207
-			}
208
-			else
205
+			} else
209 206
 			{
210 207
 				$this->_editRenderer->updateRecord($record);
211 208
 			}
212 209
 			$record->save();
213 210
 			return true;
214
-		}
215
-		else if($this->_editRenderer!==null)
211
+		} else if($this->_editRenderer!==null)
216 212
 		{
217 213
 			//preserve the form data.
218 214
 			$this->_editRenderer->updateRecord($this->getCurrentRecord());
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function setRecordPk($value)
84 84
 	{
85 85
 		$this->clearRecordObject();
86
-		$val = TPropertyValue::ensureArray($value);
86
+		$val=TPropertyValue::ensureArray($value);
87 87
 		$this->setViewState('PK', count($val) > 0 ? $val : null);
88 88
 	}
89 89
 
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function initializeEditForm()
110 110
 	{
111
-		$record = $this->getCurrentRecord();
112
-		$classPath = $this->getEditRenderer();
113
-		if($classPath === '')
111
+		$record=$this->getCurrentRecord();
112
+		$classPath=$this->getEditRenderer();
113
+		if($classPath==='')
114 114
 		{
115
-			$columns = $this->getTableInfo()->getColumns();
115
+			$columns=$this->getTableInfo()->getColumns();
116 116
 			$this->getInputRepeater()->setDataSource($columns);
117 117
 			$this->getInputRepeater()->dataBind();
118 118
 		}
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	protected function createEditRenderer($record, $classPath)
136 136
 	{
137
-		$this->_editRenderer = Prado::createComponent($classPath);
137
+		$this->_editRenderer=Prado::createComponent($classPath);
138 138
 		if($this->_editRenderer instanceof IScaffoldEditRenderer)
139 139
 		{
140
-			$index = $this->getControls()->remove($this->getInputRepeater());
141
-			$this->getControls()->insertAt($index,$this->_editRenderer);
140
+			$index=$this->getControls()->remove($this->getInputRepeater());
141
+			$this->getControls()->insertAt($index, $this->_editRenderer);
142 142
 			$this->_editRenderer->setData($record);
143 143
 		}
144 144
 		else
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	protected function createRepeaterEditItem($sender, $param)
155 155
 	{
156
-		$type = $param->getItem()->getItemType();
156
+		$type=$param->getItem()->getItemType();
157 157
 		if($type==TListItemType::Item || $type==TListItemType::AlternatingItem)
158 158
 		{
159
-			$item = $param->getItem();
160
-			$column = $item->getDataItem();
159
+			$item=$param->getItem();
160
+			$column=$item->getDataItem();
161 161
 			if($column===null)
162 162
 				return;
163 163
 
164
-			$record = $this->getCurrentRecord();
165
-			$builder = $this->getScaffoldInputBuilder($record);
164
+			$record=$this->getCurrentRecord();
165
+			$builder=$this->getScaffoldInputBuilder($record);
166 166
 			$builder->createScaffoldInput($this, $item, $column, $record);
167 167
 		}
168 168
 	}
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 	{
195 195
 		if($this->getPage()->getIsValid())
196 196
 		{
197
-			$record = $this->getCurrentRecord();
197
+			$record=$this->getCurrentRecord();
198 198
 			if($this->_editRenderer===null)
199 199
 			{
200
-				$table = $this->getTableInfo();
201
-				$builder = $this->getScaffoldInputBuilder($record);
200
+				$table=$this->getTableInfo();
201
+				$builder=$this->getScaffoldInputBuilder($record);
202 202
 				foreach($this->getInputRepeater()->getItems() as $item)
203 203
 				{
204
-					$column = $table->getColumn($item->getCustomData());
204
+					$column=$table->getColumn($item->getCustomData());
205 205
 					$builder->loadScaffoldInput($this, $item, $column, $record);
206 206
 				}
207 207
 			}
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 	protected function getScaffoldInputBuilder($record)
266 266
 	{
267 267
 		static $_builders=array();
268
-		$class = get_class($record);
268
+		$class=get_class($record);
269 269
 		if(!isset($_builders[$class]))
270 270
 		{
271 271
 			Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputBase');
272
-			$_builders[$class] = TScaffoldInputBase::createInputBuilder($record);
272
+			$_builders[$class]=TScaffoldInputBase::createInputBuilder($record);
273 273
 		}
274 274
 		return $_builders[$class];
275 275
 	}
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -121,6 +121,7 @@
 block discarded – undo
121 121
 
122 122
 	/**
123 123
 	 * @param string search condition, the SQL string after the WHERE clause.
124
+	 * @param string|null $value
124 125
 	 */
125 126
 	public function setSearchCondition($value)
126 127
 	{
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	protected function initializeSort()
55 55
 	{
56
-		$table = $this->getTableInfo();
57
-		$sorts = array('Sort By', str_repeat('-',15));
58
-		$headers = array();
56
+		$table=$this->getTableInfo();
57
+		$sorts=array('Sort By', str_repeat('-', 15));
58
+		$headers=array();
59 59
 		foreach($table->getColumns() as $name=>$colum)
60 60
 		{
61
-			$fname = ucwords(str_replace('_', ' ', $name));
62
-			$sorts[$name.' ASC'] = $fname .' Ascending';
63
-			$sorts[$name.' DESC'] = $fname .' Descending';
64
-			$headers[] = $fname ;
61
+			$fname=ucwords(str_replace('_', ' ', $name));
62
+			$sorts[$name.' ASC']=$fname.' Ascending';
63
+			$sorts[$name.' DESC']=$fname.' Descending';
64
+			$headers[]=$fname;
65 65
 		}
66 66
 		$this->_sort->setDataSource($sorts);
67 67
 		$this->_sort->dataBind();
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	protected function loadRecordData()
90 90
 	{
91
-		$search = new TActiveRecordCriteria($this->getSearchCondition(), $this->getSearchParameters());
91
+		$search=new TActiveRecordCriteria($this->getSearchCondition(), $this->getSearchParameters());
92 92
 		$this->_list->setVirtualItemCount($this->getRecordFinder()->count($search));
93
-		$finder = $this->getRecordFinder();
94
-		$criteria = $this->getRecordCriteria();
93
+		$finder=$this->getRecordFinder();
94
+		$criteria=$this->getRecordCriteria();
95 95
 		$this->_list->setDataSource($finder->findAll($criteria));
96 96
 		$this->_list->dataBind();
97 97
 	}
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	protected function getRecordCriteria()
103 103
 	{
104
-		$total = $this->_list->getVirtualItemCount();
105
-		$limit = $this->_list->getPageSize();
106
-		$offset = $this->_list->getCurrentPageIndex()*$limit;
104
+		$total=$this->_list->getVirtualItemCount();
105
+		$limit=$this->_list->getPageSize();
106
+		$offset=$this->_list->getCurrentPageIndex() * $limit;
107 107
 		if($offset + $limit > $total)
108
-			$limit = $total - $offset;
109
-		$criteria = new TActiveRecordCriteria($this->getSearchCondition(), $this->getSearchParameters());
108
+			$limit=$total - $offset;
109
+		$criteria=new TActiveRecordCriteria($this->getSearchCondition(), $this->getSearchParameters());
110 110
 		if($limit > 0)
111 111
 		{
112 112
 			$criteria->setLimit($limit);
113 113
 			if($offset <= $total)
114 114
 				$criteria->setOffset($offset);
115 115
 		}
116
-		$order = explode(' ',$this->_sort->getSelectedValue(), 2);
117
-		if(is_array($order) && count($order) === 2)
118
-			$criteria->OrdersBy[$order[0]] = $order[1];
116
+		$order=explode(' ', $this->_sort->getSelectedValue(), 2);
117
+		if(is_array($order) && count($order)===2)
118
+			$criteria->OrdersBy[$order[0]]=$order[1];
119 119
 		return $criteria;
120 120
 	}
121 121
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function setSearchParameters($value)
142 142
 	{
143
-		$this->setViewState('SearchParameters', TPropertyValue::ensureArray($value),array());
143
+		$this->setViewState('SearchParameters', TPropertyValue::ensureArray($value), array());
144 144
 	}
145 145
 
146 146
 	/**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		{
177 177
 			if($param instanceof TRepeaterCommandEventParameter)
178 178
 			{
179
-				$pk = $param->getItem()->getCustomData();
179
+				$pk=$param->getItem()->getCustomData();
180 180
 				$ctrl->setRecordPk($pk);
181 181
 				$ctrl->initializeEditForm();
182 182
 			}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	{
191 191
 		if($param instanceof TRepeaterCommandEventParameter)
192 192
 		{
193
-			$pk = $param->getItem()->getCustomData();
193
+			$pk=$param->getItem()->getCustomData();
194 194
 			$this->getRecordFinder()->deleteByPk($pk);
195 195
 		}
196 196
 	}
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	protected function listItemCreated($sender, $param)
202 202
 	{
203
-		$item = $param->getItem();
203
+		$item=$param->getItem();
204 204
 		if($item instanceof IItemDataRenderer)
205 205
 		{
206
-			$type = $item->getItemType();
206
+			$type=$item->getItemType();
207 207
 			if($type==TListItemType::Item || $type==TListItemType::AlternatingItem)
208 208
 				$this->populateField($sender, $param);
209 209
 		}
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	protected function populateField($sender, $param)
217 217
 	{
218
-		$item = $param->getItem();
219
-		if(($data = $item->getData()) !== null)
218
+		$item=$param->getItem();
219
+		if(($data=$item->getData())!==null)
220 220
 		{
221 221
 			$item->setCustomData($this->getRecordPkValues($data));
222
-			if(($prop = $item->findControl('_properties'))!==null)
222
+			if(($prop=$item->findControl('_properties'))!==null)
223 223
 			{
224 224
 				$item->_properties->setDataSource($this->getRecordPropertyValues($data));
225 225
 				$item->_properties->dataBind();
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	{
295 295
 		if(($id=$this->getEditViewID())!==null)
296 296
 		{
297
-			$ctrl = $this->getParent()->findControl($id);
297
+			$ctrl=$this->getParent()->findControl($id);
298 298
 			if($ctrl===null)
299 299
 				throw new TConfigurationException('scaffold_unable_to_find_edit_view', $id);
300 300
 			return $ctrl;
Please login to merge, or discard this patch.