|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
-
- namespace Modules;
-
- class CMultiple {
-
- public $elements=array();
- public $first_element="";
- public $last_element="";
- public $ids=array();
-
- function __construct($elements,$IDs=false) {
- $this->elements = $elements;
- if (!$IDs) {
- $keys=array_keys($this->elements);
- foreach($this->elements as $k=>$v) {
- $this->ids[] = $this->elements[$k]->id;
- }
- } else {
- $this->ids = $IDs;
- }
- //foreach ($this->ids as $k=>$v) {
- //var_dump($this->elements[$k]);
- //$this->elements[$k]->id = $v;
- //}
- }
-
-
- function __toString() {
- return sprintf("<div>%s<div>%s</div>%s</div>",
- $this->first_element,
- implode("\n", $this->elements),
- $this->last_element
- );
- }
-
- function set_layout($new,$target="") {
- switch ($target) {
- case "first":
- break;
- case "last":
- break;
- default:
- foreach($this->elements as $el) {
- $el->set_layout($new);
- }
- break;
- }
- }
-
- function set_first($element,$layout="") {
- $this->first_element=$element;
- if ($layout) {
- $this->first_element->set_layout($layout);
- }
- }
-
- function set_last($element,$layout="") {
- $this->last_element=$element;
- if ($layout) {
- $this->last_element->set_layout($layout);
- }
- }
- }
|