Project

General

Profile

1
<?php
2

    
3
// $Id: modify_post.php 1157 2009-10-09 21:54:57Z Luisehahne $
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
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.'" rows="10" cols="1" 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
// include jscalendar-setup
53
$jscal_use_time = true; // whether to use a clock, too
54
require_once(WB_PATH."/include/jscalendar/wb-setup.php");
55
?>
56
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
57
<div class="jsadmin jcalendar hide"></div> 
58
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
59

    
60
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
61
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
62
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
63
<input type="hidden" name="link" value="<?php echo $fetch_content['link']; ?>" />
64

    
65
<table class="row_a" cellpadding="2" cellspacing="0" width="100%">
66
<tr>
67
	<td><?php echo $TEXT['TITLE']; ?>:</td>
68
	<td width="80%">
69
		<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" />
70
	</td>
71
</tr>
72
<tr>
73
	<td><?php echo $TEXT['GROUP']; ?>:</td>
74
	<td>
75
		<select name="group" style="width: 100%;">
76
			<option value="0"><?php echo $TEXT['NONE']; ?></option>
77
			<?php
78
			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
79
			if($query->numRows() > 0) {
80
				// Loop through groups
81
				while($group = $query->fetchRow()) {
82
					?>
83
					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
84
					<?php
85
				}
86
			}
87
			?>
88
		</select>
89
	</td>
90
</tr>
91
<tr>
92
	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
93
	<td>
94
		<select name="commenting" style="width: 100%;">
95
			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
96
			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
97
			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
98
		</select>
99
	</td>
100
</tr>
101
<tr>
102
	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
103
	<td>
104
		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked="checked"'; } ?> />
105
		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
106
		<?php echo $TEXT['YES']; ?>
107
		</a>
108
		&nbsp;
109
		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked="checked"'; } ?> />
110
		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
111
		<?php echo $TEXT['NO']; ?>
112
		</a>
113
	</td>
114
</tr>
115
<tr>
116
	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
117
	<td>
118
	<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print date($jscal_format, strtotime((date('Y-m-d H:i')))); else print date($jscal_format, $fetch_content['published_when']);?>" style="width: 120px;" />
119
	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
120
	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" />
121
	</td>
122
</tr>
123
<tr>
124
	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
125
	<td>
126
	<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;" />
127
	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="enddate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
128
	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.enddate.value=''" />
129
	</td>
130
</tr>
131
</table>
132

    
133
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
134
<tr>
135
	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
136
</tr>
137
<tr>
138
	<td>
139
	<?php
140
	show_wysiwyg_editor("short","short",htmlspecialchars($fetch_content['content_short']),"100%","150px");
141
	?>
142
	</td>
143
</tr>
144
<tr>
145
	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
146
</tr>
147
<tr>
148
	<td>
149
	<?php
150
	show_wysiwyg_editor("long","long",htmlspecialchars($fetch_content['content_long']),"100%","350px");
151
	?>
152
	</td>
153
</tr>
154
</table>
155

    
156
<table cellpadding="2" cellspacing="0" border="0" width="100%">
157
<tr>
158
	<td align="left">
159
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
160
	</td>
161
	<td align="right">
162
		<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;" />
163
	</td>
164
</tr>
165
</table>
166
</form>
167

    
168
<script type="text/javascript">
169
	Calendar.setup(
170
		{
171
			inputField  : "publishdate",
172
			ifFormat    : "<?php echo $jscal_ifformat ?>",
173
			button      : "publishdate_trigger",
174
			firstDay    : <?php echo $jscal_firstday ?>,
175
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
176
            { ?>
177
				showsTime   : "true",
178
				timeFormat  : "24",
179
			<?php
180
            } ?>
181
			date        : "<?php echo $jscal_today ?>",
182
			range       : [1970, 2037],
183
			step        : 1
184
		}
185
	);
186
	Calendar.setup(
187
		{
188
			inputField  : "enddate",
189
			ifFormat    : "<?php echo $jscal_ifformat ?>",
190
			button      : "enddate_trigger",
191
			firstDay    : <?php echo $jscal_firstday ?>,
192
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
193
            { ?>
194
				showsTime   : "true",
195
				timeFormat  : "24",
196
			<?php
197
            } ?>
198
			date        : "<?php echo $jscal_today ?>",
199
			range       : [1970, 2037],
200
			step        : 1
201
		}
202
	);
203
</script>
204

    
205
<br />
206

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

    
209
<?php
210

    
211
// Loop through existing posts
212
$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");
213
if($query_comments->numRows() > 0) {
214
	$row = 'a';
215
	?>
216
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
217
	<?php
218
	while($comment = $query_comments->fetchRow()) {
219
		?>
220
		<tr class="row_<?php echo $row; ?>" >
221
			<td width="20" style="padding-left: 5px;">
222
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
223
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
224
				</a>
225
			</td>	
226
			<td>
227
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;comment_id=<?php echo $comment['comment_id']; ?>">
228
					<?php echo $comment['title']; ?>
229
				</a>
230
			</td>
231
			<td width="20">
232
				<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; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post_id; ?>&amp;comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
233
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
234
				</a>
235
			</td>
236
		</tr>
237
		<?php
238
		// Alternate row color
239
		if($row == 'a') {
240
			$row = 'b';
241
		} else {
242
			$row = 'a';
243
		}
244
	}
245
	?>
246
	</table>
247
	<?php
248
} else {
249
	echo $TEXT['NONE_FOUND'];
250
}
251

    
252

    
253
// Print admin footer
254
$admin->print_footer();
255

    
256
?>
(18-18/31)