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