Project

General

Profile

1
<?php
2

    
3
// $Id: modify_post.php 571 2008-01-19 19:51:10Z thorn $
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
// include jscalendar-setup
53
$jscal_use_time = false; // whether to use a clock, too
54
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
?>
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
	<td><?php echo $TEXT['DATE']; ?>:</td>
125
	<td>
126
	<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print ""; else print date($jscal_format, $fetch_content['published_when'])?>" style="width: 120px;" />
127
	<img src="<?php echo WB_URL ?>/include/jscalendar/img.gif" id="publishdate_trigger" style="cursor: pointer; border: 1px solid red;" title="Calendar" onmouseover="this.style.background='red';" onmouseout="this.style.background=''" />
128
	</td>
129
</tr>
130
</table>
131

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

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

    
166
<script type="text/javascript">
167
	Calendar.setup(
168
		{
169
			inputField  : "publishdate",
170
			ifFormat    : "<?php echo $jscal_ifformat ?>",
171
			button      : "publishdate_trigger",
172
			firstDay    : <?php echo $jscal_firstday ?>,
173
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?>
174
				showsTime   : "true",
175
				timeFormat  : "24",
176
			<?php } ?>
177
			date        : "<?php echo $jscal_today ?>",
178
			range       : [1970, 2037],
179
			step        : 1
180
		}
181
	);
182
</script>
183

    
184
<br />
185

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

    
188
<?php
189

    
190
// Loop through existing posts
191
$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");
192
if($query_comments->numRows() > 0) {
193
	$row = 'a';
194
	?>
195
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
196
	<?php
197
	while($comment = $query_comments->fetchRow()) {
198
		?>
199
		<tr class="row_<?php echo $row; ?>" height="20">
200
			<td width="20" style="padding-left: 5px;">
201
				<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']; ?>">
202
					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
203
				</a>
204
			</td>	
205
			<td>
206
				<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']; ?>">
207
					<?php echo $comment['title']; ?>
208
				</a>
209
			</td>
210
			<td width="20">
211
				<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']; ?>">
212
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
213
				</a>
214
			</td>
215
		</tr>
216
		<?php
217
		// Alternate row color
218
		if($row == 'a') {
219
			$row = 'b';
220
		} else {
221
			$row = 'a';
222
		}
223
	}
224
	?>
225
	</table>
226
	<?php
227
} else {
228
	echo $TEXT['NONE_FOUND'];
229
}
230

    
231
?>
232

    
233

    
234

    
235
<?php
236

    
237
// Print admin footer
238
$admin->print_footer();
239

    
240
?>
(20-20/32)