1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AdminModule; |
4
|
|
|
|
5
|
|
|
use Nette\Utils\Finder; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Settings presenter. |
9
|
|
|
* @author Tomáš Voslař <tomas.voslar at webcook.cz> |
10
|
|
|
* @package WebCMS2 |
11
|
|
|
*/ |
12
|
|
|
class SettingsPresenter extends \AdminModule\BasePresenter |
13
|
|
|
{ |
14
|
|
|
/* @var Thumbnail */ |
15
|
|
|
private $thumbnail; |
16
|
|
|
|
17
|
10 |
|
protected function beforeRender() |
18
|
|
|
{ |
19
|
10 |
|
parent::beforeRender(); |
20
|
10 |
|
} |
21
|
|
|
|
22
|
10 |
|
protected function startup() |
23
|
|
|
{ |
24
|
10 |
|
parent::startup(); |
25
|
10 |
|
} |
26
|
|
|
|
27
|
|
|
/* BASIC */ |
28
|
|
|
|
29
|
1 |
View Code Duplication |
public function createComponentBasicSettingsForm() |
30
|
|
|
{ |
31
|
1 |
|
$settings = array(); |
32
|
1 |
|
$settings[] = $this->settings->get('Root domain', \WebCMS\Settings::SECTION_BASIC, 'checkbox'); |
33
|
1 |
|
$settings[] = $this->settings->get('Navbar dropdown', \WebCMS\Settings::SECTION_BASIC, 'checkbox'); |
34
|
1 |
|
$settings[] = $this->settings->get('Info email', \WebCMS\Settings::SECTION_BASIC, 'text'); |
35
|
1 |
|
$settings[] = $this->settings->get('Navbar class', \WebCMS\Settings::SECTION_BASIC, 'text'); |
36
|
1 |
|
$settings[] = $this->settings->get('Navbar id', \WebCMS\Settings::SECTION_BASIC, 'text'); |
37
|
1 |
|
$settings[] = $this->settings->get('Sidebar class', \WebCMS\Settings::SECTION_BASIC, 'text'); |
38
|
|
|
|
39
|
1 |
|
return $this->createSettingsForm($settings); |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
public function renderDefault() |
43
|
|
|
{ |
44
|
1 |
|
$this->reloadContent(); |
45
|
1 |
|
} |
46
|
|
|
|
47
|
|
|
/* PICTURES */ |
48
|
|
|
|
49
|
10 |
|
public function createComponentPicturesSettingsForm() |
50
|
|
|
{ |
51
|
1 |
|
$settings = array(); |
52
|
|
|
|
53
|
|
|
// global settings for all languages |
54
|
1 |
|
$this->settings->setLanguage(null); |
55
|
|
|
|
56
|
1 |
|
$settings[] = $this->settings->get('Watermark picture path', \WebCMS\Settings::SECTION_IMAGE, 'text'); |
57
|
|
|
|
58
|
1 |
|
$settings[] = $this->settings->get('Apply watermark', \WebCMS\Settings::SECTION_IMAGE, 'radio', array( |
59
|
1 |
|
0 => 'Do not apply watermark', |
60
|
1 |
|
1 => 'Use picture as watermark', |
61
|
1 |
|
2 => 'Use text as watermark', |
62
|
1 |
|
)); |
63
|
|
|
|
64
|
1 |
|
$settings[] = $this->settings->get('Watermark text', \WebCMS\Settings::SECTION_IMAGE, 'text'); |
65
|
10 |
|
$settings[] = $this->settings->get('Watermark text size', \WebCMS\Settings::SECTION_IMAGE, 'text'); |
66
|
1 |
|
$settings[] = $this->settings->get('Watermark text font', \WebCMS\Settings::SECTION_IMAGE, 'select', array( |
67
|
1 |
|
'Courier New.ttf' => 'Courier new', |
68
|
1 |
|
'Comic Sans MS.ttf' => 'Comic sans', |
69
|
1 |
|
'Arial.ttf' => 'Arial', |
70
|
1 |
|
'Times New Roman.ttf' => 'Times new roman', |
71
|
1 |
|
)); |
72
|
|
|
|
73
|
1 |
|
$settings[] = $this->settings->get('Watermark text color', \WebCMS\Settings::SECTION_IMAGE, 'text'); |
74
|
|
|
|
75
|
10 |
|
$settings[] = $this->settings->get('Watermark position', \WebCMS\Settings::SECTION_IMAGE, 'radio', array( |
76
|
1 |
|
0 => 'Top left', |
77
|
1 |
|
1 => 'Top right', |
78
|
10 |
|
2 => 'Center', |
79
|
10 |
|
3 => 'Bottom left', |
80
|
10 |
|
4 => 'Bottom right', |
81
|
10 |
|
)); |
82
|
|
|
|
83
|
|
|
// set back language for further settings in app |
84
|
10 |
|
$this->settings->setLanguage($this->state->language); |
85
|
|
|
|
86
|
10 |
|
return $this->createSettingsForm($settings); |
87
|
|
|
} |
88
|
|
|
|
89
|
1 |
|
public function renderPictures($panel) |
90
|
|
|
{ |
91
|
1 |
|
$this->reloadContent(); |
92
|
|
|
|
93
|
1 |
|
$this->template->watermarkPath = $this->settings->get('Watermark picture path', \WebCMS\Settings::SECTION_IMAGE)->getValue(); |
|
|
|
|
94
|
1 |
|
$this->template->panel = $panel; |
|
|
|
|
95
|
1 |
|
} |
96
|
|
|
|
97
|
1 |
|
public function actionAddThumbnail($id) |
98
|
|
|
{ |
99
|
1 |
|
if ($id) { |
100
|
|
|
$this->thumbnail = $this->em->find("WebCMS\Entity\Thumbnail", $id); |
101
|
|
|
} else { |
102
|
1 |
|
$this->thumbnail = new \WebCMS\Entity\Thumbnail(); |
|
|
|
|
103
|
|
|
} |
104
|
1 |
|
} |
105
|
|
|
|
106
|
|
|
public function actionDeleteThumbnail($id) |
107
|
|
|
{ |
108
|
|
|
$this->thumbnail = $this->em->find("WebCMS\Entity\Thumbnail", $id); |
109
|
|
|
$this->em->remove($this->thumbnail); |
110
|
|
|
$this->em->flush(); |
111
|
|
|
|
112
|
|
|
$this->flashMessage('Thumbnail has been removed.', 'success'); |
113
|
|
|
|
114
|
|
|
$this->forward('Settings:pictures', array('panel' => 'thumbnails')); |
115
|
|
|
} |
116
|
|
|
|
117
|
1 |
|
public function renderAddThumbnail($id) |
118
|
|
|
{ |
119
|
1 |
|
$this->reloadModalContent(); |
120
|
|
|
|
121
|
1 |
|
$this->template->thumbnail = $this->thumbnail; |
|
|
|
|
122
|
1 |
|
} |
123
|
|
|
|
124
|
10 |
|
public function createComponentThumbnailForm() |
125
|
|
|
{ |
126
|
1 |
|
$form = $this->createForm(); |
127
|
|
|
|
128
|
1 |
|
$form->addText('key', 'Key'); |
129
|
1 |
|
$form->addSelect('resize', 'Resize type', array( |
130
|
1 |
|
\Nette\Image::EXACT => 'Exact', |
131
|
1 |
|
\Nette\Image::FILL => 'Fill', |
132
|
1 |
|
\Nette\Image::FIT => 'Fit', |
133
|
1 |
|
\Nette\Image::SHRINK_ONLY => 'Shrink', |
134
|
1 |
|
\Nette\Image::STRETCH => 'Stretch', |
135
|
1 |
|
)); |
136
|
|
|
|
137
|
1 |
|
$form->addText('x', 'Width') |
138
|
1 |
|
->setRequired('You must fill in widh') |
139
|
1 |
|
->addConditionOn($form['resize'], \Nette\Forms\Form::EQUAL, \Nette\Image::EXACT) |
140
|
1 |
|
->addRule(\Nette\Forms\Form::PATTERN, 'Width must be greater than 0', '^[1-9][0-9]*$'); |
141
|
|
|
|
142
|
10 |
|
$form->addText('y', 'Height') |
143
|
1 |
|
->setRequired('You must fill in height') |
144
|
1 |
|
->addConditionOn($form['resize'], \Nette\Forms\Form::EQUAL, \Nette\Image::EXACT) |
145
|
1 |
|
->addRule(\Nette\Forms\Form::PATTERN, 'Height must be greater than 0', '^[1-9][0-9]*$'); |
146
|
|
|
|
147
|
10 |
|
$form->addCheckbox('crop', 'Crop?'); |
148
|
1 |
|
$form->addCheckbox('watermark', 'Watermark?'); |
149
|
|
|
|
150
|
1 |
|
if (\WebCMS\Helpers\SystemHelper::isSuperAdmin($this->user)) { |
151
|
1 |
|
$form->addCheckbox('system', 'System?'); |
152
|
1 |
|
} else { |
153
|
|
|
$form->addHidden('system', 'System?'); |
154
|
|
|
} |
155
|
|
|
|
156
|
1 |
|
$form->addSubmit('submit', 'Save'); |
157
|
|
|
|
158
|
1 |
|
$form->onSuccess[] = callback($this, 'thumbnailFormSubmitted'); |
159
|
1 |
|
$form->setDefaults($this->thumbnail->toArray()); |
160
|
|
|
|
161
|
1 |
|
return $form; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function thumbnailFormSubmitted(\Nette\Forms\Form $form) |
165
|
|
|
{ |
166
|
|
|
$values = $form->getValues(); |
167
|
|
|
|
168
|
|
|
if (!$this->thumbnail->getId()) { |
169
|
|
|
$thumb = new \WebCMS\Entity\Thumbnail(); |
170
|
|
|
} else { |
171
|
|
|
$thumb = $this->thumbnail; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
if (!\WebCMS\Helpers\SystemHelper::isSuperAdmin($this->user) && $thumb->getSystem()) { |
175
|
|
|
$this->flashMessage('You do not have a permission to do this operation.', 'danger'); |
176
|
|
|
$this->redirect('Settings:pictures', array('panel' => 'thumbnails')); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
$thumb->setKey($values->key); |
180
|
|
|
$thumb->setX($values->x); |
181
|
|
|
$thumb->setY($values->y); |
182
|
|
|
$thumb->setResize($values->resize); |
183
|
|
|
$thumb->setCrop($values->crop); |
184
|
|
|
$thumb->setWatermark($values->watermark); |
185
|
|
|
$thumb->setSystem($values->system); |
186
|
|
|
|
187
|
|
|
$this->em->persist($thumb); |
188
|
|
|
$this->em->flush(); |
189
|
|
|
|
190
|
|
|
$this->flashMessage('Thumbnail setting was added.', 'success'); |
191
|
|
|
|
192
|
|
|
if (!$this->isAjax()) { |
193
|
|
|
$this->redirect('Settings:pictures', array('panel' => 'thumbnails')); |
194
|
|
|
} |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
protected function createComponentThumbnailGrid($name) |
198
|
|
|
{ |
199
|
|
|
$grid = $this->createGrid($this, $name, "Thumbnail"); |
200
|
|
|
|
201
|
|
|
$grid->addColumnText('key', 'Key'); |
202
|
|
|
$grid->addColumnText('x', 'Width'); |
203
|
|
|
$grid->addColumnText('y', 'Height'); |
204
|
|
|
|
205
|
|
|
$grid->addColumnText('watermark', 'Watermark')->setReplacement(array( |
206
|
|
|
1 => 'Yes', |
207
|
|
|
NULL => 'No', |
208
|
|
|
)); |
209
|
|
|
|
210
|
|
|
$grid->addColumnText('system', 'System')->setReplacement(array( |
211
|
|
|
1 => 'Yes', |
212
|
|
|
NULL => 'No', |
213
|
|
|
)); |
214
|
|
|
|
215
|
|
|
$grid->addActionHref("addThumbnail", 'Edit')->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'ajax'), 'data-toggle' => 'modal', 'data-target' => '#myModal', 'data-remote' => 'false')); |
216
|
|
|
$grid->addActionHref("deleteThumbnail", 'Delete')->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-danger'), 'data-confirm' => 'Are you sure you want to delete this item?')); |
217
|
|
|
|
218
|
|
|
return $grid; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/* EMAILS */ |
222
|
|
|
|
223
|
1 |
View Code Duplication |
public function createComponentEmailsSettingsForm() |
224
|
|
|
{ |
225
|
1 |
|
$settings = array(); |
226
|
1 |
|
$settings[] = $this->settings->get('User new password subject', \WebCMS\Settings::SECTION_EMAIL, 'text'); |
227
|
1 |
|
$settings[] = $this->settings->get('User new password', \WebCMS\Settings::SECTION_EMAIL, 'textarea'); |
228
|
|
|
|
229
|
1 |
|
return $this->createSettingsForm($settings); |
230
|
|
|
} |
231
|
|
|
|
232
|
1 |
|
public function renderEmails() |
233
|
|
|
{ |
234
|
1 |
|
$this->reloadContent(); |
235
|
1 |
|
} |
236
|
|
|
|
237
|
|
|
/* BOXES SETTINGS - BATCH */ |
238
|
|
|
|
239
|
1 |
|
public function renderBoxesSettings() |
240
|
|
|
{ |
241
|
1 |
|
$this->reloadContent(); |
242
|
|
|
|
243
|
|
|
// fetch all boxes |
244
|
1 |
|
$parameters = $this->getContext()->container->getParameters(); |
245
|
|
|
|
246
|
|
|
// fetch all pages |
247
|
1 |
|
$pages = $this->em->getRepository('WebCMS\Entity\Page')->findBy(array( |
248
|
1 |
|
'language' => $this->state->language, |
249
|
1 |
|
)); |
250
|
|
|
|
251
|
1 |
|
$boxesAssoc = array(); |
252
|
1 |
View Code Duplication |
foreach ($pages as $page) { |
253
|
|
|
if ($page->getParent() != NULL) { |
254
|
|
|
$module = $this->createObject($page->getModuleName()); |
255
|
|
|
|
256
|
|
|
foreach ($module->getBoxes() as $box) { |
257
|
|
|
$boxesAssoc[$page->getId().'-'.$box['module'].'-'.$box['presenter'].'-'.$box['function']] = $page->getTitle().' - '.$this->translation[$box['name']]; |
258
|
|
|
} |
259
|
|
|
} |
260
|
1 |
|
} |
261
|
|
|
|
262
|
|
|
$boxesAssoc = array( |
263
|
1 |
|
0 => $this->translation['Box is not linked.'], |
264
|
1 |
|
) + $boxesAssoc; |
265
|
|
|
|
266
|
1 |
|
$boxesAssocError = array(); |
267
|
1 |
|
foreach ($parameters['boxes'] as $name => $status) { |
268
|
|
|
|
269
|
|
|
$criteria = new \Doctrine\Common\Collections\Criteria(); |
270
|
|
|
$criteria->where($criteria->expr()->eq('box', $name)); |
271
|
|
|
$criteria->andWhere($criteria->expr()->isNull('pageTo')); |
272
|
|
|
|
273
|
|
|
$enabled = $this->em->getRepository('WebCMS\Entity\Box')->matching($criteria); |
274
|
|
|
|
275
|
|
|
if ($enabled->isEmpty()) { |
276
|
|
|
$boxesAssocError[$name] = false; |
277
|
|
|
} else { |
278
|
|
|
$boxesAssocError[$name] = true; |
279
|
|
|
} |
280
|
1 |
|
} |
281
|
|
|
|
282
|
1 |
|
$this->template->boxes = $parameters['boxes']; |
|
|
|
|
283
|
1 |
|
$this->template->pages = $pages; |
|
|
|
|
284
|
1 |
|
$this->template->boxesAssoc = $boxesAssoc; |
|
|
|
|
285
|
1 |
|
$this->template->boxesAssocError = $boxesAssocError; |
|
|
|
|
286
|
1 |
|
} |
287
|
|
|
|
288
|
|
|
public function handleUpdateBox($name, $value) |
289
|
|
|
{ |
290
|
|
|
$this->reloadContent(); |
291
|
|
|
|
292
|
|
|
$parsed = explode('-', $name); |
293
|
|
|
|
294
|
|
|
$pageTo = $this->em->getRepository('WebCMS\Entity\Page')->find($parsed[0]); |
295
|
|
|
$box = $parsed[1]; |
296
|
|
|
|
297
|
|
|
$exists = $this->em->getRepository('WebCMS\Entity\Box')->findOneBy(array( |
298
|
|
|
'pageTo' => $pageTo, |
299
|
|
|
'box' => $box, |
300
|
|
|
)); |
301
|
|
|
|
302
|
|
|
if (is_object($exists)) { |
303
|
|
|
$boxAssign = $exists; |
304
|
|
|
} else { |
305
|
|
|
$boxAssign = new \WebCMS\Entity\Box(); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
$parsed = explode('-', $value); |
309
|
|
|
|
310
|
|
View Code Duplication |
if (count($parsed) > 3) { |
311
|
|
|
$pageFrom = $this->em->getRepository('WebCMS\Entity\Page')->find($parsed[0]); |
312
|
|
|
$moduleName = $parsed[1]; |
313
|
|
|
$presenter = $parsed[2]; |
314
|
|
|
$function = $parsed[3]; |
315
|
|
|
|
316
|
|
|
$boxAssign->setBox($box); |
317
|
|
|
$boxAssign->setFunction($function); |
318
|
|
|
$boxAssign->setModuleName($moduleName); |
319
|
|
|
$boxAssign->setPresenter($presenter); |
320
|
|
|
$boxAssign->setPageFrom($pageFrom); |
321
|
|
|
$boxAssign->setPageTo($pageTo); |
322
|
|
|
|
323
|
|
|
if (!$boxAssign->getId()) { |
324
|
|
|
$this->em->persist($boxAssign); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
$this->em->persist($boxAssign); |
328
|
|
|
} else { |
329
|
|
|
if (is_object($exists)) { |
330
|
|
|
$this->em->remove($exists); |
331
|
|
|
} |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
$this->em->flush(); |
335
|
|
|
|
336
|
|
|
$this->flashMessage('Box settings changed.', 'success'); |
337
|
|
|
} |
338
|
|
|
|
339
|
1 |
|
public function handleUpdateErrorBox($name, $value) |
340
|
|
|
{ |
341
|
1 |
|
$this->reloadContent(); |
342
|
|
|
|
343
|
|
|
$parsed = explode('-', $name); |
344
|
|
|
|
345
|
|
|
$box = $parsed[1]; |
346
|
|
|
|
347
|
|
|
$criteria = new \Doctrine\Common\Collections\Criteria(); |
348
|
|
|
$criteria->where($criteria->expr()->isNull('pageTo')); |
349
|
|
|
$criteria->andWhere($criteria->expr()->eq('box', $box)); |
350
|
|
|
|
351
|
|
|
$exists = $this->em->getRepository('WebCMS\Entity\Box')->matching($criteria); |
352
|
|
|
|
353
|
|
|
if (!$exists->isEmpty()) { |
354
|
|
|
$boxInfo = $exists->toArray(); |
355
|
|
|
$boxAssign = $boxInfo[0]; |
356
|
|
|
} else { |
357
|
|
|
$boxInfo = NULL; |
358
|
|
|
$boxAssign = new \WebCMS\Entity\Box(); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
$parsed = explode('-', $value); |
362
|
|
|
|
363
|
|
View Code Duplication |
if (count($parsed) > 3) { |
364
|
|
|
$pageFrom = $this->em->getRepository('WebCMS\Entity\Page')->find($parsed[0]); |
365
|
|
|
$moduleName = $parsed[1]; |
366
|
|
|
$presenter = $parsed[2]; |
367
|
|
|
$function = $parsed[3]; |
368
|
|
|
|
369
|
|
|
$boxAssign->setBox($box); |
370
|
|
|
$boxAssign->setFunction($function); |
371
|
|
|
$boxAssign->setModuleName($moduleName); |
372
|
|
|
$boxAssign->setPresenter($presenter); |
373
|
|
|
$boxAssign->setPageFrom($pageFrom); |
374
|
|
|
|
375
|
|
|
if (!$boxAssign->getId()) { |
376
|
|
|
$this->em->persist($boxAssign); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
$this->em->persist($boxAssign); |
380
|
|
|
} else { |
381
|
|
|
if (!$exists->isEmpty()) { |
382
|
|
|
$this->em->remove($boxInfo[0]); |
383
|
|
|
} |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
$this->em->flush(); |
387
|
|
|
|
388
|
|
|
$this->flashMessage('Box settings changed.', 'success'); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/* SEO SETTINGS - BATCH */ |
392
|
|
|
|
393
|
1 |
|
public function renderSeoSettings() |
394
|
|
|
{ |
395
|
1 |
|
$this->reloadContent(); |
396
|
|
|
|
397
|
|
|
// fetch all pages |
398
|
1 |
|
$pages = $this->em->getRepository('WebCMS\Entity\Page')->findBy(array( |
399
|
1 |
|
'language' => $this->state->language, |
400
|
1 |
|
)); |
401
|
|
|
|
402
|
1 |
|
$this->template->pages = $pages; |
|
|
|
|
403
|
1 |
|
} |
404
|
|
|
|
405
|
1 |
|
public function createComponentSeoBasicForm() |
406
|
|
|
{ |
407
|
1 |
|
$settings = array(); |
408
|
|
|
|
409
|
1 |
|
$settings[] = $this->settings->get('Seo keywords', \WebCMS\Settings::SECTION_BASIC, 'text'); |
410
|
1 |
|
$settings[] = $this->settings->get('Seo title', \WebCMS\Settings::SECTION_BASIC, 'text'); |
411
|
1 |
|
$settings[] = $this->settings->get('Seo description', \WebCMS\Settings::SECTION_BASIC, 'text'); |
412
|
1 |
|
$settings[] = $this->settings->get('Seo title before', \WebCMS\Settings::SECTION_BASIC, 'checkbox'); |
413
|
|
|
|
414
|
1 |
|
return $this->createSettingsForm($settings); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
public function actionUpdateMeta($idPage, $type, $value) |
418
|
|
|
{ |
419
|
|
|
$page = $this->em->getRepository('WebCMS\Entity\Page')->find($idPage); |
420
|
|
|
|
421
|
|
|
if ($type === 'title') { |
422
|
|
|
$page->setMetaTitle($value); |
423
|
|
|
} elseif ($type === 'keywords') { |
424
|
|
|
$page->setMetaKeywords($value); |
425
|
|
|
} elseif ($type === 'description') { |
426
|
|
|
$page->setMetaDescription($value); |
427
|
|
|
} elseif ($type === 'slug') { |
428
|
|
|
$page->setSlug($value); |
429
|
|
|
|
430
|
|
|
$path = $this->em->getRepository('WebCMS\Entity\Page')->getPath($page); |
431
|
|
|
$final = array(); |
432
|
|
|
foreach ($path as $p) { |
433
|
|
|
if ($p->getParent() != NULL) { |
434
|
|
|
$final[] = $p->getSlug(); |
435
|
|
|
} |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
$page->setPath(implode('/', $final)); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
$this->em->flush(); |
442
|
|
|
|
443
|
|
|
$this->flashMessage('Seo has been updated.', 'success'); |
444
|
|
|
$this->invalidateControl('flashMessages'); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/* SCRIPTS SETTINGS */ |
448
|
|
|
|
449
|
1 |
View Code Duplication |
public function renderScriptsSettings() |
450
|
|
|
{ |
451
|
1 |
|
$this->reloadContent(); |
452
|
|
|
|
453
|
1 |
|
$globalScriptsVars = array('pageScriptsHead', 'pageScriptsBodyStart', 'pageScriptsBodyEnd'); |
454
|
1 |
|
$hooks = array(); |
455
|
|
|
|
456
|
1 |
|
foreach (Finder::findFiles('@*.latte')->in(APP_DIR . '/templates') as $key => $file) { |
457
|
|
|
$filename = $file->getFileName(); |
458
|
|
|
|
459
|
|
|
foreach ($globalScriptsVars as $key => $var) { |
460
|
|
|
if (\WebCMS\Helpers\SystemHelper::checkFileContainsStr(APP_DIR . '/templates/' . $filename, $var)) { |
461
|
|
|
$hooks[$filename][$var] = true; |
462
|
|
|
} else { |
463
|
|
|
$hooks[$filename][$var] = false; |
464
|
|
|
} |
465
|
|
|
} |
466
|
1 |
|
} |
467
|
|
|
|
468
|
1 |
|
$this->template->scriptsHooks = $hooks; |
|
|
|
|
469
|
1 |
|
} |
470
|
|
|
|
471
|
1 |
View Code Duplication |
public function createComponentScriptsGlobalForm() |
472
|
|
|
{ |
473
|
1 |
|
$settings = array(); |
474
|
|
|
|
475
|
1 |
|
$settings[] = $this->settings->get('Scripts head', \WebCMS\Settings::SECTION_BASIC, 'textarea-plain'); |
476
|
1 |
|
$settings[] = $this->settings->get('Enable scripts head', \WebCMS\Settings::SECTION_BASIC, 'checkbox-toggle'); |
477
|
1 |
|
$settings[] = $this->settings->get('Scripts body start', \WebCMS\Settings::SECTION_BASIC, 'textarea-plain'); |
478
|
1 |
|
$settings[] = $this->settings->get('Enable scripts body start', \WebCMS\Settings::SECTION_BASIC, 'checkbox-toggle'); |
479
|
1 |
|
$settings[] = $this->settings->get('Scripts body end', \WebCMS\Settings::SECTION_BASIC, 'textarea-plain'); |
480
|
1 |
|
$settings[] = $this->settings->get('Enable scripts body end', \WebCMS\Settings::SECTION_BASIC, 'checkbox-toggle'); |
481
|
|
|
|
482
|
1 |
|
return $this->createSettingsForm($settings); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/* STYLES SETTINGS */ |
486
|
|
|
|
487
|
1 |
View Code Duplication |
public function renderStylesSettings() |
488
|
|
|
{ |
489
|
1 |
|
$this->reloadContent(); |
490
|
|
|
|
491
|
1 |
|
$globalStylesVars = array('pageStylesHead'); |
492
|
1 |
|
$hooks = array(); |
493
|
|
|
|
494
|
1 |
|
foreach (Finder::findFiles('@*.latte')->in(APP_DIR . '/templates') as $key => $file) { |
495
|
|
|
$filename = $file->getFileName(); |
496
|
|
|
|
497
|
|
|
foreach ($globalStylesVars as $key => $var) { |
498
|
|
|
if (\WebCMS\Helpers\SystemHelper::checkFileContainsStr(APP_DIR . '/templates/' . $filename, $var)) { |
499
|
|
|
$hooks[$filename][$var] = true; |
500
|
|
|
} else { |
501
|
|
|
$hooks[$filename][$var] = false; |
502
|
|
|
} |
503
|
|
|
} |
504
|
1 |
|
} |
505
|
|
|
|
506
|
1 |
|
$this->template->stylesHooks = $hooks; |
|
|
|
|
507
|
1 |
|
} |
508
|
|
|
|
509
|
1 |
View Code Duplication |
public function createComponentStylesGlobalForm() |
510
|
|
|
{ |
511
|
1 |
|
$settings = array(); |
512
|
|
|
|
513
|
1 |
|
$settings[] = $this->settings->get('Styles head', \WebCMS\Settings::SECTION_BASIC, 'textarea-plain'); |
514
|
1 |
|
$settings[] = $this->settings->get('Enable styles head', \WebCMS\Settings::SECTION_BASIC, 'checkbox-toggle'); |
515
|
|
|
|
516
|
1 |
|
return $this->createSettingsForm($settings); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/* PROJECT SPECIFIC SETTINGS */ |
520
|
|
|
|
521
|
1 |
|
public function createComponentProjectSettingsForm() |
522
|
|
|
{ |
523
|
1 |
|
$parameters = $this->getContext()->container->getParameters(); |
524
|
1 |
|
$settings = array(); |
525
|
|
|
|
526
|
1 |
|
if (array_key_exists('settings', $parameters)) { |
527
|
|
|
$projectSettings = $parameters['settings']; |
528
|
|
|
|
529
|
|
|
foreach ($projectSettings as $key => $value) { |
530
|
|
|
$settings[] = $this->settings->get($key, \WebCMS\Settings::SECTION_BASIC, 'checkbox'); |
531
|
|
|
} |
532
|
|
|
} else { |
533
|
1 |
|
$this->flashMessage('There are no settings in config file.', 'info'); |
534
|
|
|
} |
535
|
|
|
|
536
|
1 |
|
return $this->createSettingsForm($settings); |
537
|
|
|
} |
538
|
|
|
|
539
|
1 |
|
public function renderProject() |
540
|
|
|
{ |
541
|
1 |
|
$this->reloadContent(); |
542
|
1 |
|
} |
543
|
|
|
|
544
|
|
|
/* API third party */ |
545
|
|
|
|
546
|
1 |
|
public function renderApi() |
547
|
|
|
{ |
548
|
1 |
|
$this->reloadContent(); |
549
|
1 |
|
} |
550
|
|
|
|
551
|
1 |
|
public function createComponentApiSettingsForm() |
552
|
|
|
{ |
553
|
1 |
|
$settings = array(); |
554
|
|
|
|
555
|
1 |
|
$settings[] = $this->settings->get('Translate service', \WebCMS\Settings::SECTION_BASIC, 'select', \Webcook\Translator\ServiceFactory::getServices()); |
556
|
|
|
|
557
|
1 |
|
$settings[] = $this->settings->get('Yandex API key', \WebCMS\Settings::SECTION_BASIC, 'text'); |
558
|
|
|
|
559
|
1 |
|
$settings[] = $this->settings->get('Google API key', \WebCMS\Settings::SECTION_BASIC, 'text'); |
560
|
|
|
|
561
|
1 |
|
$settings[] = $this->settings->get('Bing client id', \WebCMS\Settings::SECTION_BASIC, 'text'); |
562
|
1 |
|
$settings[] = $this->settings->get('Bing client secret', \WebCMS\Settings::SECTION_BASIC, 'text'); |
563
|
|
|
|
564
|
1 |
|
return $this->createSettingsForm($settings); |
565
|
|
|
} |
566
|
|
|
} |
567
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.