-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
208 lines (189 loc) · 7.29 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php namespace Depcore\Portfolio;
use Backend;
use Event;
use System\Classes\PluginBase;
use Depcore\Portfolio\Models\PortfolioItem;
/**
* portfolio Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'depcore.portfolio::lang.plugin.name',
'description' => 'depcore.portfolio::lang.plugin.description',
'author' => 'depcore',
'icon' => 'icon-portfolio'
];
}
/**
* Register method, called when the plugin is first registered.
*
* @return void
*/
public function register()
{
}
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
Event::listen('pages.menuitem.listTypes', function () {
return [
'portfolio-item' => 'depcore.portfolio::lang.portfolioitem.label' ,
'all-portfolio-items' => 'depcore.portfolio::lang.portfolioitems.menu_label',
];
});
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
if ($type === 'portfolio-item' or $type == 'all-portfolio-items') {
return PortfolioItem::getMenuTypeInfo($type);
}
});
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
if ($type === 'portfolio-item' or $type == 'all-portfolio-items') {
return PortfolioItem::resolveMenuItem($item, $url, $theme);
}
});
}
/**
* Registers any front-end components implemented in this plugin.
*
* @return array
*/
public function registerComponents()
{
return [
'Depcore\Portfolio\Components\PortfolioList' => 'PortfolioList',
'Depcore\Portfolio\Components\PortfolioItem' => 'PortfolioItem',
'Depcore\Portfolio\Components\PortfolioNavigation' => 'PortfolioNavigation',
'Depcore\Portfolio\Components\ClientsList' => 'brandsClientsList',
];
}
/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return [
'depcore.portfolio.create_portfolios' => [
'tab' => 'depcore.portfolio::lang.plugin.name',
'label' => 'depcore.portfolio::lang.permissions.manage_portfolios'
],
'depcore.portfolio.access_industries' => [
'tab' => 'depcore.portfolio::lang.plugin.name',
'label' => 'depcore.portfolio::lang.permissions.access_industries'
],
'depcore.portfolio.access_clients' => [
'tab' => 'depcore.portfolio::lang.plugin.name',
'label' => 'depcore.portfolio::lang.permissions.access_clients'
],
'depcore.portfolio.access_categories' => [
'tab' => 'depcore.portfolio::lang.plugin.name',
'label' => 'depcore.portfolio::lang.permissions.access_categories'
],
];
}
/**
* Registers back-end navigation items for this plugin.
*
* @return array
*/
public function registerNavigation()
{
return [
'portfolio' => [
'label' => 'depcore.portfolio::lang.plugin.name',
'url' => Backend::url('depcore/portfolio/portfolioitems'),
'icon' => 'icon-briefcase',
'permissions' => ['depcore.portfolio.manage_portfolios'],
'order' => 500,
'sideMenu' => [
'items' => [
'label' => 'depcore.portfolio::lang.portfolioitem.label',
'icon' => 'icon-briefcase',
'url' => Backend::url('depcore/portfolio/portfolioitems'),
'permissions' => ['depcore.portfolio.manage_portfolios'],
],
'create_portfolio' => [
'label' => 'depcore.portfolio::lang.portfolioitem.new',
'icon' => 'icon-plus',
'url' => Backend::url('depcore/portfolio/portfolioitems/create'),
'permissions' => ['depcore.portfolio.manage_portfolios'],
],
'categories' => [
'label' => 'depcore.portfolio::lang.category.label',
'icon' => 'icon-inbox',
'url' => Backend::url('depcore/portfolio/categories'),
'permissions' => ['depcore.portfolio.access_categories'],
],
'clients' => [
'label' => 'depcore.portfolio::lang.client.label',
'icon' => 'icon-user',
'url' => Backend::url('depcore/portfolio/clients'),
'permissions' => ['depcore.portfolio.access_clients']
],
'industries' => [
'label' => 'depcore.portfolio::lang.industry.label',
'icon' => 'icon-briefcase',
'url' => Backend::url('depcore/portfolio/industries'),
'permissions' => ['depcore.portfolio.access_industries']
],
'settings' => [
'label' => 'depcore.portfolio::lang.menu.secondary.settings',
'icon' => 'icon-cog',
'url' => Backend::url('system/settings/update/depcore/portfolio/form'),
'permissions' => ['depcore.portfolio.access_settings']
],
], // side menu ends
],
];
}
public function registerMarkupTags()
{
return [
'filters' => [
'getClassIdAndStyle' => [$this, 'extractStyle']
],
];
}
/**
* Return combined attributes for the section or content objects
*
* @return string
* @author Adam
* @todo Invoke media manager for background images
**/
public function extractStyle($div)
{
if (is_array($div)) {
$style = '';
if ( array_key_exists('class', $div) and $div['class'] != '') $style .= "class='{$div['class']}' ";
if ( array_key_exists('id', $div) and $div['id'] != '' ) $style .= "id='{$div['id']}' ";
if ( array_key_exists('backgroundImage', $div) and $div['backgroundImage'] != '' ) {
$image = \Config::get('cms.storage.media.path').$div['backgroundImage'];
$div['style'] .= "background-image: url($image)";
}
if (array_key_exists('style', $div) and $div['style'] != '' ) $style .= "style='{$div['style']}'";
return $style;
}
}
public function registerStormedModels()
{
return [
'\Depcore\Portfolio\Models\PortfolioItem' => [
'placement' => 'tabs',
],
];
}
}