|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package EvernoteSettings |
|
5
|
|
|
*/ |
|
6
|
|
|
class EvernoteAdminController extends LeftAndMain |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @var string |
|
11
|
|
|
*/ |
|
12
|
|
|
private static $url_segment = 'evernote-settings'; |
|
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
private static $url_rule = '/$Action/$ID/$OtherID'; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
private static $menu_title = 'Evernote'; |
|
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
private static $menu_icon = '/silverstripe-evernote/images/evernote.png'; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param null $id Not used. |
|
30
|
|
|
* @param null $fields Not used. |
|
31
|
|
|
* |
|
32
|
|
|
* @return Form |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getEditForm($id = null, $fields = null) |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
$evernoteSettings = EvernoteSettings::current_Evernote_settings(); |
|
38
|
|
|
$fields = $evernoteSettings->getCMSFields(); |
|
39
|
|
|
|
|
40
|
|
|
// Retrieve validator, if one has been setup |
|
41
|
|
|
if ($evernoteSettings->hasMethod("getCMSValidator")) { |
|
42
|
|
|
$validator = $evernoteSettings->getCMSValidator(); |
|
|
|
|
|
|
43
|
|
|
} else { |
|
44
|
|
|
$validator = null; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$actions = $evernoteSettings->getCMSActions(); |
|
48
|
|
|
|
|
49
|
|
|
$form = CMSForm::create( |
|
50
|
|
|
$this, 'EditForm', $fields, $actions, $validator |
|
51
|
|
|
)->setHTMLID('Form_EditForm'); |
|
52
|
|
|
|
|
53
|
|
|
$form->setResponseNegotiator($this->getResponseNegotiator()); |
|
|
|
|
|
|
54
|
|
|
$form->addExtraClass('cms-content center cms-edit-form'); |
|
55
|
|
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
if ($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); |
|
58
|
|
|
|
|
59
|
|
|
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses()); |
|
60
|
|
|
$form->setAttribute('data-pjax-fragment', 'CurrentForm'); |
|
61
|
|
|
|
|
62
|
|
|
$this->extend('updateEditForm', $form); |
|
63
|
|
|
|
|
64
|
|
|
return $form; |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Save the current sites {@link SiteConfig} into the database. |
|
70
|
|
|
* |
|
71
|
|
|
* @param array $data |
|
72
|
|
|
* @param Form $form |
|
73
|
|
|
* @return String |
|
74
|
|
|
*/ |
|
75
|
|
|
public function save_evernotesettings($data, $form) |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
|
|
$evernoteSettings = EvernoteSettings::current_Evernote_settings(); |
|
78
|
|
|
$form->saveInto($evernoteSettings); |
|
79
|
|
|
|
|
80
|
|
|
try { |
|
81
|
|
|
$evernoteSettings->write(); |
|
82
|
|
|
} catch (ValidationException $ex) { |
|
83
|
|
|
$form->sessionMessage($ex->getResult()->message(), 'bad'); |
|
84
|
|
|
return $this->getResponseNegotiator()->respond($this->request); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.'))); |
|
88
|
|
|
|
|
89
|
|
|
return $form->forTemplate(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.