MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
meditor.class
Ir para a documentação deste ficheiro.
1
<?php
2
32
class
MEditor
extends
MMultiLineField
33
{
34
const
BUTTON_SOURCE
=
'Source'
;
35
const
BUTTON_SAVE
=
'Save'
;
36
const
BUTTON_NEW_PAGE
=
'NewPage'
;
37
const
BUTTON_PREVIEW
=
'Preview'
;
38
const
BUTTON_TEMPLATES
=
'Templates'
;
39
const
BUTTON_CUT
=
'Cut'
;
40
const
BUTTON_COPY
=
'Copy'
;
41
const
BUTTON_PASTE
=
'Paste'
;
42
const
BUTTON_PASTE_TEXT
=
'PasteText'
;
43
const
BUTTON_PASTE_FROM_WORD
=
'PasteFromWord'
;
44
const
BUTTON_PRINT
=
'Print'
;
45
const
BUTTON_SPELL_CHECKER
=
'SpellChecker'
;
46
const
BUTTON_SCAYT
=
'Scayt'
;
47
const
BUTTON_UNDO
=
'Undo'
;
48
const
BUTTON_REDO
=
'Redo'
;
49
const
BUTTON_FIND
=
'Find'
;
50
const
BUTTON_REPLACE
=
'Replace'
;
51
const
BUTTON_SELECT_ALL
=
'SelectAll'
;
52
const
BUTTON_REMOVE_FORMAT
=
'RemoveFormat'
;
53
const
BUTTON_FORM
=
'Form'
;
54
const
BUTTON_CHECKBOX
=
'Checkbox'
;
55
const
BUTTON_RADIO
=
'Radio'
;
56
const
BUTTON_TEXT_FIELD
=
'TextField'
;
57
const
BUTTON_TEXT_AREA
=
'Textarea'
;
58
const
BUTTON_SELECT
=
'Select'
;
59
const
BUTTON_BUTTON
=
'Button'
;
60
const
BUTTON_IMAGE_BUTTON
=
'ImageButton'
;
61
const
BUTTON_HIDDEN_FIELD
=
'HiddenField'
;
62
const
BUTTON_BIDI_LTR
=
'BidiLtr'
;
63
const
BUTTON_BIDI_RTL
=
'BidiRtl'
;
64
const
BUTTON_BOLD
=
'Bold'
;
65
const
BUTTON_ITALIC
=
'Italic'
;
66
const
BUTTON_UNDERLINE
=
'Underline'
;
67
const
BUTTON_STRIKE
=
'Strike'
;
68
const
BUTTON_SUBSCRIPT
=
'Subscript'
;
69
const
BUTTON_SUPERSCRIPT
=
'Superscript'
;
70
const
BUTTON_NUMBERED_LIST
=
'NumberedList'
;
71
const
BUTTON_BULLETED_LIST
=
'BulletedList'
;
72
const
BUTTON_OUTDENT
=
'Outdent'
;
73
const
BUTTON_INDENT
=
'Indent'
;
74
const
BUTTON_BLOCKQUOTE
=
'Blockquote'
;
75
const
BUTTON_CREATE_DIV
=
'CreateDiv'
;
76
const
BUTTON_JUSTIFY_LEFT
=
'JustifyLeft'
;
77
const
BUTTON_JUSTIFY_CENTER
=
'JustifyCenter'
;
78
const
BUTTON_JUSTIFY_RIGHT
=
'JustifyRight'
;
79
const
BUTTON_JUSTIFY_BLOCK
=
'JustifyBlock'
;
80
const
BUTTON_LINK
=
'Link'
;
81
const
BUTTON_UNLINK
=
'Unlink'
;
82
const
BUTTON_ANCHOR
=
'Anchor'
;
83
const
BUTTON_IMAGE
=
'Image'
;
84
const
BUTTON_FLASH
=
'Flash'
;
85
const
BUTTON_TABLE
=
'Table'
;
86
const
BUTTON_HORIZONTAL_RULE
=
'HorizontalRule'
;
87
const
BUTTON_SMILEY
=
'Smiley'
;
88
const
BUTTON_SPECIAL_CHAR
=
'SpecialChar'
;
89
const
BUTTON_PAGE_BREAK
=
'PageBreak'
;
90
const
BUTTON_STYLES
=
'Styles'
;
91
const
BUTTON_FORMAT
=
'Format'
;
92
const
BUTTON_FONT
=
'Font'
;
93
const
BUTTON_FONT_SIZE
=
'FontSize'
;
94
const
BUTTON_TEXT_COLOR
=
'TextColor'
;
95
const
BUTTON_BG_COLOR
=
'BGColor'
;
96
const
BUTTON_MAXIMIZE
=
'Maximize'
;
97
const
BUTTON_SHOW_BLOCKS
=
'ShowBlocks'
;
98
const
BUTTON_ABOUT
=
'About'
;
99
const
BUTTON_SEPARATOR
=
'-'
;
100
const
BUTTON_LINE_SEPARATOR
=
'/'
;
101
102
private
$config;
103
111
public
function
__construct
(
$name
=NULL,
$value
=
''
,
$label
=
''
, $buttons=NULL, $buttonImage =
false
)
112
{
113
parent::__construct(
$name
,
$value
,
$label
);
114
115
if
( strpos(
MIOLO::getInstance
()->getTheme()->
id
,
"sbootstrap"
) ===
false
)
116
{
117
// update textarea valeu before doing field validation
118
$this->page->onsubmit(
"( CKEDITOR.instances['$name'].updateElement() || true )"
);
119
120
$this->page->addScript(
'ckeditor/ckeditor.js'
);
121
if
( !$buttons )
122
{
123
$buttons[] = array(self::BUTTON_BOLD, self::BUTTON_ITALIC, self::BUTTON_UNDERLINE);
124
$buttons[] = array(self::BUTTON_FONT, self::BUTTON_FONT_SIZE);
125
$buttons[] = array(self::BUTTON_TEXT_COLOR, self::BUTTON_BG_COLOR);
126
$buttons[] = array(self::BUTTON_LINK);
127
$buttons[] = array(self::BUTTON_JUSTIFY_LEFT, self::BUTTON_JUSTIFY_CENTER, self::BUTTON_JUSTIFY_RIGHT, self::BUTTON_JUSTIFY_BLOCK);
128
$buttons[] = array(self::BUTTON_NUMBERED_LIST, self::BUTTON_BULLETED_LIST, self::BUTTON_OUTDENT, self::BUTTON_INDENT);
129
$buttons[] = array(self::BUTTON_CUT, self::BUTTON_COPY, self::BUTTON_PASTE);
130
$buttons[] = array(self::BUTTON_UNDO, self::BUTTON_REDO);
131
if
( $buttonImage )
132
{
133
$buttons[] = array(self::BUTTON_IMAGE_BUTTON);
134
}
135
}
136
$this->
setButtons
($buttons);
137
}
138
139
$this->
setLanguage
($this->manager->getConf(
'i18n.language'
));
140
$this->
setClass
(
'm-editor'
);
141
}
142
149
public
function
setButtons
($buttons)
150
{
151
if
( !is_array($buttons) )
152
{
153
$buttons = array(array($buttons));
154
}
155
elseif ( !is_array($buttons[0]) )
156
{
157
$buttons = array($buttons);
158
}
159
160
$this->config[
'toolbar'
] = $buttons;
161
}
162
166
public
function
setLanguage
(
$lang
)
167
{
168
$this->config[
'language'
] =
$lang
;
169
}
170
174
public
function
setColor
($color)
175
{
176
$this->config[
'uiColor'
] = $color;
177
}
178
187
public
function
setConfigValue
($key,
$value
)
188
{
189
$this->config[$key] =
$value
;
190
}
191
196
public
function
getConfigValue
($key)
197
{
198
return
$this->config[$key];
199
}
200
204
public
function
getConfig
()
205
{
206
return
$this->config;
207
}
208
212
public
function
setConfig
($config)
213
{
214
$this->config = $config;
215
}
216
221
public
function
disableElementsPath
()
222
{
223
$removePlugins = array();
224
225
if
( $this->config[
'removePlugins'
] )
226
{
227
$removePlugins = explode(
','
, $this->config[
'removePlugins'
]);
228
}
229
230
$removePlugins[] =
'elementspath'
;
231
$this->config[
'removePlugins'
] = implode(
','
, array_unique($removePlugins));
232
}
233
237
public
function
enableElementsPath
()
238
{
239
if
( $this->config[
'removePlugins'
] )
240
{
241
$removePlugins = explode(
','
, $this->config[
'removePlugins'
]);
242
foreach
( $removePlugins as $key => $plugin )
243
{
244
if
( $plugin ==
'elementspath'
)
245
{
246
unset($removePlugins[$key]);
247
}
248
}
249
$this->config[
'removePlugins'
] = implode(
','
, $removePlugins);
250
}
251
}
252
258
public
function
generate
()
259
{
260
$MIOLO
=
MIOLO::getInstance
();
261
$jsonConfig = json_encode($this->config);
262
if
( strpos(
MIOLO::getInstance
()->getTheme()->
id
,
"sbootstrap"
) ===
false
)
263
{
264
$this->page->onload(
"CKEDITOR.replace('$this->name', $jsonConfig);"
);
265
}
266
else
267
{
268
$this->page->onload(
"
269
function InsertFile(editor){
270
editor.editing.view.document.on(
271
\"drop\",
272
async (event, data) => {
273
if (
274
data.dataTransfer.files &&
275
!data.dataTransfer.files[0].type.includes(\"image\")
276
) {
277
event.stop();
278
data.preventDefault();
279
insert(data.dataTransfer.files[0], editor);
280
}
281
},
282
{ priority: \"high\" }
283
);
284
285
editor.editing.view.document.on(
286
\"dragover\",
287
(event, data) => {
288
event.stop();
289
data.preventDefault();
290
},
291
{ priority: \"high\" }
292
);
293
}
294
295
function insert(file, editor) {
296
if (file) {
297
const form = new FormData();
298
form.append(\"Content-Type\", file.type);
299
form.append(\"upload\", file);
300
let httpRequest;
301
if (window.XMLHttpRequest) {
302
httpRequest = new XMLHttpRequest();
303
} else if (window.ActiveXObject) {
304
httpRequest = new ActiveXObject(\"Microsoft.XMLHTTP\");
305
}
306
httpRequest.open(\"POST\", \"/ckeditorUpload.php\", true);
307
httpRequest.onload = () => {
308
if (httpRequest.status === 200) {
309
const body = JSON.parse(httpRequest.responseText);
310
if (typeof body.error !== 'undefined'){
311
const error = body.error.message;
312
if(error.length > 0){
313
alert(error);
314
return;
315
}
316
}
317
const content = `<a target=\"_blank\" href=\"` + body.url + `\"/>` + file.name + `</a>`;
318
const viewFragment = editor.data.processor.toView(content);
319
const modelFragment = editor.data.toModel(viewFragment);
320
editor.model.insertContent(
321
modelFragment,
322
editor.model.document.selection
323
);
324
editor.editing.view.focus();
325
} else {
326
alert(
327
`Algo de errado com o upload do se arquivo, verifique a conexão e tente novamente!.
328
(` + httpRequest.status + ' - ' + httpRequest.statusText + `)`
329
);
330
}
331
};
332
httpRequest.send(form);
333
}
334
}
335
336
ClassicEditor
337
.create( document.querySelector( '[id=\"$this->name\"]' ), {
338
simpleUpload: {
339
uploadUrl: 'ckeditorUpload.php',
340
},
341
})
342
.then( editor => {
343
ck_editors.set('$this->name', editor );
344
InsertFile(editor);
345
editor.editing.view.change( writer => {
346
writer.setStyle('margin-bottom', '5px', editor.editing.view.document.getRoot());
347
writer.setStyle('min-height', '300px', editor.editing.view.document.getRoot());
348
writer.setStyle('max-height', '300px', editor.editing.view.document.getRoot());
349
});
350
351
var elementoOriginal = $('#m_$this->name').find('[data-cke-tooltip-text=\"Link (Ctrl+K)\"]');
352
353
var cloneElemento = elementoOriginal.clone();
354
355
cloneElemento.insertAfter(elementoOriginal);
356
357
cloneElemento.find('svg').remove();
358
cloneElemento.html('<svg class=\"ck ck-icon ck-reset_all-excluded ck-icon_inherit-color ck-button__icon\" viewBox=\"0 0 20 20\"><path d=\"M11.627 16.5zm5.873-.196zm0-7.001V8h-13v8.5h4.341c.191.54.457 1.044.785 1.5H2a1.5 1.5 0 0 1-1.5-1.5v-13A1.5 1.5 0 0 1 2 2h4.5a1.5 1.5 0 0 1 1.06.44L9.122 4H16a1.5 1.5 0 0 1 1.5 1.5v1A1.5 1.5 0 0 1 19 8v2.531a6.027 6.027 0 0 0-1.5-1.228zM16 6.5v-1H8.5l-2-2H2v13h1V8a1.5 1.5 0 0 1 1.5-1.5H16z\"></path><path d=\"M14.5 19.5a5 5 0 1 1 0-10 5 5 0 0 1 0 10zM15 14v-2h-1v2h-2v1h2v2h1v-2h2v-1h-2z\"></path></svg>');
359
cloneElemento.attr('data-cke-tooltip-text', 'Carregar documento do computador');
360
361
const inputElement = document.createElement(\"input\");
362
inputElement.type = \"file\";
363
inputElement.accept =
364
\".doc,.docx,.pdf,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text,application/zip,application/vnd.rar\";
365
inputElement.addEventListener(\"change\", (event) => {
366
insert(event.target.files[0], editor);
367
$(event.target).val('');
368
369
});
370
371
cloneElemento.on('click', function(){
372
inputElement.click();
373
});
374
375
} )
376
.catch( error => {
377
console.error( error );
378
} );
379
380
"
);
381
}
382
383
// Reset CSS dos títulos pre definidos no ckeditor
384
$MIOLO
->page->addStyleCode(
'
385
.ck-content h2 {
386
display: block;
387
font-size: 1.5em;
388
margin-block-start: 0.83em;
389
margin-block-end: 0.83em;
390
margin-inline-start: 0px;
391
margin-inline-end: 0px;
392
font-weight: bold;
393
unicode-bidi: isolate;
394
}
395
396
.ck-content h3 {
397
display: block;
398
font-size: 1.17em;
399
margin-block-start: 1em;
400
margin-block-end: 1em;
401
margin-inline-start: 0px;
402
margin-inline-end: 0px;
403
font-weight: bold;
404
unicode-bidi: isolate;
405
color: unset;
406
}
407
408
.ck-content h4 {
409
display: block;
410
font-size: unset;
411
margin-block-start: 1.33em;
412
margin-block-end: 1.33em;
413
margin-inline-start: 0px;
414
margin-inline-end: 0px;
415
font-weight: bold;
416
unicode-bidi: isolate;
417
}
418
419
.ck-source-editing-area {
420
min-height: 300px;
421
max-height: 300px;
422
margin-bottom:5px;
423
}
424
425
.ck-source-editing-area textarea {
426
overflow: auto;
427
}
428
429
.ck.ck-dropdown .ck-dropdown__arrow {
430
z-index: 0;
431
}
432
433
.image.ck-widget.ck-widget_selected.ck-widget_with-resizer {
434
z-index: 0;
435
}
436
'
);
437
438
return
parent::generate();
439
}
440
}
441
?>
MComponent\$name
$name
Definição
mcomponent.class:17
MEditor
Definição
meditor.class:33
MEditor\BUTTON_JUSTIFY_LEFT
const BUTTON_JUSTIFY_LEFT
Definição
meditor.class:76
MEditor\BUTTON_SUBSCRIPT
const BUTTON_SUBSCRIPT
Definição
meditor.class:68
MEditor\BUTTON_BOLD
const BUTTON_BOLD
Definição
meditor.class:64
MEditor\BUTTON_PASTE_FROM_WORD
const BUTTON_PASTE_FROM_WORD
Definição
meditor.class:43
MEditor\BUTTON_JUSTIFY_CENTER
const BUTTON_JUSTIFY_CENTER
Definição
meditor.class:77
MEditor\BUTTON_HIDDEN_FIELD
const BUTTON_HIDDEN_FIELD
Definição
meditor.class:61
MEditor\enableElementsPath
enableElementsPath()
Definição
meditor.class:237
MEditor\disableElementsPath
disableElementsPath()
Definição
meditor.class:221
MEditor\BUTTON_PASTE_TEXT
const BUTTON_PASTE_TEXT
Definição
meditor.class:42
MEditor\BUTTON_REPLACE
const BUTTON_REPLACE
Definição
meditor.class:50
MEditor\BUTTON_NUMBERED_LIST
const BUTTON_NUMBERED_LIST
Definição
meditor.class:70
MEditor\BUTTON_IMAGE_BUTTON
const BUTTON_IMAGE_BUTTON
Definição
meditor.class:60
MEditor\BUTTON_LINK
const BUTTON_LINK
Definição
meditor.class:80
MEditor\BUTTON_FONT_SIZE
const BUTTON_FONT_SIZE
Definição
meditor.class:93
MEditor\BUTTON_HORIZONTAL_RULE
const BUTTON_HORIZONTAL_RULE
Definição
meditor.class:86
MEditor\BUTTON_SUPERSCRIPT
const BUTTON_SUPERSCRIPT
Definição
meditor.class:69
MEditor\BUTTON_RADIO
const BUTTON_RADIO
Definição
meditor.class:55
MEditor\BUTTON_CREATE_DIV
const BUTTON_CREATE_DIV
Definição
meditor.class:75
MEditor\BUTTON_UNDO
const BUTTON_UNDO
Definição
meditor.class:47
MEditor\BUTTON_ITALIC
const BUTTON_ITALIC
Definição
meditor.class:65
MEditor\BUTTON_INDENT
const BUTTON_INDENT
Definição
meditor.class:73
MEditor\BUTTON_PASTE
const BUTTON_PASTE
Definição
meditor.class:41
MEditor\BUTTON_SOURCE
const BUTTON_SOURCE
Definição
meditor.class:34
MEditor\BUTTON_PREVIEW
const BUTTON_PREVIEW
Definição
meditor.class:37
MEditor\BUTTON_SPECIAL_CHAR
const BUTTON_SPECIAL_CHAR
Definição
meditor.class:88
MEditor\BUTTON_CUT
const BUTTON_CUT
Definição
meditor.class:39
MEditor\BUTTON_BIDI_LTR
const BUTTON_BIDI_LTR
Definição
meditor.class:62
MEditor\BUTTON_ABOUT
const BUTTON_ABOUT
Definição
meditor.class:98
MEditor\BUTTON_FONT
const BUTTON_FONT
Definição
meditor.class:92
MEditor\BUTTON_SPELL_CHECKER
const BUTTON_SPELL_CHECKER
Definição
meditor.class:45
MEditor\getConfig
getConfig()
Definição
meditor.class:204
MEditor\BUTTON_TABLE
const BUTTON_TABLE
Definição
meditor.class:85
MEditor\BUTTON_SEPARATOR
const BUTTON_SEPARATOR
Definição
meditor.class:99
MEditor\BUTTON_TEXT_AREA
const BUTTON_TEXT_AREA
Definição
meditor.class:57
MEditor\BUTTON_REDO
const BUTTON_REDO
Definição
meditor.class:48
MEditor\BUTTON_SCAYT
const BUTTON_SCAYT
Definição
meditor.class:46
MEditor\__construct
__construct($name=NULL, $value='', $label='', $buttons=NULL, $buttonImage=false)
Definição
meditor.class:111
MEditor\BUTTON_BULLETED_LIST
const BUTTON_BULLETED_LIST
Definição
meditor.class:71
MEditor\BUTTON_CHECKBOX
const BUTTON_CHECKBOX
Definição
meditor.class:54
MEditor\getConfigValue
getConfigValue($key)
Definição
meditor.class:196
MEditor\BUTTON_JUSTIFY_RIGHT
const BUTTON_JUSTIFY_RIGHT
Definição
meditor.class:78
MEditor\generate
generate()
Definição
meditor.class:258
MEditor\BUTTON_SAVE
const BUTTON_SAVE
Definição
meditor.class:35
MEditor\BUTTON_SMILEY
const BUTTON_SMILEY
Definição
meditor.class:87
MEditor\BUTTON_COPY
const BUTTON_COPY
Definição
meditor.class:40
MEditor\BUTTON_MAXIMIZE
const BUTTON_MAXIMIZE
Definição
meditor.class:96
MEditor\BUTTON_FORMAT
const BUTTON_FORMAT
Definição
meditor.class:91
MEditor\BUTTON_BUTTON
const BUTTON_BUTTON
Definição
meditor.class:59
MEditor\BUTTON_TEXT_COLOR
const BUTTON_TEXT_COLOR
Definição
meditor.class:94
MEditor\BUTTON_TEMPLATES
const BUTTON_TEMPLATES
Definição
meditor.class:38
MEditor\BUTTON_FORM
const BUTTON_FORM
Definição
meditor.class:53
MEditor\BUTTON_UNDERLINE
const BUTTON_UNDERLINE
Definição
meditor.class:66
MEditor\BUTTON_SELECT_ALL
const BUTTON_SELECT_ALL
Definição
meditor.class:51
MEditor\setLanguage
setLanguage($lang)
Definição
meditor.class:166
MEditor\setButtons
setButtons($buttons)
Definição
meditor.class:149
MEditor\BUTTON_NEW_PAGE
const BUTTON_NEW_PAGE
Definição
meditor.class:36
MEditor\BUTTON_SELECT
const BUTTON_SELECT
Definição
meditor.class:58
MEditor\BUTTON_UNLINK
const BUTTON_UNLINK
Definição
meditor.class:81
MEditor\BUTTON_FIND
const BUTTON_FIND
Definição
meditor.class:49
MEditor\BUTTON_LINE_SEPARATOR
const BUTTON_LINE_SEPARATOR
Definição
meditor.class:100
MEditor\BUTTON_OUTDENT
const BUTTON_OUTDENT
Definição
meditor.class:72
MEditor\BUTTON_BLOCKQUOTE
const BUTTON_BLOCKQUOTE
Definição
meditor.class:74
MEditor\BUTTON_FLASH
const BUTTON_FLASH
Definição
meditor.class:84
MEditor\BUTTON_BG_COLOR
const BUTTON_BG_COLOR
Definição
meditor.class:95
MEditor\BUTTON_BIDI_RTL
const BUTTON_BIDI_RTL
Definição
meditor.class:63
MEditor\BUTTON_TEXT_FIELD
const BUTTON_TEXT_FIELD
Definição
meditor.class:56
MEditor\BUTTON_JUSTIFY_BLOCK
const BUTTON_JUSTIFY_BLOCK
Definição
meditor.class:79
MEditor\BUTTON_PAGE_BREAK
const BUTTON_PAGE_BREAK
Definição
meditor.class:89
MEditor\BUTTON_SHOW_BLOCKS
const BUTTON_SHOW_BLOCKS
Definição
meditor.class:97
MEditor\setConfigValue
setConfigValue($key, $value)
Definição
meditor.class:187
MEditor\setColor
setColor($color)
Definição
meditor.class:174
MEditor\BUTTON_PRINT
const BUTTON_PRINT
Definição
meditor.class:44
MEditor\BUTTON_ANCHOR
const BUTTON_ANCHOR
Definição
meditor.class:82
MEditor\BUTTON_IMAGE
const BUTTON_IMAGE
Definição
meditor.class:83
MEditor\BUTTON_STYLES
const BUTTON_STYLES
Definição
meditor.class:90
MEditor\BUTTON_REMOVE_FORMAT
const BUTTON_REMOVE_FORMAT
Definição
meditor.class:52
MEditor\setConfig
setConfig($config)
Definição
meditor.class:212
MEditor\BUTTON_STRIKE
const BUTTON_STRIKE
Definição
meditor.class:67
MFormControl\$value
$value
Definição
mformcontrol.class:6
MFormControl\$label
$label
Definição
mformcontrol.class:5
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MMultiLineField
Definição
inputcontrols.class:132
MTextField\setClass
setClass($cssClass, $add=true)
Definição
inputcontrols.class:26
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
$lang
$lang
Definição
base.php:6
classes
ui
controls
meditor.class
Gerado por
1.10.0