1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Pages;
13
14 use Icybee\Modules\Nodes\Node;
15 use Icybee\Modules\Pages\Page;
16
17 use Brickrouge\Document;
18 use Brickrouge\Element;
19 use Brickrouge\Form;
20 use Brickrouge\Text;
21
22 class EditBlock extends \Icybee\Modules\Nodes\EditBlock
23 {
24 static protected function add_assets(Document $document)
25 {
26 parent::add_assets($document);
27
28 $document->css->add(DIR . 'public/edit.css');
29 $document->js->add(DIR . 'public/edit.js');
30 }
31
32 protected function lazy_get_attributes()
33 {
34 global $core;
35
36 return \ICanBoogie\array_merge_recursive
37 (
38 parent::lazy_get_attributes(), array
39 (
40 Form::HIDDENS => array
41 (
42 Page::SITEID => $core->site_id,
43 Page::LANGUAGE => $core->site->language
44 ),
45
46 Element::GROUPS => array
47 (
48 'advanced' => array
49 (
50 'title' => 'Advanced',
51 'weight' => 30
52 )
53 )
54 )
55 );
56 }
57
58 protected function lazy_get_children()
59 {
60 global $core;
61
62 $values = $this->values;
63 $nid = $values[Node::NID];
64 $is_alone = !$this->module->model->select('nid')->where(array('siteid' => $core->site_id))->rc;
65
66 list($contents_tags) = $this->module->get_contents_section($values[Node::NID], $values[Page::TEMPLATE]);
67
68
69
70
71
72 $parentid_el = null;
73
74 if (!$is_alone)
75 {
76 $parentid_el = new PopPage
77 (
78 'select', array
79 (
80 Form::LABEL => 'parentid',
81 Element::OPTIONS_DISABLED => $nid ? array($nid => true) : null,
82 Element::DESCRIPTION => 'parentid'
83 )
84 );
85 }
86
87
88
89
90
91 $location_el = null;
92
93 if (!$is_alone)
94 {
95 $location_el = new PopPage
96 (
97 'select', array
98 (
99 Form::LABEL => 'location',
100 Element::GROUP => 'advanced',
101 Element::WEIGHT => 10,
102 Element::OPTIONS_DISABLED => $nid ? array($nid => true) : null,
103 Element::DESCRIPTION => 'location'
104 )
105 );
106 }
107
108 $contents_children = array();
109
110 if (isset($contents_tags[Element::CHILDREN]))
111 {
112 $contents_children = $contents_tags[Element::CHILDREN];
113
114 unset($contents_tags[Element::CHILDREN]);
115
116 $this->attributes = \ICanBoogie\array_merge_recursive($this->attributes, $contents_tags);
117 }
118
119 return array_merge
120 (
121 parent::lazy_get_children(), array
122 (
123 Page::LABEL => new Text
124 (
125 array
126 (
127 Form::LABEL => 'label',
128 Element::DESCRIPTION => 'label'
129 )
130 ),
131
132 Page::PARENTID => $parentid_el,
133 Page::SITEID => null,
134
135 Page::IS_NAVIGATION_EXCLUDED => new Element
136 (
137 Element::TYPE_CHECKBOX, array
138 (
139 Element::LABEL => 'is_navigation_excluded',
140 Element::GROUP => 'visibility',
141 Element::DESCRIPTION => 'is_navigation_excluded'
142 )
143 ),
144
145 Page::PATTERN => new Text
146 (
147 array
148 (
149 Form::LABEL => 'pattern',
150 Element::GROUP => 'advanced',
151 Element::DESCRIPTION => 'pattern'
152 )
153 ),
154
155 Page::LOCATIONID => $location_el
156 ),
157
158 $contents_children
159 );
160 }
161 }