Revision 1289
Added by kweitzel almost 16 years ago
| include.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
|
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
/* |
|
| 6 |
|
|
| 7 |
Website Baker Project <http://www.websitebaker.org/> |
|
| 8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
| 9 |
|
|
| 10 |
Website Baker is free software; you can redistribute it and/or modify |
|
| 11 |
it under the terms of the GNU General Public License as published by |
|
| 12 |
the Free Software Foundation; either version 2 of the License, or |
|
| 13 |
(at your option) any later version. |
|
| 14 |
|
|
| 15 |
Website Baker is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License |
|
| 21 |
along with Website Baker; if not, write to the Free Software |
|
| 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 23 |
|
|
| 24 |
*/ |
|
| 25 |
|
|
| 26 |
function reverse_htmlentities($mixed) {
|
|
| 27 |
$mixed = str_replace(array('>','<','"','&'), array('>','<','"','&'), $mixed);
|
|
| 28 |
return $mixed; |
|
| 29 |
} |
|
| 30 |
|
|
| 31 |
function get_template_name() {
|
|
| 32 |
// returns the template name of the current displayed page |
|
| 33 |
|
|
| 34 |
// 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 |
|
| 35 |
// require_once('../../config.php');
|
|
| 36 |
require_once(WB_PATH. '/framework/class.database.php'); |
|
| 37 |
|
|
| 38 |
// work out default editor.css file for FCKEditor |
|
| 39 |
if(file_exists(WB_PATH .'/templates/' .DEFAULT_TEMPLATE .'/editor.css')) {
|
|
| 40 |
$fck_template_dir = DEFAULT_TEMPLATE; |
|
| 41 |
} else {
|
|
| 42 |
$fck_template_dir = "none"; |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
// check if a editor.css file exists in the specified template directory of current page |
|
| 46 |
if (isset($_GET["page_id"]) && (int) $_GET["page_id"] > 0) {
|
|
| 47 |
$pageid = (int) $_GET["page_id"]; |
|
| 48 |
|
|
| 49 |
// obtain template folder of current page from the database |
|
| 50 |
if(!isset($admin)) {
|
|
| 51 |
$database = new database(); |
|
| 52 |
} |
|
| 53 |
$query_page = "SELECT template FROM " .TABLE_PREFIX ."pages WHERE page_id =$pageid"; |
|
| 54 |
$pagetpl = $database->get_one($query_page); // if empty, default template is used |
|
| 55 |
|
|
| 56 |
// check if a specific template is defined for current page |
|
| 57 |
if(isset($pagetpl) && $pagetpl != '') {
|
|
| 58 |
// check if a specify editor.css file is contained in that folder |
|
| 59 |
if(file_exists(WB_PATH.'/templates/'.$pagetpl.'/editor.css')) {
|
|
| 60 |
$fck_template_dir = $pagetpl; |
|
| 61 |
} |
|
| 62 |
} |
|
| 63 |
} |
|
| 64 |
return $fck_template_dir; |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
function show_wysiwyg_editor($name, $id, $content, $width, $height) {
|
|
| 68 |
// create new FCKEditor instance |
|
| 69 |
require_once(WB_PATH.'/modules/fckeditor/fckeditor/fckeditor.php'); |
|
| 70 |
$oFCKeditor = new FCKeditor($name); |
|
| 71 |
|
|
| 72 |
// set defaults (Note: custom settings defined in: "/my_config/my_fckconfig.js" instead of "/editor/fckconfig.js") |
|
| 73 |
$oFCKeditor->BasePath = WB_URL.'/modules/fckeditor/fckeditor/'; |
|
| 74 |
$oFCKeditor->Config['CustomConfigurationsPath'] = WB_URL .'/modules/fckeditor/wb_config/wb_fckconfig.js'; |
|
| 75 |
$oFCKeditor->ToolbarSet = 'WBToolbar'; // toolbar defined in my_fckconfig.js |
|
| 76 |
|
|
| 77 |
// obtain template name of current page (if empty, no editor.css files exists) |
|
| 78 |
$template_name = get_template_name(); |
|
| 79 |
|
|
| 80 |
// work out default CSS file to be used for FCK textarea |
|
| 81 |
if($template_name == "none") {
|
|
| 82 |
// no editor.css file exists in default template folder, or template folder of current page |
|
| 83 |
$css_file = WB_URL .'/modules/fckeditor/wb_config/wb_fckeditorarea.css'; |
|
| 84 |
} else {
|
|
| 85 |
// editor.css file exists in default template folder or template folder of current page |
|
| 86 |
$css_file = WB_URL .'/templates/' .$template_name .'/editor.css'; |
|
| 87 |
} |
|
| 88 |
// set CSS file depending on $css_file |
|
| 89 |
$oFCKeditor->Config['EditorAreaCSS'] = $css_file; |
|
| 90 |
|
|
| 91 |
// work out settings for the FCK "Style" toolbar |
|
| 92 |
if ($template_name == "none") {
|
|
| 93 |
// no custom editor.css exists, use default XML definitions |
|
| 94 |
$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fckstyles.xml'; |
|
| 95 |
} else {
|
|
| 96 |
// file editor.css exists in template folder, parse it and create XML definitions |
|
| 97 |
$oFCKeditor->Config['StylesXmlPath'] = WB_URL.'/modules/fckeditor/css_to_xml.php?template_name=' .$template_name; |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
// custom templates can be defined via /wb_config/wb_fcktemplates.xml |
|
| 101 |
if(file_exists(WB_PATH .'/modules/fckeditor/wb_config/wb_fcktemplates.xml')) {
|
|
| 102 |
$oFCKeditor->Config['TemplatesXmlPath'] = WB_URL.'/modules/fckeditor/wb_config/wb_fcktemplates.xml'; |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
// set required file connectors (overwrite settings which may be made in fckconfig.js or my_fckconfig.js) |
|
| 106 |
$connectorPath = $oFCKeditor->BasePath.'editor/filemanager/connectors/php/connector.php'; |
|
| 107 |
$oFCKeditor->Config['LinkBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=' |
|
| 108 |
.$connectorPath; |
|
| 109 |
$oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=' |
|
| 110 |
.$connectorPath; |
|
| 111 |
$oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?Connector=' |
|
| 112 |
.$connectorPath; |
|
| 113 |
|
|
| 114 |
$oFCKeditor->Value = reverse_htmlentities($content); |
|
| 115 |
$oFCKeditor->Height = $height; |
|
| 116 |
$oFCKeditor->Create(); |
|
| 117 |
} |
|
| 118 |
|
|
| 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$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
function reverse_htmlentities($mixed) {
|
|
| 20 |
$mixed = str_replace(array('>','<','"','&'), 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 |
|
|
| 119 | 118 |
?> |
| 120 | 119 | |
Also available in: Unified diff
Branch 2.8.1 merged back into Trunk