This repository has been archived by the owner on Jun 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.editorinfo.php
269 lines (227 loc) · 7.06 KB
/
class.editorinfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?php
/**
* @module ckeditor
* @version see info.php of this module
* @authors Dietrich Roland Pehlke, erpe
* @copyright 2012-2018 Dietrich Roland Pehlke, erpe
* @license GNU General Public License
* @license terms see info.php of this module
*
*/
/**
* Class for the wysiwyg-admin.
*/
class editorinfo_CKEDITOR
{
/**
* @var string Holds the name of the editor - display inside wysiwyg-admin.
*/
protected $name = "CKEditor";
/**
* @var string Holds the guid of this class.
*/
protected $guid = "E3355C6B-794A-4E8C-A505-75A0C2AEFA4F";
/**
* @var string Holds the current version of this class.
*/
protected $version = "5.0.0.0";
/**
* @var string Holds the (last) author of this class.
*/
protected $author = "Dietrich Roland Pehlke (Aldus)";
/**
* @var array Holds the supported skins of this wysiwyg-editor.
*/
public $type = array(
'ClassicEditor',
'InlineEditor',
'BalloonEditor'
);
/**
* @var array Holds the supported skins of this wysiwyg-editor.
*/
public $skins = array(
'moono',
'moonocolor',
'moono-lisa'
);
/**
* @var array Holds the toolbar-definitions of this wysiwyg-editor.
*/
public $toolbars = array(
'Full' => array(
array ( 'Source','-','NewPage','Templates','Preview' ),
array ( 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','-','Scayt' ),
array ( 'Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat' ),
array ( 'Maximize','ShowBlocks','-','gMap','Code','About' ),
'/',
array ( 'Bold','Italic','Underline','Strike','-','Subscript','Superscript','Shy' ),
array ( 'NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv' ),
array ( 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ),
array ( 'Droplets', 'Pagelink', 'Link','Unlink','Anchor' ),
array ( 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar' ),
'/',
array ( 'Styles','Format','Font','FontSize' ),
array ( 'TextColor','BGColor' )
),
'Smart' => array(
array( 'Source', '-', 'Italic', 'Bold', 'Underline' ),
array( 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Droplets', 'Pagelink', '-', 'Print', 'SpellChecker', '-', 'Scayt' ),
array( 'Undo','Redo' ),
array( 'Image' ),
array( 'About' )
),
'Simple' => array(
array( 'Source', '-', 'Italic', 'Bold' ),
array( 'Image' ),
array( 'Droplets', 'Pagelink' ),
array( 'About' )
),
/**
* This one is for experimental use only. Use this one for your own studies and
* development e.g. own plugins, icons, tools, etc.
*
*/
'Experimental' => array(
array( 'Source', '-', 'Italic', 'Bold', 'Underline', 'Strike', '-', 'Undo', 'Redo' ),
array( 'Image', 'HorizontalRule', 'SpecialChar' ),
'/',
array( 'Droplets', 'Pagelink', '-', 'Unlink', 'Anchor', 'Link' ),
array( 'Shybutton', 'TextColor'),
array( 'About' )
)
);
/**
* @var string Holds the default width of this editor.
*/
public $default_width = "100%";
/**
* @var string Holds the default height of the editor.
*/
public $default_height = "250px";
/**
* The constructor of the class.
*/
public function __construct() {
}
/**
* The destructor of this class.
*/
public function __destruct() {
}
/**
* Generates a "select" (HTML-)tag
*
* @param string What (toolbars or skins)
* @param string Name of the select
* @param string Name of the selected item.
* @return string The generated (HTML-) select tag.
*
*/
public function build_select( $what="toolbars", $name="menu", $selected_item) {
switch( $what ) {
case "toolbars":
$data_ref = array_keys($this->toolbars);
break;
case 'skins':
$data_ref = &$this->skins;
break;
default:
return "";
}
$s = "\n<select name='".$name."'>\n";
foreach($data_ref as &$key) {
$s .= "<option name='".$key."' ".( $key == $selected_item ? "selected='selected'" : "" )."'>".$key."</option>\n";
}
$s .= "</select>\n";
return $s;
}
/**
* Looking for entries in the table of the wysiwyg-admin,
* if nothing found we fill it up within the "default" values of this editor.
* This function is called from the install.php and upgrade.php of this module.
*
* @param object A valid DB handle object. In LEPTON-CMS 1.3 it's an instance of PDO.
* DB connector has at last to support some methods:
* - list_tables (list of all installed tables inside the current database).
* - query (to execute a given query).
* - numRows (number of results of the last query).
* - build_mysql_query (for building MySQL queries)
*
* see class.database.php inside framework of LEPTON-CMS for details!.
*
*/
public function wysiwyg_admin_init( &$db_handle= NULL ) {
// Only execute if first param is set
if (NULL !== $db_handle) {
$ignore = TABLE_PREFIX;
$all_fields = $db_handle->list_tables( $ignore );
if (true == in_array("mod_wysiwyg_admin", $all_fields)) {
$table = TABLE_PREFIX."mod_wysiwyg_admin";
$temp_info = array();
$db_handle->execute_query(
"SELECT `id`,`skin`,`menu`,`height`,`width` from `".$table."` where `editor`='ckeditor' limit 0,1",
true,
$temp_info,
false
);
$toolbars = array_keys( $this->toolbars );
$fields = array(
'editor' => "ckeditor",
'skin' => $this->skins[0], // first entry
'menu' => $toolbars[0], // first entry
'width' => $this->default_width,
'height' => $this->default_height
);
if( 0 === count($temp_info))
{
$db_handle->build_and_execute( 'insert', $table, $fields );
} else {
$db_handle->build_and_execute( 'update', $table, $fields, "`id`=".$temp_info['id'] );
}
}
$this->__init_droplets( $db_handle );
}
}
/**
* CK-Editor 4 comes up within a "shy"-entitie plug-in which work
* together within a droplet.
*/
private function __init_droplets ( &$db_handle ) {
$droplet_name = "-"; // sic!
$droplet_desc = "Adds a shy-entity.";
$droplet_code = "return \"­\";";
$droplet_comment = "Adds a shy-entity. Used e.g. by the CK-Editor.";
$table = "mod_droplets";
$ignore = TABLE_PREFIX;
$all_tables = $db_handle->list_tables( $ignore );
if (true == in_array( $table, $all_tables))
{
$temp_info = array();
$db_handle->execute_query(
"SELECT `name` from `".TABLE_PREFIX.$table."` where `name`='".$droplet_name."'",
true,
$temp_info,
false
);
if ( 0 === count($temp_info) )
{
$fields = array(
'name' => $droplet_name,
'description' => $droplet_desc,
'code' => $droplet_code,
'active' => 1,
'modified_when' => TIME(),
'modified_by' => 1,
'comments' => $droplet_comment
);
$db_handle->build_and_execute(
'INSERT',
TABLE_PREFIX.$table,
$fields
);
}
}
}
}
?>