Project

General

Profile

« Previous | Next » 

Revision 45

Added by stefan about 19 years ago

Implemented choice of WYSIWYG editor

View differences:

modify.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, 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

  
27

  
28
// Get page content
29
$query = "SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$section_id'";
30
$get_content = $database->query($query);
31
$content = $get_content->fetchRow();
32
$content = $admin->strip_slashes_dummy(htmlspecialchars($content['content']));
33

  
34
// Load HTMLArea
35
if(!isset($loaded_htmlarea)) {
36
	
37
	// Workout how many WYSIWYG sections are used on this page
38
	$query_wysiwyg_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg' ORDER BY position ASC");
39
	$num_wysiwyg_sections = $query_wysiwyg_sections->numRows();
40
	
41
	echo '<script type="text/javascript">'
42
		. '  _editor_url = "'.WB_URL.'/include/htmlarea/";'
43
		. '  _editor_lang = "en";'
44
		. '</script>'
45
		. '<script type="text/javascript" src="'.WB_URL.'/include/htmlarea/htmlarea.js"></script>'
46
		. '<script type="text/javascript">
47
HTMLArea.loadPlugin("ContextMenu");
48
HTMLArea.loadPlugin("TableOperations");
49
function initEditor() {';
50
		
51
	
52
	$query_wysiwyg = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg'");
53
	if($query_wysiwyg->numRows() > 0) {
54
		while($wysiwyg_section = $query_wysiwyg->fetchRow()) {
55
		echo 'var editor = new HTMLArea("content'.$wysiwyg_section["section_id"].'");'
56
			. 'editor.registerPlugin(ContextMenu);'
57
			. 'editor.registerPlugin(TableOperations);'
58
			. 'editor.config.pageStyle = "body { '.$admin->strip_slashes_dummy(WYSIWYG_STYLE).' }";'
59
			. 'editor.generate();';
60
		}
61
	}
62
	
63
	echo '} </script>';
64
	
65
	$loaded_htmlarea = true;
66
	
67
}
68

  
69
?>
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, 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

  
27

  
28
// Get page content
29
$query = "SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$section_id'";
30
$get_content = $database->query($query);
31
$content = $get_content->fetchRow();
32
$content = $admin->strip_slashes_dummy(htmlspecialchars($content['content']));
33

  
34
if(!isset($wysiwyg_editor_loaded)) {
35
	$wysiwyg_editor_loaded=true;
36

  
37
	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="htmlarea" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
38
	
39
		// Workout how many WYSIWYG sections are used on this page
40
		$query_wysiwyg_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg' ORDER BY position ASC");
41
		$num_wysiwyg_sections = $query_wysiwyg_sections->numRows();
42
	
43
		echo '<script type="text/javascript">'
44
			. '  _editor_url = "'.WB_URL.'/include/htmlarea/";'
45
			. '  _editor_lang = "en";'
46
			. '</script>'
47
			. '<script type="text/javascript" src="'.WB_URL.'/include/htmlarea/htmlarea.js"></script>'
48
			. '<script type="text/javascript">
49
HTMLArea.loadPlugin("ContextMenu");
50
HTMLArea.loadPlugin("TableOperations");
51
function initEditor() {';
52
		
53
	
54
		$query_wysiwyg = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg'");
55
		if($query_wysiwyg->numRows() > 0) {
56
			while($wysiwyg_section = $query_wysiwyg->fetchRow()) {
57
			echo 'var editor = new HTMLArea("content'.$wysiwyg_section["section_id"].'");'
58
				. 'editor.registerPlugin(ContextMenu);'
59
				. 'editor.registerPlugin(TableOperations);'
60
				. 'editor.config.pageStyle = "body { '.stripslashes(WYSIWYG_STYLE).' }";'
61
				. 'editor.generate();';
62
			}
63
		}
64

  
65
		echo '} </script>';
66
		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
67
			echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
68
		}
69

  
70
	} else {
71
		$id_list=array();
72
		$query_wysiwyg = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg'");
73
		if($query_wysiwyg->numRows() > 0) {
74
			while($wysiwyg_section = $query_wysiwyg->fetchRow()) {
75
				$entry='content'.$wysiwyg_section['section_id'];
76
				array_push($id_list,$entry);
77
			}
78
			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
79
		}
80
	}
81
}
82

  
83
?>
70 84
<form name="wysiwyg<?php echo $section_id; ?>" action="<?php echo WB_URL; ?>/modules/wysiwyg/save.php" method="post">
71

  
72
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
73
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
74

  
75
<textarea id="content<?php echo $section_id; ?>" name="content" style="width: 725px; height: 350px;"><?php echo $content; ?></textarea>
76

  
77
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding-bottom: 10px;">
78
<tr>
85

  
86
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
87
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
88

  
89
<?php
90
show_wysiwyg_editor('content'.$section_id,'content'.$section_id,$content,'725px','350px');
91
?>
92

  
93
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding-bottom: 10px;">
94
<tr>
79 95
	<td align="left">
80
		<input type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
81
	</td>
82
	<td align="right">
83
		</form>
84
		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
85
	</td>
86
</tr>
87
</table>
88

  
89
</form>
90

  
91
<br />
96
		<input type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
97
	</td>
98
	<td align="right">
99
		</form>
100
		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
101
	</td>
102
</tr>
103
</table>
104

  
105
</form>
106

  
107
<br />

Also available in: Unified diff