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 |
|
|
$htmltable = get_html_translation_table(HTML_ENTITIES);
|
28 |
|
|
foreach($htmltable as $key => $value) {
|
29 |
|
|
$mixed = ereg_replace(addslashes($value),$key,$mixed);
|
30 |
|
|
}
|
31 |
|
|
return $mixed;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
function get_template_name() {
|
35 |
|
|
// returns the template name of the current displayed page
|
36 |
|
|
require_once('../../config.php');
|
37 |
|
|
require_once(WB_PATH. '/framework/class.database.php');
|
38 |
|
|
|
39 |
|
|
// work out default editor.css file for FCKEditor
|
40 |
|
|
if(file_exists(WB_PATH .'/templates/' .DEFAULT_TEMPLATE .'/editor.css')) {
|
41 |
|
|
$fck_template_dir = DEFAULT_TEMPLATE;
|
42 |
|
|
} else {
|
43 |
|
|
$fck_template_dir = "none";
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
// check if a editor.css file exists in the specified template directory of current page
|
47 |
|
|
if (isset($_GET["page_id"]) && (int) $_GET["page_id"] > 0) {
|
48 |
|
|
$pageid = (int) $_GET["page_id"];
|
49 |
|
|
|
50 |
|
|
// obtain template folder of current page from the database
|
51 |
|
|
if(!isset($admin)) {
|
52 |
|
|
$database = new database();
|
53 |
|
|
}
|
54 |
|
|
$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid";
|
55 |
|
|
$pagetpl = $database->get_one($query_page); // if empty, default template is used
|
56 |
|
|
|
57 |
|
|
// check if a specific template is defined for current page
|
58 |
|
|
if(isset($pagetpl) && $pagetpl != '') {
|
59 |
|
|
// check if a specify editor.css file is contained in that folder
|
60 |
|
|
if(file_exists(WB_PATH.'/templates/'.$pagetpl.'/editor.css')) {
|
61 |
|
|
$fck_template_dir = $pagetpl;
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
return $fck_template_dir;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
function show_wysiwyg_editor($name, $id, $content, $width, $height) {
|
69 |
|
|
// create new FCKEditor instance
|
70 |
|
|
require_once(WB_PATH.'/modules/fckeditor/fckeditor/fckeditor.php');
|
71 |
|
|
$oFCKeditor = new FCKeditor($name);
|
72 |
|
|
|
73 |
|
|
// set defaults (Note: custom settings defined in: "/my_config/my_fckconfig.js" instead of "/editor/fckconfig.js")
|
74 |
|
|
$oFCKeditor->BasePath = WB_URL.'/modules/fckeditor/fckeditor/';
|
75 |
|
|
$oFCKeditor->Config['CustomConfigurationsPath'] = WB_URL .'/modules/fckeditor/wb_config/wb_fckconfig.js';
|
76 |
|
|
$oFCKeditor->ToolbarSet = 'WBToolbar'; // toolbar defined in my_fckconfig.js
|
77 |
|
|
|
78 |
|
|
// obtain template name of current page (if empty, no editor.css files exists)
|
79 |
|
|
$template_name = get_template_name();
|
80 |
|
|
|
81 |
|
|
// work out default CSS file to be used for FCK textarea
|
82 |
|
|
if($template_name == "none") {
|
83 |
|
|
// no editor.css file exists in default template folder, or template folder of current page
|
84 |
|
|
$css_file = WB_URL .'/modules/fckeditor/wb_config/wb_fckeditorarea.css';
|
85 |
|
|
} else {
|
86 |
|
|
// editor.css file exists in default template folder or template folder of current page
|
87 |
|
|
$css_file = WB_URL .'/templates/' .$template_name .'/editor.css';
|
88 |
|
|
}
|
89 |
|
|
// set CSS file depending on $css_file
|
90 |
|
|
$oFCKeditor->Config['EditorAreaCSS'] = $css_file;
|
91 |
|
|
|
92 |
|
|
// work out settings for the FCK "Style" toolbar
|
93 |
|
|
if ($template_name == "none") {
|
94 |
|
|
// no custom editor.css exists, use default XML definitions
|
95 |
|
|
$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fckstyles.xml';
|
96 |
|
|
} else {
|
97 |
|
|
// file editor.css exists in template folder, parse it and create XML definitions
|
98 |
|
|
$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/css_to_xml.php?template_name=' .$template_name;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
// custom templates can be defined via /wb_config/wb_fcktemplates.xml
|
102 |
|
|
if(file_exists(WB_PATH .'/modules/fckeditor/wb_config/wb_fcktemplates.xml')) {
|
103 |
|
|
$oFCKeditor->Config['TemplatesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fcktemplates.xml';
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
// set required file connectors (overwrite settings which may be made in fckconfig.js or my_fckconfig.js)
|
107 |
|
|
$oFCKeditor->Config['LinkBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php';
|
108 |
|
|
$oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php';
|
109 |
|
|
$oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php';
|
110 |
|
|
|
111 |
|
|
$oFCKeditor->Value = reverse_htmlentities($content);
|
112 |
|
|
$oFCKeditor->Height = $height;
|
113 |
|
|
$oFCKeditor->Create();
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
?>
|