36 public function __construct(&$tpl, $use_icons =
true, $do_iconcheck =
false)
39 $this->_useIcons = $use_icons;
40 $this->_doIconCheck = $do_iconcheck;
41 $this->_memberHandler =& xoops_gethandler(
'member');
42 $this->_statusText = [XOOPS_COMMENT_PENDING =>
'<span style="text-decoration: none; font-weight: bold; color: #00ff00;">' . _CM_PENDING .
'</span>', XOOPS_COMMENT_ACTIVE =>
'<span style="text-decoration: none; font-weight: bold; color: #ff0000;">' . _CM_ACTIVE .
'</span>', XOOPS_COMMENT_HIDDEN =>
'<span style="text-decoration: none; font-weight: bold; color: #0000ff;">' . _CM_HIDDEN .
'</span>'];
82 foreach ($this->_comments as $iValue) {
83 if (
false !== $this->_useIcons) {
84 $title = $this->
_getTitleIcon($iValue->getVar(
'com_icon')).
' '. $iValue->getVar(
'com_title');
86 $title = $iValue->getVar(
'com_title');
89 if (
false !== $admin_view) {
90 $text = $iValue->getVar(
'com_text')
91 .
'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'
92 ._CM_STATUS.
': '.$this->_statusText[$iValue->getVar(
'com_status')].
'<br>IP: <span style="font-weight: bold;">'
93 . $iValue->getVar(
'com_ip').
'</span></div>';
94 }
else if (XOOPS_COMMENT_ACTIVE !== $iValue->getVar(
'com_status')) {
97 $text = $iValue->getVar(
'com_text');
99 $this->_tpl->append(
'comments',
101 'id' => $iValue->getVar(
'com_id'),
104 'date_posted' => formatTimestamp($iValue->getVar(
'com_created'),
'm'),
105 'date_modified' => formatTimestamp($iValue->getVar(
'com_modified'),
'm'),
121 public function renderThreadView(
int $comment_id = 0,
bool $admin_view,
bool $show_nav =
true)
123 include_once XOOPS_ROOT_PATH.
'/class/tree.php';
125 $xot =
new XoopsObjectTree($this->_comments,
'com_id',
'com_pid',
'com_rootid');
126 $tree =& $xot->getTree();
128 if (
false !== $this->_useIcons) {
129 $title = $this->
_getTitleIcon($tree[$comment_id][
'obj']->getVar(
'com_icon')).
' '.$tree[$comment_id][
'obj']->getVar(
'com_title');
131 $title = $tree[$comment_id][
'obj']->getVar(
'com_title');
133 if (
false !== $show_nav && 0 !== $tree[$comment_id][
'obj']->getVar(
'com_pid')) {
134 $this->_tpl->assign(
'lang_top', _CM_TOP);
135 $this->_tpl->assign(
'lang_parent', _CM_PARENT);
136 $this->_tpl->assign(
'show_threadnav',
true);
138 $this->_tpl->assign(
'show_threadnav',
false);
140 if (
false !== $admin_view) {
142 $text = $tree[$comment_id][
'obj']->getVar(
'com_text')
143 .
'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'
145 .$this->_statusText[$tree[$comment_id][
'obj']->getVar(
'com_status')]
146 .
'<br>IP: <span style="font-weight: bold;">'
147 .$tree[$comment_id][
'obj']->getVar(
'com_ip').
'</span></div>';
148 }
else if (XOOPS_COMMENT_ACTIVE !== $tree[$comment_id][
'obj']->getVar(
'com_status')) {
150 if (isset($tree[$comment_id][
'child']) && !empty($tree[$comment_id][
'child'])) {
151 foreach ($tree[$comment_id][
'child'] as $child_id) {
157 $text = $tree[$comment_id][
'obj']->getVar(
'com_text');
161 $show_replies = count($replies) > 0;
162 $this->_tpl->append(
'comments',
164 'pid' => $tree[$comment_id][
'obj']->getVar(
'com_pid'),
165 'id' => $tree[$comment_id][
'obj']->getVar(
'com_id'),
166 'itemid' => $tree[$comment_id][
'obj']->getVar(
'com_itemid'),
167 'rootid' => $tree[$comment_id][
'obj']->getVar(
'com_rootid'),
168 'title' => $title,
'text' => $text,
169 'date_posted' => formatTimestamp($tree[$comment_id][
'obj']->getVar(
'com_created'),
'm'),
170 'date_modified' => formatTimestamp($tree[$comment_id][
'obj']->getVar(
'com_modified'),
'm'),
171 'poster' => $this->
_getPosterArray($tree[$comment_id][
'obj']->getVar(
'com_uid')),
172 'replies' => $replies,
'show_replies' => $show_replies
190 public function _renderThreadReplies(array &$thread,
int $key, array &$replies,
string $prefix,
bool $admin_view,
int $depth = 0,
string $current_prefix =
'')
193 if (
false !== $this->_useIcons) {
194 $title = $this->
_getTitleIcon($thread[$key][
'obj']->getVar(
'com_icon')).
' '.$thread[$key][
'obj']->getVar(
'com_title');
196 $title = $thread[$key][
'obj']->getVar(
'com_title');
198 $title = (
false !== $admin_view) ? $title.
' '.$this->_statusText[$thread[$key][
'obj']->getVar(
'com_status')] : $title;
201 'prefix' => $current_prefix,
202 'date_posted' => formatTimestamp($thread[$key][
'obj']->getVar(
'com_created'),
'm'),
204 'root_id' => $thread[$key][
'obj']->getVar(
'com_rootid'),
205 'status' => $this->_statusText[$thread[$key][
'obj']->getVar(
'com_status')],
206 'poster' => $this->
_getPosterName($thread[$key][
'obj']->getVar(
'com_uid'))
208 $current_prefix .= $prefix;
210 if (isset($thread[$key][
'child']) && !empty($thread[$key][
'child'])) {
212 foreach ($thread[$key][
'child'] as $childkey) {
213 if (!$admin_view && XOOPS_COMMENT_ACTIVE !== $thread[$childkey][
'obj']->getVar(
'com_status')) {
215 if (isset($thread[$childkey][
'child']) && !empty($thread[$childkey][
'child'])) {
216 foreach ($thread[$childkey][
'child'] as $childchildkey) {
221 $this->
_renderThreadReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth, $current_prefix);
237 include_once XOOPS_ROOT_PATH.
'/class/tree.php';
238 $xot =
new XoopsObjectTree($this->_comments,
'com_id',
'com_pid',
'com_rootid');
239 $tree =& $xot->getTree();
240 if (
false !== $this->_useIcons) {
241 $title = $this->
_getTitleIcon($tree[$comment_id][
'obj']->getVar(
'com_icon')).
' '.$tree[$comment_id][
'obj']->getVar(
'com_title');
243 $title = $tree[$comment_id][
'obj']->getVar(
'com_title');
245 if (
false !== $admin_view) {
246 $text = $tree[$comment_id][
'obj']->getVar(
'com_text')
247 .
'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'
248 ._CM_STATUS.
': '.$this->_statusText[$tree[$comment_id][
'obj']->getVar(
'com_status')]
249 .
'<br>IP: <span style="font-weight: bold;">'
250 .$tree[$comment_id][
'obj']->getVar(
'com_ip').
'</span></div>';
251 }
else if (XOOPS_COMMENT_ACTIVE !== $tree[$comment_id][
'obj']->getVar(
'com_status')) {
253 if (isset($tree[$comment_id][
'child']) && !empty($tree[$comment_id][
'child'])) {
254 foreach ($tree[$comment_id][
'child'] as $child_id) {
260 $text = $tree[$comment_id][
'obj']->getVar(
'com_text');
264 $this->_tpl->append(
'comments', [
265 'pid' => $tree[$comment_id][
'obj']->getVar(
'com_pid'),
266 'id' => $tree[$comment_id][
'obj']->getVar(
'com_id'),
267 'itemid' => $tree[$comment_id][
'obj']->getVar(
'com_itemid'),
268 'rootid' => $tree[$comment_id][
'obj']->getVar(
'com_rootid'),
269 'title' => $title,
'text' => $text,
270 'date_posted' => formatTimestamp($tree[$comment_id][
'obj']->getVar(
'com_created'),
'm'),
271 'date_modified' => formatTimestamp($tree[$comment_id][
'obj']->getVar(
'com_modified'),
'm'),
272 'poster' => $this->
_getPosterArray($tree[$comment_id][
'obj']->getVar(
'com_uid')),
273 'replies' => $replies
290 public function _renderNestReplies(array &$thread,
int $key, array &$replies,
string $prefix,
bool $admin_view,
int $depth = 0)
293 if (
false !== $this->_useIcons) {
294 $title = $this->
_getTitleIcon($thread[$key][
'obj']->getVar(
'com_icon')).
' '.$thread[$key][
'obj']->getVar(
'com_title');
296 $title = $thread[$key][
'obj']->getVar(
'com_title');
298 $text = (
false !== $admin_view) ? $thread[$key][
'obj']->getVar(
'com_text')
299 .
'<div style="text-align:right; margin-top: 2px; margin-right: 2px;">'
300 ._CM_STATUS.
': '.$this->_statusText[$thread[$key][
'obj']->getVar(
'com_status')]
301 .
'<br>IP: <span style="font-weight: bold;">'
302 .$thread[$key][
'obj']->getVar(
'com_ip')
303 .
'</span></div>' : $thread[$key][
'obj']->getVar(
'com_text');
307 'pid' => $thread[$key][
'obj']->getVar(
'com_pid'),
308 'itemid' => $thread[$key][
'obj']->getVar(
'com_itemid'),
309 'rootid' => $thread[$key][
'obj']->getVar(
'com_rootid'),
312 'date_posted' => formatTimestamp($thread[$key][
'obj']->getVar(
'com_created'),
'm'),
313 'date_modified' => formatTimestamp($thread[$key][
'obj']->getVar(
'com_modified'),
'm'),
314 'poster' => $this->
_getPosterArray($thread[$key][
'obj']->getVar(
'com_uid'))
319 if (isset($thread[$key][
'child']) && !empty($thread[$key][
'child'])) {
321 foreach ($thread[$key][
'child'] as $childkey) {
322 if (!$admin_view && XOOPS_COMMENT_ACTIVE !== $thread[$childkey][
'obj']->getVar(
'com_status')) {
324 if (isset($thread[$childkey][
'child']) && !empty($thread[$childkey][
'child'])) {
325 foreach ($thread[$childkey][
'child'] as $childchildkey) {
326 $this->
_renderNestReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
330 $this->
_renderNestReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth);
371 $poster[
'id'] = (int)$poster_id;
372 if ($poster[
'id'] > 0) {
373 $com_poster =& $this->_memberHandler->getUser($poster[
'id']);
374 if (is_object($com_poster)) {
375 $poster[
'uname'] =
'<a href="'.XOOPS_URL.
'/userinfo.php?uid='.$poster[
'id'].
'">'.$com_poster->getVar(
'uname').
'</a>';
376 $poster_rank = $com_poster->rank();
377 $poster[
'rank_image'] = (
'' !== $poster_rank[
'image']) ? $poster_rank[
'image'] :
'blank.gif';
378 $poster[
'rank_title'] = $poster_rank[
'title'];
379 $poster[
'avatar'] = $com_poster->getVar(
'user_avatar');
380 $poster[
'regdate'] = formatTimestamp($com_poster->getVar(
'user_regdate'),
's');
381 $poster[
'from'] = $com_poster->getVar(
'user_from');
382 $poster[
'postnum'] = $com_poster->getVar(
'posts');
383 $poster[
'status'] = $com_poster->isOnline() ? _CM_ONLINE :
'';
388 $poster[
'uname'] = $GLOBALS[
'xoopsConfig'][
'anonymous'];
389 $poster[
'rank_title'] =
'';
390 $poster[
'avatar'] =
'blank.gif';
391 $poster[
'regdate'] =
'';
392 $poster[
'from'] =
'';
393 $poster[
'postnum'] = 0;
394 $poster[
'status'] =
'';