Revision 947
Added by aldus over 15 years ago
view.php | ||
---|---|---|
5 | 5 |
/* |
6 | 6 |
|
7 | 7 |
Website Baker Project <http://www.websitebaker.org/> |
8 |
Copyright (C) 2004-2008, Ryan Djurovich
|
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich
|
|
9 | 9 |
|
10 | 10 |
Website Baker is free software; you can redistribute it and/or modify |
11 | 11 |
it under the terms of the GNU General Public License as published by |
... | ... | |
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
// Must include code to stop this file being access directly |
27 |
if (defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
|
27 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); } |
|
28 | 28 |
|
29 | 29 |
// check if frontend.css file needs to be included into the <body></body> of view.php |
30 | 30 |
if((!function_exists('register_frontend_modfiles') || !defined('MOD_FRONTEND_CSS_REGISTERED')) && file_exists(WB_PATH .'/modules/news/frontend.css')) { |
... | ... | |
33 | 33 |
echo "\n</style>\n"; |
34 | 34 |
} |
35 | 35 |
|
36 |
/** |
|
37 |
* Load Language file |
|
38 |
*/ |
|
39 |
$lang = (dirname(__FILE__))."/languages/". LANGUAGE .".php"; |
|
40 |
require_once ( !file_exists($lang) ? (dirname(__FILE__))."/languages/EN.php" : $lang ); |
|
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 |
} |
|
41 | 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 |
|
|
42 | 50 |
// Check if there is a start point defined |
43 | 51 |
if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) { |
44 | 52 |
$position = $_GET['p']; |
... | ... | |
60 | 68 |
} |
61 | 69 |
|
62 | 70 |
// Get groups (title, if they are active, and their image [if one has been uploaded]) |
71 |
if (isset($groups)) { |
|
72 |
unset($groups); |
|
73 |
} |
|
63 | 74 |
$groups[0]['title'] = ''; |
64 | 75 |
$groups[0]['active'] = true; |
65 | 76 |
$groups[0]['image'] = ''; |
... | ... | |
128 | 139 |
if($setting_posts_per_page != 0) { |
129 | 140 |
if($position > 0) { |
130 | 141 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
131 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
|
|
142 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
|
|
132 | 143 |
} else { |
133 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
|
|
144 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
|
|
134 | 145 |
} |
135 | 146 |
$pl_append = '</a>'; |
136 | 147 |
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append; |
... | ... | |
144 | 155 |
$next_page_link = ''; |
145 | 156 |
} else { |
146 | 157 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
147 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> '; |
|
158 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
|
|
148 | 159 |
} else { |
149 | 160 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> '; |
150 | 161 |
} |
151 |
$nl_append = ' >></a>';
|
|
162 |
$nl_append = ' >></a>';
|
|
152 | 163 |
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append; |
153 | 164 |
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append; |
154 | 165 |
} |
... | ... | |
175 | 186 |
if($query_extra != '') { |
176 | 187 |
?> |
177 | 188 |
<div class="selected_group_title"> |
178 |
<?php echo '<a href="'.htmlspecialchars(strip_tags($_SERVER['PHP_SELF'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
|
|
189 |
<?php echo '<a href="'.htmlspecialchars(strip_tags($_SERVER['PHP_SELF'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
|
|
179 | 190 |
</div> |
180 | 191 |
<?php |
181 | 192 |
} |
... | ... | |
183 | 194 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
184 | 195 |
$uid = $post['posted_by']; // User who last modified the post |
185 | 196 |
// Workout date and time of last modified post |
186 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
187 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
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 |
} |
|
188 | 204 |
$publ_date = date(DATE_FORMAT,$post['published_when']); |
189 | 205 |
$publ_time = date(TIME_FORMAT,$post['published_when']); |
190 | 206 |
// Work-out the post link |
... | ... | |
193 | 209 |
$post_link .= '?p='.$position; |
194 | 210 |
} |
195 | 211 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
196 |
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; } |
|
212 |
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; }
|
|
197 | 213 |
$post_link .= 'g='.$_GET['g']; |
198 | 214 |
} |
199 | 215 |
// Get group id, title, and image |
... | ... | |
207 | 223 |
$wb->preprocess($short); |
208 | 224 |
// Replace vars with values |
209 | 225 |
$post_long_len = strlen($post['content_long']); |
210 |
|
|
211 |
$display_user_info = (isset($users[$uid]['username']) AND $users[$uid]['username'] != ''); |
|
212 |
|
|
213 |
$vars = array( |
|
214 |
'[PAGE_TITLE]' => PAGE_TITLE, |
|
215 |
'[GROUP_ID]' => $group_id, |
|
216 |
'[GROUP_TITLE]' => $group_title, |
|
217 |
'[GROUP_IMAGE]' => $group_image, |
|
218 |
'[DISPLAY_GROUP]' => $display_group, |
|
219 |
'[DISPLAY_IMAGE]' => $display_image, |
|
220 |
'[TITLE]' => $post['title'], |
|
221 |
'[SHORT]' => $short, |
|
222 |
'[LINK]' => $post_link, |
|
223 |
'[MODI_DATE]' => $post_date, |
|
224 |
'[MODI_TIME]' => $post_time, |
|
225 |
'[PUBLISHED_DATE]' => $publ_date, |
|
226 |
'[PUBLISHED_TIME]' => $publ_time, |
|
227 |
'[USER_ID]' => $uid, |
|
228 |
'[USERNAME]' => ( true === $display_user_info ) ? $users[$uid]['username'] : "", |
|
229 |
'[DISPLAY_NAME]' => ( true === $display_user_info ) ? $users[$uid]['display_name'] : "", |
|
230 |
'[EMAIL]' => ( true === $display_user_info ) ? $users[$uid]['email'] : "", |
|
231 |
'[TEXT_READ_MORE]' => ( $post_long_len < 9 ) ? "" : $TEXT['READ_MORE'], |
|
232 |
'[LAST_CHANGED]' => $MOD_NEWS['LAST_CHANGED'], |
|
233 |
'[LAST_CHANGED_AT]' => $MOD_NEWS['LAST_CHANGED_AT'], |
|
234 |
'[POSTET_BY]' => $MOD_NEWS['POSTET_BY'], |
|
235 |
'[POSTET_ON]' => $MOD_NEWS['POSTET_ON'] |
|
236 |
); |
|
237 |
|
|
238 |
echo str_replace( array_keys($vars), array_values($vars), $setting_post_loop); |
|
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]'); |
|
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, $post_link, $post_date, $post_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], ''); |
|
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']); |
|
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, $post_link, $post_date, $post_time, $publ_date, $publ_time, '', '', '', '', ''); |
|
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']); |
|
238 |
} |
|
239 |
} |
|
240 |
echo str_replace($vars, $values, $setting_post_loop); |
|
239 | 241 |
} |
240 | 242 |
} |
241 | 243 |
} |
... | ... | |
275 | 277 |
$page_link .= '?p='.$_GET['p']; |
276 | 278 |
} |
277 | 279 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
278 |
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; } |
|
280 |
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
|
|
279 | 281 |
$page_link .= 'g='.$_GET['g']; |
280 | 282 |
} |
281 | 283 |
} else { |
... | ... | |
293 | 295 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
294 | 296 |
$uid = $post['posted_by']; // User who last modified the post |
295 | 297 |
// Workout date and time of last modified post |
296 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
297 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
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 |
} |
|
298 | 305 |
$publ_date = date(DATE_FORMAT,$post['published_when']); |
299 | 306 |
$publ_time = date(TIME_FORMAT,$post['published_when']); |
300 | 307 |
// Get group id, title, and image |
... | ... | |
303 | 310 |
$group_image = $groups[$group_id]['image']; |
304 | 311 |
if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; } |
305 | 312 |
if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; } |
306 |
|
|
307 |
$display_user_info = (isset($users[$uid]['username']) AND $users[$uid]['username'] != ''); |
|
308 |
|
|
309 |
$vars = array( |
|
310 |
'[PAGE_TITLE]' => PAGE_TITLE, |
|
311 |
'[GROUP_ID]' => $group_id, |
|
312 |
'[GROUP_TITLE]' => $group_title, |
|
313 |
'[GROUP_IMAGE]' => $group_image, |
|
314 |
'[DISPLAY_GROUP]' => $display_group, |
|
315 |
'[DISPLAY_IMAGE]' => $display_image, |
|
316 |
'[TITLE]' => $post['title'], |
|
317 |
'[SHORT]' => $post_short, |
|
318 |
'[BACK]' => $page_link, |
|
319 |
'[MODI_DATE]' => $post_date, |
|
320 |
'[MODI_TIME]' => $post_time, |
|
321 |
'[PUBLISHED_DATE]' => $publ_date, |
|
322 |
'[PUBLISHED_TIME]' => $publ_time, |
|
323 |
'[USER_ID]' => ( true === $display_user_info ) ? $uid : "", |
|
324 |
'[USERNAME]' => ( true === $display_user_info ) ? $users[$uid]['username'] : "", |
|
325 |
'[DISPLAY_NAME]' => ( true === $display_user_info ) ? $users[$uid]['display_name'] : "", |
|
326 |
'[EMAIL]' => ( true === $display_user_info ) ? $users[$uid]['email'] : "", |
|
327 |
'[LAST_CHANGED]' => $MOD_NEWS['LAST_CHANGED'], |
|
328 |
'[LAST_CHANGED_AT]' => $MOD_NEWS['LAST_CHANGED_AT'], |
|
329 |
'[POSTET_BY]' => $MOD_NEWS['POSTET_BY'], |
|
330 |
'[POSTET_ON]' => $MOD_NEWS['POSTET_ON'] |
|
331 |
); |
|
332 |
|
|
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]'); |
|
333 | 314 |
$post_short=$post['content_short']; |
334 | 315 |
$wb->preprocess($post_short); |
335 |
|
|
336 |
$post_long = $post['content_long']; |
|
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']); |
|
337 | 322 |
} |
338 | 323 |
} else { |
339 | 324 |
$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], "javascript: history.go(-1);", false); |
... | ... | |
341 | 326 |
} |
342 | 327 |
|
343 | 328 |
// Print post header |
344 |
echo str_replace( array_keys($vars), array_values($vars), $setting_post_header);
|
|
329 |
echo str_replace($vars, $values, $setting_post_header);
|
|
345 | 330 |
|
346 | 331 |
// Replace [wblink--PAGE_ID--] with real link |
347 | 332 |
$wb->preprocess($post_long); |
... | ... | |
349 | 334 |
echo $post_long; |
350 | 335 |
|
351 | 336 |
// Print post footer |
352 |
echo str_replace( array_keys($vars), array_values($vars), $setting_post_footer);
|
|
337 |
echo str_replace($vars, $values, $setting_post_footer);
|
|
353 | 338 |
|
354 | 339 |
// Show comments section if we have to |
355 | 340 |
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public') { |
356 | 341 |
|
357 | 342 |
// Print comments header |
358 |
echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID.'&sid='.$section_id, $setting_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); |
|
359 | 346 |
|
360 | 347 |
// Query for comments |
361 | 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"); |
... | ... | |
368 | 355 |
$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE); |
369 | 356 |
$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE); |
370 | 357 |
$uid = $comment['commented_by']; |
371 |
$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
|
358 |
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
|
372 | 359 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
373 |
$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']));
|
|
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']));
|
|
374 | 361 |
} else { |
375 |
$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
|
|
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'], '');
|
|
376 | 363 |
} |
377 | 364 |
echo str_replace($vars, $values, $setting_comments_loop); |
378 | 365 |
} |
... | ... | |
386 | 373 |
} |
387 | 374 |
|
388 | 375 |
// Print comments footer |
389 |
echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID.'&sid='.$section_id, $setting_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); |
|
390 | 379 |
} |
391 | 380 |
if(ENABLED_ASP) { |
392 | 381 |
$_SESSION['comes_from_view'] = POST_ID; |
... | ... | |
394 | 383 |
} |
395 | 384 |
} |
396 | 385 |
|
397 |
?> |
|
386 |
?> |
Also available in: Unified diff
restore view.php to the running version of 944;
changes of 946 are obsolete to this file - upload by mistake