Project

General

Profile

1
<?php
2
/****************************************************************************
3
* SVN Version information:
4
*
5
* $Id: include.php 1241 2010-01-12 17:14:06Z Luisehahne $
6
*
7
*****************************************************************************
8
*                          WebsiteBaker
9
*
10
* WebsiteBaker Project <http://www.websitebaker2.org/>
11
* Copyright (C) 2009, Website Baker Org. e.V.
12
*         http://start.websitebaker2.org/impressum-datenschutz.php
13
* Copyright (C) 2004-2009, Ryan Djurovich
14
*
15
*                        About WebsiteBaker
16
*
17
* Website Baker is a PHP-based Content Management System (CMS)
18
* designed with one goal in mind: to enable its users to produce websites
19
* with ease.
20
*
21
*****************************************************************************
22
*
23
*****************************************************************************
24
*                        LICENSE INFORMATION
25
*
26
* WebsiteBaker is free software; you can redistribute it and/or
27
* modify it under the terms of the GNU General Public License
28
* as published by the Free Software Foundation; either version 2
29
* of the License, or (at your option) any later version.
30
*
31
* WebsiteBaker is distributed in the hope that it will be useful,
32
* but WITHOUT ANY WARRANTY; without even the implied warranty of
33
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34
* See the GNU General Public License for more details.
35
*
36
* You should have received a copy of the GNU General Public License
37
* along with this program; if not, write to the Free Software
38
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
39
****************************************************************************
40
*
41
*                   WebsiteBaker Extra Information
42
*
43
*
44
*
45
*
46
*****************************************************************************/
47
/**
48
 *
49
 * @category     modules
50
 * @package      fckeditor
51
 * @author       Ryan Djurovich
52
 * @copyright    2004-2009, Ryan Djurovich
53
 * @copyright    2009-2010, Website Baker Org. e.V.
54
 * @version      $Id: include.php 1241 2010-01-12 17:14:06Z Luisehahne $
55
 * @platform     WebsiteBaker 2.8.x
56
 * @requirements >= PHP 4.3.4
57
 * @license      http://www.gnu.org/licenses/gpl.html
58
 *
59
 */
60

    
61
function reverse_htmlentities($mixed) {
62
	$mixed = str_replace(array('&gt;','&lt;','&quot;','&amp;'), array('>','<','"','&'), $mixed);
63
	return $mixed;
64
}
65

    
66
function get_template_name() {
67
	// returns the template name of the current displayed page
68

    
69
	// Loading config.php is not needed here, it is loaded before. It breaks the module when the editor is called form another dir as WB_PATH/modules/mymodule
70
	// require_once('../../config.php');
71
	require_once(WB_PATH. '/framework/class.database.php');
72

    
73
	// work out default editor.css file for CKeditor
74
	if(file_exists(WB_PATH .'/templates/' .DEFAULT_TEMPLATE .'/editor.css')) {
75
		$fck_template_dir = DEFAULT_TEMPLATE;
76
	} else {
77
		$fck_template_dir = "none";
78
	}
79

    
80
	// check if a editor.css file exists in the specified template directory of current page
81
	if (isset($_GET["page_id"]) && (int) $_GET["page_id"] > 0) {
82
		$pageid = (int) $_GET["page_id"];
83

    
84
		// obtain template folder of current page from the database
85
		if(!isset($admin)) {
86
			$database = new database();
87
		}
88
		$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid";
89
		$pagetpl = $database->get_one($query_page);   // if empty, default template is used
90

    
91
		// check if a specific template is defined for current page
92
		if(isset($pagetpl) && $pagetpl != '') {
93
			// check if a specify editor.css file is contained in that folder
94
			if(file_exists(WB_PATH.'/templates/'.$pagetpl.'/editor.css')) {
95
				$fck_template_dir = $pagetpl;
96
			}
97
		}
98
	}
99
	return $fck_template_dir;
100
}
101

    
102
function show_wysiwyg_editor($name, $id, $content, $width, $height) {
103
	// create new CKeditor instance
104
	require_once(WB_PATH.'/modules/fckeditor/fckeditor/fckeditor.php');
105
	$oFCKeditor = new FCKeditor($name);
106

    
107
	// set defaults (Note: custom settings defined in: "/my_config/my_fckconfig.js" instead of "/editor/fckconfig.js")
108
	$oFCKeditor->BasePath = WB_URL.'/modules/fckeditor/fckeditor/';
109
	$oFCKeditor->Config['CustomConfigurationsPath'] = WB_URL .'/modules/fckeditor/wb_config/wb_fckconfig.js';
110
	$oFCKeditor->ToolbarSet = 'WBToolbar';        // toolbar defined in my_fckconfig.js
111

    
112
	// obtain template name of current page (if empty, no editor.css files exists)
113
	$template_name = get_template_name();
114

    
115
	// work out default CSS file to be used for FCK textarea
116
	if($template_name == "none") {
117
		// no editor.css file exists in default template folder, or template folder of current page
118
		$css_file = WB_URL .'/modules/fckeditor/wb_config/wb_fckeditorarea.css';
119
	} else {
120
		// editor.css file exists in default template folder or template folder of current page
121
		$css_file = WB_URL .'/templates/' .$template_name .'/editor.css';
122
	}
123
	// set CSS file depending on $css_file
124
	$oFCKeditor->Config['EditorAreaCSS'] = $css_file;
125

    
126
	// work out settings for the FCK "Style" toolbar
127
	if ($template_name == "none") {
128
		// no custom editor.css exists, use default XML definitions
129
		$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fckstyles.xml';
130
	} else {
131
		// file editor.css exists in template folder, parse it and create XML definitions
132
		$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/css_to_xml.php?template_name=' .$template_name;
133
	}
134

    
135
	// custom templates can be defined via /wb_config/wb_fcktemplates.xml
136
	if(file_exists(WB_PATH .'/modules/fckeditor/wb_config/wb_fcktemplates.xml')) {
137
		$oFCKeditor->Config['TemplatesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fcktemplates.xml';
138
	}
139

    
140
  // set required file connectors (overwrite settings which may be made in fckconfig.js or my_fckconfig.js)
141
	$connectorPath = $oFCKeditor->BasePath.'editor/filemanager/connectors/php/connector.php';
142
  $oFCKeditor->Config['LinkBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
143
		.$connectorPath;
144
  $oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
145
		.$connectorPath;
146
  $oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
147
		.$connectorPath;
148

    
149
  if(defined('EDITOR_WIDTH'))
150
  {
151
    $width = ( ($width > EDITOR_WIDTH ) OR (EDITOR_WIDTH <= 0) ) ? $width : EDITOR_WIDTH;
152
  }
153

    
154
	$oFCKeditor->Value = reverse_htmlentities($content);
155
    $oFCKeditor->Width  = $width;
156
	$oFCKeditor->Height = $height;
157
	$oFCKeditor->Create();
158
}
159

    
160
?>
(3-3/6)