1 |
4b706e38
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* CKEditor hooks implemented by the CKEditor module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_ckeditor_plugin().
|
10 |
|
|
*/
|
11 |
|
|
function ckeditor_ckeditor_plugin() {
|
12 |
|
|
$plugins = array();
|
13 |
|
|
$editor_path = '%editor_path%';
|
14 |
|
|
$plugin_dir = '%plugin_dir%';
|
15 |
|
|
$plugin_dir_additional = '%plugin_dir_extra%';
|
16 |
|
|
$pattern = '#\.addButton\([\s]*[\'"](.*?)[\'"][\s]*\,[\s]*\{[\s]*(.*?)[\s]*\}#s';
|
17 |
|
|
|
18 |
|
|
/**
|
19 |
|
|
* CKEditor built-in plugins.
|
20 |
|
|
*/
|
21 |
|
|
$_editor_path = ckeditor_path('local');
|
22 |
|
|
if ($_editor_path != '<URL>') {
|
23 |
|
|
if (file_exists($_editor_path . '/plugins/tableresize/plugin.js')) {
|
24 |
|
|
$plugins['tableresize'] = array(
|
25 |
|
|
'name' => 'tableresize',
|
26 |
|
|
'desc' => t('Table Resize plugin'),
|
27 |
|
|
'path' => $editor_path . '/plugins/tableresize/',
|
28 |
|
|
'buttons' => FALSE,
|
29 |
|
|
'default' => 't'
|
30 |
|
|
);
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
if (file_exists($_editor_path . '/plugins/autogrow/plugin.js')) {
|
34 |
|
|
$plugins['autogrow'] = array(
|
35 |
|
|
'name' => 'autogrow',
|
36 |
|
|
'desc' => t('Auto Grow plugin'),
|
37 |
|
|
'path' => $editor_path . '/plugins/autogrow/',
|
38 |
|
|
'buttons' => FALSE,
|
39 |
|
|
'default' => 'f'
|
40 |
|
|
);
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
if (file_exists($_editor_path . '/plugins/stylesheetparser/plugin.js')) {
|
44 |
|
|
$plugins['stylesheetparser'] = array(
|
45 |
|
|
'name' => 'stylesheetparser',
|
46 |
|
|
'desc' => t('Stylesheet Parser plugin'),
|
47 |
|
|
'path' => $editor_path . '/plugins/stylesheetparser/',
|
48 |
|
|
'buttons' => FALSE,
|
49 |
|
|
'default' => 'f'
|
50 |
|
|
);
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
else {
|
54 |
|
|
$_editor_url = ckeditor_path('url');
|
55 |
|
|
if (preg_match("/\/(standard|full)-all/", $_editor_url)) {
|
56 |
|
|
$plugins['tableresize'] = array(
|
57 |
|
|
'name' => 'tableresize',
|
58 |
|
|
'desc' => t('Table Resize plugin. See <a href="@ckdocs-tableresize">addon page</a> for more details.',
|
59 |
|
|
array('@ckdocs-tableresize' => 'http://ckeditor.com/addon/tableresize')
|
60 |
|
|
),
|
61 |
|
|
'path' => $_editor_url . '/plugins/tableresize/',
|
62 |
|
|
'buttons' => FALSE,
|
63 |
|
|
'default' => 't'
|
64 |
|
|
);
|
65 |
|
|
$plugins['autogrow'] = array(
|
66 |
|
|
'name' => 'autogrow',
|
67 |
|
|
'desc' => t('Auto Grow plugin. See <a href="@ckdocs-autogrow">addon page</a> for more details.',
|
68 |
|
|
array('@ckdocs-autogrow' => 'http://ckeditor.com/addon/autogrow')
|
69 |
|
|
),
|
70 |
|
|
'path' => $_editor_url . '/plugins/autogrow/',
|
71 |
|
|
'buttons' => FALSE,
|
72 |
|
|
'default' => 'f'
|
73 |
|
|
);
|
74 |
|
|
$plugins['stylesheetparser'] = array(
|
75 |
|
|
'name' => 'stylesheetparser',
|
76 |
|
|
'desc' => t('Stylesheet Parser plugin. See <a href="@ckdocs-stylesheetparser">addon page</a> for more details.',
|
77 |
|
|
array('@ckdocs-stylesheetparser' => 'http://ckeditor.com/addon/stylesheetparser')
|
78 |
|
|
),
|
79 |
|
|
'path' => $_editor_url . '/plugins/stylesheetparser/',
|
80 |
|
|
'buttons' => FALSE,
|
81 |
|
|
'default' => 'f'
|
82 |
|
|
);
|
83 |
|
|
$plugins['codesnippet'] = array(
|
84 |
|
|
'name' => 'codesnippet',
|
85 |
|
|
'desc' => t('Plugin for inserting Code Snippets. See <a href="@ckdocs-codesnippet">addon page</a> for more details. See <a href="@ckdocs-codesnippet-help">help</a> for additional instructions.',
|
86 |
|
|
array(
|
87 |
|
|
'@ckdocs-codesnippet' => 'http://ckeditor.com/addon/codesnippet',
|
88 |
|
|
'@ckdocs-codesnippet-help' => url('admin/help/ckeditor', array('fragment' => 'codesnippet')),
|
89 |
|
|
)
|
90 |
|
|
),
|
91 |
|
|
'path' => $_editor_url . '/plugins/codesnippet/',
|
92 |
|
|
'buttons' => array(
|
93 |
|
|
'CodeSnippet' => array(
|
94 |
|
|
'icon' => 'icons/codesnippet.png',
|
95 |
|
|
'label' => t('Insert Code Snippet'),
|
96 |
|
|
)
|
97 |
|
|
),
|
98 |
|
|
'default' => 'f'
|
99 |
|
|
);
|
100 |
|
|
$plugins['mathjax'] = array(
|
101 |
|
|
'name' => 'mathjax',
|
102 |
|
|
'desc' => t('Plugin for inserting Mathematical Formula (MathJax). See <a href="@ckdocs-mathjax">addon page</a> for more details. See <a href="@ckdocs-mathjax-help">help</a> for additional instructions.',
|
103 |
|
|
array(
|
104 |
|
|
'@ckdocs-mathjax' => 'http://ckeditor.com/addon/mathjax',
|
105 |
|
|
'@ckdocs-mathjax-help' => url('admin/help/ckeditor', array('fragment' => 'mathjax')),
|
106 |
|
|
)),
|
107 |
|
|
'path' => $_editor_url . '/plugins/mathjax/',
|
108 |
|
|
'buttons' => array(
|
109 |
|
|
'Mathjax' => array(
|
110 |
|
|
'icon' => 'icons/mathjax.png',
|
111 |
|
|
'label' => t('Insert Mathematical Formulas'),
|
112 |
|
|
)
|
113 |
|
|
),
|
114 |
|
|
'default' => 'f'
|
115 |
|
|
);
|
116 |
|
|
$plugins['image2'] = array(
|
117 |
|
|
'name' => 'image2',
|
118 |
|
|
'desc' => t('Enhanced Image plugin. See <a href="@ckdocs-image2">addon page</a> for more details.',
|
119 |
|
|
array('@ckdocs-image2' => 'http://ckeditor.com/addon/image2')
|
120 |
|
|
),
|
121 |
|
|
'path' => $_editor_url . '/plugins/image2/',
|
122 |
|
|
'buttons' => array(
|
123 |
|
|
'Enhanced Image' => array(
|
124 |
|
|
'icon' => 'icons/image.png',
|
125 |
|
|
'label' => t('Insert Enhanced Image'),
|
126 |
|
|
)
|
127 |
|
|
),
|
128 |
|
|
'default' => 't'
|
129 |
|
|
);
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
/**
|
134 |
|
|
* Plugins located directly in the CKEditor module folder.
|
135 |
|
|
*/
|
136 |
|
|
$_plugin_dir = ckeditor_module_path('local') . '/plugins/';
|
137 |
|
|
if ($handle = opendir($_plugin_dir)) {
|
138 |
|
|
while (false !== ($file = readdir($handle))) {
|
139 |
|
|
if (is_dir($_plugin_dir . $file) && file_exists($_plugin_dir . $file . '/plugin.js')) {
|
140 |
|
|
$source = file_get_contents($_plugin_dir . $file . '/plugin.js');
|
141 |
|
|
$buttons = array();
|
142 |
|
|
if (preg_match_all($pattern, $source, $matches)) {
|
143 |
|
|
foreach ($matches[1] as $i => $button_name) {
|
144 |
|
|
if (preg_match('#(icon)[\s]*\:[\s]*([^\,\n]*)#', $matches[2][$i], $matches2)) {
|
145 |
|
|
$buttons[$button_name] = array();
|
146 |
|
|
$buttons[$button_name]['label'] = $button_name;
|
147 |
|
|
$matches2[2] = str_replace(array('this.path', '+', '\'', '"'), array('', '', '', ''), $matches2[2]);
|
148 |
|
|
$buttons[$button_name]['icon'] = trim($matches2[2]);
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
if (preg_match('#@file ([^\n\r]*)#', $source, $matches)) {
|
153 |
|
|
$plugins[$file] = array(
|
154 |
|
|
'name' => $file,
|
155 |
|
|
'desc' => check_plain($matches[1]),
|
156 |
|
|
'path' => $plugin_dir . $file . '/',
|
157 |
|
|
'buttons' => (count($buttons) > 0) ? $buttons : FALSE,
|
158 |
|
|
'default' => 'f'
|
159 |
|
|
);
|
160 |
|
|
}
|
161 |
|
|
else {
|
162 |
|
|
$plugins[$file] = array(
|
163 |
|
|
'name' => $file,
|
164 |
|
|
'desc' => t('Plugin file: @plugin_filename', array('@plugin_filename' => $file)),
|
165 |
|
|
'path' => $plugin_dir . $file . '/',
|
166 |
|
|
'buttons' => (count($buttons) > 0) ? $buttons : FALSE,
|
167 |
|
|
'default' => 'f'
|
168 |
|
|
);
|
169 |
|
|
}
|
170 |
|
|
}
|
171 |
|
|
}
|
172 |
|
|
closedir($handle);
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
/**
|
176 |
|
|
* Plugins located in a folder specified in the CKEditor Global Profile.
|
177 |
|
|
*/
|
178 |
|
|
$_plugin_dir_additional = ckeditor_plugins_path('local') . '/';
|
179 |
|
|
if ($_plugin_dir != $_plugin_dir_additional && is_dir($_plugin_dir_additional) && $handle = opendir($_plugin_dir_additional)) {
|
180 |
|
|
while (false !== ($file = readdir($handle))) {
|
181 |
|
|
if (is_dir($_plugin_dir_additional . $file) && file_exists($_plugin_dir_additional . $file . '/plugin.js')) {
|
182 |
|
|
$source = file_get_contents($_plugin_dir_additional . $file . '/plugin.js');
|
183 |
|
|
$buttons = array();
|
184 |
|
|
if (preg_match_all($pattern, $source, $matches)) {
|
185 |
|
|
foreach ($matches[1] as $i => $button_name) {
|
186 |
|
|
if (preg_match('#(icon)[\s]*\:[\s]*([^\,\n]*)#', $matches[2][$i], $matches2)) {
|
187 |
|
|
$buttons[$button_name] = array();
|
188 |
|
|
$buttons[$button_name]['label'] = $button_name;
|
189 |
|
|
$matches2[2] = str_replace(array('this.path', '+', '\'', '"'), array('', '', '', ''), $matches2[2]);
|
190 |
|
|
$buttons[$button_name]['icon'] = trim($matches2[2]);
|
191 |
|
|
}
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
if (preg_match('#@file ([^\n\r]*)#', $source, $matches)) {
|
195 |
|
|
$plugins[$file] = array(
|
196 |
|
|
'name' => $file,
|
197 |
|
|
'desc' => check_plain($matches[1]),
|
198 |
|
|
'path' => $plugin_dir_additional . $file . '/',
|
199 |
|
|
'buttons' => (count($buttons) > 0) ? $buttons : FALSE,
|
200 |
|
|
'default' => 'f'
|
201 |
|
|
);
|
202 |
|
|
}
|
203 |
|
|
else {
|
204 |
|
|
$plugins[$file] = array(
|
205 |
|
|
'name' => $file,
|
206 |
|
|
'desc' => t('Plugin file: @plugin_filename', array('@plugin_filename' => $file)),
|
207 |
|
|
'path' => $plugin_dir_additional . $file . '/',
|
208 |
|
|
'buttons' => (count($buttons) > 0) ? $buttons : FALSE,
|
209 |
|
|
'default' => 'f'
|
210 |
|
|
);
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
closedir($handle);
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
// Remove the IMCE plugin if the IMCE module isn't installed.
|
219 |
|
|
if (isset($plugins['imce']) && module_exists('imce') == FALSE) {
|
220 |
|
|
unset($plugins['imce']);
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
// Enable the Drupal Breaks plugin by default if the plugin is available.
|
224 |
|
|
if (isset($plugins['drupalbreaks'])) {
|
225 |
|
|
$plugins['drupalbreaks']['default'] = 't';
|
226 |
|
|
|
227 |
|
|
// Remove the page break button if there is no module to handle it.
|
228 |
|
|
if (isset($plugins['drupalbreaks']['buttons']['DrupalPageBreak']) && !module_exists('paging') && !module_exists('pagebreak')) {
|
229 |
|
|
unset($plugins['drupalbreaks']['buttons']['DrupalPageBreak']);
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
return $plugins;
|
234 |
|
|
} |