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 1420 2011-01-26 17:43:56Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/fckeditor/include.php $
15
 * @lastmodified    $Date: 2011-01-26 18:43:56 +0100 (Wed, 26 Jan 2011) $
16
 *
17
 */
18
// Must include code to stop this file being access directly
19
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
20

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

    
26
function get_template_name() {
27
	global $database;
28
	// returns the template name of the current displayed page
29

    
30
	// 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
31
	// require_once('../../config.php');
32

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

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

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

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

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

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

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

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

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

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

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

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

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