@@ -48,7 +48,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function collectForeignObjects(&$results) |
77 | 77 | { |
78 | - $fkeys = $this->getRelationForeignKeys(); |
|
78 | + $fkeys=$this->getRelationForeignKeys(); |
|
79 | 79 | |
80 | - $properties = array_values($fkeys); |
|
81 | - $fields = array_keys($fkeys); |
|
80 | + $properties=array_values($fkeys); |
|
81 | + $fields=array_keys($fkeys); |
|
82 | 82 | |
83 | - $indexValues = $this->getIndexValues($properties, $results); |
|
84 | - $fkObjects = $this->findForeignObjects($fields,$indexValues); |
|
85 | - $this->populateResult($results,$properties,$fkObjects,$fields); |
|
83 | + $indexValues=$this->getIndexValues($properties, $results); |
|
84 | + $fkObjects=$this->findForeignObjects($fields, $indexValues); |
|
85 | + $this->populateResult($results, $properties, $fkObjects, $fields); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function getRelationForeignKeys() |
93 | 93 | { |
94 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
94 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
95 | 95 | return $this->findForeignKeys($fkObject, $this->getSourceRecord()); |
96 | 96 | } |
97 | 97 | |
@@ -101,18 +101,18 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function updateAssociatedRecords() |
103 | 103 | { |
104 | - $obj = $this->getContext()->getSourceRecord(); |
|
105 | - $fkObjects = &$obj->{$this->getContext()->getProperty()}; |
|
104 | + $obj=$this->getContext()->getSourceRecord(); |
|
105 | + $fkObjects=&$obj->{$this->getContext()->getProperty()}; |
|
106 | 106 | $success=true; |
107 | - if(($total = count($fkObjects))> 0) |
|
107 | + if(($total=count($fkObjects)) > 0) |
|
108 | 108 | { |
109 | - $source = $this->getSourceRecord(); |
|
110 | - $fkeys = $this->findForeignKeys($fkObjects[0], $source); |
|
111 | - for($i=0;$i<$total;$i++) |
|
109 | + $source=$this->getSourceRecord(); |
|
110 | + $fkeys=$this->findForeignKeys($fkObjects[0], $source); |
|
111 | + for($i=0; $i < $total; $i++) |
|
112 | 112 | { |
113 | 113 | foreach($fkeys as $fKey => $srcKey) |
114 | 114 | $fkObjects[$i]->setColumnValue($fKey, $source->getColumnValue($srcKey)); |
115 | - $success = $fkObjects[$i]->save() && $success; |
|
115 | + $success=$fkObjects[$i]->save() && $success; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | return $success; |
@@ -96,10 +96,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function collectForeignObjects(&$results) |
94 | 94 | { |
95 | - $fkeys = $this->getRelationForeignKeys(); |
|
96 | - $properties = array_values($fkeys); |
|
97 | - $fields = array_keys($fkeys); |
|
95 | + $fkeys=$this->getRelationForeignKeys(); |
|
96 | + $properties=array_values($fkeys); |
|
97 | + $fields=array_keys($fkeys); |
|
98 | 98 | |
99 | - $indexValues = $this->getIndexValues($properties, $results); |
|
100 | - $fkObjects = $this->findForeignObjects($fields,$indexValues); |
|
101 | - $this->populateResult($results,$properties,$fkObjects,$fields); |
|
99 | + $indexValues=$this->getIndexValues($properties, $results); |
|
100 | + $fkObjects=$this->findForeignObjects($fields, $indexValues); |
|
101 | + $this->populateResult($results, $properties, $fkObjects, $fields); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getRelationForeignKeys() |
109 | 109 | { |
110 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
110 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
111 | 111 | return $this->findForeignKeys($fkObject, $this->getSourceRecord()); |
112 | 112 | } |
113 | 113 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function setObjectProperty($source, $properties, &$collections) |
120 | 120 | { |
121 | - $hash = $this->getObjectHash($source, $properties); |
|
122 | - $prop = $this->getContext()->getProperty(); |
|
121 | + $hash=$this->getObjectHash($source, $properties); |
|
122 | + $prop=$this->getContext()->getProperty(); |
|
123 | 123 | if(isset($collections[$hash]) && count($collections[$hash]) > 0) |
124 | 124 | { |
125 | 125 | if(count($collections[$hash]) > 1) |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function updateAssociatedRecords() |
136 | 136 | { |
137 | - $fkObject = $this->getContext()->getPropertyValue(); |
|
138 | - $source = $this->getSourceRecord(); |
|
139 | - $fkeys = $this->findForeignKeys($fkObject, $source); |
|
137 | + $fkObject=$this->getContext()->getPropertyValue(); |
|
138 | + $source=$this->getSourceRecord(); |
|
139 | + $fkeys=$this->findForeignKeys($fkObject, $source); |
|
140 | 140 | foreach($fkeys as $fKey => $srcKey) |
141 | 141 | $fkObject->setColumnValue($fKey, $source->getColumnValue($srcKey)); |
142 | 142 | return $fkObject->save(); |
@@ -40,8 +40,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -53,15 +53,15 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -90,7 +90,7 @@ |
||
90 | 90 | * Handle the "edit" and "new" commands by displaying the edit view. |
91 | 91 | * Default command shows the list view. |
92 | 92 | */ |
93 | - public function bubbleEvent($sender,$param) |
|
93 | + public function bubbleEvent($sender, $param) |
|
94 | 94 | { |
95 | 95 | switch(strtolower($param->getCommandName())) |
96 | 96 | { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | case 'char': case 'varchar': |
30 | 30 | return $this->createMultiLineControl($container, $column, $record); |
31 | 31 | default: |
32 | - return $this->createDefaultControl($container,$column, $record); |
|
32 | + return $this->createDefaultControl($container, $column, $record); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | case 'timestamp': |
45 | 45 | return $this->getDateTimeValue($container, $column, $record); |
46 | 46 | default: |
47 | - return $this->getDefaultControlValue($container,$column, $record); |
|
47 | + return $this->getDefaultControlValue($container, $column, $record); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | case 'datetime': case 'smalldatetime': |
27 | 27 | return $this->createDateTimeControl($container, $column, $record); |
28 | 28 | default: |
29 | - $control = $this->createDefaultControl($container,$column, $record); |
|
29 | + $control=$this->createDefaultControl($container, $column, $record); |
|
30 | 30 | if($column->getIsExcluded()) |
31 | 31 | $control->setEnabled(false); |
32 | 32 | return $control; |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | case 'boolean': |
41 | 41 | return $container->findControl(self::DEFAULT_ID)->getChecked(); |
42 | 42 | case 'datetime': case 'smalldatetime': |
43 | - return $this->getDateTimeValue($container,$column, $record); |
|
43 | + return $this->getDateTimeValue($container, $column, $record); |
|
44 | 44 | default: |
45 | - $value = $this->getDefaultControlValue($container,$column, $record); |
|
45 | + $value=$this->getDefaultControlValue($container, $column, $record); |
|
46 | 46 | if(trim($value)==='' && $column->getAllowNull()) |
47 | 47 | return null; |
48 | 48 | else |