Project

General

Profile

1 45 stefan
<?php
2 4 ryan
3 45 stefan
// $Id$
4 4 ryan
5 45 stefan
/*
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 4 ryan
require('../../config.php');
27 45 stefan
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 4 ryan
// Get header and footer
39
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
40 45 stefan
$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";
47 4 ryan
</script>
48 45 stefan
<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
}
72 4 ryan
73 45 stefan
?>
74 4 ryan
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
75
76 45 stefan
<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; ?>">
79 4 ryan
<input type="hidden" name="link" value="<?php echo $fetch_content['link']; ?>">
80 45 stefan
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>
147 4 ryan
</table>
148 45 stefan
149
<table cellpadding="0" cellspacing="0" border="0" width="100%">
150
<tr>
151
	<td width="90">
152
		&nbsp;
153
	</td>
154 4 ryan
	<td align="left">
155 45 stefan
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 200px; margin-top: 5px;"></form>
156
	</td>
157 4 ryan
	<td align="right">
158 45 stefan
		<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>
162 4 ryan
163 45 stefan
<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
?>