forked from pointybeard-archives/richtext_tinymce
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathextension.driver.php
More file actions
executable file
·68 lines (56 loc) · 2.22 KB
/
extension.driver.php
File metadata and controls
executable file
·68 lines (56 loc) · 2.22 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
<?php
Class extension_richtext_tinymce extends Extension {
public function getSubscribedDelegates() {
return array(
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'initaliseAdminPageHead'
),
array(
'page' => '/system/preferences/',
'delegate' => 'AddCustomPreferenceFieldsets',
'callback' => 'appendPreferences'
),
array(
'page' => '/system/preferences/',
'delegate' => 'Save',
'callback' => 'savePreferences'
)
);
}
public function install() {
// set default image folder path
Symphony::Configuration()->set('imagepath', WORKSPACE . '/tinymce/images/', 'tinymce');
Symphony::Configuration()->write();
return (General::realiseDirectory(Symphony::Configuration()->get('imagepath', 'tinymce')));
}
public function uninstall() {
// remove preferences
Symphony::Configuration()->remove('tinymce');
}
public function initaliseAdminPageHead($context) {
$page = Administration::instance()->Page;
// only on publish pages
if (!$page instanceOf contentPublish)
return;
// which are showing new/edit form
$callback = Administration::instance()->getPageCallback();
if (!in_array($callback['context']['page'], array('new', 'edit')))
return;
Administration::instance()->Page->addScriptToHead(URL . '/extensions/richtext_tinymce/lib/tinymce.min.js', 200);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/richtext_tinymce/assets/richtext_tinymce.publish.js', 201);
}
public function appendPreferences($context) {
// add new fieldset
$group = new XMLElement('fieldset');
$group->setAttribute('class', 'settings');
$group->appendChild(new XMLElement('legend', 'TinyMCE'));
// add image path field
$label = Widget::Label(__('Image path'));
$label->appendChild(Widget::Input('settings[tinymce][imagepath]', Symphony::Configuration()->get('imagepath', 'tinymce'), 'text'));
$group->appendChild($label);
$group->appendChild(new XMLElement('p', 'The directory where uploaded images are stored (default: WORKSPACE/tinymce/images) Note: Trailing slash is required', array('class' => 'help')));
$context['wrapper']->appendChild($group);
}
}