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