XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
legacy_comments.php
1<?php
14
20function b_legacy_comments_show($options)
21{
22 $block = [];
23 include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
24 $comment_handler =& xoops_gethandler('comment');
25 $criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
26 $criteria->setLimit((int)$options[0]);
27 $criteria->setSort('com_created');
28 $criteria->setOrder('DESC');
29 $comments =& $comment_handler->getObjects($criteria, true);
30 $member_handler =& xoops_gethandler('member');
31 $module_handler =& xoops_gethandler('module');
32 $modules =& $module_handler->getObjects(new Criteria('hascomments', 1), true);
33 $comment_config = [];
34 foreach (array_keys($comments) as $i) {
35 $mid = $comments[$i]->getVar('com_modid');
36 $com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>';
37 if (!isset($comment_config[$mid])) {
38 $comment_config[$mid] = $modules[$mid]->getInfo('comments');
39 }
40 $com['id'] = $i;
41 $com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&amp;com_id='.$i.'&amp;com_rootid='.$comments[$i]->getVar('com_rootid').'&amp;'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>';
42 $com['icon'] = $comments[$i]->getVar('com_icon');
43 $com['icon'] = ('' !== $com['icon']) ? $com['icon'] : 'icon1.gif';
44 $com['time'] = $comments[$i]->getVar('com_created');
45 if ($comments[$i]->getVar('com_uid') > 0) {
46 $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
47 if (is_object($poster)) {
48 $com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>';
49 } else {
50 $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
51 }
52 } else {
53 $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
54 }
55 $block['comments'][] =& $com;
56 unset($com);
57 }
58 return $block;
59}
60
61function b_legacy_comments_edit($options)
62{
63 $inputtag = "<input type='text' name='options[]' value='" . (int)$options[0] . "'>";
64 $form = sprintf(_MB_LEGACY_DISPLAYC, $inputtag);
65 return $form;
66}