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 1827 2012-11-21 04:16:09Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/fckeditor/include.php $
15
 * @lastmodified    $Date: 2012-11-21 05:16:09 +0100 (Wed, 21 Nov 2012) $
16
 *
17
 */
18
/* -------------------------------------------------------- */
19
// Must include code to stop this file being accessed directly
20
if(!defined('WB_PATH')) {
21

    
22
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
23
	throw new IllegalFileException();
24
}
25
/* -------------------------------------------------------- */
26

    
27
function reverse_htmlentities($mixed) {
28
	$mixed = str_replace(array('&gt;','&lt;','&quot;','&amp;'), array('>','<','"','&'), $mixed);
29
	return $mixed;
30
}
31

    
32
function get_template_name() {
33
	global $database;
34
	// returns the template name of the current displayed page
35

    
36
	// 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
37
	// require_once('../../config.php');
38

    
39
	// work out default editor.css file for CKeditor
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
		$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid";
52
		$pagetpl = $database->get_one($query_page);   // if empty, default template is used
53

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

    
65
function show_wysiwyg_editor($name, $id, $content, $width, $height) {
66
	// create new CKeditor instance
67
	require_once(WB_PATH.'/modules/fckeditor/fckeditor/fckeditor.php');
68
	$oFCKeditor = new FCKeditor($name);
69

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

    
75
	// obtain template name of current page (if empty, no editor.css files exists)
76
	$template_name = get_template_name();
77

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

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

    
98
	// custom templates can be defined via /wb_config/wb_fcktemplates.xml
99
	if(file_exists(WB_PATH .'/modules/fckeditor/wb_config/wb_fcktemplates.xml')) {
100
		$oFCKeditor->Config['TemplatesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fcktemplates.xml';
101
	}
102

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

    
112
  if(defined('EDITOR_WIDTH'))
113
  {
114
    $width = ( ($width > EDITOR_WIDTH ) OR (EDITOR_WIDTH <= 0) ) ? $width : EDITOR_WIDTH;
115
  }
116

    
117
	$oFCKeditor->Value = reverse_htmlentities($content);
118
    $oFCKeditor->Width  = $width;
119
	$oFCKeditor->Height = $height;
120
	$oFCKeditor->Create();
121
}
(3-3/8)