| 1 |
2
|
Manuela
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
|
|
* @category modules
|
| 5 |
|
|
* @package ckeditor
|
| 6 |
|
|
* @authors WebsiteBaker Project, Michael Tenschert, Dietrich Roland Pehlke, Marmot, Luisehahne
|
| 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 |
|
|
* Function called by parent, default by the wysiwyg-module
|
| 19 |
|
|
*
|
| 20 |
|
|
* @param string The name of the textarea to watch
|
| 21 |
|
|
* @param mixed The "id" - some other modules handel this param differ
|
| 22 |
|
|
* @param string Optional the width, default "100%" of given space.
|
| 23 |
|
|
* @param string Optional the height of the editor - default is '250px'
|
| 24 |
|
|
*
|
| 25 |
|
|
*
|
| 26 |
|
|
*/
|
| 27 |
|
|
function show_wysiwyg_editor(
|
| 28 |
|
|
$name,
|
| 29 |
|
|
$id,
|
| 30 |
|
|
$content,
|
| 31 |
|
|
$width = '100%',
|
| 32 |
|
|
$height = '250px',
|
| 33 |
|
|
$toolbar = false,
|
| 34 |
|
|
$OutputAsBuffer=false
|
| 35 |
|
|
) {
|
| 36 |
|
|
global $database,$admin, $section_id;
|
| 37 |
|
|
|
| 38 |
|
|
$modAbsPath = str_replace('\\','/',dirname(__FILE__));
|
| 39 |
|
|
$ckeAbsPath = $modAbsPath.'/ckeditor/';
|
| 40 |
|
|
if (isset($_SERVER['SCRIPT_FILENAME'])) {
|
| 41 |
|
|
$realPath = str_replace('\\','/',dirname($_SERVER['SCRIPT_FILENAME']));
|
| 42 |
|
|
} else {
|
| 43 |
|
|
/**
|
| 44 |
|
|
* realpath - Returns canonicalized absolute pathname
|
| 45 |
|
|
*/
|
| 46 |
|
|
$realPath = str_replace('\\','/',realpath( './' )) ;
|
| 47 |
|
|
}
|
| 48 |
|
|
|
| 49 |
|
|
$selfPath = str_replace('\\','/',dirname($_SERVER['SCRIPT_NAME']));
|
| 50 |
|
|
$documentRoot = str_replace('\\','/',realpath(substr($realPath, 0, strlen($realPath) - strlen($selfPath))));
|
| 51 |
|
|
$tplAbsPath = str_replace('\\','/',$documentRoot.'/templates');
|
| 52 |
|
|
$tplRelPath = str_replace($documentRoot,'',$tplAbsPath);
|
| 53 |
|
|
$modRelPath = str_replace($documentRoot,'',$modAbsPath);
|
| 54 |
|
|
$ckeRelPath = $modRelPath.'/ckeditor/';
|
| 55 |
|
|
|
| 56 |
|
|
$url = parse_url(WB_URL);
|
| 57 |
|
|
$url['path'] = (isset($url['path']) ? $url['path'] : '');
|
| 58 |
|
|
$ModPath = str_replace($url['path'],'',$modRelPath).'/';
|
| 59 |
|
|
$ckeModPath = str_replace($url['path'],'',$ckeRelPath);
|
| 60 |
|
|
$tplPath = str_replace($url['path'],'',$tplRelPath).'/';
|
| 61 |
|
|
require ( $modAbsPath.'/info.php' );
|
| 62 |
|
|
/**
|
| 63 |
|
|
* http://docs.ckeditor.com/#!/api/CKEDITOR.config
|
| 64 |
|
|
*
|
| 65 |
|
|
* @param boolean
|
| 66 |
|
|
* true: set some config.index by wb_config.js
|
| 67 |
|
|
* false: set some config['index'] by include.php
|
| 68 |
|
|
*
|
| 69 |
|
|
* possible config.indexes for setting in wb_config.js
|
| 70 |
|
|
* that were normaly set in include.php
|
| 71 |
|
|
* format_tags, resize_dir, autoParagraph, skin, toolbar,
|
| 72 |
|
|
* extraPlugins, removePlugins, browserContextMenuOnCtrl, entities,
|
| 73 |
|
|
* scayt_autoStartup,
|
| 74 |
|
|
*
|
| 75 |
|
|
*
|
| 76 |
|
|
*/
|
| 77 |
|
|
$bWbConfigSetting = false;
|
| 78 |
|
|
|
| 79 |
|
|
/**
|
| 80 |
|
|
* Create new CKeditor instance.
|
| 81 |
|
|
* But first - we've got to revamp this pretty old class a little bit.
|
| 82 |
|
|
*
|
| 83 |
|
|
*/
|
| 84 |
|
|
if (!file_exists($ckeAbsPath.'CKEditor.php')) {
|
| 85 |
|
|
throw new RuntimeException('Error loading editor file CKEditor.php, please check configuration');
|
| 86 |
|
|
}
|
| 87 |
|
|
if ( !class_exists('CKEditor', false )) { require ($ckeAbsPath.'CKEditor.php'); }
|
| 88 |
|
|
if ( !class_exists('CKEditorPlus', false )) { require ($ckeAbsPath.'CKEditorPlus.php'); } // $ckeAbsPath ends with /
|
| 89 |
|
|
|
| 90 |
|
|
$ckeditor = new CKEditorPlus( $ckeRelPath );
|
| 91 |
|
|
/******************************************************************************************/
|
| 92 |
|
|
|
| 93 |
|
|
$ckeditor->config['ModulVersion'] = isset($module_version) ? $module_version : 'none';
|
| 94 |
|
|
$ckeditor->config['WBrevision'] = defined('REVISION') ? REVISION : '';
|
| 95 |
|
|
$ckeditor->config['WBversion'] = defined('VERSION') ? VERSION : '';
|
| 96 |
|
|
|
| 97 |
|
|
/******************************************************************************************/
|
| 98 |
|
|
|
| 99 |
|
|
$temp = '';
|
| 100 |
|
|
if (isset($admin->page_id)) {
|
| 101 |
|
|
$query = "SELECT `template` from `".TABLE_PREFIX."pages` where `page_id`='".intval($page_id)."'";
|
| 102 |
|
|
$temp = $database->get_one( $query );
|
| 103 |
|
|
}
|
| 104 |
|
|
$templateFolder = ($temp == "") ? DEFAULT_TEMPLATE : $temp;
|
| 105 |
|
|
$ckeditor->setTemplatePath($templateFolder);
|
| 106 |
|
|
|
| 107 |
|
|
// The language to be used if config.language is empty and it's not possible to localize the editor to the user language.
|
| 108 |
|
|
// $ckeditor->config['defaultLanguage'] = strtolower(DEFAULT_LANGUAGE);
|
| 109 |
|
|
$ckeditor->config['defaultLanguage'] = 'en';
|
| 110 |
|
|
|
| 111 |
|
|
/**
|
| 112 |
|
|
* Setup the CKE language
|
| 113 |
|
|
*
|
| 114 |
|
|
*/
|
| 115 |
|
|
$ckeditor->config['language'] = strtolower( (@LANGUAGE ?: 'en') );
|
| 116 |
|
|
|
| 117 |
|
|
/**
|
| 118 |
|
|
* A list of semi colon separated style names (by default tags) representing
|
| 119 |
|
|
* the style definition for each entry to be displayed in the Format combo in
|
| 120 |
|
|
* the toolbar. Each entry must have its relative definition configuration in a
|
| 121 |
|
|
* setting named "format_(tagName)". For example, the "p" entry has its
|
| 122 |
|
|
* definition taken from config.format_p.
|
| 123 |
|
|
* @type String
|
| 124 |
|
|
* @default 'p;h1;h2;h3;h4;h5;h6;pre;address;div'
|
| 125 |
|
|
*/
|
| 126 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['format_tags'] = 'p;div;h1;h2;h3;h4;h5;h6;pre'; }
|
| 127 |
|
|
|
| 128 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['resize_dir'] = 'both'; }
|
| 129 |
|
|
|
| 130 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['autoParagraph'] = false; }
|
| 131 |
|
|
|
| 132 |
|
|
/**
|
| 133 |
|
|
* The skin to load. It may be the name of the skin folder inside the editor installation path,
|
| 134 |
|
|
* or the name and the path separated by a comma.
|
| 135 |
|
|
* Available skins: moono, moonocolor, kama, bootstrapck
|
| 136 |
|
|
*
|
| 137 |
|
|
*/
|
| 138 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['skin'] = 'moonocolor'; }
|
| 139 |
|
|
|
| 140 |
|
|
/**
|
| 141 |
|
|
* Additional test for wysiwyg-admin
|
| 142 |
|
|
*
|
| 143 |
|
|
*/
|
| 144 |
|
|
$ckeditor->looking_for_wysiwyg_admin( $database );
|
| 145 |
|
|
|
| 146 |
|
|
/**
|
| 147 |
|
|
* Define all extra CKEditor plugins in _yourwb_/modules/ckeditor067/ckeditor/plugins here
|
| 148 |
|
|
*
|
| 149 |
|
|
*/
|
| 150 |
|
|
if (!$bWbConfigSetting ) {
|
| 151 |
|
|
$ckeditor->config['extraPlugins'] = 'justify,find,flash,colorbutton,colordialog,dialogadvtab,autogrow'
|
| 152 |
|
|
. ',div,font,forms,iframe,indentblock,bidi,liststyle,pagebreak'
|
| 153 |
|
|
. ',selectall,showblocks,smiley,templates,codemirror,syntaxhighlight'
|
| 154 |
|
|
. ',wblink,wbdroplets,oembed,backup,wbabout,wbrelation,filebrowser'
|
| 155 |
|
|
. ''
|
| 156 |
|
|
. '';
|
| 157 |
|
|
|
| 158 |
|
|
$ckeditor->config['removePlugins'] = 'link,wsc,save,newpage,print,shybutton,preview,wbsave,youtube'
|
| 159 |
|
|
. ',sourcearea,sourcedialog,imageresponsive,image2,language,flash,alphamanager'
|
| 160 |
|
|
. ',placeholder';
|
| 161 |
|
|
}
|
| 162 |
|
|
|
| 163 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['uiColor'] = '#BFD7EB'; }
|
| 164 |
|
|
|
| 165 |
|
|
//if ($toolbar && !$bWbConfigSetting) {$ckeditor->config['toolbar'] = $toolbar;}
|
| 166 |
|
|
if ($toolbar) {$ckeditor->config['toolbar'] = $toolbar;}
|
| 167 |
|
|
|
| 168 |
|
|
/**
|
| 169 |
|
|
* Whether to show the browser native context menu when the Ctrl
|
| 170 |
|
|
* or Meta (Mac) key is pressed on opening the context menu with the right mouse button click or the Menu key.
|
| 171 |
|
|
*
|
| 172 |
|
|
*/
|
| 173 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['browserContextMenuOnCtrl'] = true; }
|
| 174 |
|
|
|
| 175 |
|
|
/**
|
| 176 |
|
|
* Force the object to print/echo direct instead of returning the
|
| 177 |
|
|
* HTML source string.
|
| 178 |
|
|
*
|
| 179 |
|
|
*/
|
| 180 |
|
|
$ckeditor->bOutputAsBuffer = $OutputAsBuffer;
|
| 181 |
|
|
|
| 182 |
|
|
if (!$bWbConfigSetting ) { $ckeditor->config['entities'] = false; }
|
| 183 |
|
|
|
| 184 |
|
|
/**
|
| 185 |
|
|
* Sets the DOCTYPE to be used when loading the editor content as HTML.
|
| 186 |
|
|
* <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
| 187 |
|
|
* <!DOCTYPE html>
|
| 188 |
|
|
*/
|
| 189 |
|
|
$ckeditor->config['docType'] = '<!DOCTYPE html>';
|
| 190 |
|
|
|
| 191 |
|
|
/**
|
| 192 |
|
|
*
|
| 193 |
|
|
* Define Marmots CKEditor plugin in ../ckeditor/plugins/backup
|
| 194 |
|
|
* backup_on_start true or false
|
| 195 |
|
|
* backup_save_delay in ms
|
| 196 |
|
|
*
|
| 197 |
|
|
*/
|
| 198 |
|
|
$ckeditor->config['backup_on_start'] = true;
|
| 199 |
|
|
$ckeditor->config['backup_save_delay'] = 500;
|
| 200 |
|
|
|
| 201 |
|
|
|
| 202 |
|
|
/**
|
| 203 |
|
|
* SCAYT
|
| 204 |
|
|
* Spellchecker settings.
|
| 205 |
|
|
*
|
| 206 |
|
|
*/
|
| 207 |
|
|
$ckeditor->config['scayt_sLang'] = strtolower(LANGUAGE)."_".(LANGUAGE == "EN" ? "US" : LANGUAGE);
|
| 208 |
|
|
if (!$bWbConfigSetting ) {
|
| 209 |
|
|
$ckeditor->config['scayt_autoStartup'] = false;
|
| 210 |
|
|
}
|
| 211 |
|
|
/**
|
| 212 |
|
|
$ckeditor->config['filebrowserBrowseUrl'] = $ckeditor->basePath.'filemanager/browser/elfinder/elfinder.html';
|
| 213 |
|
|
*/
|
| 214 |
|
|
|
| 215 |
|
|
$connectorPath = $ckeditor->basePath.'/filemanager/connectors/php/connector.php';
|
| 216 |
|
|
$ckeditor->config['filebrowserBrowseUrl'] = $ckeditor->basePath.'filemanager/browser/default/browser.html?Connector='.$connectorPath;
|
| 217 |
|
|
$ckeditor->config['filebrowserImageBrowseUrl'] = $ckeditor->basePath.'filemanager/browser/default/browser.html?Type=Image&Connector='.$connectorPath;
|
| 218 |
|
|
$ckeditor->config['filebrowserFlashBrowseUrl'] = $ckeditor->basePath.'filemanager/browser/default/browser.html?Type=Flash&Connector='.$connectorPath;
|
| 219 |
|
|
/**
|
| 220 |
|
|
* The filebrowser are called in the include, because later on we can make switches, use WB_URL and so on
|
| 221 |
|
|
$ckeditor->config['filebrowserBrowseUrl'] = $ckeditor->basePath.'/filemanager/kcfinder/browse.php?opener=ckeditor&type=files';
|
| 222 |
|
|
$ckeditor->config['filebrowserImageBrowseUrl'] = $ckeditor->basePath.'/filemanager/kcfinder/browse.php?opener=ckeditor&type=images';
|
| 223 |
|
|
$ckeditor->config['filebrowserFlashBrowseUrl'] = $ckeditor->basePath.'/filemanager/kcfinder/browse.php?opener=ckeditor&type=flash';
|
| 224 |
|
|
*/
|
| 225 |
|
|
|
| 226 |
|
|
$ckeditor->config['uploader'] = false; // disabled for security reasons
|
| 227 |
|
|
|
| 228 |
|
|
/**
|
| 229 |
|
|
* The Uploader has to be called, too.
|
| 230 |
|
|
if($ckeditor->config['uploader']==true) {
|
| 231 |
|
|
$ckeditor->config['filebrowserUploadUrl'] = $ckeditor->basePath.'/filemanager/kcfinder/upload.php?opener=ckeditor&type=files';
|
| 232 |
|
|
$ckeditor->config['filebrowserImageUploadUrl'] = $ckeditor->basePath.'/filemanager/kcfinder/upload.php?opener=ckeditor&type=images';
|
| 233 |
|
|
$ckeditor->config['filebrowserFlashUploadUrl'] = $ckeditor->basePath.'/filemanager/kcfinder/upload.php?opener=ckeditor&type=flash';
|
| 234 |
|
|
}
|
| 235 |
|
|
*/
|
| 236 |
|
|
|
| 237 |
|
|
/**
|
| 238 |
|
|
*/
|
| 239 |
|
|
if($ckeditor->config['uploader']==true) {
|
| 240 |
|
|
$uploadPath = $ckeditor->basePath.'filemanager/connectors/php/upload.php?Type=';
|
| 241 |
|
|
$ckeditor->config['filebrowserUploadUrl'] = $uploadPath.'File';
|
| 242 |
|
|
$ckeditor->config['filebrowserImageUploadUrl'] = $uploadPath.'Image';
|
| 243 |
|
|
$ckeditor->config['filebrowserFlashUploadUrl'] = $uploadPath.'Flash';
|
| 244 |
|
|
}
|
| 245 |
|
|
/******************************************************************************************/
|
| 246 |
|
|
/**
|
| 247 |
|
|
* Looking for the styles
|
| 248 |
|
|
*
|
| 249 |
|
|
*/
|
| 250 |
|
|
$ckeditor->resolve_path(
|
| 251 |
|
|
'contentsCss',
|
| 252 |
|
|
$tplPath.'wb_config/editor.css',
|
| 253 |
|
|
$ModPath.'wb_config/editor.css'
|
| 254 |
|
|
);
|
| 255 |
|
|
|
| 256 |
|
|
/**
|
| 257 |
|
|
* Looking for the editor.styles at all ...
|
| 258 |
|
|
*
|
| 259 |
|
|
*/
|
| 260 |
|
|
$ckeditor->resolve_path(
|
| 261 |
|
|
'stylesSet',
|
| 262 |
|
|
$tplPath.'wb_config/editor.styles.js',
|
| 263 |
|
|
$ModPath.'wb_config/editor.styles.js',
|
| 264 |
|
|
'wb:'
|
| 265 |
|
|
);
|
| 266 |
|
|
|
| 267 |
|
|
/**
|
| 268 |
|
|
* The list of templates definition files to load.
|
| 269 |
|
|
*
|
| 270 |
|
|
*/
|
| 271 |
|
|
$ckeditor->resolve_path(
|
| 272 |
|
|
'templates_files',
|
| 273 |
|
|
$tplPath.'wb_config/editor.templates.js',
|
| 274 |
|
|
$ModPath.'wb_config/editor.templates.js'
|
| 275 |
|
|
);
|
| 276 |
|
|
|
| 277 |
|
|
/**
|
| 278 |
|
|
* Bugfix for the template files as the ckeditor want an array instead a string ...
|
| 279 |
|
|
*
|
| 280 |
|
|
*/
|
| 281 |
|
|
$ckeditor->config['templates_files'] = array($ckeditor->config['templates_files']);
|
| 282 |
|
|
|
| 283 |
|
|
/**
|
| 284 |
|
|
* Get the config file
|
| 285 |
|
|
*
|
| 286 |
|
|
*/
|
| 287 |
|
|
$ckeditor->resolve_path(
|
| 288 |
|
|
'customConfig',
|
| 289 |
|
|
$tplPath.'wb_config/wb_ckconfig.js',
|
| 290 |
|
|
$ModPath.'wb_config/wb_ckconfig.js'
|
| 291 |
|
|
);
|
| 292 |
|
|
/******************************************************************************************/
|
| 293 |
|
|
|
| 294 |
|
|
/**
|
| 295 |
|
|
* To avoid a double "else" inside the following condition, we set the
|
| 296 |
|
|
* default toolbar here to "WB_Full". Keep in mind, that the config will overwrite all
|
| 297 |
|
|
* settings inside the config.js or wb_config.js BUT you will have to define the toolbar inside
|
| 298 |
|
|
* them at all!
|
| 299 |
|
|
*
|
| 300 |
|
|
*/
|
| 301 |
|
|
|
| 302 |
|
|
if (isset($database) && $ckeditor->wysiwyg_admin_exists ) {
|
| 303 |
|
|
$aSection = $GLOBALS['section'];
|
| 304 |
|
|
$data = null;
|
| 305 |
|
|
$query = 'SELECT * from `'.TABLE_PREFIX.'mod_editor_admin` WHERE `editor`="ckeditor"';
|
| 306 |
|
|
if (method_exists($database,'doQuery')) {
|
| 307 |
|
|
if (($result = $database->query($query))) {
|
| 308 |
|
|
$data = $result->fetchArray(MYSQLI_ASSOC);
|
| 309 |
|
|
}
|
| 310 |
|
|
} else {
|
| 311 |
|
|
if (($result = $database->query($query))) {
|
| 312 |
|
|
$data = $result->fetchRow(MYSQLI_ASSOC);
|
| 313 |
|
|
}
|
| 314 |
|
|
}
|
| 315 |
|
|
// import data into $ckeditor->config
|
| 316 |
|
|
if ( $data ) {
|
| 317 |
|
|
foreach ($data as $key => $value) {
|
| 318 |
|
|
$ckeditor->config[$key] = $value;
|
| 319 |
|
|
if(!$ckeditor->config[$key]){unset($ckeditor->config[$key]);}
|
| 320 |
|
|
}
|
| 321 |
|
|
}
|
| 322 |
|
|
}
|
| 323 |
|
|
if (isset($ckeditor->config['menu'])) {$ckeditor->config['toolbar'] = $ckeditor->config['menu'];}
|
| 324 |
|
|
/*
|
| 325 |
|
|
if( !$bWbConfigSetting ) {
|
| 326 |
|
|
if ( (!$ckeditor->wysiwyg_admin_exists) || ($ckeditor->force) ) {
|
| 327 |
|
|
}
|
| 328 |
|
|
}
|
| 329 |
|
|
*/
|
| 330 |
|
|
$ckeditor->config['height'] = $height;
|
| 331 |
|
|
$ckeditor->config['width'] = $width;
|
| 332 |
|
|
|
| 333 |
|
|
$ckeditor->config['autoGrow_minHeight'] = 200;
|
| 334 |
|
|
$ckeditor->config['autoGrow_maxHeight'] = $height;
|
| 335 |
|
|
$ckeditor->config['autoGrow_bottomSpace'] = 50;
|
| 336 |
|
|
$ckeditor->config['autoGrow_onStartup'] = false;
|
| 337 |
|
|
|
| 338 |
|
|
$ckeditor->reverse_htmlentities($content);
|
| 339 |
|
|
|
| 340 |
|
|
$output = $ckeditor->to_HTML( $name, $content, $ckeditor->config);
|
| 341 |
|
|
|
| 342 |
|
|
if (!$OutputAsBuffer){
|
| 343 |
|
|
echo $output;
|
| 344 |
|
|
} else {
|
| 345 |
|
|
return $output;
|
| 346 |
|
|
}
|
| 347 |
|
|
|
| 348 |
|
|
}
|