aboutsummaryrefslogtreecommitdiff
path: root/mod/ckeditor/start.php
blob: 62801eac37656e8992c99db0229e1df1c8425e5e (plain)
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
<?php
/**
 * CKEditor wysiwyg editor
 *
 * @package ElggCKEditor
 */

elgg_register_event_handler('init', 'system', 'ckeditor_init');

function ckeditor_init() {
	elgg_extend_view('css/elgg', 'ckeditor/css');
	elgg_extend_view('css/admin', 'ckeditor/css');

	$url = elgg_get_simplecache_url('css', 'wysiwyg');
	elgg_register_css('elgg.wysiwyg', $url);
	elgg_extend_view('css/wysiwyg', 'css/elements/reset', 100);
	elgg_extend_view('css/wysiwyg', 'css/elements/typography', 100);

	elgg_register_js('ckeditor', 'mod/ckeditor/vendors/ckeditor/ckeditor.js');
	elgg_register_js('elgg.ckeditor', elgg_get_simplecache_url('js', 'ckeditor'));
	elgg_register_simplecache_view('js/ckeditor');
	
	elgg_extend_view('input/longtext', 'ckeditor/init');
	
	elgg_extend_view('embed/custom_insert_js', 'ckeditor/embed_custom_insert_js');
	
	elgg_register_plugin_hook_handler('register', 'menu:longtext', 'ckeditor_longtext_menu');
}

function ckeditor_longtext_menu($hook, $type, $items, $vars) {
	
	$items[] = ElggMenuItem::factory(array(
		'name' => 'ckeditor_toggler',
		'link_class' => 'ckeditor-toggle-editor elgg-longtext-control',
		'href' => "#{$vars['id']}",
		'text' => elgg_echo('ckeditor:remove'),
	));
	
	return $items;
}