Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
container.php
1<?php
2
4
6
11class Container extends Base
12{
16 private $elements = array();
17
21 public function printContent()
22 {
23 foreach ($this->elements as $element)
24 {
25 $element->render();
26 }
27 }
28
35 public function setName($name)
36 {
37 foreach ($this->elements as $element)
38 {
39 if ($element instanceof BaseValuable)
40 {
41 $element->setName($name);
42 }
43 }
44 }
45
53 public function addElementBefore(Base $newField, Base $targetField)
54 {
55 $indexToInsert = null;
56 $newFieldsList = array();
57 foreach ($this->elements as $key => $field)
58 {
59 if ($field === $targetField)
60 {
61 if ($newField->getKey())
62 {
63 $newFieldsList[$newField->getKey()] = $newField;
64 }
65 else
66 {
67 $newFieldsList[] = $newField;
68 }
69 }
70 $newFieldsList[$key] = $field;
71 }
72
73 $this->elements = $newFieldsList;
74 }
75
83 public function addElementAfter(Base $newField, Base $targetField)
84 {
85 $indexToInsert = null;
86 $newFieldsList = array();
87 foreach ($this->elements as $key => $field)
88 {
89 $newFieldsList[$key] = $field;
90
91 if ($field === $targetField)
92 {
93 if ($newField->getKey())
94 {
95 $newFieldsList[$newField->getKey()] = $newField;
96 }
97 else
98 {
99 $newFieldsList[] = $newField;
100 }
101 }
102 }
103
104 $this->elements = $newFieldsList;
105 }
106
111 public function addElement(Base $element)
112 {
113 if ($element->getKey())
114 {
115 $this->elements[$element->getKey()] = $element;
116 }
117 else
118 {
119 $this->elements[] = $element;
120 }
121
122 }
123
127 public function getElements()
128 {
129 return $this->elements;
130 }
131
138 public function getElement($key)
139 {
140 if (!isset($this->elements[$key]))
141 {
142 return null;
143 }
144 return $this->elements[$key];
145 }
146
153 public function setElements($elements)
154 {
155 $this->elements = $elements;
156 }
157}
addElementBefore(Base $newField, Base $targetField)
Definition container.php:53
addElementAfter(Base $newField, Base $targetField)
Definition container.php:83