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
|
<?php
/**
* @file
* Editor integration functions for EpicEditor.
*/
/**
* Plugin implementation of hook_editor().
*/
function wysiwyg_epiceditor_editor() {
$editor['epiceditor'] = array(
'title' => 'EpicEditor',
'vendor url' => 'http://oscargodson.github.com/EpicEditor',
'download url' => 'http://oscargodson.github.com/EpicEditor/docs/downloads/EpicEditor-v0.1.1.zip',
'libraries' => array(
'' => array(
'title' => 'Minified',
'files' => array('js/epiceditor.min.js'),
),
'src' => array(
'title' => 'Source',
'files' => array('js/epiceditor.js'),
),
),
'version callback' => 'wysiwyg_epiceditor_version',
'themes callback' => 'wysiwyg_epiceditor_themes',
'settings callback' => 'wysiwyg_epiceditor_settings',
'versions' => array(
'0.1.1' => array(
'js files' => array('epiceditor.js'),
),
),
);
return $editor;
}
/**
* Detect editor version.
*
* @param $editor
* An array containing editor properties as returned from hook_editor().
*
* @return
* The installed editor version.
*/
function wysiwyg_epiceditor_version($editor) {
$library = $editor['library path'] . '/js/epiceditor.js';
if (!file_exists($library)) {
return;
}
// @todo Do not load the entire file; use fgets() instead.
$library = file_get_contents($library, 'r');
$version = preg_match('%EpicEditor\.version = \'(.*)\'\;%', $library, $matches);
if (!isset($matches[1])) {
return;
}
return $matches[1];
}
/**
* Determine available editor themes or check/reset a given one.
*
* @param $editor
* A processed hook_editor() array of editor properties.
* @param $profile
* A wysiwyg editor profile.
*
* @return
* An array of theme names. The first returned name should be the default
* theme name.
*/
function wysiwyg_epiceditor_themes($editor, $profile) {
return array('epic-dark', 'epic-light');
// @todo Use the preview themes somewhere.
//return array('preview-dark', 'github');
}
/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
* A processed hook_editor() array of editor properties.
* @param $config
* An array containing wysiwyg editor profile settings.
* @param $theme
* The name of a theme/GUI/skin to use.
*
* @return
* A settings array to be populated in
* Drupal.settings.wysiwyg.configs.{editor}
*/
function wysiwyg_epiceditor_settings($editor, $config, $theme) {
$settings = array(
'basePath' => base_path() . $editor['library path'],
'clientSideStorage' => FALSE,
'theme' => $theme,
//'preview_theme' => '',
);
return $settings;
}
|