1 |
1425
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
1457
|
Luisehahne
|
* @category WebsiteBaker
|
5 |
|
|
* @package modules
|
6 |
|
|
* @subpackage news
|
7 |
|
|
* @author Ryan Djurovich, Rob Smith, Werner v.d.Decken
|
8 |
|
|
* @copyright 2004-2011, Ryan Djurovich
|
9 |
1425
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @version $Id$
|
12 |
|
|
* @filesource $HeadURL$
|
13 |
|
|
*
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
// Must include code to stop this file being access directly
|
17 |
|
|
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
18 |
1457
|
Luisehahne
|
global $post_id, $post_section,$TEXT,$MESSAGE;
|
19 |
1425
|
Luisehahne
|
|
20 |
|
|
// load module language file
|
21 |
|
|
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php';
|
22 |
|
|
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
|
23 |
|
|
|
24 |
|
|
//overwrite php.ini on Apache servers for valid SESSION ID Separator
|
25 |
|
|
if(function_exists('ini_set'))
|
26 |
|
|
{
|
27 |
|
|
ini_set('arg_separator.output', '&');
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
// Check if there is a start point defined
|
31 |
1457
|
Luisehahne
|
$position = ( isset($_GET['p']) ? intval($_GET['p']) : 0);
|
32 |
1425
|
Luisehahne
|
// Get user's username, display name, email, and id - needed for insertion into post info
|
33 |
|
|
$users = array();
|
34 |
1457
|
Luisehahne
|
$sql = 'SELECT `user_id`,`username`,`display_name`,`email` FROM `'.TABLE_PREFIX.'users`';
|
35 |
|
|
if( ($resUsers = $database->query($sql)) ) {
|
36 |
|
|
while( $recUser = $resUsers->fetchRow() ) {
|
37 |
|
|
$users[$recUser['user_id']] = $recUser;
|
38 |
1425
|
Luisehahne
|
}
|
39 |
|
|
}
|
40 |
|
|
// Get groups (title, if they are active, and their image [if one has been uploaded])
|
41 |
|
|
if (isset($groups))
|
42 |
|
|
{
|
43 |
|
|
unset($groups);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
$groups[0]['title'] = '';
|
47 |
|
|
$groups[0]['active'] = true;
|
48 |
|
|
$groups[0]['image'] = '';
|
49 |
|
|
|
50 |
|
|
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
|
51 |
|
|
if($query_users->numRows() > 0)
|
52 |
|
|
{
|
53 |
1457
|
Luisehahne
|
|
54 |
1425
|
Luisehahne
|
while( false != ($group = $query_users->fetchRow()) )
|
55 |
|
|
{
|
56 |
|
|
// Insert user info into users array
|
57 |
|
|
$group_id = $group['group_id'];
|
58 |
|
|
$groups[$group_id]['title'] = ($group['title']);
|
59 |
|
|
$groups[$group_id]['active'] = $group['active'];
|
60 |
|
|
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'))
|
61 |
|
|
{
|
62 |
|
|
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
|
63 |
|
|
} else {
|
64 |
|
|
$groups[$group_id]['image'] = '';
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
// Check if we should show the main page or a post itself
|
70 |
1457
|
Luisehahne
|
// if(!defined('POST_ID') OR !is_numeric(POST_ID))
|
71 |
|
|
if(!isset($post_id) || !is_numeric($post_id))
|
72 |
1425
|
Luisehahne
|
{
|
73 |
|
|
|
74 |
|
|
// Check if we should only list posts from a certain group
|
75 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g']))
|
76 |
|
|
{
|
77 |
1457
|
Luisehahne
|
$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
|
78 |
1425
|
Luisehahne
|
} else {
|
79 |
|
|
$query_extra = '';
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
// Check if we should only list posts from a certain group
|
83 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g']))
|
84 |
|
|
{
|
85 |
1457
|
Luisehahne
|
$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
|
86 |
1425
|
Luisehahne
|
} else {
|
87 |
|
|
$query_extra = '';
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
// Get settings
|
91 |
1457
|
Luisehahne
|
$setting_header = $setting_post_loop = $setting_footer = $setting_posts_per_page = '';
|
92 |
|
|
$sql = 'SELECT `header`, `post_loop`, `footer`, `posts_per_page` ';
|
93 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
|
94 |
|
|
$sql .= 'WHERE `section_id`='.(int)$section_id;
|
95 |
|
|
if( ($resSettings = $database->query($sql)) ){
|
96 |
|
|
if( ($recSettings = $resSettings->fetchRow()) ) {
|
97 |
|
|
foreach($recSettings as $key=>$val){
|
98 |
|
|
${'setting_'.$key} = $val;
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
1425
|
Luisehahne
|
}
|
102 |
|
|
$t = time();
|
103 |
|
|
// Get total number of posts
|
104 |
1457
|
Luisehahne
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_news_posts` ';
|
105 |
|
|
$sql .= 'WHERE `section_id`='.(int)$section_id.' AND `active`=1 ';
|
106 |
|
|
$sql .= 'AND `title`!=\'\' '.$query_extra;
|
107 |
|
|
$sql .= 'AND (`published_when`=0 OR `published_when`<='.$t.') ';
|
108 |
|
|
$sql .= 'AND (`published_until`=0 OR `published_until`>='.$t.') ';
|
109 |
|
|
$total_num = intval($database->get_one($sql));
|
110 |
1425
|
Luisehahne
|
// Work-out if we need to add limit code to sql
|
111 |
|
|
if($setting_posts_per_page != 0)
|
112 |
|
|
{
|
113 |
|
|
$limit_sql = " LIMIT $position, $setting_posts_per_page";
|
114 |
|
|
} else {
|
115 |
|
|
$limit_sql = "";
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
// Query posts (for this page)
|
119 |
|
|
$query_posts = $database->query("SELECT * 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 |
|
|
ORDER BY position DESC".$limit_sql);
|
123 |
|
|
$num_posts = $query_posts->numRows();
|
124 |
|
|
|
125 |
|
|
// Create previous and next links
|
126 |
|
|
if($setting_posts_per_page != 0)
|
127 |
|
|
{
|
128 |
|
|
if($position > 0)
|
129 |
|
|
{
|
130 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g']))
|
131 |
|
|
{
|
132 |
|
|
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
|
133 |
|
|
} else {
|
134 |
|
|
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
|
135 |
|
|
}
|
136 |
|
|
$pl_append = '</a>';
|
137 |
|
|
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
|
138 |
|
|
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
|
139 |
|
|
} else {
|
140 |
|
|
$previous_link = '';
|
141 |
|
|
$previous_page_link = '';
|
142 |
|
|
}
|
143 |
|
|
if($position + $setting_posts_per_page >= $total_num)
|
144 |
|
|
{
|
145 |
|
|
$next_link = '';
|
146 |
|
|
$next_page_link = '';
|
147 |
|
|
} else {
|
148 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g']))
|
149 |
|
|
{
|
150 |
|
|
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
|
151 |
|
|
} else {
|
152 |
|
|
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
|
153 |
|
|
}
|
154 |
|
|
$nl_append = ' >></a>';
|
155 |
|
|
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
|
156 |
|
|
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
|
157 |
|
|
}
|
158 |
|
|
if($position+$setting_posts_per_page > $total_num)
|
159 |
|
|
{
|
160 |
|
|
$num_of = $position+$num_posts;
|
161 |
|
|
} else {
|
162 |
|
|
$num_of = $position+$setting_posts_per_page;
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
|
166 |
|
|
$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
|
167 |
|
|
$display_previous_next_links = '';
|
168 |
|
|
} else {
|
169 |
|
|
$display_previous_next_links = 'none';
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
if ($num_posts === 0)
|
173 |
|
|
{
|
174 |
|
|
$setting_header = '';
|
175 |
|
|
$setting_post_loop = '';
|
176 |
|
|
$setting_footer = '';
|
177 |
|
|
$setting_posts_per_page = '';
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
// Print header
|
181 |
|
|
if($display_previous_next_links == 'none')
|
182 |
|
|
{
|
183 |
|
|
print str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
|
184 |
|
|
array('','','','','','', $display_previous_next_links), $setting_header);
|
185 |
|
|
} else {
|
186 |
|
|
print str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
|
187 |
|
|
array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
|
188 |
|
|
}
|
189 |
|
|
if($num_posts > 0)
|
190 |
|
|
{
|
191 |
|
|
if($query_extra != '')
|
192 |
|
|
{
|
193 |
|
|
?>
|
194 |
|
|
<div class="selected-group-title">
|
195 |
|
|
<?php print '<a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
|
196 |
|
|
</div>
|
197 |
|
|
<?php
|
198 |
|
|
}
|
199 |
|
|
while( false != ($post = $query_posts->fetchRow()) )
|
200 |
|
|
{
|
201 |
|
|
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
|
202 |
|
|
{ // Make sure parent group is active
|
203 |
|
|
$uid = $post['posted_by']; // User who last modified the post
|
204 |
|
|
// Workout date and time of last modified post
|
205 |
|
|
if ($post['published_when'] === '0') $post['published_when'] = time();
|
206 |
|
|
if ($post['published_when'] > $post['posted_when'])
|
207 |
|
|
{
|
208 |
1457
|
Luisehahne
|
$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
|
209 |
|
|
$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
|
210 |
1425
|
Luisehahne
|
} else {
|
211 |
1457
|
Luisehahne
|
$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
|
212 |
|
|
$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
|
213 |
1425
|
Luisehahne
|
}
|
214 |
|
|
|
215 |
|
|
$publ_date = date(DATE_FORMAT,$post['published_when']);
|
216 |
|
|
$publ_time = date(TIME_FORMAT,$post['published_when']);
|
217 |
|
|
|
218 |
|
|
// Work-out the post link
|
219 |
|
|
$post_link = page_link($post['link']);
|
220 |
|
|
|
221 |
|
|
$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
|
222 |
1457
|
Luisehahne
|
$create_date = date(DATE_FORMAT, $post['created_when']);
|
223 |
|
|
$create_time = date(TIME_FORMAT, $post['created_when']);
|
224 |
1425
|
Luisehahne
|
|
225 |
|
|
if(isset($_GET['p']) AND $position > 0)
|
226 |
|
|
{
|
227 |
|
|
$post_link .= '?p='.$position;
|
228 |
|
|
}
|
229 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g']))
|
230 |
|
|
{
|
231 |
|
|
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; }
|
232 |
|
|
{
|
233 |
|
|
$post_link .= 'g='.$_GET['g'];
|
234 |
|
|
}
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
// Get group id, title, and image
|
238 |
|
|
$group_id = $post['group_id'];
|
239 |
|
|
$group_title = $groups[$group_id]['title'];
|
240 |
|
|
$group_image = $groups[$group_id]['image'];
|
241 |
|
|
$display_image = ($group_image == '') ? "none" : "inherit";
|
242 |
|
|
$display_group = ($group_id == 0) ? 'none' : 'inherit';
|
243 |
|
|
|
244 |
|
|
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
|
245 |
|
|
|
246 |
|
|
// Replace [wblink--PAGE_ID--] with real link
|
247 |
|
|
$short = ($post['content_short']);
|
248 |
|
|
// Replace vars with values
|
249 |
|
|
$post_long_len = strlen($post['content_long']);
|
250 |
|
|
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[MODI_DATE]', '[MODI_TIME]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]','[SHOW_READ_MORE]');
|
251 |
|
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
|
252 |
|
|
{
|
253 |
|
|
if($post_long_len < 9)
|
254 |
|
|
{
|
255 |
|
|
$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, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '', 'hidden');
|
256 |
|
|
} else {
|
257 |
|
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $MOD_NEWS['TEXT_READ_MORE'], 'visible');
|
258 |
|
|
}
|
259 |
|
|
} else {
|
260 |
|
|
if($post_long_len < 9)
|
261 |
|
|
{
|
262 |
|
|
$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, $create_date, $create_time, $publ_date, $publ_time, '', '', '', '', '','hidden');
|
263 |
|
|
} else {
|
264 |
|
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, '', '', '', '', $MOD_NEWS['TEXT_READ_MORE'],'visible');
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
print str_replace($vars, $values, $setting_post_loop);
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
}
|
271 |
|
|
// Print footer
|
272 |
|
|
if($display_previous_next_links == 'none')
|
273 |
|
|
{
|
274 |
|
|
print 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);
|
275 |
|
|
}
|
276 |
|
|
else
|
277 |
|
|
{
|
278 |
|
|
print 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);
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
}
|
282 |
1457
|
Luisehahne
|
//elseif(defined('POST_ID') AND is_numeric(POST_ID))
|
283 |
|
|
elseif(isset($post_id) && is_numeric($post_id))
|
284 |
1425
|
Luisehahne
|
{
|
285 |
|
|
|
286 |
|
|
// print '<h2>'.POST_ID.'/'.PAGE_ID.'/'.POST_SECTION.'</h2>';
|
287 |
1457
|
Luisehahne
|
// if(defined('POST_SECTION') AND POST_SECTION == $section_id)
|
288 |
|
|
if(isset($post_section) && ($post_section == $section_id))
|
289 |
1425
|
Luisehahne
|
{
|
290 |
|
|
// Get settings
|
291 |
1457
|
Luisehahne
|
$setting_post_header = $setting_post_footer = $setting_comments_header
|
292 |
|
|
= $setting_comments_loop = $setting_comments_footer = '';
|
293 |
|
|
$sql = 'SELECT `post_header`, `post_footer`, `comments_header`, `comments_loop`, `comments_footer` ';
|
294 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
|
295 |
|
|
$sql .= 'WHERE `section_id`='.(int)$section_id;
|
296 |
|
|
if( ($resSettings = $database->query($sql)) ){
|
297 |
|
|
if( ($recSettings = $resSettings->fetchRow()) ) {
|
298 |
|
|
foreach($recSettings as $key=>$val){
|
299 |
|
|
${'setting_'.$key} = $val;
|
300 |
|
|
}
|
301 |
|
|
}
|
302 |
|
|
}
|
303 |
1425
|
Luisehahne
|
// Get page info
|
304 |
|
|
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
|
305 |
|
|
if($query_page->numRows() > 0)
|
306 |
|
|
{
|
307 |
|
|
$page = $query_page->fetchRow();
|
308 |
|
|
$page_link = page_link($page['link']);
|
309 |
|
|
if(isset($_GET['p']) AND $position > 0)
|
310 |
|
|
{
|
311 |
|
|
$page_link .= '?p='.$_GET['p'];
|
312 |
|
|
}
|
313 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g']))
|
314 |
|
|
{
|
315 |
|
|
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
|
316 |
|
|
$page_link .= 'g='.$_GET['g'];
|
317 |
|
|
}
|
318 |
|
|
} else {
|
319 |
|
|
exit($MESSAGE['PAGES']['NOT_FOUND']);
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
// Get post info
|
323 |
|
|
$t = time();
|
324 |
|
|
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
|
325 |
1457
|
Luisehahne
|
WHERE post_id = '".$post_id."' AND active = '1'
|
326 |
1425
|
Luisehahne
|
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)");
|
327 |
|
|
|
328 |
|
|
if($query_post->numRows() > 0)
|
329 |
|
|
{
|
330 |
|
|
$post = $query_post->fetchRow();
|
331 |
|
|
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
|
332 |
|
|
{ // Make sure parent group is active
|
333 |
|
|
$uid = $post['posted_by']; // User who last modified the post
|
334 |
|
|
// Workout date and time of last modified post
|
335 |
|
|
if ($post['published_when'] === '0') $post['published_when'] = time();
|
336 |
|
|
if ($post['published_when'] > $post['posted_when'])
|
337 |
|
|
{
|
338 |
1457
|
Luisehahne
|
$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
|
339 |
|
|
$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
|
340 |
1425
|
Luisehahne
|
}
|
341 |
|
|
else
|
342 |
|
|
{
|
343 |
1457
|
Luisehahne
|
$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
|
344 |
|
|
$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
|
345 |
1425
|
Luisehahne
|
}
|
346 |
|
|
|
347 |
|
|
$publ_date = date(DATE_FORMAT,$post['published_when']);
|
348 |
|
|
$publ_time = date(TIME_FORMAT,$post['published_when']);
|
349 |
|
|
|
350 |
1457
|
Luisehahne
|
// Work-out the post link
|
351 |
|
|
$post_link = page_link($post['link']);
|
352 |
1425
|
Luisehahne
|
|
353 |
1457
|
Luisehahne
|
$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
|
354 |
|
|
$create_date = date(DATE_FORMAT, $post['created_when']);
|
355 |
|
|
$create_time = date(TIME_FORMAT, $post['created_when']);
|
356 |
1425
|
Luisehahne
|
// Get group id, title, and image
|
357 |
|
|
$group_id = $post['group_id'];
|
358 |
|
|
$group_title = $groups[$group_id]['title'];
|
359 |
|
|
$group_image = $groups[$group_id]['image'];
|
360 |
|
|
$display_image = ($group_image == '') ? "none" : "inherit";
|
361 |
|
|
$display_group = ($group_id == 0) ? 'none' : 'inherit';
|
362 |
|
|
|
363 |
|
|
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
|
364 |
|
|
|
365 |
|
|
$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]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[TEXT_POSTED_BY]', '[TEXT_ON]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
|
366 |
|
|
$post_short=$post['content_short'];
|
367 |
|
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
|
368 |
|
|
{
|
369 |
|
|
$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, $create_date, $create_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']);
|
370 |
|
|
} else {
|
371 |
|
|
$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, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], '', '', '', '');
|
372 |
|
|
}
|
373 |
1457
|
Luisehahne
|
// $post_long = ($post['content_long']);
|
374 |
|
|
$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];
|
375 |
1425
|
Luisehahne
|
}
|
376 |
|
|
} else {
|
377 |
|
|
$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], 'view.php', false);
|
378 |
|
|
}
|
379 |
|
|
|
380 |
|
|
// Print post header
|
381 |
|
|
print str_replace($vars, $values, $setting_post_header);
|
382 |
|
|
// Print long
|
383 |
|
|
print $post_long;
|
384 |
|
|
|
385 |
|
|
// Print post footer
|
386 |
|
|
print str_replace($vars, $values, $setting_post_footer);
|
387 |
|
|
|
388 |
|
|
// Show comments section if we have to
|
389 |
|
|
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public')
|
390 |
|
|
{
|
391 |
|
|
// Print comments header
|
392 |
|
|
$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]');
|
393 |
|
|
// $pid = $admin->getIDKEY(POST_ID);
|
394 |
1457
|
Luisehahne
|
$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id, $MOD_NEWS['TEXT_COMMENTS']);
|
395 |
1425
|
Luisehahne
|
print str_replace($vars, $values, $setting_comments_header);
|
396 |
|
|
|
397 |
|
|
// Query for comments
|
398 |
1457
|
Luisehahne
|
$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");
|
399 |
1425
|
Luisehahne
|
if($query_comments->numRows() > 0)
|
400 |
|
|
{
|
401 |
|
|
while( false != ($comment = $query_comments->fetchRow()) )
|
402 |
|
|
{
|
403 |
|
|
// Display Comments without slashes, but with new-line characters
|
404 |
|
|
$comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
|
405 |
|
|
$comment['title'] = $wb->strip_slashes($comment['title']);
|
406 |
|
|
// Print comments loop
|
407 |
1457
|
Luisehahne
|
$commented_date = date(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
|
408 |
|
|
$commented_time = date(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
|
409 |
1425
|
Luisehahne
|
$uid = $comment['commented_by'];
|
410 |
|
|
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
411 |
|
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
|
412 |
|
|
{
|
413 |
|
|
$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']));
|
414 |
|
|
} else {
|
415 |
|
|
$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'], '');
|
416 |
|
|
}
|
417 |
|
|
print str_replace($vars, $values, $setting_comments_loop);
|
418 |
|
|
}
|
419 |
|
|
} else {
|
420 |
|
|
// Say no comments found
|
421 |
|
|
$content = '';
|
422 |
1458
|
Luisehahne
|
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
423 |
|
|
$values = array( '', $MOD_NEWS['NO_COMMENT_FOUND'], '', '', '', '', '', '', '', '');
|
424 |
|
|
print str_replace($vars, $values, $setting_comments_loop);
|
425 |
1425
|
Luisehahne
|
}
|
426 |
|
|
|
427 |
|
|
// Print comments footer
|
428 |
|
|
$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]');
|
429 |
1457
|
Luisehahne
|
$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']);
|
430 |
1425
|
Luisehahne
|
print str_replace($vars, $values, $setting_comments_footer);
|
431 |
|
|
|
432 |
|
|
}
|
433 |
|
|
|
434 |
|
|
}
|
435 |
|
|
|
436 |
|
|
if(ENABLED_ASP)
|
437 |
|
|
{
|
438 |
1457
|
Luisehahne
|
$_SESSION['comes_from_view'] = $post_id;
|
439 |
1425
|
Luisehahne
|
$_SESSION['comes_from_view_time'] = time();
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
}
|