Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         wysiwyg
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, 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 5.2.2 and higher
13
 * @version         $Id: include.php 1374 2011-01-10 12:21:47Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/fckeditor/include.php $
15
 * @lastmodified    $Date: 2011-01-10 13:21:47 +0100 (Mon, 10 Jan 2011) $
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
	global $database;
26
	// returns the template name of the current displayed page
27

    
28
	// 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
29
	// require_once('../../config.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
		$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid";
44
		$pagetpl = $database->get_one($query_page);   // if empty, default template is used
45

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

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

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

    
67
	// obtain template name of current page (if empty, no editor.css files exists)
68
	$template_name = get_template_name();
69

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

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

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

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

    
104
  if(defined('EDITOR_WIDTH'))
105
  {
106
    $width = ( ($width > EDITOR_WIDTH ) OR (EDITOR_WIDTH <= 0) ) ? $width : EDITOR_WIDTH;
107
  }
108

    
109
	$oFCKeditor->Value = reverse_htmlentities($content);
110
    $oFCKeditor->Width  = $width;
111
	$oFCKeditor->Height = $height;
112
	$oFCKeditor->Create();
113
}
(3-3/8)