Project

General

Profile

1
<?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
?>
53
<script type="text/javascript" src="calendar/calendarDateInput.js"></script>
54

    
55
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
56

    
57
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
58

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

    
64
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
65
<tr>
66
	<td><?php echo $TEXT['TITLE']; ?>:</td>
67
	<td width="80%">
68
		<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" />
69
	</td>
70
</tr>
71
<tr>
72
	<td><?php echo $TEXT['GROUP']; ?>:</td>
73
	<td>
74
		<select name="group" style="width: 100%;">
75
			<option value="0"><?php echo $TEXT['NONE']; ?></option>
76
			<?php
77
			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
78
			if($query->numRows() > 0) {
79
				// Loop through groups
80
				while($group = $query->fetchRow()) {
81
					?>
82
					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected'; } ?>><?php echo $group['title']; ?></option>
83
					<?php
84
				}
85
			}
86
			?>
87
		</select>
88
	</td>
89
</tr>
90
<tr>
91
	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
92
	<td>
93
		<select name="commenting" style="width: 100%;">
94
			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
95
			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo 'selected'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
96
			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo 'selected'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
97
		</select>
98
	</td>
99
</tr>
100
<tr>
101
	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
102
	<td>
103
		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
104
		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
105
		<?php echo $TEXT['YES']; ?>
106
		</a>
107
		&nbsp;
108
		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
109
		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
110
		<?php echo $TEXT['NO']; ?>
111
		</a>
112
	</td>
113
</tr>
114
<tr>
115
	<td><?php echo $TEXT['DATE']; ?>:</td>
116
	<td><script>DateInput('publishdate', true, 'YYYY-MM-DD'<?php if($fetch_content['published_when'] != 0) { echo ",'" . date("Y-m-d",$fetch_content['published_when']) . "'"; } ?>)</script></td>
117
</tr>
118
</table>
119

    
120
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
121
<tr>
122
	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
123
</tr>
124
<tr>
125
	<td>
126
	<?php
127
	show_wysiwyg_editor("short","short",htmlspecialchars($fetch_content['content_short']),"100%","135px");
128
	?>
129
	</td>
130
</tr>
131
<tr>
132
	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
133
</tr>
134
<tr>
135
	<td>
136
	<?php
137
	show_wysiwyg_editor("long","long",htmlspecialchars($fetch_content['content_long']),"100%","300px");
138
	?>
139
	</td>
140
</tr>
141
</table>
142

    
143
<table cellpadding="2" cellspacing="0" border="0" width="100%">
144
<tr>
145
	<td align="left">
146
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;"></form>
147
	</td>
148
	<td align="right">
149
		<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;" />
150
	</td>
151
</tr>
152
</table>
153

    
154
<br />
155

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

    
158
<?php
159

    
160
// Loop through existing posts
161
$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");
162
if($query_comments->numRows() > 0) {
163
	$row = 'a';
164
	?>
165
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
166
	<?php
167
	while($comment = $query_comments->fetchRow()) {
168
		?>
169
		<tr class="row_<?php echo $row; ?>" height="20">
170
			<td width="20" style="padding-left: 5px;">
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']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
172
					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
173
				</a>
174
			</td>	
175
			<td>
176
				<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']; ?>">
177
					<?php echo $comment['title']; ?>
178
				</a>
179
			</td>
180
			<td width="20">
181
				<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']; ?>">
182
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
183
				</a>
184
			</td>
185
		</tr>
186
		<?php
187
		// Alternate row color
188
		if($row == 'a') {
189
			$row = 'b';
190
		} else {
191
			$row = 'a';
192
		}
193
	}
194
	?>
195
	</table>
196
	<?php
197
} else {
198
	echo $TEXT['NONE_FOUND'];
199
}
200

    
201
?>
202

    
203

    
204

    
205
<?php
206

    
207
// Print admin footer
208
$admin->print_footer();
209

    
210
?>
(20-20/32)