forked from GregMage/xmcontent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewcontent.php
114 lines (101 loc) · 4.68 KB
/
viewcontent.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
<?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.
*/
/**
* xmcontent module
*
* @copyright XOOPS Project (https://xoops.org)
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @author Mage Gregory (AKA Mage)
*/
include __DIR__ . '/header.php';
$xoopsOption['template_main'] = 'xmcontent_viewcontent.tpl';
include_once XOOPS_ROOT_PATH . '/header.php';
$content_id = XoopsRequest::getInt('content_id', 0);
$xoopsTpl->assign('content_id', $content_id);
if (0 == $content_id) {
redirect_header('index.php', 2, _AM_XMCONTENT_VIEWCONTENT_NOCONTENT);
exit();
}
$content = $contentHandler->get($content_id);
if (empty($content)) {
redirect_header('index.php', 2, _AM_XMCONTENT_VIEWCONTENT_NOCONTENT);
exit();
}
if (0 == $content->getVar('content_status')) {
redirect_header('index.php', 2, _AM_XMCONTENT_VIEWCONTENT_NACTIVE);
exit();
}
// permission to view
if ($permHelper->checkPermission('xmcontent_contentview', $content_id) === false){
redirect_header('index.php',2, _NOPERM);
}
// permission to edit
$xoopsTpl->assign('perm_edit', $permHelper->checkPermission('xmcontent_contentedit', $content_id));
// css
if (true == $helper->getConfig('options_css', 0) && '' != $content->getVar('content_css')){
$xoTheme->addStylesheet( XOOPS_URL . '/uploads/xmcontent/css/' . $content->getVar('content_css'), null );
}
// template
if (true == $helper->getConfig('options_template', 0) && '' != $content->getVar('content_template')){
$xoopsTpl->assign('content_template', XOOPS_ROOT_PATH . "/uploads/xmcontent/templates/" . $content->getVar('content_template'));
}
$xoopsTpl->assign('content_title', $content->getVar('content_title'));
$new_content = XmcontentUtility::includeContent(str_replace('[break_dsc]', '', $content->getVar('content_text', 'show')));
$xoopsTpl->assign('content_text' , $new_content['text']);
$xoopsTpl->assign('content_error' , $new_content['error']);
$xoopsTpl->assign('content_warning' , $new_content['warning']);
$xoopsTpl->assign('content_docomment', $content->getVar('content_docomment'));
$xoopsTpl->assign('content_dopdf', $content->getVar('content_dopdf'));
$xoopsTpl->assign('content_doprint', $content->getVar('content_doprint'));
$xoopsTpl->assign('content_dosocial', $content->getVar('content_dosocial'));
$xoopsTpl->assign('content_domail', $content->getVar('content_domail'));
$xoopsTpl->assign('content_dotitle', $content->getVar('content_dotitle'));
//xmdoc
if (xoops_isActiveModule('xmdoc') && $helper->getConfig('options_xmdoc', 0) == 1) {
xoops_load('utility', 'xmdoc');
XmdocUtility::renderDocuments($xoopsTpl, $xoTheme, 'xmcontent', $content_id);
} else {
$xoopsTpl->assign('xmdoc_viewdocs', false);
}
//xmsocial
if (xoops_isActiveModule('xmsocial')){
xoops_load('utility', 'xmsocial');
if ($helper->getConfig('options_xmsocial', 0) == 1){
$xmsocial_arr = XmsocialUtility::renderRating($xoTheme, 'xmcontent', $content_id, 5, $content->getVar('content_rating'), $content->getVar('content_votes'));
$xoopsTpl->assign('xmsocial_arr', $xmsocial_arr);
$xoopsTpl->assign('dorating', $content->getVar('content_dorating'));
} else {
$xoopsTpl->assign('dorating', 0);
}
if ($helper->getConfig('options_xmsocial_social', 0) == 1) {
XmsocialUtility::renderSocial($xoopsTpl,'xmcontent', $content_id, XOOPS_URL . '/modules/xmcontent/viewcontent.php?content_id=' . $content_id);
$xoopsTpl->assign('social', true);
} else {
$xoopsTpl->assign('social', false);
}
}
//SEO
// pagetitle
$xoopsTpl->assign('xoops_pagetitle', strip_tags($content->getVar('content_title')) . ' - ' . $xoopsModule->name());
//description
if ('' == $content->getVar('content_mdescription')) {
$xoTheme->addMeta('meta', 'description', XmcontentUtility::generateDescriptionTagSafe($content->getVar('content_text'), 80));
} else {
$xoTheme->addMeta('meta', 'description', strip_tags($content->getVar('content_mdescription')));
}
//keywords
if ('' == $content->getVar('content_mkeyword')) {
$keywords = \Xmf\Metagen::generateKeywords(XmcontentUtility::TagSafe($content->getVar('content_text')), 10);
$xoTheme->addMeta('meta', 'keywords', implode(', ', $keywords));
} else {
$xoTheme->addMeta('meta', 'keywords', XmcontentUtility::TagSafe($content->getVar('content_mkeyword')));
}
include XOOPS_ROOT_PATH.'/include/comment_view.php';
include XOOPS_ROOT_PATH . '/footer.php';