1: <?php
2: /**
3: * This file contains the abstract WYSIWYG editor class.
4: *
5: * @package Core
6: * @subpackage Backend
7: * @version SVN Revision $Rev:$
8: *
9: * @author Timo Hummel
10: * @copyright four for business AG <www.4fb.de>
11: * @license http://www.contenido.org/license/LIZENZ.txt
12: * @link http://www.4fb.de
13: * @link http://www.contenido.org
14: */
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: /**
19: * Base class for all WYSIWYG editors
20: *
21: * @package Core
22: * @subpackage Backend
23: */
24: abstract class cWYSIWYGEditor {
25:
26: /**
27: *
28: * @var string
29: */
30: protected $_sPath;
31:
32: /**
33: *
34: * @var string
35: */
36: protected $_sEditor;
37:
38: /**
39: *
40: * @var string
41: */
42: protected $_sEditorName;
43:
44: /**
45: *
46: * @var string
47: */
48: protected $_sEditorContent;
49:
50: /**
51: *
52: * @var array
53: */
54: protected $_aSettings;
55:
56: /**
57: *
58: * @param string $sEditorName
59: * @param string $sEditorContent
60: */
61: public function __construct($sEditorName, $sEditorContent) {
62: $cfg = cRegistry::getConfig();
63:
64: $this->_sPath = $cfg['path']['all_wysiwyg_html'];
65: $this->_setEditorName($sEditorName);
66: $this->_setEditorContent($sEditorContent);
67: }
68:
69: /**
70: *
71: * @param string $sContent
72: */
73: protected function _setEditorContent($sEditorContent) {
74: $this->_sEditorContent = $sEditorContent;
75: }
76:
77: /**
78: *
79: * @param string $sEditor
80: */
81: protected function _setEditor($sEditor) {
82: global $cfg;
83:
84: if (is_dir($cfg['path']['all_wysiwyg'] . $sEditor)) {
85: if (substr($sEditor, strlen($sEditor) - 1, 1) != "/") {
86: $sEditor = $sEditor . "/";
87: }
88:
89: $this->_sEditor = $sEditor;
90: }
91: }
92:
93: /**
94: * Sets given setting if setting was not yet defined.
95: * Overwriting defined setting can be achieved with $bForceSetting = true.
96: *
97: * @param string $sKey of setting to set
98: * @param string $sValue of setting to set
99: * @param bool $bForceSetting to overwrite defined setting
100: */
101: protected function _setSetting($sKey, $sValue, $bForceSetting = false) {
102: if ($bForceSetting || !array_key_exists($sKey, $this->_aSettings)) {
103: $this->_aSettings[$sKey] = $sValue;
104: }
105: }
106:
107: /**
108: *
109: * @param string $sKey
110: */
111: protected function _unsetSetting($sKey) {
112: unset($this->_aSettings[$sKey]);
113: }
114:
115: /**
116: *
117: * @return string
118: */
119: protected function _getEditorPath() {
120: return $this->_sPath . $this->_sEditor;
121: }
122:
123: /**
124: *
125: * @param string $sEditorName
126: */
127: protected function _setEditorName($sEditorName) {
128: $this->_sEditorName = $sEditorName;
129: }
130:
131: /**
132: *
133: * @throws cBadMethodCallException if this method is not overridden in the
134: * subclass
135: */
136: protected function _getScripts() {
137: throw new cBadMethodCallException('You need to override the method _getScripts');
138: }
139:
140: /**
141: *
142: * @throws cBadMethodCallException if this method is not overridden in the
143: * subclass
144: */
145: protected function _getEditor() {
146: throw new cBadMethodCallException('You need to override the method _getEditor');
147: }
148: }
149: