-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBootstrap.php
More file actions
261 lines (221 loc) · 8.06 KB
/
Bootstrap.php
File metadata and controls
261 lines (221 loc) · 8.06 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
/**
* BlurCreative Cosmiq Banner - Shopping Worlds extention
* @copyright Copyright (c) BlurCreative (http://blurcreative.de/)
*/
use Shopware\Components\Theme\LessDefinition;
use Doctrine\Common\Collections\ArrayCollection;
class Shopware_Plugins_Backend_BlurCosmiqBanner_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
/*
* readable plugin name
*/
public function getLabel()
{
return 'Cosmiq Banner';
}
/*
* plugin version
*/
public function getVersion()
{
return "0.0.1";
}
/**
* Returns a Meta Infos
*/
public function getInfo() {
include 'meta.php';
return $meta;
}
// Set the new secureUninstall capability
public function getCapabilities()
{
return array(
'install' => true,
'enable' => true,
'update' => true,
'secureUninstall' => true
);
}
/*
* here comes the install routine
*/
public function install()
{
$cosmiqBannerElement = $this->createEmotionComponent([
'name' => 'Cosmiq Banner',
'xtype' => 'emotion-components-cosmiqbanner',
'template' => 'emotion_cosmiq_banner',
'cls' => 'emotion-cosmiq-banner-element',
'description' => 'A simple responsive banner element for the shopping worlds.'
]);
//banner title
$cosmiqBannerElement->createTextField([
'name' => 'cosmiq_banner_title',
'fieldLabel' => 'Title',
'supportText' => 'Set a title for the banner element',
'allowBlank' => true
]);
//banner description
$cosmiqBannerElement->createTinyMceField([
'name' => 'cosmiq_banner_description',
'fieldLabel' => 'Description',
'supportText' => 'Set a description for the banner element',
'allowBlank' => true
]);
//banner button title
$cosmiqBannerElement->createTextField([
'name' => 'cosmiq_banner_button_title',
'fieldLabel' => 'Button Title',
'supportText' => 'Set a button for the banner element',
'allowBlank' => true
]);
//banner button link
$cosmiqBannerElement->createTextField([
'name' => 'cosmiq_banner_button_link',
'defaultValue' => 'banner_button_link',
'fieldLabel' => 'Button Link',
'supportText' => 'Set a button link for the banner element',
'allowBlank' => true
]);
//banner textfield orientation - top left
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'fieldLabel' => 'Textfield Position',
'defaultValue' => 'top-left',
'allowBlank' => true
]);
//banner textfield orientation - top center
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'top-center',
'allowBlank' => true
]);
//banner textfield orientation - top right
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'top-right',
'allowBlank' => true
]);
//banner textfield orientation - center left
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'center-left',
'allowBlank' => true
]);
//banner textfield orientation - center center
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'center-center',
'allowBlank' => true
]);
//banner textfield orientation - center right
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'center-right',
'allowBlank' => true
]);
//banner textfield orientation - bottom left
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'bottom-left',
'allowBlank' => true
]);
//banner textfield orientation - bottom center
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'bottom-center',
'allowBlank' => true
]);
//banner textfield orientation - bottom right
$cosmiqBannerElement->createRadioField([
'name' => 'cosmiq_banner_textfield_orientation',
'defaultValue' => 'bottom-right',
'allowBlank' => true
]);
//banner full sized
$cosmiqBannerElement->createCheckboxField([
'name' => 'cosmiq_banner_full_sized_content',
'fieldLabel' => 'Full Sized Content',
'helpText' => 'If this option is set the content of the banner will be full sized. Otherwise the content is boxed with a max size of 1260px (less variable can be changed)',
'allowBlank' => true
]);
//banner background image
$cosmiqBannerElement->createMediaField([
'name' => 'cosmiq_banner_background_image',
'fieldLabel' => 'Background Image',
'supportText' => 'Set a background image for the banner element',
'allowBlank' => true
]);
/**
* Subscribe to the post dispatch event of the emotion backend module to extend the components.
*/
$this->subscribeEvent(
'Enlight_Controller_Action_PostDispatchSecure_Backend_Emotion',
'onPostDispatchBackendEmotion'
);
//subscribe event: add the less file
$this->subscribeEvent(
'Theme_Compiler_Collect_Plugin_Less',
'addLessFiles'
);
$this->subscribeEvent(
'Shopware_Controllers_Widgets_Emotion_AddElement',
'onEmotionAddElement'
);
return true;
}
/**
* Extends the backend template to add the grid component for the emotion designer.
*
* @param Enlight_Controller_ActionEventArgs $args
*/
public function onPostDispatchBackendEmotion(Enlight_Controller_ActionEventArgs $args)
{
/** @var \Shopware_Controllers_Backend_Emotion $controller */
$controller = $args->getSubject();
$view = $controller->View();
$view->addTemplateDir($this->Path() . 'Views/');
$view->extendsTemplate('backend/emotion/blur_cosmiq_banner/view/detail/elements/cosmiq_banner.js');
}
// function: add the less file
public function addLessFiles(Enlight_Event_EventArgs $args) {
$less = new \Shopware\Components\Theme\LessDefinition(
array(),
array( __DIR__ . '/Views/frontend/_public/src/less/all.less' ),
__DIR__
);
return new Doctrine\Common\Collections\ArrayCollection(array($less));
}
public function onEmotionAddElement(Enlight_Event_EventArgs $args)
{
$element = $args->get('element');
if ($element['component']['xType'] !== 'emotion-components-cosmiqbanner') {
return;
}
$data = $args->getReturn();
// Do some stuff with the element data
$args->setReturn($data);
}
public function uninstall()
{
$this->secureUninstall();
return true;
}
public function enable()
{
return [
'success' => true,
'invalidateCache' => ['backend', 'frontend', 'theme']
];
}
public function disable()
{
return [
'success' => true,
'invalidateCache' => ['backend', 'frontend', 'theme']
];
}
}
?>