1 <?php
2
3 class SimpleWysiwygField extends TextareaField
4 {
5
6 private static $default_configuration = array();
7 private $configuration = array();
8
9 function __construct($name, $title = null, $config = array(), $rows = 15, $cols = 55, $value = "", $form = null)
10 {
11 parent::__construct($name, $title, $rows, $cols, $value, $form);
12
13 }
14
15 public static function set_default_configuration($conf)
16 {
17 self::$default_configuration = $conf;
18 }
19
20 public function configure($conf)
21 {
22 $this->configuration = $conf;
23 }
24
25 private function getConfiguration()
26 {
27 return !empty($this->configuration) ? $this->configuration : self::$default_configuration;
28 }
29
30 private function buildJS()
31 {
32 $js = "
33 $(function() {
34 $('#{$this->id()}').htmlbox().idir('dataobject_manager/code/simple_wysiwyg_field/images/')";
35 foreach($this->getConfiguration() as $row => $buttons) {
36 $r = $row+1;
37 $r = $r == 1 ? "" : ",$r";
38 foreach($buttons as $button)
39 $js .= $button == "|" ? ".separator('dots'$r)" : ".button('$button'$r)";
40 }
41 $js .= "
42 .init();
43 });";
44 return $js;
45 }
46
47
48 function Field()
49 {
50 Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js");
51 Requirements::javascript("dataobject_manager/code/simple_wysiwyg_field/javascript/htmlbox.min.js");
52 Requirements::javascript("dataobject_manager/code/simple_wysiwyg_field/javascript/xhtml.js");
53 Requirements::customScript($this->buildJS());
54 return parent::Field();
55 }
56
57 }
58
59
60
61
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-