1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Forms;
13
14 use ICanBoogie\I18n;
15
16 use Brickrouge\Element;
17 use Brickrouge\Form;
18 use Brickrouge\Text;
19
20 21 22
23 class EditBlock extends \Icybee\Modules\Nodes\EditBlock
24 {
25 static protected function add_assets(\Brickrouge\Document $document)
26 {
27 parent::add_assets($document);
28
29 $document->css->add(DIR . 'public/admin.css');
30 $document->js->add(DIR . 'public/admin.js');
31 }
32
33 protected function lazy_get_attributes()
34 {
35 return \ICanBoogie\array_merge_recursive
36 (
37 parent::lazy_get_attributes(), array
38 (
39 Element::GROUPS => array
40 (
41 'messages' => array
42 (
43 'title' => 'messages'
44 ),
45
46 'options' => array
47 (
48 'title' => 'options'
49 ),
50
51 'operation' => array
52 (
53 'title' => 'operation'
54 )
55 )
56 )
57 );
58 }
59
60 protected function lazy_get_children()
61 {
62 global $core;
63
64 $models = $core->configs->synthesize('formmodels', 'merge');
65 $models_options = array();
66
67 if ($models)
68 {
69 foreach ($models as $modelid => $model)
70 {
71 $models_options[$modelid] = $model['title'];
72 }
73
74 asort($models_options);
75 }
76
77 $label_default_values = I18n\t('Default values');
78 $description_notify = I18n\t('description_notify', array(':link' => '<a href="http://github.com/Weirdog/WdPatron" target="_blank">WdPatron</a>'));
79
80 return array_merge
81 (
82 parent::lazy_get_children(), array
83 (
84 'modelid' => new Element
85 (
86 'select', array
87 (
88 Form::LABEL => 'modelid',
89 Element::REQUIRED => true,
90 Element::OPTIONS => array(null => '') + $models_options,
91 Element::LABEL_POSITION => 'before'
92 )
93 ),
94
95 'before' => $core->editors['rte']->from
96 (
97 array
98 (
99 Form::LABEL => 'before',
100 Element::GROUP => 'messages',
101
102 'rows' => 5
103 )
104 ),
105
106 'after' => $core->editors['rte']->from
107 (
108 array
109 (
110 Form::LABEL => 'after',
111 Element::GROUP => 'messages',
112
113 'rows' => 5
114 )
115 ),
116
117 'complete' => $core->editors['rte']->from
118 (
119 array
120 (
121 Form::LABEL => 'complete',
122 Element::GROUP => 'messages',
123 Element::REQUIRED => true,
124 Element::DESCRIPTION => 'complete',
125 Element::DEFAULT_VALUE => '<p>' . I18n\t('default.complete') . '</p>',
126
127 'rows' => 5
128 )
129 ),
130
131 'is_notify' => new Element
132 (
133 Element::TYPE_CHECKBOX, array
134 (
135 Element::LABEL => 'is_notify',
136 Element::GROUP => 'options',
137 Element::DESCRIPTION => 'is_notify'
138 )
139 ),
140
141 'notify_' => new EmailComposer
142 (
143 array
144 (
145 Element::GROUP => 'options',
146 Element::DEFAULT_VALUE => array
147 (
148 'from' => $core->site->email,
149 'destination' => $core->site->email
150 ),
151
152 'class' => 'form-horizontal'
153 )
154 )
155 )
156 );
157 }
158 }