Project

General

Profile

« Previous | Next » 

Revision 45

Added by stefan about 19 years ago

Implemented choice of WYSIWYG editor

View differences:

modify_post.php
1
<?php
2

  
3
// $Id$
1
<?php
4 2

  
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
*/
3
// $Id$
25 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 26
require('../../config.php');
27

  
28
// Get id
29
if(!isset($_GET['post_id']) OR !is_numeric($_GET['post_id'])) {
30
	header("Location: ".ADMIN_URL."/pages/index.php");
31
} else {
32
	$post_id = $_GET['post_id'];
33
}
34

  
35
// Include WB admin wrapper script
36
require(WB_PATH.'/modules/admin.php');
37

  
27

  
28
// Get id

29
if(!isset($_GET['post_id']) OR !is_numeric($_GET['post_id'])) {

30
	header("Location: ".ADMIN_URL."/pages/index.php");

31
} else {

32
	$post_id = $_GET['post_id'];

33
}

34

  
35
// Include WB admin wrapper script

36
require(WB_PATH.'/modules/admin.php');

37

  
38 38
// Get header and footer
39 39
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
40
$fetch_content = $query_content->fetchRow();
41

  
42
?>
43
<script type="text/javascript">
44
_editor_url = "<?php echo WB_URL; ?>/include/htmlarea/";
45
_editor_lang = "en";
46
</script>
47
<script type="text/javascript" src="<?php echo WB_URL; ?>/include/htmlarea/htmlarea.js"></script>
48
<script type="text/javascript">
49
HTMLArea.loadPlugin("ContextMenu");
50
HTMLArea.loadPlugin("TableOperations");
51
function initEditor() {
52
	var editor = new HTMLArea("short");
53
	editor.registerPlugin(ContextMenu);
54
	editor.config.pageStyle = "body { <?php echo $admin->strip_slashes_dummy(WYSIWYG_STYLE); ?> }";
55
	editor.generate();
56
	var editor = new HTMLArea("long");
57
	editor.registerPlugin(ContextMenu);
58
	editor.registerPlugin(TableOperations);
59
	editor.config.pageStyle = "body { <?php echo $admin->strip_slashes_dummy(WYSIWYG_STYLE); ?> }";
60
	editor.generate();
61
}
40
$fetch_content = $query_content->fetchRow();
41

  
42
if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="htmlarea" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
43
?>
44
<script type="text/javascript">
45
_editor_url = "<?php echo WB_URL; ?>/include/htmlarea/";
46
_editor_lang = "en";
62 47
</script>
48
<script type="text/javascript" src="<?php echo WB_URL; ?>/include/htmlarea/htmlarea.js"></script>
49
<script type="text/javascript">
50
HTMLArea.loadPlugin("ContextMenu");
51
HTMLArea.loadPlugin("TableOperations");
52
function initEditor() {
53
	var editor = new HTMLArea("short");
54
	editor.registerPlugin(ContextMenu);
55
	editor.config.pageStyle = "body { <?php echo $admin->strip_slashes_dummy(WYSIWYG_STYLE); ?> }";
56
	editor.generate();
57
	var editor = new HTMLArea("long");
58
	editor.registerPlugin(ContextMenu);
59
	editor.registerPlugin(TableOperations);
60
	editor.config.pageStyle = "body { <?php echo $admin->strip_slashes_dummy(WYSIWYG_STYLE); ?> }";
61
	editor.generate();
62
}
63
</script>
64
<?php
65
	function show_wysiwyg_editor($name,$id,$content,$width,$height) {
66
		echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
67
	}
68
} else {
69
	$id_list=array("short","long");
70
			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
71
}
63 72

  
73
?>
64 74
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
65 75

  
66
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
67
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
68
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>">
76
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">

77
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">

78
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>">

69 79
<input type="hidden" name="link" value="<?php echo $fetch_content['link']; ?>">
70

  
71
<table cellpadding="4" cellspacing="0" border="0" width="100%">
72
<tr>
73
	<td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
74
	<td>
75
		<input type="text" name="title" value="<?php echo $admin->strip_slashes_dummy(htmlspecialchars($fetch_content['title'])); ?>" style="width: 100%;" maxlength="255" />
76
	</td>
77
</tr>
78
<tr>
79
	<td><?php echo $TEXT['GROUP']; ?>:</td>
80
	<td>
81
		<select name="group" style="width: 100%;">
82
			<option value="0"><?php echo $TEXT['NONE']; ?></option>
83
			<?php
84
			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
85
			if($query->numRows() > 0) {
86
				// Loop through groups
87
				while($group = $query->fetchRow()) {
88
					?>
89
					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected'; } ?>><?php echo $group['title']; ?></option>
90
					<?php
91
				}
92
			}
93
			?>
94
		</select>
95
	</td>
96
</tr>
97
<tr>
98
	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
99
	<td>
100
		<select name="commenting" style="width: 100%;">
101
			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
102
			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo 'selected'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
103
			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo 'selected'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
104
		</select>
105
	</td>
106
</tr>
107
<tr>
108
	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
109
	<td>
110
		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
111
		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
112
		<?php echo $TEXT['YES']; ?>
113
		</a>
114
		&nbsp;
115
		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
116
		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
117
		<?php echo $TEXT['NO']; ?>
118
		</a>
119
	</td>
120
</tr>
121
<tr>
122
	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
123
	<td>
124
		<textarea name="short" id="short" style="width: 100%; height: 135px;"><?php echo htmlspecialchars($admin->strip_slashes_dummy($fetch_content['short'])); ?></textarea>
125
	</td>
126
</tr>
127
<tr>
128
	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
129
	<td>
130
		<textarea name="long" id="long" style="width: 100%; height: 300px;"><?php echo htmlspecialchars($admin->strip_slashes_dummy($fetch_content['long'])); ?></textarea>
131
	</td>
132
</tr>
80

  
81
<table cellpadding="4" cellspacing="0" border="0" width="100%">
82
<tr>
83
	<td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
84
	<td>
85
		<input type="text" name="title" value="<?php echo $admin->strip_slashes_dummy(htmlspecialchars($fetch_content['title'])); ?>" style="width: 100%;" maxlength="255" />
86
	</td>
87
</tr>
88
<tr>
89
	<td><?php echo $TEXT['GROUP']; ?>:</td>
90
	<td>
91
		<select name="group" style="width: 100%;">
92
			<option value="0"><?php echo $TEXT['NONE']; ?></option>
93
			<?php
94
			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
95
			if($query->numRows() > 0) {
96
				// Loop through groups
97
				while($group = $query->fetchRow()) {
98
					?>
99
					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected'; } ?>><?php echo $group['title']; ?></option>
100
					<?php
101
				}
102
			}
103
			?>
104
		</select>
105
	</td>
106
</tr>
107
<tr>
108
	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
109
	<td>
110
		<select name="commenting" style="width: 100%;">
111
			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
112
			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo 'selected'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
113
			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo 'selected'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
114
		</select>
115
	</td>
116
</tr>
117
<tr>
118
	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
119
	<td>
120
		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
121
		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
122
		<?php echo $TEXT['YES']; ?>
123
		</a>
124
		&nbsp;
125
		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
126
		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
127
		<?php echo $TEXT['NO']; ?>
128
		</a>
129
	</td>
130
</tr>
131
<tr>
132
	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
133
	<td>
134
	<?php
135
	show_wysiwyg_editor("short","short",$fetch_content['short'],"100%","135px");
136
	?>
137
	</td>
138
</tr>
139
<tr>
140
	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
141
	<td>
142
	<?php
143
	show_wysiwyg_editor("long","long",$fetch_content['long'],"100%","300px");
144
	?>
145
	</td>
146
</tr>
133 147
</table>
134

  
135
<table cellpadding="0" cellspacing="0" border="0" width="100%">
136
<tr>
137
	<td width="90">
138
		&nbsp;
139
	</td>
148

  
149
<table cellpadding="0" cellspacing="0" border="0" width="100%">

150
<tr>

151
	<td width="90">

152
		&nbsp;

153
	</td>

140 154
	<td align="left">
141
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 200px; margin-top: 5px;"></form>
142
	</td>
155
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 200px; margin-top: 5px;"></form>

156
	</td>

143 157
	<td align="right">
144
		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
145
	</td>
146
</tr>
147
</table>
148

  
149
<br />
158
		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
159
	</td>
160
</tr>
161
</table>
150 162

  
151
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
152

  
153
<?php
154

  
155
// Loop through existing posts
156
$query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
157
if($query_comments->numRows() > 0) {
158
	$row = 'a';
159
	?>
160
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
161
	<?php
162
	while($comment = $query_comments->fetchRow()) {
163
		?>
164
		<tr class="row_<?php echo $row; ?>" height="20">
165
			<td width="20" style="padding-left: 5px;">
166
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
167
					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
168
				</a>
169
			</td>	
170
			<td>
171
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>">
172
					<?php echo $comment['title']; ?>
173
				</a>
174
			</td>
175
			<td width="20">
176
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
177
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
178
				</a>
179
			</td>
180
		</tr>
181
		<?php
182
		// Alternate row color
183
		if($row == 'a') {
184
			$row = 'b';
185
		} else {
186
			$row = 'a';
187
		}
188
	}
189
	?>
190
	</table>
191
	<?php
192
} else {
193
	echo $TEXT['NONE_FOUND'];
194
}
195

  
196
?>
197

  
198

  
199

  
200
<?php
201

  
202
// Print admin footer
203
$admin->print_footer();
204

  
205
?>
163
<br />
164

  
165
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
166

  
167
<?php
168

  
169
// Loop through existing posts
170
$query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
171
if($query_comments->numRows() > 0) {
172
	$row = 'a';
173
	?>
174
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
175
	<?php
176
	while($comment = $query_comments->fetchRow()) {
177
		?>
178
		<tr class="row_<?php echo $row; ?>" height="20">
179
			<td width="20" style="padding-left: 5px;">
180
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
181
					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
182
				</a>
183
			</td>	
184
			<td>
185
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>">
186
					<?php echo $comment['title']; ?>
187
				</a>
188
			</td>
189
			<td width="20">
190
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
191
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
192
				</a>
193
			</td>
194
		</tr>
195
		<?php
196
		// Alternate row color
197
		if($row == 'a') {
198
			$row = 'b';
199
		} else {
200
			$row = 'a';
201
		}
202
	}
203
	?>
204
	</table>
205
	<?php
206
} else {
207
	echo $TEXT['NONE_FOUND'];
208
}
209

  
210
?>
211

  
212

  
213

  
214
<?php
215

  
216
// Print admin footer
217
$admin->print_footer();
218

  
219
?>

Also available in: Unified diff