1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Nodes;
13
14 use ICanBoogie\Event;
15
16 use Brickrouge\Element;
17 use Brickrouge\Form;
18 use Brickrouge\Widget;
19
20 21 22
23 class Module extends \Icybee\Module
24 {
25 const PERMISSION_MODIFY_BELONGING_SITE = 'modify belonging site';
26
27 28 29
30 protected function lazy_get_views()
31 {
32 return \ICanBoogie\array_merge_recursive(parent::lazy_get_views(), [
33
34 'view' => [
35
36 'title' => "Record detail",
37 'provider' => __NAMESPACE__ . '\ViewProvider',
38 'assets' => [],
39 'renders' => \Icybee\Modules\Views\View::RENDERS_ONE
40
41 ],
42
43 'list' => [
44
45 'title' => "Records list",
46 'provider' => __NAMESPACE__ . '\ViewProvider',
47 'assets' => [],
48 'renders' => \Icybee\Modules\Views\View::RENDERS_MANY
49
50 ],
51
52 'home' => [
53
54 'title' => "Records home",
55 'provider' => __NAMESPACE__ . '\ViewProvider',
56 'assets' => [],
57 'renders' => \Icybee\Modules\Views\View::RENDERS_MANY
58
59 ]
60
61 ]);
62 }
63
64 protected function resolve_primary_model_tags($tags)
65 {
66 return parent::resolve_model_tags($tags, 'primary') + [
67
68 Model::T_CONSTRUCTOR => $this->id
69
70 ];
71 }
72
73 static public function create_default_routes()
74 {
75 global $core;
76
77 $routes = [];
78 $modules = $core->modules;
79
80 foreach ($modules->enabled_modules_descriptors as $module_id => $descriptor)
81 {
82 if ($module_id == 'nodes' || $module_id == 'contents' || !$modules->is_extending($module_id, 'nodes'))
83 {
84 continue;
85 }
86
87 $common = [
88
89 'module' => $module_id,
90 'controller' => 'Icybee\BlockController',
91 'visibility' => 'visible'
92
93 ];
94
95
96
97
98
99 $routes["admin:$module_id"] = [
100
101 'pattern' => "/admin/$module_id",
102 'title' => '.manage',
103 'block' => 'manage',
104 'index' => true
105
106 ] + $common;
107
108 if ($module_id == 'contents' || $modules->is_extending($module_id, 'contents') || $module_id == 'files' || $modules->is_extending($module_id, 'files'))
109 {
110
111
112 $routes["admin:$module_id/config"] = [
113
114 'pattern' => "/admin/$module_id/config",
115 'title' => '.config',
116 'block' => 'config',
117 'permission' => self::PERMISSION_ADMINISTER,
118
119 ] + $common;
120 }
121
122
123
124 $routes["admin:$module_id/new"] = [
125
126 'pattern' => "/admin/$module_id/new",
127 'title' => '.new',
128 'block' => 'edit'
129
130 ] + $common;
131
132
133
134 $routes["admin:$module_id/edit"] = [
135
136 'pattern' => "/admin/$module_id/<\d+>/edit",
137 'controller' => 'Icybee\EditController',
138 'title' => '.edit',
139 'block' => 'edit',
140 'visibility' => 'auto'
141
142 ] + $common;
143
144
145
146 $routes["admin:$module_id/delete"] = [
147
148 'pattern' => "/admin/$module_id/<\d+>/delete",
149 'controller' => 'Icybee\DeleteController',
150 'title' => '.delete',
151 'block' => 'delete',
152 'visibility' => 'auto'
153
154 ] + $common;
155 }
156
157 new Module\CreateDefaultRoutesEvent($modules['nodes'], [ 'routes' => &$routes ]);
158
159
160
161 $export = var_export($routes,true);
162
163 $core->vars['default_nodes_routes'] = "<?php\n\nreturn " . $export . ';';
164 }
165 }
166
167 namespace Icybee\Modules\Nodes\Module;
168
169 170 171
172 class CreateDefaultRoutesEvent extends \ICanBoogie\Event
173 {
174 175 176 177 178
179 public $routes;
180
181 182 183 184 185 186
187 public function __construct(\Icybee\Modules\Nodes\Module $target, array $payload)
188 {
189 parent::__construct($target, 'create_default_routes', $payload);
190 }
191 }