Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         fckeditor
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2010, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 4.3.4 and higher
13
 * @version         $Id: include.php 1277 2010-01-28 05:18:18Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/fckeditor/include.php $
15
 * @lastmodified    $Date: 2010-01-28 06:18:18 +0100 (Thu, 28 Jan 2010) $
16
 *
17
 */
18

    
19
function reverse_htmlentities($mixed) {
20
	$mixed = str_replace(array('&gt;','&lt;','&quot;','&amp;'), array('>','<','"','&'), $mixed);
21
	return $mixed;
22
}
23

    
24
function get_template_name() {
25
	// returns the template name of the current displayed page
26

    
27
	// 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
28
	// require_once('../../config.php');
29
	require_once(WB_PATH. '/framework/class.database.php');
30

    
31
	// work out default editor.css file for CKeditor
32
	if(file_exists(WB_PATH .'/templates/' .DEFAULT_TEMPLATE .'/editor.css')) {
33
		$fck_template_dir = DEFAULT_TEMPLATE;
34
	} else {
35
		$fck_template_dir = "none";
36
	}
37

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

    
42
		// obtain template folder of current page from the database
43
		if(!isset($admin)) {
44
			$database = new database();
45
		}
46
		$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid";
47
		$pagetpl = $database->get_one($query_page);   // if empty, default template is used
48

    
49
		// check if a specific template is defined for current page
50
		if(isset($pagetpl) && $pagetpl != '') {
51
			// check if a specify editor.css file is contained in that folder
52
			if(file_exists(WB_PATH.'/templates/'.$pagetpl.'/editor.css')) {
53
				$fck_template_dir = $pagetpl;
54
			}
55
		}
56
	}
57
	return $fck_template_dir;
58
}
59

    
60
function show_wysiwyg_editor($name, $id, $content, $width, $height) {
61
	// create new CKeditor instance
62
	require_once(WB_PATH.'/modules/fckeditor/fckeditor/fckeditor.php');
63
	$oFCKeditor = new FCKeditor($name);
64

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

    
70
	// obtain template name of current page (if empty, no editor.css files exists)
71
	$template_name = get_template_name();
72

    
73
	// work out default CSS file to be used for FCK textarea
74
	if($template_name == "none") {
75
		// no editor.css file exists in default template folder, or template folder of current page
76
		$css_file = WB_URL .'/modules/fckeditor/wb_config/wb_fckeditorarea.css';
77
	} else {
78
		// editor.css file exists in default template folder or template folder of current page
79
		$css_file = WB_URL .'/templates/' .$template_name .'/editor.css';
80
	}
81
	// set CSS file depending on $css_file
82
	$oFCKeditor->Config['EditorAreaCSS'] = $css_file;
83

    
84
	// work out settings for the FCK "Style" toolbar
85
	if ($template_name == "none") {
86
		// no custom editor.css exists, use default XML definitions
87
		$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fckstyles.xml';
88
	} else {
89
		// file editor.css exists in template folder, parse it and create XML definitions
90
		$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/css_to_xml.php?template_name=' .$template_name;
91
	}
92

    
93
	// custom templates can be defined via /wb_config/wb_fcktemplates.xml
94
	if(file_exists(WB_PATH .'/modules/fckeditor/wb_config/wb_fcktemplates.xml')) {
95
		$oFCKeditor->Config['TemplatesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fcktemplates.xml';
96
	}
97

    
98
  // set required file connectors (overwrite settings which may be made in fckconfig.js or my_fckconfig.js)
99
	$connectorPath = $oFCKeditor->BasePath.'editor/filemanager/connectors/php/connector.php';
100
  $oFCKeditor->Config['LinkBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
101
		.$connectorPath;
102
  $oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
103
		.$connectorPath;
104
  $oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector='
105
		.$connectorPath;
106

    
107
  if(defined('EDITOR_WIDTH'))
108
  {
109
    $width = ( ($width > EDITOR_WIDTH ) OR (EDITOR_WIDTH <= 0) ) ? $width : EDITOR_WIDTH;
110
  }
111

    
112
	$oFCKeditor->Value = reverse_htmlentities($content);
113
    $oFCKeditor->Width  = $width;
114
	$oFCKeditor->Height = $height;
115
	$oFCKeditor->Create();
116
}
117

    
118
?>
(3-3/7)