@@ -28,6 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * Constructor. |
30 | 30 | * @param integer old page index |
31 | + * @param integer $oldPage |
|
31 | 32 | */ |
32 | 33 | public function __construct($oldPage) |
33 | 34 | { |
@@ -143,6 +143,7 @@ discard block |
||
143 | 143 | /** |
144 | 144 | * This must be called internally or when instantiated. |
145 | 145 | * @param numeric sets the default priority of inserted items without a specified priority |
146 | + * @param integer $value |
|
146 | 147 | */ |
147 | 148 | protected function setDefaultPriority($value) |
148 | 149 | { |
@@ -160,6 +161,7 @@ discard block |
||
160 | 161 | /** |
161 | 162 | * This must be called internally or when instantiated. |
162 | 163 | * @param integer The precision of numeric priorities. |
164 | + * @param integer $value |
|
163 | 165 | */ |
164 | 166 | protected function setPrecision($value) |
165 | 167 | { |
@@ -169,7 +171,7 @@ discard block |
||
169 | 171 | /** |
170 | 172 | * Returns an iterator for traversing the items in the list. |
171 | 173 | * This method is required by the interface \IteratorAggregate. |
172 | - * @return Iterator an iterator for traversing the items in the list. |
|
174 | + * @return \ArrayIterator an iterator for traversing the items in the list. |
|
173 | 175 | */ |
174 | 176 | public function getIterator() |
175 | 177 | { |
@@ -596,6 +598,7 @@ discard block |
||
596 | 598 | * Combines the map elements which have a priority below the parameter value |
597 | 599 | * @param numeric the cut-off priority. All items of priority less than this are returned. |
598 | 600 | * @param boolean whether or not the input cut-off priority is inclusive. Default: false, not inclusive. |
601 | + * @param integer $priority |
|
599 | 602 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
600 | 603 | * The priorities are sorted so important priorities, lower numerics, are first. |
601 | 604 | */ |
@@ -616,6 +619,7 @@ discard block |
||
616 | 619 | * Combines the map elements which have a priority above the parameter value |
617 | 620 | * @param numeric the cut-off priority. All items of priority greater than this are returned. |
618 | 621 | * @param boolean whether or not the input cut-off priority is inclusive. Default: true, inclusive. |
622 | + * @param integer $priority |
|
619 | 623 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
620 | 624 | * The priorities are sorted so important priorities, lower numerics, are first. |
621 | 625 | */ |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | if($priority===null) |
128 | 128 | $priority=$this->getDefaultPriority(); |
129 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
129 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
130 | 130 | |
131 | 131 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
132 | 132 | return false; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function setDefaultPriority($value) |
149 | 149 | { |
150 | - $this->_dp=(string)round(TPropertyValue::ensureFloat($value), $this->_p); |
|
150 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function itemAt($index) |
225 | 225 | { |
226 | - if($index>=0&&$index<$this->getCount()) { |
|
226 | + if($index >= 0 && $index < $this->getCount()) { |
|
227 | 227 | $arr=$this->flattenPriorities(); |
228 | 228 | return $arr[$index]; |
229 | 229 | } else |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | { |
240 | 240 | if($priority===null) |
241 | 241 | $priority=$this->getDefaultPriority(); |
242 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
242 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
243 | 243 | |
244 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
244 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | { |
255 | 255 | if($priority===null) |
256 | 256 | $priority=$this->getDefaultPriority(); |
257 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
257 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
258 | 258 | |
259 | - return !isset($this->_d[$priority])?false:( |
|
260 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
259 | + return !isset($this->_d[$priority]) ?false:( |
|
260 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
261 | 261 | ); |
262 | 262 | } |
263 | 263 | |
@@ -313,35 +313,35 @@ discard block |
||
313 | 313 | |
314 | 314 | if($priority===null) |
315 | 315 | $priority=$this->getDefaultPriority(); |
316 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
316 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
317 | 317 | |
318 | 318 | if($preserveCache) { |
319 | 319 | $this->sortPriorities(); |
320 | 320 | $cc=0; |
321 | 321 | foreach($this->_d as $prioritykey=>$items) |
322 | - if($prioritykey>=$priority) |
|
322 | + if($prioritykey >= $priority) |
|
323 | 323 | break; |
324 | 324 | else |
325 | 325 | $cc+=count($items); |
326 | 326 | |
327 | - if($index===false&&isset($this->_d[$priority])) { |
|
327 | + if($index===false && isset($this->_d[$priority])) { |
|
328 | 328 | $c=count($this->_d[$priority]); |
329 | 329 | $c+=$cc; |
330 | 330 | $this->_d[$priority][]=$item; |
331 | 331 | } elseif(isset($this->_d[$priority])) { |
332 | - $c=$index+$cc; |
|
332 | + $c=$index + $cc; |
|
333 | 333 | array_splice($this->_d[$priority], $index, 0, [$item]); |
334 | 334 | } else { |
335 | - $c = $cc; |
|
336 | - $this->_o = false; |
|
335 | + $c=$cc; |
|
336 | + $this->_o=false; |
|
337 | 337 | $this->_d[$priority]=[$item]; |
338 | 338 | } |
339 | 339 | |
340 | - if($this->_fd&&is_array($this->_fd)) // if there is a flattened array cache |
|
340 | + if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache |
|
341 | 341 | array_splice($this->_fd, $c, 0, [$item]); |
342 | 342 | } else { |
343 | 343 | $c=null; |
344 | - if($index===false&&isset($this->_d[$priority])) { |
|
344 | + if($index===false && isset($this->_d[$priority])) { |
|
345 | 345 | $cc=count($this->_d[$priority]); |
346 | 346 | $this->_d[$priority][]=$item; |
347 | 347 | } elseif(isset($this->_d[$priority])) { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $this->_o=false; |
353 | 353 | $this->_d[$priority]=[$item]; |
354 | 354 | } |
355 | - if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) |
|
355 | + if($this->_fd && is_array($this->_fd) && count($this->_d)==1) |
|
356 | 356 | array_splice($this->_fd, $cc, 0, [$item]); |
357 | 357 | else |
358 | 358 | $this->_fd=null; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | if($priority!==false) { |
385 | 385 | if($priority===null) |
386 | 386 | $priority=$this->getDefaultPriority(); |
387 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
387 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
388 | 388 | |
389 | 389 | if($p[0]!=$priority) |
390 | 390 | throw new TInvalidDataValueException('list_item_inexistent'); |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | |
429 | 429 | if($priority===null) |
430 | 430 | $priority=$this->getDefaultPriority(); |
431 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
431 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
432 | 432 | |
433 | - if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) |
|
433 | + if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
|
434 | 434 | throw new TInvalidDataValueException('list_item_inexistent'); |
435 | 435 | |
436 | 436 | // $value is an array of elements removed, only one |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
455 | 455 | |
456 | 456 | foreach($this->_d as $priority=>$items) { |
457 | - for($index=count($items)-1;$index>=0;$index--) |
|
457 | + for($index=count($items) - 1; $index >= 0; $index--) |
|
458 | 458 | $this->removeAtIndexInPriority($index, $priority); |
459 | 459 | unset($this->_d[$priority]); |
460 | 460 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | public function contains($item) |
468 | 468 | { |
469 | - return $this->indexOf($item)>=0; |
|
469 | + return $this->indexOf($item) >= 0; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -490,16 +490,16 @@ discard block |
||
490 | 490 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
491 | 491 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
492 | 492 | */ |
493 | - public function priorityOf($item, $withindex = false) |
|
493 | + public function priorityOf($item, $withindex=false) |
|
494 | 494 | { |
495 | 495 | $this->sortPriorities(); |
496 | 496 | |
497 | - $absindex = 0; |
|
497 | + $absindex=0; |
|
498 | 498 | foreach($this->_d as $priority=>$items) { |
499 | 499 | if(($index=array_search($item, $items, true))!==false) { |
500 | 500 | $absindex+=$index; |
501 | - return $withindex?[$priority,$index,$absindex, |
|
502 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex]:$priority; |
|
501 | + return $withindex ? [$priority, $index, $absindex, |
|
502 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex] : $priority; |
|
503 | 503 | } else |
504 | 504 | $absindex+=count($items); |
505 | 505 | } |
@@ -516,19 +516,19 @@ discard block |
||
516 | 516 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
517 | 517 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
518 | 518 | */ |
519 | - public function priorityAt($index, $withindex = false) |
|
519 | + public function priorityAt($index, $withindex=false) |
|
520 | 520 | { |
521 | - if($index<0||$index>=$this->getCount()) |
|
521 | + if($index < 0 || $index >= $this->getCount()) |
|
522 | 522 | throw new TInvalidDataValueException('list_index_invalid', $index); |
523 | 523 | |
524 | 524 | $absindex=$index; |
525 | 525 | $this->sortPriorities(); |
526 | 526 | foreach($this->_d as $priority=>$items) { |
527 | - if($index>=($c=count($items))) |
|
527 | + if($index >= ($c=count($items))) |
|
528 | 528 | $index-=$c; |
529 | 529 | else |
530 | - return $withindex?[$priority,$index,$absindex, |
|
531 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex]:$priority; |
|
530 | + return $withindex ? [$priority, $index, $absindex, |
|
531 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex] : $priority; |
|
532 | 532 | } |
533 | 533 | return false; |
534 | 534 | } |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | if(($priority=$this->priorityOf($indexitem, true))===false) |
571 | 571 | throw new TInvalidDataValueException('list_item_inexistent'); |
572 | 572 | |
573 | - $this->insertAtIndexInPriority($item, $priority[1]+1, $priority[0]); |
|
573 | + $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
|
574 | 574 | |
575 | - return $priority[2]+1; |
|
575 | + return $priority[2] + 1; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $items=[]; |
606 | 606 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
607 | 607 | { |
608 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
608 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
609 | 609 | break; |
610 | 610 | $items=array_merge($items, $itemsatpriority); |
611 | 611 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | $items=[]; |
626 | 626 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
627 | 627 | { |
628 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
628 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
629 | 629 | continue; |
630 | 630 | $items=array_merge($items, $itemsatpriority); |
631 | 631 | } |
@@ -643,15 +643,15 @@ discard block |
||
643 | 643 | { |
644 | 644 | if($data instanceof TPriorityList) |
645 | 645 | { |
646 | - if($this->getCount()>0) |
|
646 | + if($this->getCount() > 0) |
|
647 | 647 | $this->clear(); |
648 | 648 | foreach($data->getPriorities() as $priority) |
649 | 649 | { |
650 | 650 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
651 | 651 | $this->insertAtIndexInPriority($item, $index, $priority); |
652 | 652 | } |
653 | - } elseif(is_array($data)||$data instanceof \Traversable) { |
|
654 | - if($this->getCount()>0) |
|
653 | + } elseif(is_array($data) || $data instanceof \Traversable) { |
|
654 | + if($this->getCount() > 0) |
|
655 | 655 | $this->clear(); |
656 | 656 | foreach($data as $key=>$item) |
657 | 657 | $this->add($item); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $this->insertAtIndexInPriority($item, false, $priority); |
678 | 678 | } |
679 | 679 | } |
680 | - elseif(is_array($data)||$data instanceof \Traversable) |
|
680 | + elseif(is_array($data) || $data instanceof \Traversable) |
|
681 | 681 | { |
682 | 682 | foreach($data as $priority=>$item) |
683 | 683 | $this->add($item); |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | */ |
696 | 696 | public function offsetExists($offset) |
697 | 697 | { |
698 | - return ($offset>=0&&$offset<$this->getCount()); |
|
698 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | if($offset===null) |
727 | 727 | return $this->add($item); |
728 | 728 | if($offset===$this->getCount()) { |
729 | - $priority=$this->priorityAt($offset-1, true); |
|
729 | + $priority=$this->priorityAt($offset - 1, true); |
|
730 | 730 | $priority[1]++; |
731 | 731 | } else { |
732 | 732 | $priority=$this->priorityAt($offset, true); |
@@ -391,8 +391,7 @@ discard block |
||
391 | 391 | } |
392 | 392 | $this->removeAtIndexInPriority($p[1], $p[0]); |
393 | 393 | return $p[2]; |
394 | - } |
|
395 | - else |
|
394 | + } else |
|
396 | 395 | throw new TInvalidDataValueException('list_item_inexistent'); |
397 | 396 | } |
398 | 397 | |
@@ -676,14 +675,12 @@ discard block |
||
676 | 675 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
677 | 676 | $this->insertAtIndexInPriority($item, false, $priority); |
678 | 677 | } |
679 | - } |
|
680 | - elseif(is_array($data)||$data instanceof \Traversable) |
|
678 | + } elseif(is_array($data)||$data instanceof \Traversable) |
|
681 | 679 | { |
682 | 680 | foreach($data as $priority=>$item) |
683 | 681 | $this->add($item); |
684 | 682 | |
685 | - } |
|
686 | - elseif($data!==null) |
|
683 | + } elseif($data!==null) |
|
687 | 684 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
688 | 685 | } |
689 | 686 |
@@ -149,7 +149,7 @@ |
||
149 | 149 | /** |
150 | 150 | * Returns an iterator for traversing the items in the queue. |
151 | 151 | * This method is required by the interface \IteratorAggregate. |
152 | - * @return Iterator an iterator for traversing the items in the queue. |
|
152 | + * @return \ArrayIterator an iterator for traversing the items in the queue. |
|
153 | 153 | */ |
154 | 154 | public function getIterator() |
155 | 155 | { |
@@ -144,7 +144,7 @@ |
||
144 | 144 | public function enqueue($item) |
145 | 145 | { |
146 | 146 | ++$this->_c; |
147 | - $this->_d[] = $item; |
|
147 | + $this->_d[]=$item; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -84,8 +84,7 @@ |
||
84 | 84 | $this->_d[]=$item; |
85 | 85 | ++$this->_c; |
86 | 86 | } |
87 | - } |
|
88 | - elseif($data!==null) |
|
87 | + } elseif($data!==null) |
|
89 | 88 | throw new TInvalidDataTypeException('queue_data_not_iterable'); |
90 | 89 | } |
91 | 90 |
@@ -148,7 +148,7 @@ |
||
148 | 148 | /** |
149 | 149 | * Returns an iterator for traversing the items in the stack. |
150 | 150 | * This method is required by the interface \IteratorAggregate. |
151 | - * @return Iterator an iterator for traversing the items in the stack. |
|
151 | + * @return \ArrayIterator an iterator for traversing the items in the stack. |
|
152 | 152 | */ |
153 | 153 | public function getIterator() |
154 | 154 | { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if($this->_c===0) |
118 | 118 | throw new TInvalidOperationException('stack_empty'); |
119 | 119 | else |
120 | - return $this->_d[$this->_c-1]; |
|
120 | + return $this->_d[$this->_c - 1]; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function push($item) |
144 | 144 | { |
145 | 145 | ++$this->_c; |
146 | - $this->_d[] = $item; |
|
146 | + $this->_d[]=$item; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -83,8 +83,7 @@ |
||
83 | 83 | $this->_d[]=$item; |
84 | 84 | ++$this->_c; |
85 | 85 | } |
86 | - } |
|
87 | - elseif($data!==null) |
|
86 | + } elseif($data!==null) |
|
88 | 87 | throw new TInvalidDataTypeException('stack_data_not_iterable'); |
89 | 88 | } |
90 | 89 |
@@ -35,6 +35,9 @@ discard block |
||
35 | 35 | private $_relation; //data from an entry of TActiveRecord::$RELATION |
36 | 36 | private $_fkeys; |
37 | 37 | |
38 | + /** |
|
39 | + * @param TActiveRecord $record |
|
40 | + */ |
|
38 | 41 | public function __construct($record, $property=null, $relation=null) |
39 | 42 | { |
40 | 43 | $this->_record=$record; |
@@ -168,6 +171,7 @@ discard block |
||
168 | 171 | * An instance of TActiveRecordHasOne, TActiveRecordBelongsTo, TActiveRecordHasMany, |
169 | 172 | * or TActiveRecordHasManyAssocation will be returned. |
170 | 173 | * @param TActiveRecordCriteria search criteria |
174 | + * @param \Prado\Data\DataGateway\TSqlCriteria $criteria |
|
171 | 175 | * @return TActiveRecordRelation record relationship handler instnace. |
172 | 176 | * @throws TActiveRecordException if property is not defined or missing. |
173 | 177 | */ |
@@ -196,7 +200,7 @@ discard block |
||
196 | 200 | } |
197 | 201 | |
198 | 202 | /** |
199 | - * @return TActiveRecordRelationCommand |
|
203 | + * @return boolean |
|
200 | 204 | */ |
201 | 205 | public function updateAssociatedRecords($updateBelongsTo=false) |
202 | 206 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function getPropertyValue() |
56 | 56 | { |
57 | - $obj = $this->getSourceRecord(); |
|
57 | + $obj=$this->getSourceRecord(); |
|
58 | 58 | return $obj->getColumnValue($this->getProperty()); |
59 | 59 | } |
60 | 60 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getCondition() |
119 | 119 | { |
120 | - return isset($this->_relation[3])?$this->_relation[3]:null; |
|
120 | + return isset($this->_relation[3]) ? $this->_relation[3] : null; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getParameters() |
128 | 128 | { |
129 | - return isset($this->_relation[4])?$this->_relation[4]:[]; |
|
129 | + return isset($this->_relation[4]) ? $this->_relation[4] : []; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function hasFkField() |
137 | 137 | { |
138 | - $notManyToMany = $this->getRelationType() !== TActiveRecord::MANY_TO_MANY; |
|
138 | + $notManyToMany=$this->getRelationType()!==TActiveRecord::MANY_TO_MANY; |
|
139 | 139 | return $notManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]); |
140 | 140 | } |
141 | 141 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function hasAssociationTable() |
154 | 154 | { |
155 | - $isManyToMany = $this->getRelationType() === TActiveRecord::MANY_TO_MANY; |
|
155 | + $isManyToMany=$this->getRelationType()===TActiveRecord::MANY_TO_MANY; |
|
156 | 156 | return $isManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]); |
157 | 157 | } |
158 | 158 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $this->_property, get_class($this->_record), 'RELATIONS'); |
181 | 181 | } |
182 | 182 | if($criteria===null) |
183 | - $criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters()); |
|
183 | + $criteria=new TActiveRecordCriteria($this->getCondition(), $this->getParameters()); |
|
184 | 184 | switch($this->getRelationType()) |
185 | 185 | { |
186 | 186 | case TActiveRecord::HAS_MANY: |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | $success=true; |
205 | 205 | foreach($this->_record->getRecordRelations() as $data) |
206 | 206 | { |
207 | - list($property, $relation) = $data; |
|
208 | - $belongsTo = $relation[0]==TActiveRecord::BELONGS_TO; |
|
207 | + list($property, $relation)=$data; |
|
208 | + $belongsTo=$relation[0]==TActiveRecord::BELONGS_TO; |
|
209 | 209 | if(($updateBelongsTo && $belongsTo) || (!$updateBelongsTo && !$belongsTo)) |
210 | 210 | { |
211 | - $obj = $this->getSourceRecord(); |
|
211 | + $obj=$this->getSourceRecord(); |
|
212 | 212 | if(!$this->isEmptyFkObject($obj->getColumnValue($property))) |
213 | 213 | { |
214 | - $context = new TActiveRecordRelationContext($this->getSourceRecord(), $property, $relation); |
|
215 | - $success = $context->getRelationHandler()->updateAssociatedRecords() && $success; |
|
214 | + $context=new TActiveRecordRelationContext($this->getSourceRecord(), $property, $relation); |
|
215 | + $success=$context->getRelationHandler()->updateAssociatedRecords() && $success; |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | protected function isEmptyFkObject($obj) |
223 | 223 | { |
224 | 224 | if(is_object($obj)) |
225 | - return $obj instanceof TList ? $obj->count() === 0 : false; |
|
225 | + return $obj instanceof TList ? $obj->count()===0 : false; |
|
226 | 226 | elseif(is_array($obj)) |
227 | 227 | return count($obj)===0; |
228 | 228 | else |
@@ -52,6 +52,10 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | + /** |
|
56 | + * @param \Prado\Data\ActiveRecord\Scaffold\TScaffoldEditView $parent |
|
57 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
58 | + */ |
|
55 | 59 | public function createScaffoldInput($parent, $item, $column, $record) |
56 | 60 | { |
57 | 61 | $this->_parent=$parent; |
@@ -68,6 +72,10 @@ discard block |
||
68 | 72 | $label->setForControl(self::DEFAULT_ID); |
69 | 73 | } |
70 | 74 | |
75 | + /** |
|
76 | + * @param \Prado\Data\ActiveRecord\Scaffold\TScaffoldEditView $parent |
|
77 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
78 | + */ |
|
71 | 79 | public function loadScaffoldInput($parent, $item, $column, $record) |
72 | 80 | { |
73 | 81 | $this->_parent=$parent; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | class TScaffoldInputBase |
17 | 17 | { |
18 | - const DEFAULT_ID = 'scaffold_input'; |
|
18 | + const DEFAULT_ID='scaffold_input'; |
|
19 | 19 | private $_parent; |
20 | 20 | |
21 | 21 | protected function getParent() |
@@ -26,25 +26,25 @@ discard block |
||
26 | 26 | public static function createInputBuilder($record) |
27 | 27 | { |
28 | 28 | $record->getDbConnection()->setActive(true); //must be connected before retrieving driver name! |
29 | - $driver = $record->getDbConnection()->getDriverName(); |
|
29 | + $driver=$record->getDbConnection()->getDriverName(); |
|
30 | 30 | switch(strtolower($driver)) |
31 | 31 | { |
32 | 32 | case 'sqlite': //sqlite 3 |
33 | 33 | case 'sqlite2': //sqlite 2 |
34 | - require_once(dirname(__FILE__) . '/TSqliteScaffoldInput.php'); |
|
34 | + require_once(dirname(__FILE__).'/TSqliteScaffoldInput.php'); |
|
35 | 35 | return new TSqliteScaffoldInput($conn); |
36 | 36 | case 'mysqli': |
37 | 37 | case 'mysql': |
38 | - require_once(dirname(__FILE__) . '/TMysqlScaffoldInput.php'); |
|
38 | + require_once(dirname(__FILE__).'/TMysqlScaffoldInput.php'); |
|
39 | 39 | return new TMysqlScaffoldInput($conn); |
40 | 40 | case 'pgsql': |
41 | - require_once(dirname(__FILE__) . '/TPgsqlScaffoldInput.php'); |
|
41 | + require_once(dirname(__FILE__).'/TPgsqlScaffoldInput.php'); |
|
42 | 42 | return new TPgsqlScaffoldInput($conn); |
43 | 43 | case 'mssql': |
44 | - require_once(dirname(__FILE__) . '/TMssqlScaffoldInput.php'); |
|
44 | + require_once(dirname(__FILE__).'/TMssqlScaffoldInput.php'); |
|
45 | 45 | return new TMssqlScaffoldInput($conn); |
46 | 46 | case 'ibm': |
47 | - require_once(dirname(__FILE__) . '/TIbmScaffoldInput.php'); |
|
47 | + require_once(dirname(__FILE__).'/TIbmScaffoldInput.php'); |
|
48 | 48 | return new TIbmScaffoldInput($conn); |
49 | 49 | default: |
50 | 50 | throw new TConfigurationException( |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | protected function createControlLabel($label, $column, $record) |
65 | 65 | { |
66 | - $fieldname = ucwords(str_replace('_', ' ', $column->getColumnId())) . ':'; |
|
66 | + $fieldname=ucwords(str_replace('_', ' ', $column->getColumnId())).':'; |
|
67 | 67 | $label->setText($fieldname); |
68 | 68 | $label->setForControl(self::DEFAULT_ID); |
69 | 69 | } |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | $this->_parent=$parent; |
74 | 74 | if($this->getIsEnabled($column, $record)) |
75 | 75 | { |
76 | - $prop = $column->getColumnId(); |
|
76 | + $prop=$column->getColumnId(); |
|
77 | 77 | $record->setColumnValue($prop, $this->getControlValue($item->_input, $column, $record)); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | protected function getIsEnabled($column, $record) |
82 | 82 | { |
83 | - return !($this->getParent()->getRecordPk() !== null |
|
83 | + return !($this->getParent()->getRecordPk()!==null |
|
84 | 84 | && $column->getIsPrimaryKey() || $column->hasSequence()); |
85 | 85 | } |
86 | 86 | |
87 | 87 | protected function getRecordPropertyValue($column, $record) |
88 | 88 | { |
89 | - $value = $record->getColumnValue($column->getColumnId()); |
|
89 | + $value=$record->getColumnValue($column->getColumnId()); |
|
90 | 90 | if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null) |
91 | 91 | return $column->getDefaultValue(); |
92 | 92 | else |
@@ -28,6 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * This method should update the record with the user input data. |
30 | 30 | * @param TActiveRecord record to be saved. |
31 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
31 | 32 | */ |
32 | 33 | public function updateRecord($record); |
33 | 34 | } |
34 | 35 | \ No newline at end of file |
@@ -91,6 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Name of the Active Record class to be viewed or scaffolded. |
93 | 93 | * @param string Active Record class name. |
94 | + * @param string $value |
|
94 | 95 | */ |
95 | 96 | public function setRecordClass($value) |
96 | 97 | { |
@@ -190,6 +191,7 @@ discard block |
||
190 | 191 | |
191 | 192 | /** |
192 | 193 | * @param boolean enable default stylesheet, default is true. |
194 | + * @param boolean $value |
|
193 | 195 | */ |
194 | 196 | public function setEnableDefaultStyle($value) |
195 | 197 | { |
@@ -132,8 +132,7 @@ |
||
132 | 132 | if($this->_record===null) |
133 | 133 | throw new TConfigurationException('scaffold_invalid_record_pk', |
134 | 134 | $this->getRecordClass(), $pk); |
135 | - } |
|
136 | - else |
|
135 | + } else |
|
137 | 136 | { |
138 | 137 | $class = $this->getRecordClass(); |
139 | 138 | if($class!==null) |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function getTableInfo() |
49 | 49 | { |
50 | - $finder = $this->getRecordFinder(); |
|
51 | - $gateway = $finder->getRecordManager()->getRecordGateWay(); |
|
50 | + $finder=$this->getRecordFinder(); |
|
51 | + $gateway=$finder->getRecordManager()->getRecordGateWay(); |
|
52 | 52 | return $gateway->getRecordTableInfo($finder); |
53 | 53 | } |
54 | 54 | |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function getRecordPropertyValues($record) |
60 | 60 | { |
61 | - $data = []; |
|
61 | + $data=[]; |
|
62 | 62 | foreach($this->getTableInfo()->getColumns() as $name=>$column) |
63 | - $data[] = $record->getColumnValue($name); |
|
63 | + $data[]=$record->getColumnValue($name); |
|
64 | 64 | return $data; |
65 | 65 | } |
66 | 66 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | foreach($this->getTableInfo()->getColumns() as $name=>$column) |
75 | 75 | { |
76 | 76 | if($column->getIsPrimaryKey()) |
77 | - $data[] = $record->getColumnValue($name); |
|
77 | + $data[]=$record->getColumnValue($name); |
|
78 | 78 | } |
79 | 79 | return $data; |
80 | 80 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function copyFrom(TScaffoldBase $obj) |
105 | 105 | { |
106 | - $this->_record = $obj->_record; |
|
106 | + $this->_record=$obj->_record; |
|
107 | 107 | $this->setRecordClass($obj->getRecordClass()); |
108 | 108 | $this->setEnableDefaultStyle($obj->getEnableDefaultStyle()); |
109 | 109 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | else |
137 | 137 | { |
138 | - $class = $this->getRecordClass(); |
|
138 | + $class=$this->getRecordClass(); |
|
139 | 139 | if($class!==null) |
140 | 140 | $this->_record=Prado::createComponent($class); |
141 | 141 | else |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | parent::onPreRender($param); |
205 | 205 | if($this->getEnableDefaultStyle()) |
206 | 206 | { |
207 | - $url = $this->publishAsset($this->getDefaultStyle() . '.css'); |
|
207 | + $url=$this->publishAsset($this->getDefaultStyle().'.css'); |
|
208 | 208 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
209 | 209 | } |
210 | 210 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | - * @return TActiveRecord current Active Record instance |
|
106 | + * @return \Prado\Data\ActiveRecord\TActiveRecord current Active Record instance |
|
107 | 107 | */ |
108 | 108 | protected function getCurrentRecord() |
109 | 109 | { |
@@ -136,6 +136,8 @@ discard block |
||
136 | 136 | * Instantiate the external edit renderer. |
137 | 137 | * @param TActiveRecord record to be edited |
138 | 138 | * @param string external edit renderer class name. |
139 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
140 | + * @param string $classPath |
|
139 | 141 | * @throws TConfigurationException raised when renderer is not an |
140 | 142 | * instance of IScaffoldEditRenderer. |
141 | 143 | */ |
@@ -267,6 +269,7 @@ discard block |
||
267 | 269 | /** |
268 | 270 | * Create the default scaffold editor control factory. |
269 | 271 | * @param TActiveRecord record instance. |
272 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
270 | 273 | * @return TScaffoldInputBase scaffold editor control factory. |
271 | 274 | */ |
272 | 275 | protected function getScaffoldInputBuilder($record) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function setRecordPk($value) |
91 | 91 | { |
92 | 92 | $this->clearRecordObject(); |
93 | - $val = TPropertyValue::ensureArray($value); |
|
93 | + $val=TPropertyValue::ensureArray($value); |
|
94 | 94 | $this->setViewState('PK', count($val) > 0 ? $val : null); |
95 | 95 | } |
96 | 96 | |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function initializeEditForm() |
117 | 117 | { |
118 | - $record = $this->getCurrentRecord(); |
|
119 | - $classPath = $this->getEditRenderer(); |
|
120 | - if($classPath === '') |
|
118 | + $record=$this->getCurrentRecord(); |
|
119 | + $classPath=$this->getEditRenderer(); |
|
120 | + if($classPath==='') |
|
121 | 121 | { |
122 | - $columns = $this->getTableInfo()->getColumns(); |
|
122 | + $columns=$this->getTableInfo()->getColumns(); |
|
123 | 123 | $this->getInputRepeater()->setDataSource($columns); |
124 | 124 | $this->getInputRepeater()->dataBind(); |
125 | 125 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function createEditRenderer($record, $classPath) |
143 | 143 | { |
144 | - $this->_editRenderer = Prado::createComponent($classPath); |
|
144 | + $this->_editRenderer=Prado::createComponent($classPath); |
|
145 | 145 | if($this->_editRenderer instanceof IScaffoldEditRenderer) |
146 | 146 | { |
147 | - $index = $this->getControls()->remove($this->getInputRepeater()); |
|
147 | + $index=$this->getControls()->remove($this->getInputRepeater()); |
|
148 | 148 | $this->getControls()->insertAt($index, $this->_editRenderer); |
149 | 149 | $this->_editRenderer->setData($record); |
150 | 150 | } |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function createRepeaterEditItem($sender, $param) |
162 | 162 | { |
163 | - $type = $param->getItem()->getItemType(); |
|
163 | + $type=$param->getItem()->getItemType(); |
|
164 | 164 | if($type==TListItemType::Item || $type==TListItemType::AlternatingItem) |
165 | 165 | { |
166 | - $item = $param->getItem(); |
|
167 | - $column = $item->getData(); |
|
166 | + $item=$param->getItem(); |
|
167 | + $column=$item->getData(); |
|
168 | 168 | if($column===null) |
169 | 169 | return; |
170 | 170 | |
171 | - $record = $this->getCurrentRecord(); |
|
172 | - $builder = $this->getScaffoldInputBuilder($record); |
|
171 | + $record=$this->getCurrentRecord(); |
|
172 | + $builder=$this->getScaffoldInputBuilder($record); |
|
173 | 173 | $builder->createScaffoldInput($this, $item, $column, $record); |
174 | 174 | } |
175 | 175 | } |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | { |
202 | 202 | if($this->getPage()->getIsValid()) |
203 | 203 | { |
204 | - $record = $this->getCurrentRecord(); |
|
204 | + $record=$this->getCurrentRecord(); |
|
205 | 205 | if($this->_editRenderer===null) |
206 | 206 | { |
207 | - $table = $this->getTableInfo(); |
|
208 | - $builder = $this->getScaffoldInputBuilder($record); |
|
207 | + $table=$this->getTableInfo(); |
|
208 | + $builder=$this->getScaffoldInputBuilder($record); |
|
209 | 209 | foreach($this->getInputRepeater()->getItems() as $item) |
210 | 210 | { |
211 | - $column = $table->getColumn($item->getCustomData()); |
|
211 | + $column=$table->getColumn($item->getCustomData()); |
|
212 | 212 | $builder->loadScaffoldInput($this, $item, $column, $record); |
213 | 213 | } |
214 | 214 | } |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | protected function getScaffoldInputBuilder($record) |
273 | 273 | { |
274 | 274 | static $_builders=[]; |
275 | - $class = get_class($record); |
|
275 | + $class=get_class($record); |
|
276 | 276 | if(!isset($_builders[$class])) |
277 | 277 | { |
278 | - $_builders[$class] = TScaffoldInputBase::createInputBuilder($record); |
|
278 | + $_builders[$class]=TScaffoldInputBase::createInputBuilder($record); |
|
279 | 279 | } |
280 | 280 | return $_builders[$class]; |
281 | 281 | } |
@@ -285,6 +285,6 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function getValidationGroup() |
287 | 287 | { |
288 | - return 'group_' . $this->getUniqueID(); |
|
288 | + return 'group_'.$this->getUniqueID(); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | \ No newline at end of file |
@@ -122,8 +122,7 @@ discard block |
||
122 | 122 | $columns = $this->getTableInfo()->getColumns(); |
123 | 123 | $this->getInputRepeater()->setDataSource($columns); |
124 | 124 | $this->getInputRepeater()->dataBind(); |
125 | - } |
|
126 | - else |
|
125 | + } else |
|
127 | 126 | { |
128 | 127 | if($this->_editRenderer===null) |
129 | 128 | $this->createEditRenderer($record, $classPath); |
@@ -147,8 +146,7 @@ discard block |
||
147 | 146 | $index = $this->getControls()->remove($this->getInputRepeater()); |
148 | 147 | $this->getControls()->insertAt($index, $this->_editRenderer); |
149 | 148 | $this->_editRenderer->setData($record); |
150 | - } |
|
151 | - else |
|
149 | + } else |
|
152 | 150 | { |
153 | 151 | throw new TConfigurationException( |
154 | 152 | 'scaffold_invalid_edit_renderer', $this->getID(), get_class($record)); |
@@ -211,15 +209,13 @@ discard block |
||
211 | 209 | $column = $table->getColumn($item->getCustomData()); |
212 | 210 | $builder->loadScaffoldInput($this, $item, $column, $record); |
213 | 211 | } |
214 | - } |
|
215 | - else |
|
212 | + } else |
|
216 | 213 | { |
217 | 214 | $this->_editRenderer->updateRecord($record); |
218 | 215 | } |
219 | 216 | $record->save(); |
220 | 217 | return true; |
221 | - } |
|
222 | - elseif($this->_editRenderer!==null) |
|
218 | + } elseif($this->_editRenderer!==null) |
|
223 | 219 | { |
224 | 220 | //preserve the form data. |
225 | 221 | $this->_editRenderer->updateRecord($this->getCurrentRecord()); |