-
Notifications
You must be signed in to change notification settings - Fork 2
/
include.php
139 lines (120 loc) · 5.06 KB
/
include.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
<?php
/**
* WBCE CMS
* Way Better Content Editing.
* Visit https://wbce.org to learn more and to join the community.
*
* @copyright Ryan Djurovich (2004-2009)
* @copyright WebsiteBaker Org. e.V. (2009-2015)
* @copyright WBCE Project (2015-)
* @license GNU GPL2 (or any later version)
*/
//no direct file access
if (count(get_included_files()) == 1) {
$z = "HTTP/1.0 404 Not Found";
header($z);
die($z);
}
if (defined('WB_FRONTEND') && WB_FRONTEND == true) {
/**
* do nothing
*/
} else {
/**
* Function called by parent, default by the wysiwyg-module
* @param string The name of the textarea to watch
* @param mixed The "id" - some other modules handel this param differ
* @param string Optional the width, default "100%" of given space.
* @param string Optional the height of the editor - default is '250px'
*/
function show_wysiwyg_editor($name, $id, $content, $width = '100%', $height = '350px', $toolbar = false)
{
global $database;
$oApp = isset($GLOBALS['admin']) ? $GLOBALS['admin'] : $GLOBALS['wb'];
$modAbsPath = str_replace('\\', '/', dirname(__FILE__));
$ckeAbsPath = $modAbsPath . '/ckeditor/';
if (isset($_SERVER['SCRIPT_FILENAME'])) {
$realPath = str_replace('\\', '/', dirname($_SERVER['SCRIPT_FILENAME']));
} else {
/**
* realpath - Returns canonicalized absolute pathname
*/
$realPath = str_replace('\\', '/', realpath('./'));
}
$selfPath = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
$documentRoot = str_replace('\\', '/', realpath(substr($realPath, 0, strlen($realPath) - strlen($selfPath))));
$tplAbsPath = str_replace('\\', '/', $documentRoot . '/templates');
$tplRelPath = str_replace($documentRoot, '', $tplAbsPath);
$modRelPath = str_replace($documentRoot, '', $modAbsPath);
$ckeRelPath = $modRelPath . '/ckeditor/';
$url = parse_url(WB_URL);
$url['path'] = (isset($url['path']) ? $url['path'] : '');
$ModPath = str_replace($url['path'], '', $modRelPath);
$ckeModPath = str_replace($url['path'], '', $ckeRelPath);
$tplPath = str_replace($url['path'], '', $tplRelPath);
/**
* Create new CKeditor instance.
* But first - we've got to revamp this pretty old class a little bit.
*/
require($modAbsPath.'/info.php');
require_once($ckeAbsPath.'ckeditor.php'); // $ckeAbsPath ends with /
require_once($ckeAbsPath.'CKEditorPlus.php');
$ckeditor = new CKEditorPlus($ckeRelPath);
$ckeditor->config['ModulVersion'] = isset($module_version) ? $module_version : 'none';
$temp = '';
if (isset($oApp->page_id)) {
$query = "SELECT `template` from `{TP}pages` where `page_id`='" . (int) $oApp->page_id . "'";
$temp = $database->get_one($query);
}
$templateFolder = ($temp == "") ? DEFAULT_TEMPLATE : $temp;
$ckeditor->setTemplatePath($templateFolder);
/**
* Set user language
*/
$ckeditor->config['language'] = strtolower(LANGUAGE);
/**
* The language to be used if config.language is empty and it's not possible to localize the editor to the user language.
*/
$ckeditor->config['defaultLanguage'] = strtolower(DEFAULT_LANGUAGE);
/**
* Looking for the styles
*/
$ckeditor->resolve_path(
$tplPath.'/wb_config/editor.css',
$ModPath.'/ckeditor/contents.css',
'contentsCss'
);
/**
* Looking for the editor.styles at all ...
*/
$ckeditor->resolve_path(
$tplPath.'/wb_config/editor.styles.js',
$ModPath.'/ckeditor/styles.js',
'stylesSet',
'wb:'
);
/**
* Call the filebrowser
*/
$ckeditor->config['filebrowserBrowseUrl'] = $url['path'] . '/modules/elfinder/ef/elfinder_cke.php';
/**
* Define all extra CKEditor plugins here
*/
$ckeditor->config['extraPlugins'] = 'ckawesome,codemirror,textselection,wbdroplets,wbembed,wblink,wbsave,wbshybutton,autolink,colorbutton,copyformatting,font,indentblock,justify,lineutils,panelbutton,textmatch,widgetselection';
$ckeditor->config['removePlugins'] = 'save,pastetext,pastefromword';
$ckeditor->config['removeButtons'] = 'Font,Cut,Copy,Paste';
$ckeditor->config['fontawesomePath'] = WB_URL . '/include/font-awesome/css/font-awesome.min.css';
if ($toolbar) {
$ckeditor->config['toolbar'] = $toolbar;
}
$ckeditor->config['height'] = $height;
$ckeditor->config['width'] = $width;
/**
* Force the object to print/echo direct instead of returning the
* HTML source string.
*/
$ckeditor->returnOutput = false;
$ckeditor->reverse_htmlentities($content);
echo $ckeditor->to_HTML($name, $content, $ckeditor->config);
}
}