-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathckeditor.php
More file actions
executable file
·61 lines (55 loc) · 1.4 KB
/
Copy pathckeditor.php
File metadata and controls
executable file
·61 lines (55 loc) · 1.4 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
<?php
/**
* CKEditor Field for Kirby 2
*
* @version 1.0.1
* @author David Hohl <david.hohl@gmail.com>
* @copyright David Hohl <david.hohl@gmail.com>
* @license GNU GPL v3.0 <http://opensource.org/licenses/GPL-3.0>
*/
/**
* CKEditor Field
*
* @since 1.0.0
*/
class ckeditorField extends InputField {
/**
* Define frontend assets
*
* @var array
* @since 1.0.0
*/
public static $assets = array(
'css' => array(
'ckeditor.css'
)
);
/**
* Create input element
*
* @since 1.0.0
*
* @return \Brick
*/
public function input()
{
// Set up textarea
$input = parent::input();
$input->tag('textarea');
$input->removeAttr('type');
$input->removeAttr('value');
$input->html($this->value() ?: false);
$input->data('field', 'ckeditorfield');
// Set up wrapping element
$wrapper = new Brick('div', false);
$wrapper->append($input);
$wrapper->append('<script src="'.str_replace('/panel/index.php','',$_SERVER['SCRIPT_NAME']) . '/site/fields/ckeditor/assets/js/ckeditor.js"></script><script>CKEDITOR.inline( "'.$this->name().'" );</script>');
return $wrapper;
}
public function element()
{
$element = parent::element();
$element->addClass('field-with-textarea');
return $element;
}
}