|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace SKien\Formgenerator; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* WYSIWYG - HTML input using TinyMCE. |
|
8
|
|
|
* |
|
9
|
|
|
* @see https://www.tiny.cloud/docs/tinymce/6/ |
|
10
|
|
|
* |
|
11
|
|
|
* @package Formgenerator |
|
12
|
|
|
* @author Stefanius <[email protected]> |
|
13
|
|
|
* @copyright MIT License - see the LICENSE file for details |
|
14
|
|
|
*/ |
|
15
|
|
|
class FormTinyMCE extends FormTextArea |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Creates a TinyMCE WYSIWYG editor. |
|
19
|
|
|
* @param string $strName |
|
20
|
|
|
* @param int $iRows |
|
21
|
|
|
* @param string $strWidth |
|
22
|
|
|
* @param int $wFlags |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct(string $strName, int $iRows, string $strWidth = '100%', int $wFlags = 0) |
|
25
|
|
|
{ |
|
26
|
|
|
// add 2 rows to increase height for toolbar |
|
27
|
|
|
parent::__construct($strName, 0, $iRows + 2, $strWidth, $wFlags); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
* @see \SKien\Formgenerator\FormElement::fromXML() |
|
33
|
|
|
*/ |
|
34
|
|
|
static public function fromXML(\DOMElement $oXMLElement, FormCollection $oFormParent) : ?FormElement |
|
35
|
|
|
{ |
|
36
|
|
|
$strName = self::getAttribString($oXMLElement, 'name'); |
|
37
|
|
|
$iRows = self::getAttribInt($oXMLElement, 'rows', 10); |
|
38
|
|
|
$strWidth = self::getAttribString($oXMLElement, 'width', '100%'); |
|
39
|
|
|
$wFlags = self::getAttribFlags($oXMLElement); |
|
40
|
|
|
$oFormElement = new self($strName, $iRows, $strWidth, $wFlags); |
|
41
|
|
|
$oFormParent->add($oFormElement); |
|
42
|
|
|
$oFormElement->readAdditionalXML($oXMLElement); |
|
43
|
|
|
return $oFormElement; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritDoc} |
|
48
|
|
|
* @see \SKien\Formgenerator\FormElement::readAdditionalXML() |
|
49
|
|
|
*/ |
|
50
|
|
|
public function readAdditionalXML(\DOMElement $oXMLElement) : void |
|
51
|
|
|
{ |
|
52
|
|
|
parent::readAdditionalXML($oXMLElement); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Load some configuratin after parent set. |
|
57
|
|
|
* {@inheritDoc} |
|
58
|
|
|
* @see \SKien\Formgenerator\FormElement::onParentSet() |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function onParentSet() : void |
|
61
|
|
|
{ |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Build TinyMCE specific styles. |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getStyle() : string |
|
69
|
|
|
{ |
|
70
|
|
|
$strStyle = ''; |
|
71
|
|
|
return $strStyle; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|