This repository was 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
Expand file tree
/
Copy pathinclude.php
More file actions
256 lines (219 loc) · 7.28 KB
/
include.php
File metadata and controls
256 lines (219 loc) · 7.28 KB
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
<?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
*
*/
// include class.secure.php to protect this file and the whole CMS!
if (defined('LEPTON_PATH')) {
include(LEPTON_PATH.'/framework/class.secure.php');
} else {
$oneback = "../";
$root = $oneback;
$level = 1;
while (($level < 10) && (!file_exists($root.'/framework/class.secure.php'))) {
$root .= $oneback;
$level += 1;
}
if (file_exists($root.'/framework/class.secure.php')) {
include($root.'/framework/class.secure.php');
} else {
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
}
}
// end include class.secure.php
global $id_list;
global $database;
/**
* returns the template name of the current displayed page
*
* @param string A path to the editor.css - if there is one. Default is an empty string. Pass by reference!
* @return STR $tiny_template_dir
*/
function get_template_name( &$css_path = "") {
global $database;
$lookup_paths = array(
'/css/editor.css',
'/editor.css'
);
$cke_template_dir = "none";
/**
* Looking up for an editor.css file
*
*/
foreach($lookup_paths as $temp_path) {
if (file_exists(LEPTON_PATH .'/templates/' .DEFAULT_TEMPLATE .$temp_path ) ) {
$css_path = $temp_path; // keep in mind, that this one is pass_by_reference
$cke_template_dir = DEFAULT_TEMPLATE;
break;
}
}
// check if a editor.css file exists in the specified template directory of current page
if (isset($_GET["page_id"]) && ((int) $_GET["page_id"] > 0)) {
$pageid = (int) $_GET["page_id"];
// obtain template folder of current page from the database
$query_page = "SELECT `template` FROM `" .TABLE_PREFIX ."pages` WHERE `page_id`='".$pageid."'";
$pagetpl = $database->get_one($query_page);
/**
* check if a specific template is defined for current page
*
*/
if (isset($pagetpl) && ($pagetpl != '')) {
/**
* check if a specify editor.css file is contained in that folder
*
*/
foreach($lookup_paths as $temp_path) {
if (file_exists(LEPTON_PATH.'/templates/'.$pagetpl.$temp_path)) {
$css_path = $temp_path; // keep in mind, that this one is pass_by_reference
$cke_template_dir = $pagetpl;
break;
}
}
}
}
return $cke_template_dir;
} // get_template_name()
/**
* Initialize CKE and create an textarea
*
* @param STR $name Name of the textarea.
* @param STR $id Id of the textarea.
* @param STR $content The content to edit.
* @param INT $width The width of the editor, overwritten by wysiwyg-admin.
* @param INT $height The height of the editor, overwritten by wysiwyg-admin.
* @param BOOL $prompt Direct output to the client via echo (true) or returnd as HTML-textarea (false)?
* @return MIXED Could be a BOOL or STR (textarea-tags).
*
*/
function show_wysiwyg_editor( $name, $id, $content, $width=NULL, $height=NULL, $prompt=true) {
global $id_list;
global $database;
global $parser; // twig parser
global $loader; // twig file manager
/**
* 0.1 Get Twig
*/
if (!is_object($parser)) require_once( LEPTON_PATH."/modules/lib_twig/library.php" );
// prependpath to make sure twig is looking in this module template folder first
$loader->prependPath( dirname(__FILE__)."/templates/" );
/**
* 0.2 Get the "defaults" from the editorinfo.php
*
require_once( dirname(__FILE__)."/class.editorinfo.php" );
$oCKE_info = new editorinfo_CKEDITOR();
$toolbar = $oCKE_info->toolbars[ $oCKE_info->default_toolbar ];
$skin = $oCKE_info->default_skin;
if( $width === NULL ) $width = $oCKE_info->default_width;
if( $height === NULL ) $height = $oCKE_info->default_height;
*/
/** *****
* 1. CKE main script part
*
*/
/**
* make sure that the script-part is only load/generated once
*
*/
if (!defined("cke_loaded")) {
define("cke_loaded", true);
$cke_url = LEPTON_URL."/modules/ckeditor/ckeditor";
$temp_css_path = "/editor.css";
$template_name = get_template_name( $temp_css_path );
/**
* If editor.css file exists in default template folder or template folder of current page
* See: http://www.tinymce.com/wiki.php/Configuration:content_css
*/
$css_file = '"'.LEPTON_URL .'/templates/' .$template_name .$temp_css_path.'"';
if ( !file_exists (LEPTON_PATH .'/templates/' .$template_name .$temp_css_path) )
{
$css_file = "''";
}
/**
* If backend.css file exists in default theme folder overwrite module backend.css
*/
$backend_css = LEPTON_URL.'/templates/'.DEFAULT_THEME.'/backend/ckeditor/backend.css';
if(!file_exists(LEPTON_PATH.'/templates/'.DEFAULT_THEME.'/backend/ckeditor/backend.css')) {
$backend_css = LEPTON_URL.'/modules/ckeditor/css/backend.css';
}
/**
* Include language file
* If the file is not found (local) we use an empty string,
* TinyMCE will use english as the defaut language in this case.
*/
$lang = strtolower( LANGUAGE );
$language = (file_exists( dirname(__FILE__)."/tinymce/langs/". $lang .".js" )) ? $lang : "";
/**
* Get wysiwyg-admin information for this editor.
*
*/
$strip = TABLE_PREFIX;
$all_tables= $database->list_tables( $strip );
if (in_array("mod_wysiwyg_admin", $all_tables)) {
$wysiwyg_admin_editor_settings = array();
$database->execute_query(
"SELECT `skin`, `menu`,`width`,`height` from `".TABLE_PREFIX."mod_wysiwyg_admin` where `editor` ='ckeditor'",
true,
$wysiwyg_admin_editor_settings,
false
);
if (count($wysiwyg_admin_editor_settings) > 0) {
$width = $wysiwyg_admin_editor_settings['width'];
$height = $wysiwyg_admin_editor_settings['height'];
// $skin = $wysiwyg_admin_editor_settings['skin'];
// $toolbar = $oCKE_info->toolbars[ $wysiwyg_admin_editor_settings['menu'] ];
}
}
// define filemanager url and access keys
$filemanager_url = LEPTON_URL."/modules/lib_r_filemanager";
$akey = password_hash( LEPTON_GUID, PASSWORD_DEFAULT);
$akey = str_replace(array('$','/'),'',$akey);
$akey = substr($akey, -30);
$_SESSION['rfkey'] = $akey;
$data = array(
'filemanager_url'=> $filemanager_url,
'LEPTON_URL' => LEPTON_URL,
'ACCESS_KEY' => $akey,
'cke_url' => $cke_url,
'backend_css' => $backend_css,
'selector' => 'textarea[id!=no_wysiwyg]',
'language' => $language,
'width' => $width,
'height' => $height,
'css_file' => $css_file,
'id' => $id,
// 'toolbar' => $toolbar,
// 'skin' => $skin
);
echo $parser->render(
"ckeditor.lte", // template-filename
$data // template-data
);
}
/** *****
* 2. textarea part
*
*/
// values for the textarea
$data = array(
'id' => $id,
'name' => $name,
'content' => htmlspecialchars_decode( $content ),
'width' => $width,
'height' => $height
);
$result = $parser->render(
'textarea.lte', // template-filename
$data // template-data
);
if ($prompt) {
echo $result;
return true;
}
return $result;
} // show_wysiwyg_editor()
?>