1 |
2
|
Manuela
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category modules
|
5 |
|
|
* @package ckeditor
|
6 |
|
|
* @authors WebsiteBaker Project, Michael Tenschert, Dietrich Roland Pehlke,D. Wöllbrink,Marmot
|
7 |
|
|
* @copyright WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://websitebaker.org/
|
9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.3
|
11 |
|
|
* @requirements PHP 5.3.6 and higher
|
12 |
|
|
* @version $Id$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
class CKEditorPlus extends CKEditor
|
19 |
|
|
{
|
20 |
|
|
public $pretty = true;
|
21 |
|
|
|
22 |
|
|
private $lookup_html = array(
|
23 |
|
|
'>' => ">",
|
24 |
|
|
'<' => "<",
|
25 |
|
|
'"' => "\"",
|
26 |
|
|
'&' => "&"
|
27 |
|
|
);
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Public var to force the editor to use the given params for width and height
|
31 |
|
|
*
|
32 |
|
|
*/
|
33 |
|
|
public $force = false;
|
34 |
|
|
|
35 |
|
|
public $paths = Array(
|
36 |
|
|
'contentsCss' => "",
|
37 |
|
|
'stylesSet' => "",
|
38 |
|
|
'templates_files' => "",
|
39 |
|
|
'customConfig' => ""
|
40 |
|
|
);
|
41 |
|
|
|
42 |
|
|
private $templateFolder = '';
|
43 |
|
|
|
44 |
|
|
public $files = array(
|
45 |
|
|
'contentsCss' => Array(
|
46 |
|
|
'/editor.css',
|
47 |
|
|
'/css/editor.css',
|
48 |
|
|
'/editor/editor.css'
|
49 |
|
|
),
|
50 |
|
|
'stylesSet' => Array(
|
51 |
|
|
'/editor.styles.js',
|
52 |
|
|
'/js/editor.styles.js',
|
53 |
|
|
'/editor/editor.styles.js'
|
54 |
|
|
),
|
55 |
|
|
'templates_files' => Array(
|
56 |
|
|
'/editor.templates.js',
|
57 |
|
|
'/js/editor.templates.js',
|
58 |
|
|
'/editor/editor.templates.js'
|
59 |
|
|
),
|
60 |
|
|
'customConfig' => Array(
|
61 |
|
|
'/wb_ckconfig.js',
|
62 |
|
|
'/js/wb_ckconfig.js',
|
63 |
|
|
'/editor/wb_ckconfig.js'
|
64 |
|
|
)
|
65 |
|
|
);
|
66 |
|
|
|
67 |
|
|
// public function __construct() { }
|
68 |
|
|
|
69 |
|
|
public function setTemplatePath ($templateFolder='')
|
70 |
|
|
{
|
71 |
|
|
// static $initComplete;
|
72 |
|
|
if($templateFolder=='') { return; }
|
73 |
|
|
$this->templateFolder = $templateFolder;
|
74 |
|
|
$_config = $this->config;
|
75 |
|
|
foreach($this->files as $key=>$val) {
|
76 |
|
|
foreach($val as $temp_path) {
|
77 |
|
|
$base = "/templates/".$this->templateFolder.$temp_path;
|
78 |
|
|
if (true == file_exists(WB_PATH.$base) ){
|
79 |
|
|
$this->paths[$key] = (($key=="stylesSet") ? "wb:" : "").WB_URL.$base;
|
80 |
|
|
break;
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
$this->config = array_merge($_config, $this->paths);;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
/**
|
88 |
|
|
* JavaScript handels LF/LB in another way as PHP, even inside an array.
|
89 |
|
|
* So we're in the need of pre-parse the entries.
|
90 |
|
|
*
|
91 |
|
|
*/
|
92 |
|
|
public function javascript_clean_str( &$aStr) {
|
93 |
|
|
$vars = array(
|
94 |
|
|
'"' => "\\\"",
|
95 |
|
|
'\'' => "",
|
96 |
|
|
"\n" => "<br />",
|
97 |
|
|
"\r" => ""
|
98 |
|
|
);
|
99 |
|
|
|
100 |
|
|
return str_replace( array_keys($vars), array_values($vars), $aStr);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
/**
|
104 |
|
|
* @param string Any HTML-Source, pass by reference
|
105 |
|
|
*
|
106 |
|
|
*/
|
107 |
|
|
public function reverse_htmlentities(&$html_source) {
|
108 |
|
|
|
109 |
|
|
$html_source = str_replace(
|
110 |
|
|
array_keys( $this->lookup_html ),
|
111 |
|
|
array_values( $this->lookup_html ),
|
112 |
|
|
$html_source
|
113 |
|
|
);
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
/** *************************************
|
117 |
|
|
* Additional test for the wysiwyg-admin
|
118 |
|
|
*/
|
119 |
|
|
|
120 |
|
|
/**
|
121 |
|
|
* @var boolean
|
122 |
|
|
*
|
123 |
|
|
*/
|
124 |
|
|
public $wysiwyg_admin_exists = false;
|
125 |
|
|
|
126 |
|
|
/**
|
127 |
|
|
* Public function to look for the wysiwyg-admin table in the used database
|
128 |
|
|
*
|
129 |
|
|
* @param object Any DB-Connector instance. Must be able to use a "query" method inside.
|
130 |
|
|
*
|
131 |
|
|
*/
|
132 |
|
|
public function looking_for_wysiwyg_admin( $db ) {
|
133 |
|
|
if ($db->query("SHOW TABLES LIKE '%mod_editor_admin'")->numRows())
|
134 |
|
|
$this->wysiwyg_admin_exists = true;
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
/**
|
138 |
|
|
* Looks for an (local) url
|
139 |
|
|
*
|
140 |
|
|
* @param string Key for tha assoc. config array
|
141 |
|
|
* @param string Local file we are looking for
|
142 |
|
|
* @param string Optional file-default-path if it not exists
|
143 |
|
|
* @param string Optional a path_addition, e.g. "wb:"
|
144 |
|
|
*
|
145 |
|
|
*/
|
146 |
|
|
public function resolve_path($key= "", $aPath, $aPath_default, $path_addition="")
|
147 |
|
|
{
|
148 |
|
|
static $initComplete = array();
|
149 |
|
|
$temp = WB_PATH.$aPath;
|
150 |
|
|
if (true === file_exists($temp)) {
|
151 |
|
|
$aPath = $path_addition.WB_URL.$aPath;
|
152 |
|
|
} else {
|
153 |
|
|
$aPath = $path_addition.WB_URL.$aPath_default;
|
154 |
|
|
}
|
155 |
|
|
if (array_key_exists($key, $this->paths)) {
|
156 |
|
|
$this->config[$key] = (($this->paths[$key ] == "") ? $aPath : $this->paths[$key]) ;
|
157 |
|
|
$initComplete[$key] = $this->config[$key];
|
158 |
|
|
} else {
|
159 |
|
|
$this->config[$key] = $aPath;
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
/**
|
165 |
|
|
* More or less for debugging
|
166 |
|
|
*
|
167 |
|
|
* @param string Name
|
168 |
|
|
* @param string Any content. Pass by reference!
|
169 |
|
|
* @return string The "editor"-JS HTML code
|
170 |
|
|
*
|
171 |
|
|
*/
|
172 |
|
|
public function to_HTML( $name, &$content, $config) {
|
173 |
|
|
$old_return = $this->bOutputAsBuffer;
|
174 |
|
|
$this->bOutputAsBuffer = true;
|
175 |
|
|
$temp_HTML = $this->editor( $name, $content, $config);
|
176 |
|
|
$this->bOutputAsBuffer = $old_return;
|
177 |
|
|
if (true === $this->pretty) {
|
178 |
|
|
$temp_HTML = str_replace (", ", ",\n ", $temp_HTML);
|
179 |
|
|
$temp_HTML = "\n\n\n".$temp_HTML."\n\n\n";
|
180 |
|
|
}
|
181 |
|
|
return $temp_HTML;
|
182 |
|
|
}
|
183 |
|
|
}
|