Project

General

Profile

1 562 Ruebenwurz
<?php
2
3
// $Id$
4
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, 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
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
	exit(0);
32
} else {
33
	$post_id = $_GET['post_id'];
34
}
35
36
// Include WB admin wrapper script
37
require(WB_PATH.'/modules/admin.php');
38
39
// Get header and footer
40
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
41
$fetch_content = $query_content->fetchRow();
42
43
if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
44
	function show_wysiwyg_editor($name,$id,$content,$width,$height) {
45
		echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
46
	}
47
} else {
48
	$id_list=array("short","long");
49
			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
50
}
51
52 571 thorn
// include jscalendar-setup
53 600 thorn
$jscal_use_time = true; // whether to use a clock, too
54 571 thorn
require_once(WB_PATH."/include/jscalendar/wb-setup.php");
55
// override some vars: (normally, there is no need to change this)
56
//$jscal_lang = "en"; //- calendar-language (default: wb-backend-language)
57
//$jscal_today = ""; // - date the calendar offers if the text-field is empty (default: today)
58
//$jscal_firstday = "0"; // - first-day-of-week (0-sunday, 1-monday, ...) (default: 0(EN) or 1(everything else))
59
//$jscal_format = "Y-m-d"; // - initial-format used for the text-field (default: from wb-backend-date-format)
60
//$jscal_ifformat = "%Y-%m-%d"; // - format for jscalendar (default: from wb-backend-date-format)
61
62 562 Ruebenwurz
?>
63
64
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
65
66
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
67
68
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
69
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
70
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>">
71
<input type="hidden" name="link" value="<?php echo $fetch_content['link']; ?>">
72
73
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
74
<tr>
75
	<td><?php echo $TEXT['TITLE']; ?>:</td>
76
	<td width="80%">
77
		<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" />
78
	</td>
79
</tr>
80
<tr>
81
	<td><?php echo $TEXT['GROUP']; ?>:</td>
82
	<td>
83
		<select name="group" style="width: 100%;">
84
			<option value="0"><?php echo $TEXT['NONE']; ?></option>
85
			<?php
86
			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
87
			if($query->numRows() > 0) {
88
				// Loop through groups
89
				while($group = $query->fetchRow()) {
90
					?>
91
					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected'; } ?>><?php echo $group['title']; ?></option>
92
					<?php
93
				}
94
			}
95
			?>
96
		</select>
97
	</td>
98
</tr>
99
<tr>
100
	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
101
	<td>
102
		<select name="commenting" style="width: 100%;">
103
			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
104
			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo 'selected'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
105
			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo 'selected'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
106
		</select>
107
	</td>
108
</tr>
109
<tr>
110
	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
111
	<td>
112
		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
113
		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
114
		<?php echo $TEXT['YES']; ?>
115
		</a>
116
		&nbsp;
117
		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
118
		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
119
		<?php echo $TEXT['NO']; ?>
120
		</a>
121
	</td>
122
</tr>
123
<tr>
124 600 thorn
	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
125 571 thorn
	<td>
126 600 thorn
	<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print date($jscal_format, time()); else print date($jscal_format, $fetch_content['published_when']);?>" style="width: 120px;" />
127
	<img src="<?php echo ADMIN_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="Calendar" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
128
	<img src="<?php echo ADMIN_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="delete date" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" />
129 571 thorn
	</td>
130 562 Ruebenwurz
</tr>
131 600 thorn
<tr>
132
	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
133
	<td>
134
	<input type="text" id="enddate" name="enddate" value="<?php if($fetch_content['published_until']==0) print ""; else print date($jscal_format, $fetch_content['published_until'])?>" style="width: 120px;" />
135
	<img src="<?php echo ADMIN_URL ?>/images/clock_16.png" id="enddate_trigger" style="cursor: pointer;" title="Calendar" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
136
	<img src="<?php echo ADMIN_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="delete date" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.enddate.value=''" />
137
	</td>
138
</tr>
139 562 Ruebenwurz
</table>
140
141
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
142
<tr>
143
	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
144
</tr>
145
<tr>
146
	<td>
147
	<?php
148
	show_wysiwyg_editor("short","short",htmlspecialchars($fetch_content['content_short']),"100%","135px");
149
	?>
150
	</td>
151
</tr>
152
<tr>
153
	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
154
</tr>
155
<tr>
156
	<td>
157
	<?php
158
	show_wysiwyg_editor("long","long",htmlspecialchars($fetch_content['content_long']),"100%","300px");
159
	?>
160
	</td>
161
</tr>
162
</table>
163
164
<table cellpadding="2" cellspacing="0" border="0" width="100%">
165
<tr>
166
	<td align="left">
167
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;"></form>
168
	</td>
169
	<td align="right">
170
		<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;" />
171
	</td>
172
</tr>
173
</table>
174
175 571 thorn
<script type="text/javascript">
176
	Calendar.setup(
177
		{
178
			inputField  : "publishdate",
179
			ifFormat    : "<?php echo $jscal_ifformat ?>",
180
			button      : "publishdate_trigger",
181
			firstDay    : <?php echo $jscal_firstday ?>,
182
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?>
183
				showsTime   : "true",
184
				timeFormat  : "24",
185
			<?php } ?>
186
			date        : "<?php echo $jscal_today ?>",
187
			range       : [1970, 2037],
188
			step        : 1
189
		}
190
	);
191 600 thorn
	Calendar.setup(
192
		{
193
			inputField  : "enddate",
194
			ifFormat    : "<?php echo $jscal_ifformat ?>",
195
			button      : "enddate_trigger",
196
			firstDay    : <?php echo $jscal_firstday ?>,
197
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?>
198
				showsTime   : "true",
199
				timeFormat  : "24",
200
			<?php } ?>
201
			date        : "<?php echo $jscal_today ?>",
202
			range       : [1970, 2037],
203
			step        : 1
204
		}
205
	);
206 571 thorn
</script>
207
208 562 Ruebenwurz
<br />
209
210
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
211
212
<?php
213
214
// Loop through existing posts
215
$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");
216
if($query_comments->numRows() > 0) {
217
	$row = 'a';
218
	?>
219
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
220
	<?php
221
	while($comment = $query_comments->fetchRow()) {
222
		?>
223
		<tr class="row_<?php echo $row; ?>" height="20">
224
			<td width="20" style="padding-left: 5px;">
225
				<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']; ?>">
226
					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
227
				</a>
228
			</td>
229
			<td>
230
				<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']; ?>">
231
					<?php echo $comment['title']; ?>
232
				</a>
233
			</td>
234
			<td width="20">
235
				<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']; ?>">
236
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
237
				</a>
238
			</td>
239
		</tr>
240
		<?php
241
		// Alternate row color
242
		if($row == 'a') {
243
			$row = 'b';
244
		} else {
245
			$row = 'a';
246
		}
247
	}
248
	?>
249
	</table>
250
	<?php
251
} else {
252
	echo $TEXT['NONE_FOUND'];
253
}
254
255
?>
256
257
258
259
<?php
260
261
// Print admin footer
262
$admin->print_footer();
263
264
?>