1: <?php
2:
3: App::uses('AccessControlComponent', 'AccessControl.Controller/Component');
4:
5: class ExtendedFieldSet {
6:
7: 8: 9: 10:
11: private $fieldsetData;
12:
13: 14: 15: 16:
17: private $parent;
18:
19: public function __construct(ExtendedFormHelper $parent, \FieldSetDefinition $fieldsetData, $blacklist) {
20: $this->parent = $parent;
21: $this->fieldsetData = $fieldsetData;
22: $this->blacklist = $blacklist;
23: }
24:
25: public function output() {
26: return $this->parent->Html->tag(
27: 'fieldSet',
28: $this->_legend() .
29: $this->_inputs()
30: );
31: }
32:
33: private function _legend() {
34: return $this->fieldsetData->getLabel() ?
35: $this->parent->Html->tag('legend', $this->fieldsetData->getLabel()) :
36: '';
37: }
38:
39: private function _inputs() {
40: return $this->parent->FieldSetLayout->fieldSet(
41: $this->_lines()
42: );
43: }
44:
45: private function _lines() {
46: $lines = array();
47: foreach ($this->fieldsetData->getLines() as $line) {
48: $line = $this->_line($line);
49: if (!empty($line)) {
50: $lines[] = $line;
51: }
52: }
53: return $lines;
54: }
55:
56: private function _line(\FieldRowDefinition $line) {
57: $columns = array();
58: foreach ($line->getFields() as $field) {
59: $column = $this->_column($field);
60: if (!empty($column)) {
61: list($label, $content) = $column;
62: $columns[$label] = $content;
63: }
64: }
65: return $columns;
66: }
67:
68: private function _column(\FieldDefinition $field) {
69: return array(
70: $this->_fieldLabel($field),
71: $this->_fieldInput($field)
72: );
73: }
74:
75: private function _fieldLabel(\FieldDefinition $field) {
76: return __d('extended_scaffold', Inflector::humanize($field->getName()));
77: }
78:
79: private function _fieldInput(\FieldDefinition $field) {
80: $options = $field->getOptions();
81: $options['div'] = false;
82: $options['label'] = false;
83: return $this->parent->input($field->getName(), $options);
84: }
85:
86: }
87: