1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package news
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright WebsiteBaker Org. e.V.
|
8
|
* @link http://websitebaker.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.3
|
11
|
* @requirements PHP 5.3.6 and higher
|
12
|
* @version $Id: modify_post.php 2 2017-07-02 15:14:29Z Manuela $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/modules/news/modify_post.php $
|
14
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
19
|
|
20
|
// $admin_header = true;
|
21
|
// Tells script to update when this page was last updated
|
22
|
$update_when_modified = false;
|
23
|
// show the info banner
|
24
|
$print_info_banner = true;
|
25
|
// Include WB admin wrapper script
|
26
|
require(WB_PATH.'/modules/admin.php');
|
27
|
|
28
|
$backlink = ADMIN_URL.'/pages/modify.php?page_id='.(int)$page_id;
|
29
|
$post_id = intval($admin->checkIDKEY('post_id', false, 'GET'));
|
30
|
if (!$post_id) {
|
31
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $backlink);
|
32
|
}
|
33
|
|
34
|
// Get header and footer
|
35
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` '
|
36
|
. 'WHERE `post_id` = '.$post_id.' '
|
37
|
. 'ORDER BY `position` ASC';
|
38
|
$query_content = $database->query($sql);
|
39
|
$fetch_content = $query_content->fetchRow(MYSQLI_ASSOC);
|
40
|
|
41
|
if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
|
42
|
function show_wysiwyg_editor($name,$id,$content,$width,$height) {
|
43
|
echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
|
44
|
}
|
45
|
} else {
|
46
|
$id_list=array("short","long");
|
47
|
require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
|
48
|
}
|
49
|
|
50
|
// include jscalendar-setup
|
51
|
$jscal_use_time = true; // whether to use a clock, too
|
52
|
require_once(WB_PATH."/include/jscalendar/wb-setup.php");
|
53
|
?>
|
54
|
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
|
55
|
<div class="jsadmin jcalendar hide"></div>
|
56
|
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
|
57
|
<?php echo $admin->getFTAN(); ?>
|
58
|
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
|
59
|
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
|
60
|
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
|
61
|
|
62
|
<table class="row_a news">
|
63
|
<tr>
|
64
|
<td><?php echo $TEXT['TITLE']; ?>:</td>
|
65
|
<td width="80%">
|
66
|
<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" />
|
67
|
</td>
|
68
|
</tr>
|
69
|
<tr>
|
70
|
<td><?php echo $TEXT['GROUP']; ?>:</td>
|
71
|
<td>
|
72
|
<select name="group" style="width: 100%;">
|
73
|
<option value="0"><?php echo $TEXT['NONE']; ?></option>
|
74
|
<?php
|
75
|
$sql = 'SELECT `group_id`, `title` FROM `'.TABLE_PREFIX.'mod_news_groups` '
|
76
|
.'WHERE `section_id` = '.$section_id.' '
|
77
|
.'ORDER BY `position` ASC';
|
78
|
$query = $database->query($sql);
|
79
|
if($query->numRows() > 0) {
|
80
|
// Loop through groups
|
81
|
while($group = $query->fetchRow(MYSQLI_ASSOC)) {
|
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="document.getElementById('active_true').checked = true;">
|
106
|
<?php echo $TEXT['YES']; ?>
|
107
|
</a>
|
108
|
|
109
|
<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked="checked"'; } ?> />
|
110
|
<a href="#" onclick="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
|
<?php
|
119
|
if ($fetch_content['published_when']==0) {
|
120
|
$iPublishedWhen = date($jscal_format, strtotime((date('Y-m-d H:i')))+TIMEZONE);
|
121
|
} else {
|
122
|
$iPublishedWhen = date($jscal_format, $fetch_content['published_when']+TIMEZONE);
|
123
|
}
|
124
|
?>
|
125
|
<input type="text" id="publishdate" name="publishdate" value="<?php echo $iPublishedWhen;?>" style="width: 120px;" />
|
126
|
<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=''" />
|
127
|
<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=''" />
|
128
|
</td>
|
129
|
</tr>
|
130
|
<tr>
|
131
|
<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
|
132
|
<td>
|
133
|
<?php
|
134
|
if ($fetch_content['published_until']==0) {
|
135
|
$iPublishedUntil = '';
|
136
|
} else {
|
137
|
$iPublishedUntil = date($jscal_format, $fetch_content['published_until']+TIMEZONE);
|
138
|
}
|
139
|
?>
|
140
|
<input type="text" id="enddate" name="enddate" value="<?php echo $iPublishedUntil;?>" style="width: 120px;" />
|
141
|
<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=''" />
|
142
|
<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=''" />
|
143
|
</td>
|
144
|
</tr>
|
145
|
</table>
|
146
|
|
147
|
<table class="row_a news">
|
148
|
<tr>
|
149
|
<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
|
150
|
</tr>
|
151
|
<tr>
|
152
|
<td>
|
153
|
<?php
|
154
|
$contentShort = $fetch_content['content_short'];
|
155
|
$contentLong = $fetch_content['content_long'];
|
156
|
$sFilterApi = WB_PATH.'/modules/output_filter/OutputFilterApi.php';
|
157
|
if (is_readable($sFilterApi)) {
|
158
|
require_once($sFilterApi);
|
159
|
$contentShort = OutputFilterApi('ReplaceSysvar', $contentShort);
|
160
|
$contentLong = OutputFilterApi('ReplaceSysvar', $contentLong);
|
161
|
}
|
162
|
show_wysiwyg_editor("short","short",htmlspecialchars($contentShort),"100%","200px");
|
163
|
?>
|
164
|
</td>
|
165
|
</tr>
|
166
|
<tr>
|
167
|
<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
|
168
|
</tr>
|
169
|
<tr>
|
170
|
<td>
|
171
|
<?php
|
172
|
show_wysiwyg_editor("long","long",htmlspecialchars($contentLong),"100%","650px");
|
173
|
?>
|
174
|
</td>
|
175
|
</tr>
|
176
|
</table>
|
177
|
|
178
|
<table class="news">
|
179
|
<tr>
|
180
|
<td align="left">
|
181
|
<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
|
182
|
</td>
|
183
|
<td align="right">
|
184
|
<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;" />
|
185
|
</td>
|
186
|
</tr>
|
187
|
</table>
|
188
|
</form>
|
189
|
|
190
|
<script type="text/javascript">
|
191
|
Calendar.setup(
|
192
|
{
|
193
|
inputField : "publishdate",
|
194
|
ifFormat : "<?php echo $jscal_ifformat ?>",
|
195
|
button : "publishdate_trigger",
|
196
|
firstDay : <?php echo $jscal_firstday ?>,
|
197
|
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
|
198
|
{ ?>
|
199
|
showsTime : "true",
|
200
|
timeFormat : "24",
|
201
|
<?php
|
202
|
} ?>
|
203
|
date : "<?php echo $jscal_today ?>",
|
204
|
range : [1970, 2037],
|
205
|
step : 1
|
206
|
}
|
207
|
);
|
208
|
Calendar.setup(
|
209
|
{
|
210
|
inputField : "enddate",
|
211
|
ifFormat : "<?php echo $jscal_ifformat ?>",
|
212
|
button : "enddate_trigger",
|
213
|
firstDay : <?php echo $jscal_firstday ?>,
|
214
|
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
|
215
|
{ ?>
|
216
|
showsTime : "true",
|
217
|
timeFormat : "24",
|
218
|
<?php
|
219
|
} ?>
|
220
|
date : "<?php echo $jscal_today ?>",
|
221
|
range : [1970, 2037],
|
222
|
step : 1
|
223
|
}
|
224
|
);
|
225
|
</script>
|
226
|
|
227
|
<br />
|
228
|
|
229
|
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
|
230
|
|
231
|
<?php
|
232
|
|
233
|
// Loop through existing posts
|
234
|
$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");
|
235
|
if($query_comments->numRows() > 0) {
|
236
|
$row = 'a';
|
237
|
$pid = $admin->getIDKEY($post_id);
|
238
|
?>
|
239
|
<table class="news">
|
240
|
<?php
|
241
|
while($comment = $query_comments->fetchRow()) {
|
242
|
$cid = $admin->getIDKEY($comment['comment_id']);
|
243
|
?>
|
244
|
<tr class="row_<?php echo $row; ?>" >
|
245
|
<td width="20" style="padding-left: 5px;">
|
246
|
<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php
|
247
|
echo $section_id; ?>&comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
|
248
|
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
|
249
|
</a>
|
250
|
</td>
|
251
|
<td>
|
252
|
<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php
|
253
|
echo $section_id; ?>&comment_id=<?php echo $cid; ?>">
|
254
|
<?php echo $comment['title']; ?>
|
255
|
</a>
|
256
|
</td>
|
257
|
<td width="20">
|
258
|
<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
|
259
|
echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php
|
260
|
echo $section_id; ?>&post_id=<?php echo $pid; ?>&comment_id=<?php echo $cid; ?>');" title="<?php
|
261
|
echo $TEXT['DELETE']; ?>">
|
262
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
263
|
</a>
|
264
|
</td>
|
265
|
</tr>
|
266
|
<?php
|
267
|
// Alternate row color
|
268
|
if($row == 'a') {
|
269
|
$row = 'b';
|
270
|
} else {
|
271
|
$row = 'a';
|
272
|
}
|
273
|
}
|
274
|
?>
|
275
|
</table>
|
276
|
<?php
|
277
|
} else {
|
278
|
echo $TEXT['NONE_FOUND'];
|
279
|
}
|
280
|
|
281
|
// Print admin footer
|
282
|
$admin->print_footer();
|