1 |
528
|
doc
|
<?php
|
2 |
|
|
|
3 |
559
|
Ruebenwurz
|
// $Id$
|
4 |
|
|
|
5 |
528
|
doc
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2008, Ryan Djurovich
|
9 |
|
|
|
10 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with Website Baker; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
function reverse_htmlentities($mixed) {
|
27 |
761
|
thorn
|
$mixed = str_replace(array('>','<','"','&'), array('>','<','"','&'), $mixed);
|
28 |
528
|
doc
|
return $mixed;
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
function get_template_name() {
|
32 |
|
|
// returns the template name of the current displayed page
|
33 |
|
|
require_once('../../config.php');
|
34 |
|
|
require_once(WB_PATH. '/framework/class.database.php');
|
35 |
|
|
|
36 |
|
|
// work out default editor.css file for FCKEditor
|
37 |
|
|
if(file_exists(WB_PATH .'/templates/' .DEFAULT_TEMPLATE .'/editor.css')) {
|
38 |
|
|
$fck_template_dir = DEFAULT_TEMPLATE;
|
39 |
|
|
} else {
|
40 |
|
|
$fck_template_dir = "none";
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
// check if a editor.css file exists in the specified template directory of current page
|
44 |
|
|
if (isset($_GET["page_id"]) && (int) $_GET["page_id"] > 0) {
|
45 |
|
|
$pageid = (int) $_GET["page_id"];
|
46 |
|
|
|
47 |
|
|
// obtain template folder of current page from the database
|
48 |
|
|
if(!isset($admin)) {
|
49 |
|
|
$database = new database();
|
50 |
|
|
}
|
51 |
|
|
$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid";
|
52 |
|
|
$pagetpl = $database->get_one($query_page); // if empty, default template is used
|
53 |
|
|
|
54 |
|
|
// check if a specific template is defined for current page
|
55 |
|
|
if(isset($pagetpl) && $pagetpl != '') {
|
56 |
|
|
// check if a specify editor.css file is contained in that folder
|
57 |
|
|
if(file_exists(WB_PATH.'/templates/'.$pagetpl.'/editor.css')) {
|
58 |
|
|
$fck_template_dir = $pagetpl;
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
return $fck_template_dir;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
function show_wysiwyg_editor($name, $id, $content, $width, $height) {
|
66 |
|
|
// create new FCKEditor instance
|
67 |
|
|
require_once(WB_PATH.'/modules/fckeditor/fckeditor/fckeditor.php');
|
68 |
|
|
$oFCKeditor = new FCKeditor($name);
|
69 |
|
|
|
70 |
|
|
// set defaults (Note: custom settings defined in: "/my_config/my_fckconfig.js" instead of "/editor/fckconfig.js")
|
71 |
|
|
$oFCKeditor->BasePath = WB_URL.'/modules/fckeditor/fckeditor/';
|
72 |
|
|
$oFCKeditor->Config['CustomConfigurationsPath'] = WB_URL .'/modules/fckeditor/wb_config/wb_fckconfig.js';
|
73 |
|
|
$oFCKeditor->ToolbarSet = 'WBToolbar'; // toolbar defined in my_fckconfig.js
|
74 |
|
|
|
75 |
|
|
// obtain template name of current page (if empty, no editor.css files exists)
|
76 |
|
|
$template_name = get_template_name();
|
77 |
|
|
|
78 |
|
|
// work out default CSS file to be used for FCK textarea
|
79 |
|
|
if($template_name == "none") {
|
80 |
|
|
// no editor.css file exists in default template folder, or template folder of current page
|
81 |
|
|
$css_file = WB_URL .'/modules/fckeditor/wb_config/wb_fckeditorarea.css';
|
82 |
|
|
} else {
|
83 |
|
|
// editor.css file exists in default template folder or template folder of current page
|
84 |
|
|
$css_file = WB_URL .'/templates/' .$template_name .'/editor.css';
|
85 |
|
|
}
|
86 |
|
|
// set CSS file depending on $css_file
|
87 |
|
|
$oFCKeditor->Config['EditorAreaCSS'] = $css_file;
|
88 |
|
|
|
89 |
|
|
// work out settings for the FCK "Style" toolbar
|
90 |
|
|
if ($template_name == "none") {
|
91 |
|
|
// no custom editor.css exists, use default XML definitions
|
92 |
|
|
$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fckstyles.xml';
|
93 |
|
|
} else {
|
94 |
|
|
// file editor.css exists in template folder, parse it and create XML definitions
|
95 |
|
|
$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/css_to_xml.php?template_name=' .$template_name;
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
// custom templates can be defined via /wb_config/wb_fcktemplates.xml
|
99 |
|
|
if(file_exists(WB_PATH .'/modules/fckeditor/wb_config/wb_fcktemplates.xml')) {
|
100 |
|
|
$oFCKeditor->Config['TemplatesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fcktemplates.xml';
|
101 |
|
|
}
|
102 |
|
|
|
103 |
717
|
doc
|
// set required file connectors (overwrite settings which may be made in fckconfig.js or my_fckconfig.js)
|
104 |
|
|
$connectorPath = $oFCKeditor->BasePath.'editor/filemanager/connectors/php/connector.php';
|
105 |
|
|
$oFCKeditor->Config['LinkBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
|
106 |
|
|
.$connectorPath;
|
107 |
|
|
$oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
|
108 |
|
|
.$connectorPath;
|
109 |
|
|
$oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
|
110 |
|
|
.$connectorPath;
|
111 |
528
|
doc
|
|
112 |
|
|
$oFCKeditor->Value = reverse_htmlentities($content);
|
113 |
|
|
$oFCKeditor->Height = $height;
|
114 |
|
|
$oFCKeditor->Create();
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
?>
|