| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: |
|
| 9: |
|
| 10: |
|
| 11: | class ForLoop extends \Sphp\tools\Component {
|
| 12: |
|
| 13: | private $counterMin = 0;
|
| 14: | private $counterStep = 1;
|
| 15: | private $counterMax = 0;
|
| 16: | private $childrenroot = null;
|
| 17: | public $counter = 0;
|
| 18: |
|
| 19: | protected function onaftercreate() {
|
| 20: |
|
| 21: | $this->childrenroot = $this->frontobj->getChildrenWrapper($this);
|
| 22: | }
|
| 23: |
|
| 24: | public function fu_setLoopFrom($val) {
|
| 25: | $this->counterMin = $val;
|
| 26: | }
|
| 27: |
|
| 28: | public function fu_setLoopTo($val) {
|
| 29: | $this->counterMax = $val;
|
| 30: | }
|
| 31: |
|
| 32: | public function fu_setStep($val) {
|
| 33: | $this->counterStep = $val;
|
| 34: | }
|
| 35: |
|
| 36: | private function genrender() {
|
| 37: | $stro = '';
|
| 38: | for($this->counter = $this->counterMin; $this->counter < $this->counterMax; $this->counter += $this->counterStep){
|
| 39: | $stro .= $this->frontobj->parseComponentChildren($this->childrenroot);
|
| 40: | }
|
| 41: | return $stro;
|
| 42: | }
|
| 43: |
|
| 44: | protected function onprerender() {
|
| 45: |
|
| 46: | $this->innerHTML = "";
|
| 47: | }
|
| 48: | protected function onrender() {
|
| 49: | $this->innerHTML = $this->genrender();
|
| 50: | }
|
| 51: |
|
| 52: | }
|
| 53: |
|
| 54: |
|
| 55: | |