1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Brickrouge;
13
14 use ICanBoogie\I18n;
15
16 class Section extends Element
17 {
18 const T_PANEL_CLASS = '#form-section-panel-class';
19
20 protected static $auto_panelname;
21
22 protected function render_inner_html()
23 {
24 $rc = null;
25 $children = $this->get_ordered_children();
26
27 foreach ($children as $name => $element)
28 {
29 if (!$element)
30 {
31 continue;
32 }
33
34 $context_class = $name ? normalize($name) : ++self::$auto_panelname;
35
36 $class = 'panel panel-' . $context_class . ' ' . (is_object($element) ? $element[self::T_PANEL_CLASS] : '');
37
38 $rc .= '<div class="' . rtrim($class) . '">';
39
40 if (is_object($element))
41 {
42 $label = I18n\t($element[Form::LABEL]);
43
44 if ($label)
45 {
46 if ($label{0} == '.')
47 {
48 $label = I18n\t(substr($label, 1), array(), array('scope' => 'element.label'));
49 }
50
51 $rc .= '<div class="form-label form-label-' . $context_class . '">';
52 $rc .= $label;
53
54 if ($element[Element::REQUIRED])
55 {
56 $rc .= ' <sup>*</sup>';
57 }
58
59 $rc .= '<span class="separator"> :</span>';
60
61 $rc .= '</div>';
62 }
63 }
64
65 $rc .= '<div class="form-element form-element-' . $context_class . '">';
66 $rc .= $element;
67 $rc .= '</div>';
68
69 $rc .= '</div>';
70 }
71
72 return $rc;
73 }
74 }