-
Notifications
You must be signed in to change notification settings - Fork 1
/
article.php
executable file
·319 lines (282 loc) · 12.1 KB
/
article.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* News index file
*
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Hossein Azizabadi (AKA Voltan)
* @version $Id$
*/
// Include module header
require dirname(__FILE__) . '/header.php';
// Include content template
$xoopsOption ['template_main'] = 'news_article.tpl';
// include Xoops header
require_once XOOPS_ROOT_PATH . '/header.php';
// Add Stylesheet
$xoTheme->addStylesheet(XOOPS_URL . '/modules/news/css/style.css');
// get story id
if (isset($_REQUEST['storyid'])) {
$story_id = NewsUtils::NewsUtilityCleanVars($_REQUEST, 'storyid', 0, 'int');
} else {
$story_alias = NewsUtils::NewsUtilityCleanVars($_REQUEST, 'story', 0, 'string');
if ($story_alias) {
$_GET['storyid'] = $story_id = $story_handler->NewsStoryGetId($story_alias);
}
}
if (empty($story_id)) {
redirect_header('index.php', 3, _NEWS_MD_ERROR_EXIST);
exit ();
}
$story = [];
$obj = $story_handler->get($story_id);
if (!$obj) {
redirect_header('index.php', 3, _NEWS_MD_ERROR_EXIST);
exit ();
}
$story_topic = $obj->getVar('story_topic');
if (!$obj->getVar('story_status')) {
redirect_header('index.php', 3, _NEWS_MD_ERROR_STATUS);
exit ();
}
$story = $obj->toArray();
// Update content hits
$story_handler->NewsStoryUpdateHits($story_id);
// set arrey
$view_topic = $topic_handler->get($story_topic);
$story ['topic'] = $view_topic->getVar('topic_title');
$story ['topic_alias'] = $view_topic->getVar('topic_alias');
$story ['topic_id'] = $view_topic->getVar('topic_id');
$story ['story_publish'] = formatTimestamp($story ['story_publish'], _MEDIUMDATESTRING);
$story ['story_update'] = formatTimestamp($story ['story_update'], _MEDIUMDATESTRING);
$story ['imageurl'] = XOOPS_URL . '/uploads/news/image/medium/' . $story ['story_img'];
$story ['thumburl'] = XOOPS_URL . '/uploads/news/image/thumb/' . $story ['story_img'];
if (isset ($story_topic) && $story_topic > 0) {
if (!isset ($view_topic)) {
redirect_header('index.php', 3, _NEWS_MD_TOPIC_ERROR);
exit ();
}
if ($view_topic->getVar('topic_online') == '0') {
redirect_header('index.php', 3, _NEWS_MD_TOPIC_ERROR);
exit ();
}
// Check the access permission
if (!$perm_handler->NewsPermissionIsAllowed($xoopsUser, 'news_view', $view_topic->getVar('topic_id'))) {
redirect_header("index.php", 3, _NOPERM);
exit ();
}
}
$link = [];
if (isset ($story_topic) && $story_topic > 0 && $view_topic->getVar('topic_showtype') != '0') { // The option for select setting from topic or module options must be added
// get topic confing from topic
if ($view_topic->getVar('topic_showtopic')) {
$link ['topic'] = $view_topic->getVar('topic_title');
$link ['topicid'] = $story_topic;
$link ['topicshow'] = '1';
}
if ($view_topic->getVar('topic_showauthor')) {
$story ['author'] = XoopsUser::getUnameFromId($obj->getVar('story_uid'));
}
if ($view_topic->getVar('topic_showdate')) {
$link ['date'] = '1';
}
if ($view_topic->getVar('topic_showpdf')) {
$link ['pdf'] = NewsUtils::NewsUtilityStoryUrl($story, 'pdf');
}
if ($view_topic->getVar('topic_showprint')) {
$link ['print'] = NewsUtils::NewsUtilityStoryUrl($story, 'print');
}
if ($view_topic->getVar('topic_showhits')) {
$link ['hits'] = '1';
}
if ($view_topic->getVar('topic_showcoms') == '1') {
$link ['coms'] = '1';
}
if ($view_topic->getVar('topic_showmail')) {
// Mail link & label
$link ['mail_subject'] = $story ['story_title'] . ' - ' . $xoopsConfig ['sitename'];
$link ['mail_linkto'] = NewsUtils::NewsUtilityStoryUrl($story);
if (xoops_getModuleOption('tellafriend')) {
$link ['mail'] = "mailto:|xoops_tellafriend:" . $link ['mail_subject'];
} else {
$link ['mail'] = "mailto:?subject=" . $link ['mail_subject'] . "&body=" . $link ['mail_linkto'];
}
}
if ($view_topic->getVar('topic_shownav')) {
if ($obj->getVar('story_next') != 0) {
$next_obj = $story_handler->get($obj->getVar('story_next'));
$next_link = $next_obj->toArray();
$next_link ['topic'] = $story ['topic'];
$link ['next'] = NewsUtils::NewsUtilityStoryUrl($next_link);
$link ['next_title'] = $next_link ['story_title'];
}
if ($obj->getVar('story_prev') != 0) {
$prev_obj = $story_handler->get($obj->getVar('story_prev'));
$prev_link = $prev_obj->toArray();
$prev_link ['topic'] = $story ['topic'];
$link ['prev'] = NewsUtils::NewsUtilityStoryUrl($prev_link);
$link ['prev_title'] = $prev_link ['story_title'];
}
}
} else {
// get topic config from module option
if (xoops_getModuleOption('disp_topic')) {
$link ['topic'] = $view_topic->getVar('topic_title');
$link ['topicid'] = $story_topic;
if ($story_topic) {
$link ['topicshow'] = '1';
} else {
$link ['topicshow'] = '0';
}
}
if (xoops_getModuleOption('disp_date', 'news')) {
$link ['date'] = XoopsUser::getUnameFromId($obj->getVar('story_publish'));
}
if (xoops_getModuleOption('disp_author', 'news')) {
$story ['author'] = XoopsUser::getUnameFromId($obj->getVar('story_uid'));
}
if (xoops_getModuleOption('disp_pdflink', 'news')) {
$link ['pdf'] = NewsUtils::NewsUtilityStoryUrl($story, 'pdf');
}
if (xoops_getModuleOption('disp_printlink', 'news')) {
$link ['print'] = NewsUtils::NewsUtilityStoryUrl($story, 'print');
}
if (xoops_getModuleOption('disp_hits', 'news')) {
$link ['hits'] = '1';
}
if (xoops_getModuleOption('disp_coms', 'news')) {
$link ['coms'] = '1';
}
if (xoops_getModuleOption('disp_maillink', 'news')) {
// Mail link & label
$link ['mail_subject'] = $story ['story_title'] . ' - ' . $xoopsConfig ['sitename'];
$link ['mail_linkto'] = NewsUtils::NewsUtilityStoryUrl($story);
if (xoops_getModuleOption('tellafriend', 'news')) {
$link ['mail'] = "mailto:|xoops_tellafriend:" . $link ['mail_subject'];
} else {
$link ['mail'] = "mailto:?subject=" . $link ['mail_subject'] . "&body=" . $link ['mail_linkto'];
}
}
if (xoops_getModuleOption('disp_navlink', 'news')) {
if ($obj->getVar('story_next') != 0) {
$next_obj = $story_handler->get($obj->getVar('story_next'));
$next_link = $next_obj->toArray();
$next_link ['topic'] = $story ['topic'];
$link ['next'] = NewsUtils::NewsUtilityStoryUrl($next_link);
$link ['next_title'] = $next_link ['story_title'];
}
if ($obj->getVar('story_prev') != 0) {
$prev_obj = $story_handler->get($obj->getVar('story_prev'));
$prev_link = $prev_obj->toArray();
$prev_link ['topic'] = $story ['topic'];
$link ['prev'] = NewsUtils::NewsUtilityStoryUrl($prev_link);
$link ['prev_title'] = $prev_link ['story_title'];
}
}
}
if (xoops_getModuleOption('img_lightbox', 'news')) {
// Add scripts
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.lightbox.js');
// Add Stylesheet
$xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/lightbox.css');
$xoopsTpl->assign('img_lightbox', true);
}
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $GLOBALS ['xoopsConfig'] ['language'] . '/main.php')) {
$xoopsTpl->assign('xoops_language', $GLOBALS ['xoopsConfig'] ['language']);
} else {
$xoopsTpl->assign('xoops_language', 'english');
}
if (isset ($xoTheme) && is_object($xoTheme)) {
if ($story ['story_words'] != '') {
$xoTheme->addMeta('meta', 'keywords', $story ['story_words']);
}
if ($story ['story_desc'] != '') {
$xoTheme->addMeta('meta', 'description', $story ['story_desc']);
}
} elseif (isset ($xoopsTpl) && is_object($xoopsTpl)) { // Compatibility for old Xoops versions
if ($story ['story_words'] != '') {
$xoopsTpl->assign('xoops_meta_keywords', $story ['story_words']);
}
if ($story ['story_desc'] != '') {
$xoopsTpl->assign('xoops_meta_description', $story ['story_desc']);
}
}
// For social networks scripts
if (xoops_getModuleOption('show_social_book', 'news') == '1' || xoops_getModuleOption('show_social_book', 'news') == '3') {
$xoTheme->addScript('http://platform.twitter.com/widgets.js');
$xoTheme->addScript('http://connect.facebook.net/en_US/all.js#xfbml=1');
$xoTheme->addScript('https://apis.google.com/js/plusone.js');
}
// For xoops tag
if ((xoops_getModuleOption('usetag', 'news')) and (is_dir(XOOPS_ROOT_PATH . '/modules/tag'))) {
include_once XOOPS_ROOT_PATH . "/modules/tag/include/tagbar.php";
$xoopsTpl->assign('tagbar', tagBar($story ['story_id'], $catid = 0));
$xoopsTpl->assign('tags', true);
} else {
$xoopsTpl->assign('tags', false);
}
// Get URLs
$link ['url'] = NewsUtils::NewsUtilityStoryUrl($story);
$link ['topicurl'] = NewsUtils::NewsUtilityTopicUrl($story);
// breadcrumb
if (xoops_getModuleOption('bc_show', 'news')) {
$breadcrumb = NewsUtils::NewsUtilityBreadcrumb(true, $story ['story_title'], $story ['story_topic'], ' » ', 'topic_title');
}
// Get Attached files information
if ($story ['story_file'] > 0) {
$file = [];
$file['order'] = 'DESC';
$file['sort'] = 'file_id';
$file['start'] = 0;
$file['content'] = $story_id;
$view_file = $file_handler->NewsFileList($file);
$xoopsTpl->assign('files', $view_file);
$xoopsTpl->assign('jwwidth', '470');
$xoopsTpl->assign('jwheight', '320');
}
// Get related contents
if (xoops_getModuleOption('related', 'news')) {
$related_infos ['story_id'] = $obj->getVar('story_id');
$related_infos ['story_topic'] = $obj->getVar('story_topic');
$related_infos ['story_limit'] = xoops_getModuleOption('related_limit', 'news');
$related_infos ['topic_alias'] = $view_topic->getVar('topic_alias');
$related = $story_handler->NewsStoryRelated($related_infos);
$xoopsTpl->assign('related', $related);
}
// Add topic style if set
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/css/' . $view_topic->getVar('topic_style') . '.css')) {
$xoTheme->addStylesheet(XOOPS_URL . '/modules/news/css/' . $view_topic->getVar('topic_style') . '.css');
}
// Vote system
if (xoops_getModuleOption('vote_active', 'news')) {
// Add scripts
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
$xoTheme->addScript(XOOPS_URL . '/modules/news/js/rateit.js');
// Add Stylesheet
$xoTheme->addStylesheet(XOOPS_URL . '/modules/news/css/rateit.css');
$xoopsTpl->assign('vote', true);
}
$xoopsTpl->assign('content', $story);
$xoopsTpl->assign('link', $link);
$xoopsTpl->assign('xoops_pagetitle', $story ['story_title']);
$xoopsTpl->assign('rss', xoops_getModuleOption('rss_show', 'news'));
$xoopsTpl->assign('multiple_columns', xoops_getModuleOption('multiple_columns', 'news'));
$xoopsTpl->assign('show_social_book', xoops_getModuleOption('show_social_book', 'news'));
$xoopsTpl->assign('advertisement', xoops_getModuleOption('advertisement', 'news'));
$xoopsTpl->assign('imgwidth', xoops_getModuleOption('imgwidth', 'news'));
$xoopsTpl->assign('imgfloat', xoops_getModuleOption('imgfloat', 'news'));
$xoopsTpl->assign('alluserpost', xoops_getModuleOption('alluserpost', 'news'));
$xoopsTpl->assign('breadcrumb', $breadcrumb);
// include Xoops footer
require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
require_once XOOPS_ROOT_PATH . '/footer.php';
?>