1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Contents;
13
14 use Brickrouge\Element;
15 use Brickrouge\Form;
16 use Brickrouge\Text;
17
18 use Icybee\Modules\Editor\MultiEditorElement;
19
20 class EditBlock extends \Icybee\Modules\Nodes\EditBlock
21 {
22 protected function lazy_get_attributes()
23 {
24 $attributes = parent::lazy_get_attributes();
25
26 $attributes[Element::GROUPS] = array_merge
27 (
28 $attributes[Element::GROUPS], [
29
30 'contents' => [ 'title' => 'Content' ],
31 'date' => []
32
33 ]
34 );
35
36 return $attributes;
37 }
38
39 protected function lazy_get_children()
40 {
41 global $core;
42
43 $module_flat_id = $this->module->flat_id;
44
45 $default_editor = $core->site->metas->get($module_flat_id . '.default_editor', 'rte');
46 $use_multi_editor = $core->site->metas->get($module_flat_id . '.use_multi_editor');
47
48 if ($use_multi_editor)
49 {
50
51 }
52 else
53 {
54
55 }
56
57 $values = $this->values;
58
59 return array_merge(parent::lazy_get_children(), [
60
61 Content::SUBTITLE => new Text([
62
63 Form::LABEL => 'subtitle'
64 ]),
65
66 Content::BODY => new MultiEditorElement
67 (
68 $values['editor'] ? $values['editor'] : $default_editor, [
69
70 Element::LABEL_MISSING => 'Contents',
71 Element::GROUP => 'contents',
72 Element::REQUIRED => true,
73
74 'rows' => 16
75 ]
76 ),
77
78 Content::EXCERPT => $core->editors['rte']->from([
79
80 Form::LABEL => 'excerpt',
81 Element::GROUP => 'contents',
82 Element::DESCRIPTION => "excerpt",
83
84 'rows' => 3
85 ]),
86
87 Content::DATE => new \Brickrouge\Date([
88
89 Form::LABEL => 'Date',
90 Element::REQUIRED => true,
91 Element::DEFAULT_VALUE => date('Y-m-d')
92 ]),
93
94 Content::IS_HOME_EXCLUDED => new Element(Element::TYPE_CHECKBOX, [
95
96 Element::LABEL => "is_home_excluded",
97 Element::GROUP => 'visibility',
98 Element::DESCRIPTION => "is_home_excluded"
99 ])
100 ]);
101 }
102
103 protected function lazy_get_values()
104 {
105 global $core;
106
107 $values = parent::lazy_get_values();
108
109 if (isset($values['editor']) && isset($values['body']))
110 {
111 $editor = $core->editors[$values['editor']];
112
113 $values['body'] = $editor->unserialize($values['body']);
114 }
115
116 return $values;
117 }
118 }