/** * Shows the comments screen */ function _showComments() { global $mainframe, $mainframe, $rsgConfig; if ($rsgConfig->get('comment')) { $gallery = rsgGalleryManager::get(); $item = $gallery->getItem(); $id = $item->id; $css = "<link rel=\"stylesheet\" href=\"" . JURI_SITE . "/components/com_rsgallery2/lib/rsgcomments/rsgcomments.css\" type=\"text/css\" />"; $mainframe->addCustomHeadTag($css); $comment = new rsgComments(); $comment->showComments($id); $comment->editComment($id); } else { echo JText::_('Commenting is disabled'); } }
function showComments($item_id) { global $database; // Get the current JUser object $user =& JFactory::getUser(); $deleteComment = false; // user is admin or super admin and can delete the comment if ($user->get('gid') > 22) { $deleteComment = true; ?> <script type="text/javascript"> //<![CDATA[ function delComment(id, item_id, catid) { var delCom = confirm('<?php echo JText::_("Delete Comment"); ?> ' + id ); if (delCom) { window.location = '<?php echo JRoute::_("index.php?option=com_rsgallery2&rsgOption=rsgComments&task=delete", false); ?> &id='+id+'&item_id='+item_id+'&catid='+catid; } } //]]> </script> <?php } $comments = rsgComments::_getList($item_id); if (count($comments) > 0) { ?> <div id="comment"> <table width="100%" class="comment_table"> <tr> <td class="title" width="25%"><?php echo JText::_('Comments'); ?> </td> <td class="title" width="50%"><?php echo JText::_('comments added'); ?> </td> <td class="title"><div class="addcomment"><a class="special" href="#comment2"><?php echo JText::_('Add Comment'); ?> </a></div></td> </tr> </table> <br /> </div> <?php foreach ($comments as $comment) { $catid = galleryUtils::getCatIdFromFileId($comment['item_id']); ?> <div id="comment"> <table width="100%" class="comment_table"> <tr> <td colspan="2" class="title"><span class='posttitle'><?php echo $comment['subject']; ?> </span></td> </tr> <tr> <td valign="top" width="100"><span class="postusername"><?php echo $comment['user_name']; ?> </span></td></td> <td valign="top" class="content_area"> <?php echo JHTML::_("date", $comment['datetime']); ?> <hr /> <?php echo rsgComments::parse($comment['comment']); ?> <?php if ($deleteComment) { ?> <div style="float:right;"><a href="javascript:void(0);" onclick="javascript:delComment(<?php echo $comment['id']; ?> , <?php echo $comment['item_id']; ?> , <?php echo $catid; ?> );"><?php echo JText::_('Delete Comment'); ?> </a></div> <?php } ?> </td> </tr> </table> <br /> </div> <?php } } else { ?> <div id="comment"> <table width="100%" class="comment_table"> <tr> <td class="title"><span class='posttitle'><?php echo JText::_('No comments yet!'); ?> </span></td> </tr> </table> </div> <?php } }