1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | /* |
||||||
5 | You may not change or alter any portion of this comment or credits |
||||||
6 | of supporting developers from this source code or any supporting source code |
||||||
7 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
8 | |||||||
9 | This program is distributed in the hope that it will be useful, |
||||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
12 | */ |
||||||
13 | |||||||
14 | /** |
||||||
15 | * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
||||||
16 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
||||||
17 | * @since 1.0 |
||||||
18 | * @author trabis <[email protected]> |
||||||
19 | * @author The SmartFactory <www.smartfactory.ca> |
||||||
20 | */ |
||||||
21 | |||||||
22 | use Xmf\Request; |
||||||
23 | use XoopsModules\Publisher\{ |
||||||
24 | Helper, |
||||||
25 | Metagen, |
||||||
26 | Utility |
||||||
27 | }; |
||||||
28 | |||||||
29 | require_once __DIR__ . '/header.php'; |
||||||
30 | |||||||
31 | $itemId = Request::getInt('itemid', 0, 'GET'); |
||||||
32 | $itemPageId = Request::getInt('page', -1, 'GET'); |
||||||
33 | |||||||
34 | if (0 == $itemId) { |
||||||
35 | redirect_header('<script>javascript:history.go(-1)</script>', 1, _MD_PUBLISHER_NOITEMSELECTED); |
||||||
36 | } |
||||||
37 | |||||||
38 | $helper = Helper::getInstance(); |
||||||
39 | |||||||
40 | // Creating the item object for the selected item |
||||||
41 | $itemObj = $helper->getHandler('Item')->get($itemId); |
||||||
42 | |||||||
43 | // if the selected item was not found, exit |
||||||
44 | if (!$itemObj) { |
||||||
0 ignored issues
–
show
introduced
by
![]() |
|||||||
45 | redirect_header('<script>javascript:history.go(-1)</script>', 1, _MD_PUBLISHER_NOITEMSELECTED); |
||||||
46 | } |
||||||
47 | |||||||
48 | $GLOBALS['xoopsOption']['template_main'] = 'publisher_item.tpl'; |
||||||
49 | require_once $GLOBALS['xoops']->path('header.php'); |
||||||
50 | |||||||
51 | //$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||||||
52 | //$xoTheme->addScript(PUBLISHER_URL . '/assets/js/jquery.popeye-2.1.js'); |
||||||
53 | //$xoTheme->addScript(PUBLISHER_URL . '/assets/js/publisher.js'); |
||||||
54 | // |
||||||
55 | //$xoTheme->addStylesheet(PUBLISHER_URL . '/assets/css/jquery.popeye.css'); |
||||||
56 | //$xoTheme->addStylesheet(PUBLISHER_URL . '/assets/css/jquery.popeye.style.css'); |
||||||
57 | //$xoTheme->addStylesheet(PUBLISHER_URL . '/assets/css/publisher.css'); |
||||||
58 | |||||||
59 | require_once PUBLISHER_ROOT_PATH . '/footer.php'; |
||||||
60 | |||||||
61 | // Creating the category object that holds the selected item |
||||||
62 | $categoryObj = $helper->getHandler('Category')->get($itemObj->categoryid()); |
||||||
0 ignored issues
–
show
The method
categoryid() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
63 | |||||||
64 | // Check user permissions to access that category of the selected item |
||||||
65 | if (!$itemObj->accessGranted()) { |
||||||
0 ignored issues
–
show
The method
accessGranted() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
66 | redirect_header('<script>javascript:history.go(-1)</script>', 1, _NOPERM); |
||||||
67 | } |
||||||
68 | $com_replytitle = $itemObj->getTitle(); |
||||||
0 ignored issues
–
show
The method
getTitle() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
69 | |||||||
70 | // Update the read counter of the selected item |
||||||
71 | if (!$GLOBALS['xoopsUser'] |
||||||
72 | || ($GLOBALS['xoopsUser'] && !$GLOBALS['xoopsUser']->isAdmin($helper->getModule()->mid())) |
||||||
73 | || ($GLOBALS['xoopsUser']->isAdmin($helper->getModule()->mid()) && 1 == $helper->getConfig('item_admin_hits'))) { |
||||||
74 | $itemObj->updateCounter(); |
||||||
0 ignored issues
–
show
The method
updateCounter() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
75 | } |
||||||
76 | |||||||
77 | // creating the Item objects that belong to the selected category |
||||||
78 | switch ($helper->getConfig('format_order_by')) { |
||||||
79 | case 'title': |
||||||
80 | $sort = 'title'; |
||||||
81 | $order = 'ASC'; |
||||||
82 | break; |
||||||
83 | case 'date': |
||||||
84 | $sort = 'datesub'; |
||||||
85 | $order = 'DESC'; |
||||||
86 | break; |
||||||
87 | case 'counter': |
||||||
88 | $sort = 'counter'; |
||||||
89 | $order = 'DESC'; |
||||||
90 | break; |
||||||
91 | case 'rating': |
||||||
92 | $sort = 'rating'; |
||||||
93 | $order = 'DESC'; |
||||||
94 | break; |
||||||
95 | case 'votes': |
||||||
96 | $sort = 'votes'; |
||||||
97 | $order = 'DESC'; |
||||||
98 | break; |
||||||
99 | case 'comments': |
||||||
100 | $sort = 'comments'; |
||||||
101 | $order = 'DESC'; |
||||||
102 | break; |
||||||
103 | default: |
||||||
104 | $sort = 'weight'; |
||||||
105 | $order = 'ASC'; |
||||||
106 | break; |
||||||
107 | } |
||||||
108 | |||||||
109 | if ('previous_next' === $helper->getConfig('item_other_items_type')) { |
||||||
110 | // Retrieving the next and previous object |
||||||
111 | $previousItemLink = ''; |
||||||
112 | $previousItemUrl = ''; |
||||||
113 | $nextItemLink = ''; |
||||||
114 | $nextItemUrl = ''; |
||||||
115 | |||||||
116 | $previousObj = $helper->getHandler('Item')->getPreviousPublished($itemObj); |
||||||
117 | $nextObj = $helper->getHandler('Item')->getNextPublished($itemObj); |
||||||
118 | if (is_object($previousObj)) { |
||||||
119 | $previousItemLink = $previousObj->getItemLink(); |
||||||
120 | $previousItemUrl = $previousObj->getItemUrl(); |
||||||
121 | } |
||||||
122 | |||||||
123 | if (is_object($nextObj)) { |
||||||
124 | $nextItemLink = $nextObj->getItemLink(); |
||||||
125 | $nextItemUrl = $nextObj->getItemUrl(); |
||||||
126 | } |
||||||
127 | unset($previousObj, $nextObj); |
||||||
128 | $xoopsTpl->assign('previousItemLink', $previousItemLink); |
||||||
129 | $xoopsTpl->assign('nextItemLink', $nextItemLink); |
||||||
130 | $xoopsTpl->assign('previousItemUrl', $previousItemUrl); |
||||||
131 | $xoopsTpl->assign('nextItemUrl', $nextItemUrl); |
||||||
132 | } |
||||||
133 | |||||||
134 | //CAREFUL!! with many items this will exhaust memory |
||||||
135 | if ('all' === $helper->getConfig('item_other_items_type')) { |
||||||
136 | $itemsObj = $helper->getHandler('Item')->getAllPublished(0, 0, $categoryObj->categoryid(), $sort, $order, '', true, true); |
||||||
137 | $items = []; |
||||||
138 | foreach ($itemsObj[''] as $theItemObj) { |
||||||
139 | $theItem = []; |
||||||
140 | $theItem['body'] = $theItemObj->getBody(); |
||||||
141 | $theItem['title'] = $theItemObj->getTitle(); |
||||||
142 | $theItem['titlelink'] = $theItemObj->getItemLink(); |
||||||
143 | $theItem['itemid'] = $theItemObj->itemid(); |
||||||
144 | $theItem['itemurl'] = $theItemObj->getItemUrl(); |
||||||
145 | $theItem['datesub'] = $theItemObj->getDatesub(); |
||||||
146 | $theItem['counter'] = $theItemObj->counter(); |
||||||
147 | $theItem['who'] = $theItemObj->getWho(); |
||||||
148 | $theItem['category'] = $theItemObj->getCategoryLink(); |
||||||
149 | $theItem['more'] = '<a href="' . $theItemObj->getItemUrl() . '">' . _MD_PUBLISHER_READMORE . '</a>'; |
||||||
150 | |||||||
151 | $summary = $theItemObj->getSummary(300); |
||||||
152 | if (!$summary) { |
||||||
153 | $summary = $theItemObj->getBody(300); |
||||||
154 | } |
||||||
155 | $theItem['summary'] = $summary; |
||||||
156 | |||||||
157 | $theItem['cancomment'] = $theItemObj->cancomment(); |
||||||
158 | $comments = $theItemObj->comments(); |
||||||
159 | if ($comments > 0) { |
||||||
160 | //shows 1 comment instead of 1 comm. if comments ==1 |
||||||
161 | //langugage file modified accordingly |
||||||
162 | if (1 == $comments) { |
||||||
163 | $theItem['comments'] = ' ' . _MD_PUBLISHER_ONECOMMENT . ' '; |
||||||
164 | } else { |
||||||
165 | $theItem['comments'] = ' ' . $comments . ' ' . _MD_PUBLISHER_COMMENTS . ' '; |
||||||
166 | } |
||||||
167 | } else { |
||||||
168 | $theItem['comments'] = ' ' . _MD_PUBLISHER_NO_COMMENTS . ' '; |
||||||
169 | } |
||||||
170 | |||||||
171 | $mainImage = $theItemObj->getMainImage(); |
||||||
172 | // check to see if GD function exist |
||||||
173 | $theItem['item_image'] = $mainImage['image_path']; |
||||||
174 | if (!empty($mainImage['image_path']) && function_exists('imagecreatetruecolor')) { |
||||||
175 | $theItem['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&w=100'; |
||||||
176 | $theItem['image_path'] = $mainImage['image_path']; |
||||||
177 | } |
||||||
178 | |||||||
179 | if ($theItemObj->itemId() == $itemObj->itemId()) { |
||||||
0 ignored issues
–
show
The method
itemId() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
180 | $theItem['titlelink'] = $theItemObj->getItemLink(); |
||||||
181 | } |
||||||
182 | $items[] = $theItem; |
||||||
183 | unset($theItem); |
||||||
184 | } |
||||||
185 | unset($itemsObj); |
||||||
186 | $xoopsTpl->assign('items', $items); |
||||||
187 | unset($items); |
||||||
188 | } |
||||||
189 | |||||||
190 | // Populating the smarty variables with information related to the selected item |
||||||
191 | $item = $itemObj->toArraySimple($itemPageId); |
||||||
0 ignored issues
–
show
The method
toArraySimple() does not exist on XoopsObject . Did you maybe mean toArray() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
192 | $xoopsTpl->assign('show_subtitle', $helper->getConfig('item_disp_subtitle')); |
||||||
193 | |||||||
194 | if ($itemObj->pagescount() > 0) { |
||||||
0 ignored issues
–
show
The method
pagescount() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
195 | if (-1 == $itemPageId) { |
||||||
196 | $itemPageId = 0; |
||||||
197 | } |
||||||
198 | require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
||||||
199 | // $pagenav = new \XoopsPageNav($itemObj->pagescount(), 1, $itemPageId, 'page', 'itemid=' . $itemObj->itemId()); |
||||||
200 | |||||||
201 | $pagenav = new \XoopsPageNav($itemObj->pagescount(), 1, $itemPageId, 'page', 'itemid=' . $itemObj->itemid()); //SMEDrieben changed ->itemId to ->itemid |
||||||
0 ignored issues
–
show
The method
itemid() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
202 | |||||||
203 | $xoopsTpl->assign('pagenav', $pagenav->renderNav()); |
||||||
204 | } |
||||||
205 | |||||||
206 | // Creating the files object associated with this item |
||||||
207 | $file = []; |
||||||
208 | $files = []; |
||||||
209 | $embededFiles = []; |
||||||
210 | $filesObj = $itemObj->getFiles(); |
||||||
0 ignored issues
–
show
The method
getFiles() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
211 | |||||||
212 | // check if user has permission to modify files |
||||||
213 | $hasFilePermissions = true; |
||||||
214 | if (!(Utility::userIsAdmin() || Utility::userIsModerator($itemObj))) { |
||||||
215 | $hasFilePermissions = false; |
||||||
216 | } |
||||||
217 | if (null !== $filesObj) { |
||||||
218 | foreach ($filesObj as $fileObj) { |
||||||
219 | $file = []; |
||||||
220 | $file['mod'] = false; |
||||||
221 | if ($hasFilePermissions || (is_object($GLOBALS['xoopsUser']) && $fileObj->getVar('uid') == $GLOBALS['xoopsUser']->getVar('uid'))) { |
||||||
222 | $file['mod'] = true; |
||||||
223 | } |
||||||
224 | |||||||
225 | if ('application/x-shockwave-flash' === $fileObj->mimetype()) { |
||||||
226 | $file['content'] = $fileObj->displayFlash(); |
||||||
227 | if (mb_strpos($item['maintext'], '[flash-' . $fileObj->getVar('fileid') . ']')) { |
||||||
228 | $item['maintext'] = str_replace('[flash-' . $fileObj->getVar('fileid') . ']', $file['content'], $item['maintext']); |
||||||
229 | } else { |
||||||
230 | $embededFiles[] = $file; |
||||||
231 | } |
||||||
232 | } else { |
||||||
233 | $file['fileid'] = $fileObj->fileid(); |
||||||
234 | $file['name'] = $fileObj->name(); |
||||||
235 | $file['description'] = $fileObj->description(); |
||||||
236 | $file['name'] = $fileObj->name(); |
||||||
237 | $file['type'] = $fileObj->mimetype(); |
||||||
238 | $file['datesub'] = $fileObj->getDatesub(); |
||||||
239 | $file['hits'] = $fileObj->counter(); |
||||||
240 | $files[] = $file; |
||||||
241 | } |
||||||
242 | } |
||||||
243 | } |
||||||
244 | |||||||
245 | $item['files'] = $files; |
||||||
246 | $item['embeded_files'] = $embededFiles; |
||||||
247 | unset($file, $embededFiles, $filesObj, $fileObj); |
||||||
248 | |||||||
249 | // Language constants |
||||||
250 | $xoopsTpl->assign('mail_link', 'mailto:?subject=' . sprintf(_CO_PUBLISHER_INTITEM, $GLOBALS['xoopsConfig']['sitename']) . '&body=' . sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']) . ': ' . $itemObj->getItemUrl()); |
||||||
0 ignored issues
–
show
The method
getItemUrl() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
251 | $xoopsTpl->assign('itemid', $itemObj->itemId()); |
||||||
252 | $xoopsTpl->assign('sectionname', $helper->getModule()->getVar('name')); |
||||||
253 | $xoopsTpl->assign('module_dirname', $helper->getDirname()); |
||||||
254 | $xoopsTpl->assign('module_home', Utility::moduleHome($helper->getConfig('format_linked_path'))); |
||||||
255 | $xoopsTpl->assign('categoryPath', '<li>' . $item['categoryPath'] . '</li><li> ' . $item['title'] . '</li>'); |
||||||
256 | $xoopsTpl->assign('commentatarticlelevel', $helper->getConfig('perm_com_art_level')); |
||||||
257 | $xoopsTpl->assign('com_rule', $helper->getConfig('com_rule')); |
||||||
258 | $xoopsTpl->assign('other_items', $helper->getConfig('item_other_items_type')); |
||||||
259 | $xoopsTpl->assign('itemfooter', $myts->displayTarea($helper->getConfig('item_footer'), 1)); |
||||||
260 | $xoopsTpl->assign('perm_author_items', $helper->getConfig('perm_author_items')); |
||||||
261 | |||||||
262 | // tags support |
||||||
263 | if (xoops_isActiveModule('tag')) { |
||||||
264 | require_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php'); |
||||||
265 | $xoopsTpl->assign('tagbar', tagBar($itemId, $catId = 0)); |
||||||
266 | } |
||||||
267 | |||||||
268 | /** |
||||||
269 | * Generating meta information for this page |
||||||
270 | */ |
||||||
271 | $publisherMetagen = new Metagen($itemObj->getVar('title'), $itemObj->getVar('meta_keywords', 'n'), $itemObj->getVar('meta_description', 'n'), $itemObj->getCategoryPath()); |
||||||
0 ignored issues
–
show
The method
getCategoryPath() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
$itemObj->getVar('title') can also be of type array and array ; however, parameter $title of XoopsModules\Publisher\Metagen::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
272 | $publisherMetagen->createMetaTags(); |
||||||
273 | |||||||
274 | // Include the comments if the selected ITEM supports comments |
||||||
275 | if ((0 != $helper->getConfig('com_rule')) && ((1 == $itemObj->cancomment()) || !$helper->getConfig('perm_com_art_level'))) { |
||||||
0 ignored issues
–
show
The method
cancomment() does not exist on XoopsObject . It seems like you code against a sub-type of XoopsObject such as XoopsModules\Publisher\Item or XoopsModules\Publisher\File or XoopsModules\Publisher\Category .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
276 | require_once $GLOBALS['xoops']->path('include/comment_view.php'); |
||||||
277 | // Problem with url_rewrite and posting comments : |
||||||
278 | $xoopsTpl->assign( |
||||||
279 | [ |
||||||
280 | 'editcomment_link' => PUBLISHER_URL . '/comment_edit.php?com_itemid=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode . $link_extra, |
||||||
281 | 'deletecomment_link' => PUBLISHER_URL . '/comment_delete.php?com_itemid=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode . $link_extra, |
||||||
282 | 'replycomment_link' => PUBLISHER_URL . '/comment_reply.php?com_itemid=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode . $link_extra, |
||||||
283 | ] |
||||||
284 | ); |
||||||
285 | $xoopsTpl->_tpl_vars['commentsnav'] = str_replace("self.location.href='", "self.location.href='" . PUBLISHER_URL . '/', $xoopsTpl->_tpl_vars['commentsnav']); |
||||||
286 | } |
||||||
287 | |||||||
288 | // Include support for AJAX rating |
||||||
289 | if ($helper->getConfig('perm_rating')) { |
||||||
290 | $xoopsTpl->assign('rating_enabled', true); |
||||||
291 | $item['ratingbar'] = Utility::ratingBar($itemId); |
||||||
292 | $xoTheme->addScript(PUBLISHER_URL . '/assets/js/behavior.js'); |
||||||
293 | $xoTheme->addScript(PUBLISHER_URL . '/assets/js/rating.js'); |
||||||
294 | } |
||||||
295 | |||||||
296 | $xoopsTpl->assign('item', $item); |
||||||
297 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||||||
298 |