Revision 1064
Added by Matthias over 15 years ago
trunk/CHANGELOG | ||
---|---|---|
11 | 11 |
! = Update/Change |
12 | 12 |
|
13 | 13 |
------------------------------------- 2.8.0 ------------------------------------- |
14 |
14-July 2009 Matthias Gallas |
|
15 |
# Fixed some validiation bugs in news modul (Thanks to Luisehahne) |
|
14 | 16 |
14-July 2009 Dietrich Roland Pehlke |
15 |
# Removed added marker, placed by mistake, to avoid double loading of backend.js files |
|
16 |
14-July 2009 Dietrich Roland Pehlke |
|
17 | 17 |
! changes in frontend.functions.php, line 323: 'date' to 'gmdate' to avoid E_STRICT warnings. |
18 | 18 |
! changes in wb-setup.php, line 50: 'date' to 'gmdate' to avoid E_STRICT warnings. See also #741. |
19 |
! Add missing backend-js marker in the backend-themes templates (header.htt) |
|
20 | 19 |
13-July 2009 Matthias Gallas |
21 | 20 |
+ added changes from news/add.php to the upgrade-script.php |
22 | 21 |
13-July-2009 Ruud Eisinga |
trunk/wb/modules/news/modify_post.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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.'" 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 |
|
|
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" border="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'; } ?>><?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'; } ?>><?php echo $TEXT['PUBLIC']; ?></option> |
|
97 |
<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo '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'; } ?> /> |
|
105 |
<a href="#" onclick="javascript: 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'; } ?> /> |
|
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']; ?>" 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']; ?>" 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']; ?>" 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']; ?>" 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%","135px"); |
|
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%","300px"); |
|
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;"></form> |
|
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 |
|
|
167 |
<script type="text/javascript"> |
|
168 |
Calendar.setup( |
|
169 |
{ |
|
170 |
inputField : "publishdate", |
|
171 |
ifFormat : "<?php echo $jscal_ifformat ?>", |
|
172 |
button : "publishdate_trigger", |
|
173 |
firstDay : <?php echo $jscal_firstday ?>, |
|
174 |
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?> |
|
175 |
showsTime : "true", |
|
176 |
timeFormat : "24", |
|
177 |
<?php } ?> |
|
178 |
date : "<?php echo $jscal_today ?>", |
|
179 |
range : [1970, 2037], |
|
180 |
step : 1 |
|
181 |
} |
|
182 |
); |
|
183 |
Calendar.setup( |
|
184 |
{ |
|
185 |
inputField : "enddate", |
|
186 |
ifFormat : "<?php echo $jscal_ifformat ?>", |
|
187 |
button : "enddate_trigger", |
|
188 |
firstDay : <?php echo $jscal_firstday ?>, |
|
189 |
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?> |
|
190 |
showsTime : "true", |
|
191 |
timeFormat : "24", |
|
192 |
<?php } ?> |
|
193 |
date : "<?php echo $jscal_today ?>", |
|
194 |
range : [1970, 2037], |
|
195 |
step : 1 |
|
196 |
} |
|
197 |
); |
|
198 |
</script> |
|
199 |
|
|
200 |
<br /> |
|
201 |
|
|
202 |
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2> |
|
203 |
|
|
204 |
<?php |
|
205 |
|
|
206 |
// Loop through existing posts |
|
207 |
$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"); |
|
208 |
if($query_comments->numRows() > 0) { |
|
209 |
$row = 'a'; |
|
210 |
?> |
|
211 |
<table cellpadding="2" cellspacing="0" border="0" width="100%"> |
|
212 |
<?php |
|
213 |
while($comment = $query_comments->fetchRow()) { |
|
214 |
?> |
|
215 |
<tr class="row_<?php echo $row; ?>" height="20"> |
|
216 |
<td width="20" style="padding-left: 5px;"> |
|
217 |
<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"> |
|
218 |
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" /> |
|
219 |
</a> |
|
220 |
</td> |
|
221 |
<td> |
|
222 |
<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>"> |
|
223 |
<?php echo $comment['title']; ?> |
|
224 |
</a> |
|
225 |
</td> |
|
226 |
<td width="20"> |
|
227 |
<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; ?>§ion_id=<?php echo $section_id; ?>&post_id=<?php echo $post_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>"> |
|
228 |
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" /> |
|
229 |
</a> |
|
230 |
</td> |
|
231 |
</tr> |
|
232 |
<?php |
|
233 |
// Alternate row color |
|
234 |
if($row == 'a') { |
|
235 |
$row = 'b'; |
|
236 |
} else { |
|
237 |
$row = 'a'; |
|
238 |
} |
|
239 |
} |
|
240 |
?> |
|
241 |
</table> |
|
242 |
<?php |
|
243 |
} else { |
|
244 |
echo $TEXT['NONE_FOUND']; |
|
245 |
} |
|
246 |
|
|
247 |
?> |
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
<?php |
|
252 |
|
|
253 |
// Print admin footer |
|
254 |
$admin->print_footer(); |
|
255 |
|
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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.'" 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 |
|
|
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" border="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'; } ?>><?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'; } ?>><?php echo $TEXT['PUBLIC']; ?></option> |
|
97 |
<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo '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 |
|
|
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%","135px"); |
|
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%","300px"); |
|
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 |
showsTime : "true", |
|
177 |
timeFormat : "24", |
|
178 |
<?php } ?> |
|
179 |
date : "<?php echo $jscal_today ?>", |
|
180 |
range : [1970, 2037], |
|
181 |
step : 1 |
|
182 |
} |
|
183 |
); |
|
184 |
Calendar.setup( |
|
185 |
{ |
|
186 |
inputField : "enddate", |
|
187 |
ifFormat : "<?php echo $jscal_ifformat ?>", |
|
188 |
button : "enddate_trigger", |
|
189 |
firstDay : <?php echo $jscal_firstday ?>, |
|
190 |
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?> |
|
191 |
showsTime : "true", |
|
192 |
timeFormat : "24", |
|
193 |
<?php } ?> |
|
194 |
date : "<?php echo $jscal_today ?>", |
|
195 |
range : [1970, 2037], |
|
196 |
step : 1 |
|
197 |
} |
|
198 |
); |
|
199 |
</script> |
|
200 |
|
|
201 |
<br /> |
|
202 |
|
|
203 |
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2> |
|
204 |
|
|
205 |
<?php |
|
206 |
|
|
207 |
// Loop through existing posts |
|
208 |
$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"); |
|
209 |
if($query_comments->numRows() > 0) { |
|
210 |
$row = 'a'; |
|
211 |
?> |
|
212 |
<table cellpadding="2" cellspacing="0" border="0" width="100%"> |
|
213 |
<?php |
|
214 |
while($comment = $query_comments->fetchRow()) { |
|
215 |
?> |
|
216 |
<tr class="row_<?php echo $row; ?>" > |
|
217 |
<td width="20" style="padding-left: 5px;"> |
|
218 |
<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"> |
|
219 |
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" /> |
|
220 |
</a> |
|
221 |
</td> |
|
222 |
<td> |
|
223 |
<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>"> |
|
224 |
<?php echo $comment['title']; ?> |
|
225 |
</a> |
|
226 |
</td> |
|
227 |
<td width="20"> |
|
228 |
<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; ?>§ion_id=<?php echo $section_id; ?>&post_id=<?php echo $post_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>"> |
|
229 |
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" /> |
|
230 |
</a> |
|
231 |
</td> |
|
232 |
</tr> |
|
233 |
<?php |
|
234 |
// Alternate row color |
|
235 |
if($row == 'a') { |
|
236 |
$row = 'b'; |
|
237 |
} else { |
|
238 |
$row = 'a'; |
|
239 |
} |
|
240 |
} |
|
241 |
?> |
|
242 |
</table> |
|
243 |
<?php |
|
244 |
} else { |
|
245 |
echo $TEXT['NONE_FOUND']; |
|
246 |
} |
|
247 |
|
|
248 |
?> |
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
<?php |
|
253 |
|
|
254 |
// Print admin footer |
|
255 |
$admin->print_footer(); |
|
256 |
|
|
256 | 257 |
?> |
trunk/wb/modules/news/modify_group.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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['group_id']) OR !is_numeric($_GET['group_id'])) { |
|
30 |
header("Location: ".ADMIN_URL."/pages/index.php"); |
|
31 |
exit(0); |
|
32 |
} else { |
|
33 |
$group_id = $_GET['group_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_groups WHERE group_id = '$group_id'"); |
|
41 |
$fetch_content = $query_content->fetchRow(); |
|
42 |
|
|
43 |
?> |
|
44 |
|
|
45 |
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['GROUP']; ?></h2> |
|
46 |
|
|
47 |
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_group.php" method="post" enctype="multipart/form-data" style="margin: 0;"> |
|
48 |
|
|
49 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
|
|
50 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
|
|
51 |
<input type="hidden" name="group_id" value="<?php echo $group_id; ?>">
|
|
52 |
|
|
53 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%"> |
|
54 |
<tr> |
|
55 |
<td width="80"><?php echo $TEXT['TITLE']; ?>:</td> |
|
56 |
<td> |
|
57 |
<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" /> |
|
58 |
</td> |
|
59 |
</tr> |
|
60 |
<tr> |
|
61 |
<td><?php echo $TEXT['IMAGE']; ?>:</td> |
|
62 |
<?php if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) { ?> |
|
63 |
<td> |
|
64 |
<a href="<?php echo WB_URL.MEDIA_DIRECTORY; ?>/.news/image<?php echo $group_id; ?>.jpg" target="_blank">View</a> |
|
65 |
|
|
66 |
<input type="checkbox" name="delete_image" id="delete_image" value="true" /> |
|
67 |
<label for="delete_image">Delete</label> |
|
68 |
</td> |
|
69 |
<?php } else { ?> |
|
70 |
<td> |
|
71 |
<input type="file" name="image" /> |
|
72 |
</td> |
|
73 |
<?php } ?> |
|
74 |
</tr> |
|
75 |
<tr> |
|
76 |
<td><?php echo $TEXT['ACTIVE']; ?>:</td> |
|
77 |
<td> |
|
78 |
<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
|
|
79 |
<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;"> |
|
80 |
<?php echo $TEXT['YES']; ?> |
|
81 |
</a> |
|
82 |
- |
|
83 |
<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
|
|
84 |
<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;"> |
|
85 |
<?php echo $TEXT['NO']; ?> |
|
86 |
</a> |
|
87 |
</td> |
|
88 |
</tr> |
|
89 |
</table> |
|
90 |
|
|
91 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
92 |
<tr> |
|
93 |
<td align="left"> |
|
94 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;"></form>
|
|
95 |
</td> |
|
96 |
<td align="right"> |
|
97 |
<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;" /> |
|
98 |
</td> |
|
99 |
</tr> |
|
100 |
</table> |
|
101 |
|
|
102 |
|
|
103 |
<?php |
|
104 |
|
|
105 |
// Print admin footer |
|
106 |
$admin->print_footer(); |
|
107 |
|
|
1 |
<?php
|
|
2 |
|
|
3 |
// $Id$
|
|
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['group_id']) OR !is_numeric($_GET['group_id'])) {
|
|
30 |
header("Location: ".ADMIN_URL."/pages/index.php");
|
|
31 |
exit(0);
|
|
32 |
} else {
|
|
33 |
$group_id = $_GET['group_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_groups WHERE group_id = '$group_id'");
|
|
41 |
$fetch_content = $query_content->fetchRow();
|
|
42 |
|
|
43 |
?>
|
|
44 |
|
|
45 |
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['GROUP']; ?></h2>
|
|
46 |
|
|
47 |
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_group.php" method="post" enctype="multipart/form-data" style="margin: 0;">
|
|
48 |
|
|
49 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
|
|
50 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
|
|
51 |
<input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
|
|
52 |
|
|
53 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
|
|
54 |
<tr>
|
|
55 |
<td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
|
|
56 |
<td>
|
|
57 |
<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" />
|
|
58 |
</td>
|
|
59 |
</tr>
|
|
60 |
<tr>
|
|
61 |
<td><?php echo $TEXT['IMAGE']; ?>:</td>
|
|
62 |
<?php if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) { ?>
|
|
63 |
<td>
|
|
64 |
<a href="<?php echo WB_URL.MEDIA_DIRECTORY; ?>/.news/image<?php echo $group_id; ?>.jpg" target="_blank">View</a>
|
|
65 |
|
|
66 |
<input type="checkbox" name="delete_image" id="delete_image" value="true" />
|
|
67 |
<label for="delete_image">Delete</label>
|
|
68 |
</td>
|
|
69 |
<?php } else { ?>
|
|
70 |
<td>
|
|
71 |
<input type="file" name="image" />
|
|
72 |
</td>
|
|
73 |
<?php } ?>
|
|
74 |
</tr>
|
|
75 |
<tr>
|
|
76 |
<td><?php echo $TEXT['ACTIVE']; ?>:</td>
|
|
77 |
<td>
|
|
78 |
<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked="checked"'; } ?> />
|
|
79 |
<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
|
|
80 |
<?php echo $TEXT['YES']; ?>
|
|
81 |
</a>
|
|
82 |
-
|
|
83 |
<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked="checked"'; } ?> />
|
|
84 |
<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
|
|
85 |
<?php echo $TEXT['NO']; ?>
|
|
86 |
</a>
|
|
87 |
</td>
|
|
88 |
</tr>
|
|
89 |
</table>
|
|
90 |
|
|
91 |
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
92 |
<tr>
|
|
93 |
<td align="left">
|
|
94 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
|
|
95 |
</td>
|
|
96 |
<td align="right">
|
|
97 |
<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;" />
|
|
98 |
</td>
|
|
99 |
</tr>
|
|
100 |
</table>
|
|
101 |
</form> |
|
102 |
|
|
103 |
<?php
|
|
104 |
|
|
105 |
// Print admin footer
|
|
106 |
$admin->print_footer();
|
|
107 |
|
|
108 | 108 |
?> |
trunk/wb/modules/news/view.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
// Must include code to stop this file being access directly |
|
27 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); } |
|
28 |
|
|
29 |
// check if frontend.css file needs to be included into the <body></body> of view.php |
|
30 |
if((!function_exists('register_frontend_modfiles') || !defined('MOD_FRONTEND_CSS_REGISTERED')) && file_exists(WB_PATH .'/modules/news/frontend.css')) { |
|
31 |
echo '<style type="text/css">'; |
|
32 |
include(WB_PATH .'/modules/news/frontend.css'); |
|
33 |
echo "\n</style>\n"; |
|
34 |
} |
|
35 |
|
|
36 |
// check if module language file exists for the language set by the user (e.g. DE, EN) |
|
37 |
if(!file_exists(WB_PATH .'/modules/news/languages/'.LANGUAGE .'.php')) { |
|
38 |
// no module language file exists for the language set by the user, include default module language file EN.php |
|
39 |
require_once(WB_PATH .'/modules/news/languages/EN.php'); |
|
40 |
} else { |
|
41 |
// a module language file exists for the language defined by the user, load it |
|
42 |
require_once(WB_PATH .'/modules/news/languages/'.LANGUAGE .'.php'); |
|
43 |
} |
|
44 |
|
|
45 |
//overwrite php.ini on Apache servers for valid SESSION ID Separator |
|
46 |
if(function_exists('ini_set')) { |
|
47 |
ini_set('arg_separator.output', '&'); |
|
48 |
} |
|
49 |
|
|
50 |
// Check if there is a start point defined |
|
51 |
if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) { |
|
52 |
$position = $_GET['p']; |
|
53 |
} else { |
|
54 |
$position = 0; |
|
55 |
} |
|
56 |
|
|
57 |
// Get user's username, display name, email, and id - needed for insertion into post info |
|
58 |
$users = array(); |
|
59 |
$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users"); |
|
60 |
if($query_users->numRows() > 0) { |
|
61 |
while($user = $query_users->fetchRow()) { |
|
62 |
// Insert user info into users array |
|
63 |
$user_id = $user['user_id']; |
|
64 |
$users[$user_id]['username'] = $user['username']; |
|
65 |
$users[$user_id]['display_name'] = $user['display_name']; |
|
66 |
$users[$user_id]['email'] = $user['email']; |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
// Get groups (title, if they are active, and their image [if one has been uploaded]) |
|
71 |
if (isset($groups)) { |
|
72 |
unset($groups); |
|
73 |
} |
|
74 |
$groups[0]['title'] = ''; |
|
75 |
$groups[0]['active'] = true; |
|
76 |
$groups[0]['image'] = ''; |
|
77 |
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC"); |
|
78 |
if($query_users->numRows() > 0) { |
|
79 |
while($group = $query_users->fetchRow()) { |
|
80 |
// Insert user info into users array |
|
81 |
$group_id = $group['group_id']; |
|
82 |
$groups[$group_id]['title'] = ($group['title']); |
|
83 |
$groups[$group_id]['active'] = $group['active']; |
|
84 |
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) { |
|
85 |
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'; |
|
86 |
} else { |
|
87 |
$groups[$group_id]['image'] = ''; |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
// Check if we should show the main page or a post itself |
|
93 |
if(!defined('POST_ID') OR !is_numeric(POST_ID)) { |
|
94 |
|
|
95 |
// Check if we should only list posts from a certain group |
|
96 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
97 |
$query_extra = " AND group_id = '".$_GET['g']."'"; |
|
98 |
} else { |
|
99 |
$query_extra = ''; |
|
100 |
} |
|
101 |
|
|
102 |
// Get settings |
|
103 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
104 |
if($query_settings->numRows() > 0) { |
|
105 |
$fetch_settings = $query_settings->fetchRow(); |
|
106 |
$setting_header = ($fetch_settings['header']); |
|
107 |
$setting_post_loop = ($fetch_settings['post_loop']); |
|
108 |
$setting_footer = ($fetch_settings['footer']); |
|
109 |
$setting_posts_per_page = $fetch_settings['posts_per_page']; |
|
110 |
} else { |
|
111 |
$setting_header = ''; |
|
112 |
$setting_post_loop = ''; |
|
113 |
$setting_footer = ''; |
|
114 |
$setting_posts_per_page = ''; |
|
115 |
} |
|
116 |
|
|
117 |
$t = time(); |
|
118 |
// Get total number of posts |
|
119 |
$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts |
|
120 |
WHERE section_id = '$section_id' AND active = '1' AND title != '' $query_extra |
|
121 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)"); |
|
122 |
$total_num = $query_total_num->numRows(); |
|
123 |
|
|
124 |
// Work-out if we need to add limit code to sql |
|
125 |
if($setting_posts_per_page != 0) { |
|
126 |
$limit_sql = " LIMIT $position,$setting_posts_per_page"; |
|
127 |
} else { |
|
128 |
$limit_sql = ""; |
|
129 |
} |
|
130 |
|
|
131 |
// Query posts (for this page) |
|
132 |
$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts |
|
133 |
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra |
|
134 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
135 |
ORDER BY position DESC".$limit_sql); |
|
136 |
$num_posts = $query_posts->numRows(); |
|
137 |
|
|
138 |
// Create previous and next links |
|
139 |
if($setting_posts_per_page != 0) { |
|
140 |
if($position > 0) { |
|
141 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
142 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< '; |
|
143 |
} else { |
|
144 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< '; |
|
145 |
} |
|
146 |
$pl_append = '</a>'; |
|
147 |
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append; |
|
148 |
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append; |
|
149 |
} else { |
|
150 |
$previous_link = ''; |
|
151 |
$previous_page_link = ''; |
|
152 |
} |
|
153 |
if($position+$setting_posts_per_page >= $total_num) { |
|
154 |
$next_link = ''; |
|
155 |
$next_page_link = ''; |
|
156 |
} else { |
|
157 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
158 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> '; |
|
159 |
} else { |
|
160 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> '; |
|
161 |
} |
|
162 |
$nl_append = ' >></a>'; |
|
163 |
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append; |
|
164 |
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append; |
|
165 |
} |
|
166 |
if($position+$setting_posts_per_page > $total_num) { |
|
167 |
$num_of = $position+$num_posts; |
|
168 |
} else { |
|
169 |
$num_of = $position+$setting_posts_per_page; |
|
170 |
} |
|
171 |
$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num; |
|
172 |
$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num; |
|
173 |
$display_previous_next_links = ''; |
|
174 |
} else { |
|
175 |
$display_previous_next_links = 'none'; |
|
176 |
} |
|
177 |
|
|
178 |
// Print header |
|
179 |
if($display_previous_next_links == 'none') { |
|
180 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_header); |
|
181 |
} else { |
|
182 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header); |
|
183 |
} |
|
184 |
|
|
185 |
if($num_posts > 0) { |
|
186 |
if($query_extra != '') { |
|
187 |
?> |
|
188 |
<div class="selected_group_title"> |
|
189 |
<?php echo '<a href="'.htmlspecialchars(strip_tags($_SERVER['PHP_SELF'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?> |
|
190 |
</div> |
|
191 |
<?php |
|
192 |
} |
|
193 |
while($post = $query_posts->fetchRow()) { |
|
194 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
|
195 |
$uid = $post['posted_by']; // User who last modified the post |
|
196 |
// Workout date and time of last modified post |
|
197 |
if ($post['published_when'] > $post['posted_when']) { |
|
198 |
$post_date = gmdate(DATE_FORMAT, $post['published_when']+TIMEZONE); |
|
199 |
$post_time = gmdate(TIME_FORMAT, $post['published_when']+TIMEZONE); |
|
200 |
} else { |
|
201 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
202 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
203 |
} |
|
204 |
$publ_date = date(DATE_FORMAT,$post['published_when']); |
|
205 |
$publ_time = date(TIME_FORMAT,$post['published_when']); |
|
206 |
// Work-out the post link |
|
207 |
$post_link = page_link($post['link']); |
|
208 |
if(isset($_GET['p']) AND $position > 0) { |
|
209 |
$post_link .= '?p='.$position; |
|
210 |
} |
|
211 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
212 |
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; } |
|
213 |
$post_link .= 'g='.$_GET['g']; |
|
214 |
} |
|
215 |
// Get group id, title, and image |
|
216 |
$group_id = $post['group_id']; |
|
217 |
$group_title = $groups[$group_id]['title']; |
|
218 |
$group_image = $groups[$group_id]['image']; |
|
219 |
$display_image = ($group_image == '') ? "none" : "inherit"; |
|
220 |
$display_group = ($group_id == 0) ? 'none' : 'inherit'; |
|
221 |
// Replace [wblink--PAGE_ID--] with real link |
|
222 |
$short = ($post['content_short']); |
|
223 |
$wb->preprocess($short); |
|
224 |
// Replace vars with values |
|
225 |
$post_long_len = strlen($post['content_long']); |
|
226 |
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[MODI_DATE]', '[MODI_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]','[SHOW_READ_MORE]'); |
|
227 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
228 |
if($post_long_len < 9) { |
|
229 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;"', $post_date, $post_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '', 'none'); |
|
230 |
} else { |
|
231 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $MOD_NEWS['TEXT_READ_MORE'], 'visible'); |
|
232 |
} |
|
233 |
} else { |
|
234 |
if($post_long_len < 9) { |
|
235 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;"', $post_date, $post_time, $publ_date, $publ_time, '', '', '', '', '','none'); |
|
236 |
} else { |
|
237 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $publ_date, $publ_time, '', '', '', '', $MOD_NEWS['TEXT_READ_MORE'],'visible'); |
|
238 |
} |
|
239 |
} |
|
240 |
echo str_replace($vars, $values, $setting_post_loop); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
// Print footer |
|
246 |
if($display_previous_next_links == 'none') { |
|
247 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer); |
|
248 |
} else { |
|
249 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer); |
|
250 |
} |
|
251 |
|
|
252 |
} elseif(defined('POST_ID') AND is_numeric(POST_ID)) { |
|
253 |
|
|
254 |
// Get settings |
|
255 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
256 |
if($query_settings->numRows() > 0) { |
|
257 |
$fetch_settings = $query_settings->fetchRow(); |
|
258 |
$setting_post_header = ($fetch_settings['post_header']); |
|
259 |
$setting_post_footer = ($fetch_settings['post_footer']); |
|
260 |
$setting_comments_header = ($fetch_settings['comments_header']); |
|
261 |
$setting_comments_loop = ($fetch_settings['comments_loop']); |
|
262 |
$setting_comments_footer = ($fetch_settings['comments_footer']); |
|
263 |
} else { |
|
264 |
$setting_post_header = ''; |
|
265 |
$setting_post_footer = ''; |
|
266 |
$setting_comments_header = ''; |
|
267 |
$setting_comments_loop = ''; |
|
268 |
$setting_comments_footer = ''; |
|
269 |
} |
|
270 |
|
|
271 |
// Get page info |
|
272 |
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'"); |
|
273 |
if($query_page->numRows() > 0) { |
|
274 |
$page = $query_page->fetchRow(); |
|
275 |
$page_link = page_link($page['link']); |
|
276 |
if(isset($_GET['p']) AND $position > 0) { |
|
277 |
$page_link .= '?p='.$_GET['p']; |
|
278 |
} |
|
279 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
280 |
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; } |
|
281 |
$page_link .= 'g='.$_GET['g']; |
|
282 |
} |
|
283 |
} else { |
|
284 |
exit('Page not found'); |
|
285 |
} |
|
286 |
|
|
287 |
// Get post info |
|
288 |
$t = time(); |
|
289 |
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts |
|
290 |
WHERE post_id = '".POST_ID."' AND active = '1' |
|
291 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
292 |
"); |
|
293 |
if($query_post->numRows() > 0) { |
|
294 |
$post = $query_post->fetchRow(); |
|
295 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
|
296 |
$uid = $post['posted_by']; // User who last modified the post |
|
297 |
// Workout date and time of last modified post |
|
298 |
if ($post['published_when'] > $post['posted_when']) { |
|
299 |
$post_date = gmdate(DATE_FORMAT, $post['published_when']+TIMEZONE); |
|
300 |
$post_time = gmdate(TIME_FORMAT, $post['published_when']+TIMEZONE); |
|
301 |
} else { |
|
302 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
303 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
304 |
} |
|
305 |
$publ_date = date(DATE_FORMAT,$post['published_when']); |
|
306 |
$publ_time = date(TIME_FORMAT,$post['published_when']); |
|
307 |
// Get group id, title, and image |
|
308 |
$group_id = $post['group_id']; |
|
309 |
$group_title = $groups[$group_id]['title']; |
|
310 |
$group_image = $groups[$group_id]['image']; |
|
311 |
$display_image = ($group_image == '') ? "none" : "inherit"; |
|
312 |
$display_group = ($group_id == 0) ? 'none' : 'inherit'; |
|
313 |
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[TEXT_BACK]', '[TEXT_LAST_CHANGED]', '[MODI_DATE]', '[TEXT_AT]', '[MODI_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[TEXT_POSTED_BY]', '[TEXT_ON]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]'); |
|
314 |
$post_short=$post['content_short']; |
|
315 |
$wb->preprocess($post_short); |
|
316 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
317 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']); |
|
318 |
} else { |
|
319 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], '', '', '', ''); |
|
320 |
} |
|
321 |
$post_long = ($post['content_long']); |
|
322 |
} |
|
323 |
} else { |
|
324 |
$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], "javascript: history.go(-1);", false); |
|
325 |
exit(0); |
|
326 |
} |
|
327 |
|
|
328 |
// Print post header |
|
329 |
echo str_replace($vars, $values, $setting_post_header); |
|
330 |
|
|
331 |
// Replace [wblink--PAGE_ID--] with real link |
|
332 |
$wb->preprocess($post_long); |
|
333 |
// Print long |
|
334 |
echo $post_long; |
|
335 |
|
|
336 |
// Print post footer |
|
337 |
echo str_replace($vars, $values, $setting_post_footer); |
|
338 |
|
|
339 |
// Show comments section if we have to |
|
340 |
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public') { |
|
341 |
|
|
342 |
// Print comments header |
|
343 |
$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]'); |
|
344 |
$values = array(WB_URL.'/modules/news/comment.php?id='.POST_ID.'&sid='.$section_id, $MOD_NEWS['TEXT_COMMENTS']); |
|
345 |
echo str_replace($vars, $values, $setting_comments_header); |
|
346 |
|
|
347 |
// Query for comments |
|
348 |
$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC"); |
|
349 |
if($query_comments->numRows() > 0) { |
|
350 |
while($comment = $query_comments->fetchRow()) { |
|
351 |
// Display Comments without slashes, but with new-line characters |
|
352 |
$comment['comment'] = nl2br($wb->strip_slashes($comment['comment'])); |
|
353 |
$comment['title'] = $wb->strip_slashes($comment['title']); |
|
354 |
// Print comments loop |
|
355 |
$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE); |
|
356 |
$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE); |
|
357 |
$uid = $comment['commented_by']; |
|
358 |
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]'); |
|
359 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
360 |
$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email'])); |
|
361 |
} else { |
|
362 |
$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], ''); |
|
363 |
} |
|
364 |
echo str_replace($vars, $values, $setting_comments_loop); |
|
365 |
} |
|
366 |
} else { |
|
367 |
// Say no comments found |
|
368 |
if(isset($TEXT['NONE_FOUND'])) { |
|
369 |
$content .= "<tr><td>".$TEXT['NONE_FOUND'].'<br /></td></tr>'; |
|
370 |
} else { |
|
371 |
$content .= '<tr><td>None Found<br /></td></tr>'; |
|
372 |
} |
|
373 |
} |
|
374 |
|
|
375 |
// Print comments footer |
|
376 |
$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]'); |
|
377 |
$values = array(WB_URL.'/modules/news/comment.php?id='.POST_ID.'&sid='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']); |
|
378 |
echo str_replace($vars, $values, $setting_comments_footer); |
|
379 |
} |
|
380 |
if(ENABLED_ASP) { |
|
381 |
$_SESSION['comes_from_view'] = POST_ID; |
|
382 |
$_SESSION['comes_from_view_time'] = time(); |
|
383 |
} |
|
384 |
} |
|
385 |
|
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
// Must include code to stop this file being access directly |
|
27 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); } |
|
28 |
|
|
29 |
// check if frontend.css file needs to be included into the <body></body> of view.php |
|
30 |
if((!function_exists('register_frontend_modfiles') || !defined('MOD_FRONTEND_CSS_REGISTERED')) && file_exists(WB_PATH .'/modules/news/frontend.css')) { |
|
31 |
echo '<style type="text/css">'; |
|
32 |
include(WB_PATH .'/modules/news/frontend.css'); |
|
33 |
echo "\n</style>\n"; |
|
34 |
} |
|
35 |
|
|
36 |
// check if module language file exists for the language set by the user (e.g. DE, EN) |
|
37 |
if(!file_exists(WB_PATH .'/modules/news/languages/'.LANGUAGE .'.php')) { |
|
38 |
// no module language file exists for the language set by the user, include default module language file EN.php |
|
39 |
require_once(WB_PATH .'/modules/news/languages/EN.php'); |
|
40 |
} else { |
|
41 |
// a module language file exists for the language defined by the user, load it |
|
42 |
require_once(WB_PATH .'/modules/news/languages/'.LANGUAGE .'.php'); |
|
43 |
} |
|
44 |
|
|
45 |
//overwrite php.ini on Apache servers for valid SESSION ID Separator |
|
46 |
if(function_exists('ini_set')) { |
|
47 |
ini_set('arg_separator.output', '&'); |
|
48 |
} |
|
49 |
|
|
50 |
// Check if there is a start point defined |
|
51 |
if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) { |
|
52 |
$position = $_GET['p']; |
|
53 |
} else { |
|
54 |
$position = 0; |
|
55 |
} |
|
56 |
|
|
57 |
// Get user's username, display name, email, and id - needed for insertion into post info |
|
58 |
$users = array(); |
|
59 |
$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users"); |
|
60 |
if($query_users->numRows() > 0) { |
|
61 |
while($user = $query_users->fetchRow()) { |
|
62 |
// Insert user info into users array |
|
63 |
$user_id = $user['user_id']; |
|
64 |
$users[$user_id]['username'] = $user['username']; |
|
65 |
$users[$user_id]['display_name'] = $user['display_name']; |
|
66 |
$users[$user_id]['email'] = $user['email']; |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
// Get groups (title, if they are active, and their image [if one has been uploaded]) |
|
71 |
if (isset($groups)) { |
|
72 |
unset($groups); |
|
73 |
} |
|
74 |
$groups[0]['title'] = ''; |
|
75 |
$groups[0]['active'] = true; |
|
76 |
$groups[0]['image'] = ''; |
|
77 |
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC"); |
|
78 |
if($query_users->numRows() > 0) { |
|
79 |
while($group = $query_users->fetchRow()) { |
|
80 |
// Insert user info into users array |
|
81 |
$group_id = $group['group_id']; |
|
82 |
$groups[$group_id]['title'] = ($group['title']); |
|
83 |
$groups[$group_id]['active'] = $group['active']; |
|
84 |
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) { |
|
85 |
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'; |
|
86 |
} else { |
|
87 |
$groups[$group_id]['image'] = ''; |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
// Check if we should show the main page or a post itself |
|
93 |
if(!defined('POST_ID') OR !is_numeric(POST_ID)) { |
|
94 |
|
|
95 |
// Check if we should only list posts from a certain group |
|
96 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
97 |
$query_extra = " AND group_id = '".$_GET['g']."'"; |
|
98 |
} else { |
|
99 |
$query_extra = ''; |
|
100 |
} |
|
101 |
|
|
102 |
// Get settings |
|
103 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
104 |
if($query_settings->numRows() > 0) { |
|
105 |
$fetch_settings = $query_settings->fetchRow(); |
|
106 |
$setting_header = ($fetch_settings['header']); |
|
107 |
$setting_post_loop = ($fetch_settings['post_loop']); |
|
108 |
$setting_footer = ($fetch_settings['footer']); |
|
109 |
$setting_posts_per_page = $fetch_settings['posts_per_page']; |
|
110 |
} else { |
|
111 |
$setting_header = ''; |
|
112 |
$setting_post_loop = ''; |
|
113 |
$setting_footer = ''; |
|
114 |
$setting_posts_per_page = ''; |
|
115 |
} |
|
116 |
|
|
117 |
$t = time(); |
|
118 |
// Get total number of posts |
|
119 |
$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts |
|
120 |
WHERE section_id = '$section_id' AND active = '1' AND title != '' $query_extra |
|
121 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)"); |
|
122 |
$total_num = $query_total_num->numRows(); |
|
123 |
|
|
124 |
// Work-out if we need to add limit code to sql |
|
125 |
if($setting_posts_per_page != 0) { |
|
126 |
$limit_sql = " LIMIT $position,$setting_posts_per_page"; |
|
127 |
} else { |
|
128 |
$limit_sql = ""; |
|
129 |
} |
|
130 |
|
|
131 |
// Query posts (for this page) |
|
132 |
$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts |
|
133 |
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra |
|
134 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
135 |
ORDER BY position DESC".$limit_sql); |
|
136 |
$num_posts = $query_posts->numRows(); |
|
137 |
|
|
138 |
// Create previous and next links |
|
139 |
if($setting_posts_per_page != 0) { |
|
140 |
if($position > 0) { |
|
141 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
142 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< '; |
|
143 |
} else { |
|
144 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< '; |
|
145 |
} |
|
146 |
$pl_append = '</a>'; |
|
147 |
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append; |
|
148 |
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append; |
|
149 |
} else { |
|
150 |
$previous_link = ''; |
|
151 |
$previous_page_link = ''; |
|
152 |
} |
|
153 |
if($position+$setting_posts_per_page >= $total_num) { |
|
154 |
$next_link = ''; |
|
155 |
$next_page_link = ''; |
|
156 |
} else { |
|
157 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
158 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> '; |
|
159 |
} else { |
|
160 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> '; |
|
161 |
} |
|
162 |
$nl_append = ' >></a>'; |
|
163 |
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append; |
|
164 |
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append; |
|
165 |
} |
|
166 |
if($position+$setting_posts_per_page > $total_num) { |
|
167 |
$num_of = $position+$num_posts; |
|
168 |
} else { |
|
169 |
$num_of = $position+$setting_posts_per_page; |
|
170 |
} |
|
171 |
$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num; |
|
172 |
$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num; |
|
173 |
$display_previous_next_links = ''; |
|
174 |
} else { |
|
175 |
$display_previous_next_links = 'none'; |
|
176 |
} |
|
177 |
|
|
178 |
// Print header |
|
179 |
if($display_previous_next_links == 'none') { |
|
180 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_header); |
|
181 |
} else { |
|
182 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header); |
|
183 |
} |
|
184 |
|
|
185 |
if($num_posts > 0) { |
|
186 |
if($query_extra != '') { |
|
187 |
?> |
|
188 |
<div class="selected_group_title"> |
|
189 |
<?php echo '<a href="'.htmlspecialchars(strip_tags($_SERVER['PHP_SELF'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?> |
|
190 |
</div> |
|
191 |
<?php |
|
192 |
} |
|
193 |
while($post = $query_posts->fetchRow()) { |
|
194 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
|
195 |
$uid = $post['posted_by']; // User who last modified the post |
|
196 |
// Workout date and time of last modified post |
|
197 |
if ($post['published_when'] > $post['posted_when']) { |
|
198 |
$post_date = gmdate(DATE_FORMAT, $post['published_when']+TIMEZONE); |
|
199 |
$post_time = gmdate(TIME_FORMAT, $post['published_when']+TIMEZONE); |
|
200 |
} else { |
|
201 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
202 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
203 |
} |
|
204 |
$publ_date = date(DATE_FORMAT,$post['published_when']); |
|
205 |
$publ_time = date(TIME_FORMAT,$post['published_when']); |
|
206 |
// Work-out the post link |
|
207 |
$post_link = page_link($post['link']); |
|
208 |
if(isset($_GET['p']) AND $position > 0) { |
|
209 |
$post_link .= '?p='.$position; |
|
210 |
} |
|
211 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
212 |
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; } |
|
213 |
$post_link .= 'g='.$_GET['g']; |
|
214 |
} |
|
215 |
// Get group id, title, and image |
|
216 |
$group_id = $post['group_id']; |
|
217 |
$group_title = $groups[$group_id]['title']; |
|
218 |
$group_image = $groups[$group_id]['image']; |
|
219 |
$display_image = ($group_image == '') ? "none" : "inherit"; |
|
220 |
$display_group = ($group_id == 0) ? 'none' : 'inherit'; |
|
221 |
// Replace [wblink--PAGE_ID--] with real link |
|
222 |
$short = ($post['content_short']); |
|
223 |
$wb->preprocess($short); |
|
224 |
// Replace vars with values |
|
225 |
$post_long_len = strlen($post['content_long']); |
|
226 |
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[MODI_DATE]', '[MODI_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]','[SHOW_READ_MORE]'); |
|
227 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
228 |
if($post_long_len < 9) { |
|
229 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;', $post_date, $post_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '', 'none'); |
|
230 |
} else { |
|
231 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $MOD_NEWS['TEXT_READ_MORE'], 'visible'); |
|
232 |
} |
|
233 |
} else { |
|
234 |
if($post_long_len < 9) { |
|
235 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;', $post_date, $post_time, $publ_date, $publ_time, '', '', '', '', '','none'); |
|
236 |
} else { |
|
237 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $publ_date, $publ_time, '', '', '', '', $MOD_NEWS['TEXT_READ_MORE'],'visible'); |
|
238 |
} |
|
239 |
} |
|
240 |
echo str_replace($vars, $values, $setting_post_loop); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
// Print footer |
|
246 |
if($display_previous_next_links == 'none') { |
|
247 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer); |
|
248 |
} else { |
|
249 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer); |
|
250 |
} |
|
251 |
|
|
252 |
} elseif(defined('POST_ID') AND is_numeric(POST_ID)) { |
|
253 |
|
|
254 |
// Get settings |
|
255 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
256 |
if($query_settings->numRows() > 0) { |
|
257 |
$fetch_settings = $query_settings->fetchRow(); |
|
258 |
$setting_post_header = ($fetch_settings['post_header']); |
|
259 |
$setting_post_footer = ($fetch_settings['post_footer']); |
|
260 |
$setting_comments_header = ($fetch_settings['comments_header']); |
|
261 |
$setting_comments_loop = ($fetch_settings['comments_loop']); |
|
262 |
$setting_comments_footer = ($fetch_settings['comments_footer']); |
|
263 |
} else { |
|
264 |
$setting_post_header = ''; |
|
265 |
$setting_post_footer = ''; |
|
266 |
$setting_comments_header = ''; |
|
267 |
$setting_comments_loop = ''; |
|
268 |
$setting_comments_footer = ''; |
|
269 |
} |
|
270 |
|
|
271 |
// Get page info |
|
272 |
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'"); |
|
273 |
if($query_page->numRows() > 0) { |
|
274 |
$page = $query_page->fetchRow(); |
|
275 |
$page_link = page_link($page['link']); |
|
276 |
if(isset($_GET['p']) AND $position > 0) { |
|
277 |
$page_link .= '?p='.$_GET['p']; |
|
278 |
} |
|
279 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
280 |
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; } |
|
281 |
$page_link .= 'g='.$_GET['g']; |
|
282 |
} |
|
283 |
} else { |
|
284 |
exit('Page not found'); |
|
285 |
} |
|
286 |
|
|
287 |
// Get post info |
|
288 |
$t = time(); |
|
289 |
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts |
|
290 |
WHERE post_id = '".POST_ID."' AND active = '1' |
|
291 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
292 |
"); |
|
293 |
if($query_post->numRows() > 0) { |
|
294 |
$post = $query_post->fetchRow(); |
|
295 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
|
296 |
$uid = $post['posted_by']; // User who last modified the post |
|
297 |
// Workout date and time of last modified post |
|
298 |
if ($post['published_when'] > $post['posted_when']) { |
|
299 |
$post_date = gmdate(DATE_FORMAT, $post['published_when']+TIMEZONE); |
|
300 |
$post_time = gmdate(TIME_FORMAT, $post['published_when']+TIMEZONE); |
|
301 |
} else { |
|
302 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
303 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
304 |
} |
|
305 |
$publ_date = date(DATE_FORMAT,$post['published_when']); |
|
306 |
$publ_time = date(TIME_FORMAT,$post['published_when']); |
|
307 |
// Get group id, title, and image |
|
308 |
$group_id = $post['group_id']; |
|
309 |
$group_title = $groups[$group_id]['title']; |
|
310 |
$group_image = $groups[$group_id]['image']; |
|
311 |
$display_image = ($group_image == '') ? "none" : "inherit"; |
|
312 |
$display_group = ($group_id == 0) ? 'none' : 'inherit'; |
|
313 |
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[TEXT_BACK]', '[TEXT_LAST_CHANGED]', '[MODI_DATE]', '[TEXT_AT]', '[MODI_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[TEXT_POSTED_BY]', '[TEXT_ON]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]'); |
|
314 |
$post_short=$post['content_short']; |
|
315 |
$wb->preprocess($post_short); |
|
316 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
317 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']); |
|
318 |
} else { |
|
319 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], '', '', '', ''); |
|
320 |
} |
|
321 |
$post_long = ($post['content_long']); |
|
322 |
} |
|
323 |
} else { |
|
324 |
$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], "javascript: history.go(-1);", false); |
|
325 |
exit(0); |
|
326 |
} |
|
327 |
|
|
328 |
// Print post header |
|
329 |
echo str_replace($vars, $values, $setting_post_header); |
|
330 |
|
|
331 |
// Replace [wblink--PAGE_ID--] with real link |
|
332 |
$wb->preprocess($post_long); |
|
333 |
// Print long |
|
334 |
echo $post_long; |
|
335 |
|
|
336 |
// Print post footer |
|
337 |
echo str_replace($vars, $values, $setting_post_footer); |
|
338 |
|
|
339 |
// Show comments section if we have to |
|
340 |
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public') { |
|
341 |
|
|
342 |
// Print comments header |
|
343 |
$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]'); |
|
344 |
$values = array(WB_URL.'/modules/news/comment.php?id='.POST_ID.'&sid='.$section_id, $MOD_NEWS['TEXT_COMMENTS']); |
|
345 |
echo str_replace($vars, $values, $setting_comments_header); |
|
346 |
|
|
347 |
// Query for comments |
|
348 |
$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC"); |
|
349 |
if($query_comments->numRows() > 0) { |
|
350 |
while($comment = $query_comments->fetchRow()) { |
|
351 |
// Display Comments without slashes, but with new-line characters |
|
352 |
$comment['comment'] = nl2br($wb->strip_slashes($comment['comment'])); |
|
353 |
$comment['title'] = $wb->strip_slashes($comment['title']); |
Also available in: Unified diff
Fixed some validiation bugs in news modul (Thanks to Luisehahne)