-
Notifications
You must be signed in to change notification settings - Fork 4
/
view.php
198 lines (176 loc) · 6.6 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/**
*
* @category modules
* @package news_img
* @author WBCE Community
* @copyright 2004-2009, Ryan Djurovich
* @copyright 2009-2010, Website Baker Org. e.V.
* @copyright 2019-, WBCE Community
* @link https://www.wbce.org/
* @license http://www.gnu.org/licenses/gpl.html
* @platform WBCE
*
*/
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
require_once __DIR__.'/functions.inc.php'; // also loads lang file
global $MOD_NEWS_IMG, $TEXT;
require __DIR__ . '/languages/EN.php';
$lang = __DIR__ . '/languages/' . LANGUAGE . '.php';
if(file_exists($lang)) {
require $lang;
}
$output='';
// overwrite php.ini on Apache servers for valid SESSION ID Separator
if (function_exists('ini_set')) {
ini_set('arg_separator.output', '&');
}
// get settings for current section
$post_section = (
defined('POST_SECTION') ?
POST_SECTION :
$section_id
);
$settings = mod_nwi_settings_get(intval($post_section));
// Get page info
$query_page = $database->query(sprintf(
"SELECT `t1`.`link`, `t1`.`page_title`, `t1`.`menu_title` FROM `%spages` AS `t1` " .
"JOIN `%ssections` AS `t2` " .
"ON `t1`.`page_id`=`t2`.`page_id` " .
"WHERE `t2`.`section_id`=%d",
TABLE_PREFIX,TABLE_PREFIX,intval($post_section)
));
if ($query_page->numRows() > 0) {
$page = $query_page->fetchRow();
if($page['link']!=$wb->default_link) {
$page_link = page_link($page['link']);
} else {
$page_link = WB_URL;
}
if (isset($_GET['p']) and intval($_GET['p']) > 0) {
$page_link .= '?p='.intval($_GET['p']);
}
if (isset($_GET['g']) and is_numeric($_GET['g'])) {
if (isset($_GET['p']) and $position > 0) {
$delim = '&';
} else {
$delim = '?';
}
$page_link .= $delim.'g='.$_GET['g'];
}
}
list($vars,$default_replacements) = mod_nwi_replacements();
// switch: posting list or post details
$page_keywords = array();
$tagListArray = array();
// ----- read post ---------------------------------------------------------------
if (defined('POST_ID') && is_numeric(POST_ID)) {
if(!$page_link) {
exit($MESSAGE['PAGES_NOT_FOUND']);
}
// for functions that use global $section_id
$section_id = $post_section;
$tags = mod_nwi_get_tags_for_post(POST_ID);
foreach ($tags as $i => $tag) {
$tagListArray[$i] = $tag['tag'];
$tags[$i] = "<span class=\"mod_nwi_tag\" id=\"mod_nwi_tag_".POST_ID."_".$i."\""
. (!empty($tag['tag_color']) ? " style=\"background-color:".$tag['tag_color']."\"" : "" ) .">"
. "<a href=\"".$wb->page_link(PAGE_ID)."?tags=".$tag['tag']."\">".$tag['tag']."</a></span>";
if(!isset($page_keywords[$tag['tag']])) {
$page_keywords[] = htmlspecialchars($tag['tag'], ENT_QUOTES | ENT_HTML401);
}
}
$post = mod_nwi_post_show(intval(POST_ID));
if($post !== false) {
$images = mod_nwi_img_get_by_post(intval(POST_ID),true);
$replacements = array_merge(
$default_replacements,
$TEXT,
array_change_key_case($post,CASE_UPPER),
$MOD_NEWS_IMG,
array(
'IMAGE' => $post['post_img'],
'IMAGE_URL' => WB_URL.MEDIA_DIRECTORY.'/.news_img/'.$post['image'],
'IMAGES' => implode("", $images),
'SHORT' => $post['content_short'],
'LINK' => $post['post_link'],
'MODI_DATE' => $post['post_date'],
'MODI_TIME' => $post['post_time'],
'PAGE_TITLE' => (strlen((string)$page['page_title']) ? $page['page_title'] : $page['menu_title']),
'TAGS' => implode(" ", $tags),
'TAGLIST' => implode(',',$tagListArray),
'CONTENT' => $post['content_short'].$post['content_long'],
'BACK' => $page_link,
'PREVIOUS_PAGE_LINK'
=> (strlen((string)$post['prev_link'])>0 ? '<a href="'.$post['prev_link'].'">'.$MOD_NEWS_IMG['TEXT_PREV_POST'].'</a>' : null),
'NEXT_PAGE_LINK'
=> (strlen((string)$post['next_link'])>0 ? '<a href="'.$post['next_link'].'">'.$MOD_NEWS_IMG['TEXT_NEXT_POST'].'</a>' : null),
'DISPLAY_PREVIOUS_NEXT_LINKS'
=> (strlen((string)($post['prev_link'])>0 || strlen((string)$post['next_link'])>0) ? 'visible' : 'hidden'),
)
);
// use block 2
$post_block2 = '';
if ($settings['use_second_block']=='Y') {
// get content from post
$post_block2 = ($post['content_block2']);
if (empty($post_block2) && !empty($settings['block2'])) {
// get content from settings
$post_block2 = $settings['block2'];
}
// replace placeholders
$post_block2 = preg_replace_callback(
'~\[('.implode('|',$vars).')+\]~',
function($match) use($replacements) {
return (isset($match[1]) && isset($replacements[$match[1]]))
? $replacements[$match[1]]
: '';
},
$post_block2
);
if (!defined("MODULES_BLOCK2")) {
define("MODULES_BLOCK2", $post_block2);
}
if(!defined("NEWS_BLOCK2")) {
define("NEWS_BLOCK2", $post_block2);
}
if(!defined("TOPIC_BLOCK2")) {
define("TOPIC_BLOCK2", $post_block2);
}
}
$output = preg_replace_callback(
'~\[('.implode('|',$vars).')+\]~',
function($match) use($replacements) {
return (isset($match[1]) && isset($replacements[$match[1]]))
? $replacements[$match[1]]
: '';
},
$settings['post_header'].$settings['post_content'].$settings['post_footer']
);
$output=str_replace('{SYSVAR:MEDIA_REL}',WB_URL.MEDIA_DIRECTORY,$output);
// include gallery template
if (strlen($settings['gallery'])) {
include __DIR__.'/js/galleries/'.$settings['gallery'].'/include.tpl';
}
}
// ----- list of posts -----------------------------------------------------------
} else {
$posts = mod_nwi_post_list(intval($section_id));
$tpl_data = mod_nwi_posts_render($section_id,$posts,$settings['posts_per_page']);
$tags = mod_nwi_get_tags($section_id);
foreach($tags as $t) {
$page_keywords[] = htmlspecialchars($t['tag'], ENT_QUOTES | ENT_HTML401);
}
}
$view = (strlen($settings['view']) ? $settings['view'] : 'default');
if(!defined('CAT_PATH')) {
if (defined('WBCE_VERSION') && version_compare(WBCE_VERSION, '1.4.0', '>')) {
I::insertMetaTag(array (
"setname" => "keywords",
"name" => "keywords",
"content" => implode(' ',$page_keywords),
"append" => ", "
));
}
}
include __DIR__.'/templates/default/view.phtml';