| 1 | <?php |
|---|
| 2 | // $Id: commentrenderer.php,v 1.3 2005/10/24 11:44:16 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | // Author: Kazumi Ono (AKA onokazu) // |
|---|
| 28 | // URL: http://www.xoops.org/ http://jp.xoops.org/ http://www.myweb.ne.jp/ // |
|---|
| 29 | // Project: The XOOPS Project (http://www.xoops.org/) // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | /** |
|---|
| 32 | * Display comments |
|---|
| 33 | * |
|---|
| 34 | * @package kernel |
|---|
| 35 | * @subpackage comment |
|---|
| 36 | * |
|---|
| 37 | * @author Kazumi Ono <[email protected]> |
|---|
| 38 | * @copyright (c) 2000-2003 The Xoops Project - www.xoops.org |
|---|
| 39 | */ |
|---|
| 40 | class XoopsCommentRenderer { |
|---|
| 41 | |
|---|
| 42 | /**#@+ |
|---|
| 43 | * @access private |
|---|
| 44 | */ |
|---|
| 45 | var $_tpl; |
|---|
| 46 | var $_comments = null; |
|---|
| 47 | var $_useIcons = true; |
|---|
| 48 | var $_doIconCheck = false; |
|---|
| 49 | var $_memberHandler; |
|---|
| 50 | var $_statusText; |
|---|
| 51 | /**#@-*/ |
|---|
| 52 | |
|---|
| 53 | /** |
|---|
| 54 | * Constructor |
|---|
| 55 | * |
|---|
| 56 | * @param object &$tpl |
|---|
| 57 | * @param boolean $use_icons |
|---|
| 58 | * @param boolean $do_iconcheck |
|---|
| 59 | **/ |
|---|
| 60 | function XoopsCommentRenderer(&$tpl, $use_icons = true, $do_iconcheck = false) |
|---|
| 61 | { |
|---|
| 62 | $this->_tpl =& $tpl; |
|---|
| 63 | $this->_useIcons = $use_icons; |
|---|
| 64 | $this->_doIconCheck = $do_iconcheck; |
|---|
| 65 | $this->_memberHandler =& xoops_gethandler('member'); |
|---|
| 66 | $this->_statusText = array(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>'); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * Access the only instance of this class |
|---|
| 71 | * |
|---|
| 72 | * @param object $tpl reference to a {@link Smarty} object |
|---|
| 73 | * @param boolean $use_icons |
|---|
| 74 | * @param boolean $do_iconcheck |
|---|
| 75 | * @return |
|---|
| 76 | **/ |
|---|
| 77 | function &instance(&$tpl, $use_icons = true, $do_iconcheck = false) |
|---|
| 78 | { |
|---|
| 79 | static $instance; |
|---|
| 80 | if (!isset($instance)) { |
|---|
| 81 | $instance = new XoopsCommentRenderer($tpl, $use_icons, $do_iconcheck); |
|---|
| 82 | } |
|---|
| 83 | return $instance; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | /** |
|---|
| 87 | * Accessor |
|---|
| 88 | * |
|---|
| 89 | * @param object &$comments_arr array of {@link XoopsComment} objects |
|---|
| 90 | **/ |
|---|
| 91 | function setComments(&$comments_arr) |
|---|
| 92 | { |
|---|
| 93 | if (isset($this->_comments)) { |
|---|
| 94 | unset($this->_comments); |
|---|
| 95 | } |
|---|
| 96 | $this->_comments =& $comments_arr; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | /** |
|---|
| 100 | * Render the comments in flat view |
|---|
| 101 | * |
|---|
| 102 | * @param boolean $admin_view |
|---|
| 103 | **/ |
|---|
| 104 | function renderFlatView($admin_view = false) |
|---|
| 105 | { |
|---|
| 106 | $count = count($this->_comments); |
|---|
| 107 | for ($i = 0; $i < $count; $i++) { |
|---|
| 108 | if (false != $this->_useIcons) { |
|---|
| 109 | $title = $this->_getTitleIcon($this->_comments[$i]->getVar('com_icon')).' '.$this->_comments[$i]->getVar('com_title'); |
|---|
| 110 | } else { |
|---|
| 111 | $title = $this->_comments[$i]->getVar('com_title'); |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | //Modified By viva(2005/12/13) ---> |
|---|
| 115 | //$poster = $this->_getPosterArray($this->_comments[$i]->getVar('com_uid')); |
|---|
| 116 | $poster = $this->_getPosterArray($this->_comments[$i]->getVar('com_uid'), $this->_comments[$i]->getVar('com_poster_name')); |
|---|
| 117 | //Modified By viva(2005/12/13) <--- |
|---|
| 118 | |
|---|
| 119 | if (false != $admin_view) { |
|---|
| 120 | $text = $this->_comments[$i]->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$this->_comments[$i]->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$this->_comments[$i]->getVar('com_ip').'</span></div>'; |
|---|
| 121 | } else { |
|---|
| 122 | // hide comments that are not active |
|---|
| 123 | if (XOOPS_COMMENT_ACTIVE != $this->_comments[$i]->getVar('com_status')) { |
|---|
| 124 | continue; |
|---|
| 125 | } else { |
|---|
| 126 | $text = $this->_comments[$i]->getVar('com_text'); |
|---|
| 127 | } |
|---|
| 128 | } |
|---|
| 129 | $this->_tpl->append('comments', array('id' => $this->_comments[$i]->getVar('com_id'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($this->_comments[$i]->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($this->_comments[$i]->getVar('com_modified'), 'm'), 'poster' => $poster)); |
|---|
| 130 | } |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | /** |
|---|
| 134 | * Render the comments in thread view |
|---|
| 135 | * |
|---|
| 136 | * This method calls itself recursively |
|---|
| 137 | * |
|---|
| 138 | * @param integer $comment_id Should be "0" when called by client |
|---|
| 139 | * @param boolean $admin_view |
|---|
| 140 | * @param boolean $show_nav |
|---|
| 141 | **/ |
|---|
| 142 | function renderThreadView($comment_id = 0, $admin_view = false, $show_nav = true) |
|---|
| 143 | { |
|---|
| 144 | include_once XOOPS_ROOT_PATH.'/class/tree.php'; |
|---|
| 145 | // construct comment tree |
|---|
| 146 | $xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid'); |
|---|
| 147 | $tree =& $xot->getTree(); |
|---|
| 148 | |
|---|
| 149 | if (false != $this->_useIcons) { |
|---|
| 150 | $title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).' '.$tree[$comment_id]['obj']->getVar('com_title'); |
|---|
| 151 | } else { |
|---|
| 152 | $title = $tree[$comment_id]['obj']->getVar('com_title'); |
|---|
| 153 | } |
|---|
| 154 | if (false != $show_nav && $tree[$comment_id]['obj']->getVar('com_pid') != 0) { |
|---|
| 155 | $this->_tpl->assign('lang_top', _CM_TOP); |
|---|
| 156 | $this->_tpl->assign('lang_parent', _CM_PARENT); |
|---|
| 157 | $this->_tpl->assign('show_threadnav', true); |
|---|
| 158 | } else { |
|---|
| 159 | $this->_tpl->assign('show_threadnav', false); |
|---|
| 160 | } |
|---|
| 161 | if (false != $admin_view) { |
|---|
| 162 | // admins can see all |
|---|
| 163 | $text = $tree[$comment_id]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$tree[$comment_id]['obj']->getVar('com_ip').'</span></div>'; |
|---|
| 164 | } else { |
|---|
| 165 | // hide comments that are not active |
|---|
| 166 | if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) { |
|---|
| 167 | // if there are any child comments, display them as root comments |
|---|
| 168 | if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) { |
|---|
| 169 | foreach ($tree[$comment_id]['child'] as $child_id) { |
|---|
| 170 | $this->renderThreadView($child_id, $admin_view, false); |
|---|
| 171 | } |
|---|
| 172 | } |
|---|
| 173 | return; |
|---|
| 174 | } else { |
|---|
| 175 | $text = $tree[$comment_id]['obj']->getVar('com_text'); |
|---|
| 176 | } |
|---|
| 177 | } |
|---|
| 178 | $replies = array(); |
|---|
| 179 | $this->_renderThreadReplies($tree, $comment_id, $replies, ' ', $admin_view); |
|---|
| 180 | $show_replies = (count($replies) > 0) ? true : false; |
|---|
| 181 | |
|---|
| 182 | //Modified By viva(2005/12/13) ---> |
|---|
| 183 | //$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies, 'show_replies' => $show_replies)); |
|---|
| 184 | $this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid'), $tree[$comment_id]['obj']->getVar('com_poster_name')), 'replies' => $replies, 'show_replies' => $show_replies)); |
|---|
| 185 | //Modified By viva(2005/12/13) <--- |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | /** |
|---|
| 189 | * Render replies to a thread |
|---|
| 190 | * |
|---|
| 191 | * @param array &$thread |
|---|
| 192 | * @param int $key |
|---|
| 193 | * @param array $replies |
|---|
| 194 | * @param string $prefix |
|---|
| 195 | * @param bool $admin_view |
|---|
| 196 | * @param integer $depth |
|---|
| 197 | * @param string $current_prefix |
|---|
| 198 | * |
|---|
| 199 | * @access private |
|---|
| 200 | **/ |
|---|
| 201 | function _renderThreadReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0, $current_prefix = '') |
|---|
| 202 | { |
|---|
| 203 | if ($depth > 0) { |
|---|
| 204 | if (false != $this->_useIcons) { |
|---|
| 205 | $title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).' '.$thread[$key]['obj']->getVar('com_title'); |
|---|
| 206 | } else { |
|---|
| 207 | $title = $thread[$key]['obj']->getVar('com_title'); |
|---|
| 208 | } |
|---|
| 209 | $title = (false != $admin_view) ? $title.' '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')] : $title; |
|---|
| 210 | |
|---|
| 211 | //Modified By viva(2005/12/13) ---> |
|---|
| 212 | //$replies[] = array('id' => $key, 'prefix' => $current_prefix, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'title' => $title, 'root_id' => $thread[$key]['obj']->getVar('com_rootid'), 'status' => $this->_statusText[$thread[$key]['obj']->getVar('com_status')], 'poster' => $this->_getPosterName($thread[$key]['obj']->getVar('com_uid'))); |
|---|
| 213 | $replies[] = array('id' => $key, 'prefix' => $current_prefix, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'title' => $title, 'root_id' => $thread[$key]['obj']->getVar('com_rootid'), 'status' => $this->_statusText[$thread[$key]['obj']->getVar('com_status')], 'poster' => $this->_getPosterName($thread[$key]['obj']->getVar('com_uid'), $thread[$key]['obj']->getVar('com_poster_name'))); |
|---|
| 214 | //Modified By viva(2005/12/13) <--- |
|---|
| 215 | |
|---|
| 216 | $current_prefix .= $prefix; |
|---|
| 217 | } |
|---|
| 218 | if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) { |
|---|
| 219 | $depth++; |
|---|
| 220 | foreach ($thread[$key]['child'] as $childkey) { |
|---|
| 221 | if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) { |
|---|
| 222 | // skip this comment if it is not active and continue on processing its child comments instead |
|---|
| 223 | if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) { |
|---|
| 224 | foreach ($thread[$childkey]['child'] as $childchildkey) { |
|---|
| 225 | $this->_renderThreadReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth); |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | } else { |
|---|
| 229 | $this->_renderThreadReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth, $current_prefix); |
|---|
| 230 | } |
|---|
| 231 | } |
|---|
| 232 | } |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | /** |
|---|
| 236 | * Render comments in nested view |
|---|
| 237 | * |
|---|
| 238 | * Danger: Recursive! |
|---|
| 239 | * |
|---|
| 240 | * @param integer $comment_id Always "0" when called by client. |
|---|
| 241 | * @param boolean $admin_view |
|---|
| 242 | **/ |
|---|
| 243 | function renderNestView($comment_id = 0, $admin_view = false) |
|---|
| 244 | { |
|---|
| 245 | include_once XOOPS_ROOT_PATH.'/class/tree.php'; |
|---|
| 246 | $xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid'); |
|---|
| 247 | $tree =& $xot->getTree(); |
|---|
| 248 | if (false != $this->_useIcons) { |
|---|
| 249 | $title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).' '.$tree[$comment_id]['obj']->getVar('com_title'); |
|---|
| 250 | } else { |
|---|
| 251 | $title = $tree[$comment_id]['obj']->getVar('com_title'); |
|---|
| 252 | } |
|---|
| 253 | if (false != $admin_view) { |
|---|
| 254 | $text = $tree[$comment_id]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$tree[$comment_id]['obj']->getVar('com_ip').'</span></div>'; |
|---|
| 255 | } else { |
|---|
| 256 | // skip this comment if it is not active and continue on processing its child comments instead |
|---|
| 257 | if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) { |
|---|
| 258 | // if there are any child comments, display them as root comments |
|---|
| 259 | if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) { |
|---|
| 260 | foreach ($tree[$comment_id]['child'] as $child_id) { |
|---|
| 261 | $this->renderNestView($child_id, $admin_view); |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | return; |
|---|
| 265 | } else { |
|---|
| 266 | $text = $tree[$comment_id]['obj']->getVar('com_text'); |
|---|
| 267 | } |
|---|
| 268 | } |
|---|
| 269 | $replies = array(); |
|---|
| 270 | $this->_renderNestReplies($tree, $comment_id, $replies, 25, $admin_view); |
|---|
| 271 | |
|---|
| 272 | //Modified By viva(2005/12/13) ---> |
|---|
| 273 | //$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies)); |
|---|
| 274 | $this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid'), $tree[$comment_id]['obj']->getVar('com_poster_name')), 'replies' => $replies)); |
|---|
| 275 | //Modified By viva(2005/12/13) <--- |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | /** |
|---|
| 279 | * Render replies in nested view |
|---|
| 280 | * |
|---|
| 281 | * @param array $thread |
|---|
| 282 | * @param int $key |
|---|
| 283 | * @param array $replies |
|---|
| 284 | * @param string $prefix |
|---|
| 285 | * @param bool $admin_view |
|---|
| 286 | * @param integer $depth |
|---|
| 287 | * |
|---|
| 288 | * @access private |
|---|
| 289 | **/ |
|---|
| 290 | function _renderNestReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0) |
|---|
| 291 | { |
|---|
| 292 | if ($depth > 0) { |
|---|
| 293 | if (false != $this->_useIcons) { |
|---|
| 294 | $title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).' '.$thread[$key]['obj']->getVar('com_title'); |
|---|
| 295 | } else { |
|---|
| 296 | $title = $thread[$key]['obj']->getVar('com_title'); |
|---|
| 297 | } |
|---|
| 298 | $text = (false != $admin_view) ? $thread[$key]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$thread[$key]['obj']->getVar('com_ip').'</span></div>' : $thread[$key]['obj']->getVar('com_text'); |
|---|
| 299 | |
|---|
| 300 | //Modified By viva(2005/12/13) ---> |
|---|
| 301 | //$replies[] = array('id' => $key, 'prefix' => $prefix, 'pid' => $thread[$key]['obj']->getVar('com_pid'), 'itemid' => $thread[$key]['obj']->getVar('com_itemid'), 'rootid' => $thread[$key]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($thread[$key]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($thread[$key]['obj']->getVar('com_uid'))); |
|---|
| 302 | $replies[] = array('id' => $key, 'prefix' => $prefix, 'pid' => $thread[$key]['obj']->getVar('com_pid'), 'itemid' => $thread[$key]['obj']->getVar('com_itemid'), 'rootid' => $thread[$key]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($thread[$key]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($thread[$key]['obj']->getVar('com_uid'), $thread[$key]['obj']->getVar('com_poster_name'))); |
|---|
| 303 | //Modified By viva(2005/12/13) <--- |
|---|
| 304 | |
|---|
| 305 | $prefix = $prefix + 25; |
|---|
| 306 | } |
|---|
| 307 | if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) { |
|---|
| 308 | $depth++; |
|---|
| 309 | foreach ($thread[$key]['child'] as $childkey) { |
|---|
| 310 | if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) { |
|---|
| 311 | // skip this comment if it is not active and continue on processing its child comments instead |
|---|
| 312 | if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) { |
|---|
| 313 | foreach ($thread[$childkey]['child'] as $childchildkey) { |
|---|
| 314 | $this->_renderNestReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth); |
|---|
| 315 | } |
|---|
| 316 | } |
|---|
| 317 | } else { |
|---|
| 318 | $this->_renderNestReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth); |
|---|
| 319 | } |
|---|
| 320 | } |
|---|
| 321 | } |
|---|
| 322 | } |
|---|
| 323 | |
|---|
| 324 | |
|---|
| 325 | /** |
|---|
| 326 | * Get the name of the poster |
|---|
| 327 | * |
|---|
| 328 | * @param int $poster_id |
|---|
| 329 | * @return string |
|---|
| 330 | * |
|---|
| 331 | * @access private |
|---|
| 332 | **/ |
|---|
| 333 | //Modified By viva(2005/12/13) ---> |
|---|
| 334 | //function _getPosterName($poster_id) |
|---|
| 335 | function _getPosterName($poster_id, $poster_name) |
|---|
| 336 | //Modified By viva(2005/12/13) <--- |
|---|
| 337 | { |
|---|
| 338 | $poster['id'] = intval($poster_id); |
|---|
| 339 | if ($poster['id'] > 0) { |
|---|
| 340 | $com_poster =& $this->_memberHandler->getUser($poster_id); |
|---|
| 341 | if (is_object($com_poster)) { |
|---|
| 342 | $poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>'; |
|---|
| 343 | return $poster; |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | $poster['id'] = 0; // to cope with deleted user accounts |
|---|
| 347 | |
|---|
| 348 | //Modified By viva(2005/12/13) ---> |
|---|
| 349 | //$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous']; |
|---|
| 350 | $poster['uname'] = $poster_name; |
|---|
| 351 | //Modified By viva(2005/12/13) <--- |
|---|
| 352 | |
|---|
| 353 | return $poster; |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | /** |
|---|
| 357 | * Get an array with info about the poster |
|---|
| 358 | * |
|---|
| 359 | * @param int $poster_id |
|---|
| 360 | * @return array |
|---|
| 361 | * |
|---|
| 362 | * @access private |
|---|
| 363 | **/ |
|---|
| 364 | //Modified By viva(2005/12/13) ---> |
|---|
| 365 | //function _getPosterArray($poster_id) |
|---|
| 366 | function _getPosterArray($poster_id, $poster_name) |
|---|
| 367 | //Modified By viva(2005/12/13) <--- |
|---|
| 368 | { |
|---|
| 369 | $poster['id'] = intval($poster_id); |
|---|
| 370 | if ($poster['id'] > 0) { |
|---|
| 371 | $com_poster =& $this->_memberHandler->getUser($poster['id']); |
|---|
| 372 | if (is_object($com_poster)) { |
|---|
| 373 | $poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>'; |
|---|
| 374 | $poster_rank = $com_poster->rank(); |
|---|
| 375 | $poster['rank_image'] = ($poster_rank['image'] != '') ? $poster_rank['image'] : 'blank.gif'; |
|---|
| 376 | $poster['rank_title'] = $poster_rank['title']; |
|---|
| 377 | $poster['avatar'] = $com_poster->getVar('user_avatar'); |
|---|
| 378 | $poster['regdate'] = formatTimestamp($com_poster->getVar('user_regdate'), 's'); |
|---|
| 379 | $poster['from'] = $com_poster->getVar('user_from'); |
|---|
| 380 | $poster['postnum'] = $com_poster->getVar('posts'); |
|---|
| 381 | $poster['status'] = $com_poster->isOnline() ? _CM_ONLINE : ''; |
|---|
| 382 | return $poster; |
|---|
| 383 | } |
|---|
| 384 | } |
|---|
| 385 | $poster['id'] = 0; // to cope with deleted user accounts |
|---|
| 386 | |
|---|
| 387 | //Modified By viva(2005/12/13) ---> |
|---|
| 388 | //$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous']; |
|---|
| 389 | $poster['uname'] = $poster_name; |
|---|
| 390 | //Modified By viva(2005/12/13) <--- |
|---|
| 391 | |
|---|
| 392 | $poster['rank_title'] = ''; |
|---|
| 393 | $poster['avatar'] = 'blank.gif'; |
|---|
| 394 | $poster['regdate'] = ''; |
|---|
| 395 | $poster['from'] = ''; |
|---|
| 396 | $poster['postnum'] = 0; |
|---|
| 397 | $poster['status'] = ''; |
|---|
| 398 | return $poster; |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | /** |
|---|
| 402 | * Get the IMG tag for the title icon |
|---|
| 403 | * |
|---|
| 404 | * @param string $icon_image |
|---|
| 405 | * @return string HTML IMG tag |
|---|
| 406 | * |
|---|
| 407 | * @access private |
|---|
| 408 | **/ |
|---|
| 409 | function _getTitleIcon($icon_image) |
|---|
| 410 | { |
|---|
| 411 | $icon_image = trim($icon_image); |
|---|
| 412 | if ($icon_image != '') { |
|---|
| 413 | $icon_image = htmlspecialchars($icon_image); |
|---|
| 414 | if (false != $this->_doIconCheck) { |
|---|
| 415 | if (!file_exists(XOOPS_URL.'/images/subject/'.$icon_image)) { |
|---|
| 416 | return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />'; |
|---|
| 417 | } else { |
|---|
| 418 | return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />'; |
|---|
| 419 | } |
|---|
| 420 | } else { |
|---|
| 421 | return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />'; |
|---|
| 422 | } |
|---|
| 423 | } |
|---|
| 424 | return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />'; |
|---|
| 425 | } |
|---|
| 426 | } |
|---|
| 427 | ?> |
|---|