1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Editor;
13
14 use Brickrouge\Document;
15 use Brickrouge\Element;
16
17 18 19
20 class RTEEditorElement extends Element implements EditorElement
21 {
22 const ACTIONS = '#rteeditorelement-actions';
23
24 static protected function add_assets(Document $document)
25 {
26 parent::add_assets($document);
27
28 $document->css->add('assets/editor.css');
29 $document->js->add('assets/editor.js');
30 }
31
32 public function __construct(array $attributes=array())
33 {
34 parent::__construct
35 (
36 'textarea', $attributes + array
37 (
38 'class' => 'editor moo',
39
40 'rows' => 16
41 )
42 );
43 }
44
45 46 47 48 49
50 public function alter_dataset(array $dataset)
51 {
52 global $core;
53
54 $dataset = parent::alter_dataset($dataset);
55
56 $document = $core->document;
57
58 $css = $this[self::STYLESHEETS] ?: array();
59
60 $css[] = Document::resolve_url(\Brickrouge\ASSETS . 'brickrouge.css');
61
62 if (!$css)
63 {
64 $info = \Icybee\Modules\Pages\Module::get_template_info('page.html');
65
66 if (isset($info[1]))
67 {
68 $css = $info[1];
69 }
70 }
71
72 array_unshift($css, Document::resolve_url('assets/body.css'));
73
74 $try = \ICanBoogie\DOCUMENT_ROOT . 'public/page.css';
75
76 if (file_exists($try))
77 {
78 $css[] = Document::resolve_url($try);
79 }
80
81 $actions = $this[self::ACTIONS] ?: 'standard';
82
83 if ($actions == 'standard')
84 {
85 $actions = 'bold italic underline strikethrough | formatBlock justifyleft justifyright justifycenter justifyfull | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | image | removeformat paste outline toggleview';
86
87 if (0)
88 {
89 $actions .= ' / tableadd | tableedit | tablerowspan tablerowsplit tablerowdelete | tablecolspan tablecolsplit tablecoldelete';
90
91 $document->css->add('mooeditable/Assets/MooEditable/MooEditable.Table.css');
92 $document->js->add('mooeditable/Source/MooEditable/MooEditable.Table.js');
93 }
94 }
95 else if ($actions == 'minimal')
96 {
97 $actions = 'bold italic underline strikethrough | insertunorderedlist insertorderedlist | undo redo | createlink unlink | removeformat paste toggleview';
98 }
99
100 $dataset['base-url'] = '/';
101 $dataset['actions'] = $actions;
102 $dataset['external-css'] = $css;
103
104 return $dataset;
105 }
106 }