Example #1
0
function output_comment($comment_id, $level, $db)
{
    // Получение из базы комментариев как от авторизованных, так и не авторизованных пользователей
    $comres = mysql_query($s = sprintf('(select file_id,comment_text, email from comments,users where comment_id=%d and users.user_id=comments.user_id) union (select file_id,comment_text, concat(user_name," (гость)") as email from comments,users where comment_id=%d)', $comment_id, $comment_id), $db);
    $comrow = mysql_fetch_assoc($comres);
    echo '<p style="padding-left:' . $level * 50 . 'px; border:1">';
    echo 'Автор: ' . htmlspecialchars(stripslashes($comrow['email'])) . '<br>';
    echo htmlspecialchars(stripslashes($comrow['comment_text'])) . '<br>';
    echo '<a href="comments.php?file_id=' . intval($comrow['file_id']) . '&repl_id=' . $comment_id . '">Ответить на комментарий</a>';
    echo '</p>';
    mysql_free_result($comres);
    // Получение из базы комментариев более низкого уровня (по дереву) относительно только что выведенного
    $comres = mysql_query($s = sprintf('select comment_id from comments where repl_id=%d', $comment_id), $db);
    if (mysql_num_rows($comres)) {
        while ($comrow = mysql_fetch_assoc($comres)) {
            output_comment($comrow['comment_id'], $level + 1, $db);
        }
    }
    mysql_free_result($comres);
}
Example #2
0
 protected function output_widget_content($instance)
 {
     $disqus_params = array('api_key' => $instance['api_key'], 'forum' => $instance['forum_name'], 'limit' => $instance['request_comment_limit'], 'related' => 'thread', 'include' => 'approved');
     $comments = get_last_comments($disqus_params, $instance['comments_per_thread'], $instance['comment_limit'], $instance['comment_length'], $instance['cache_timeout'], $this->number);
     foreach ($comments as $comment) {
         output_comment($comment);
     }
 }
Example #3
0
	function output_comment($comment,$number) {
		global $url; global $sets;

		$where = array('main' => 'оставлен на главной','workshop' => 'оставлен в мастерской', 'flea_market' => 'оставлен в барахолке');
		if (!$comment['area']) $comment['area'] = 'main';
		?>
			<div class="comment" id="comment-<?php 
echo $comment['id'];
?>
"<?php 
echo $comment['position'] ? ' style="padding-left: ' . $comment['position'] * 50 . 'px;"' : '';
?>
>
				<div class="comment-top">
					<b><?php 
echo $number;
?>
) <?php 
echo $comment['username'];
?>
</b>
					<span class="datetime">
						 <?php 
echo $comment['pretty_date'] . ($url[1] != 'news' && $url[1] != 'order' && $comment['area'] != $url['area'] && array_key_exists($comment['area'], $where) ? ' (' . $where[$comment['area']] . ')' : '');
?>
					</span>
					<span class="commentmetadata"><a href="#comment-<?php 
echo $comment['id'];
?>
" title="">#</a></span>
					<? if ($sets['user']['rights'] || $comment['cookie'] == query::$cookie || !empty($comment['edit_date'])) { ?>					
						<div class="right">
							<? if (!empty($comment['edit_date'])) { ?>
								<span class="datetime">
									Дата редактирования: <?php 
echo $comment['edit_date'];
?>
								</span>
							<? } ?>
							<? if ($sets['user']['rights'] || $comment['cookie'] == query::$cookie) { ?>
								<?php 
echo $sets['user']['rights'] == 2 ? substr($comment['cookie'], 0, 6) . '&nbsp;' . $comment['ip'] . '&nbsp;' : '';
?>
								<img src="<?php 
echo $def['site']['dir'];
?>
/images/comment_edit.png" alt="редактировать" rel="<?php 
echo $comment['id'];
?>
" class="edit_comment">
								<? if ($sets['user']['rights']) { ?>
									&nbsp;&nbsp;&nbsp;
									<img src="<?php 
echo $def['site']['dir'];
?>
/images/comment_delete.png" alt="удалить" rel="<?php 
echo $comment['id'];
?>
" class="delete_comment">
								<? } ?>
							<? } ?>
						</div>
					<? } ?>
				</div>
				<div class="comment-content">
					<div class="avatar-n">
						<img alt='' src='http://www.gravatar.com/avatar/<?php 
echo md5(strtolower($comment['email']));
?>
?s=50&d=identicon&r=G' class='avatar avatar-50 photo' height='50' width='50' />
					</div>
					<div class="comment-text">
					<span><?php 
echo $comment['text'];
?>
</span>
					<?
						if ($comment['position'] < 5) {
							?>
								<br /><br />
								<a href="#" rel="<?php 
echo $comment['id'];
?>
" class="disabled reply">Ответить</a>
								<div id="reply-<?php 
echo $comment['id'];
?>
"></div>
							<?
						}
					?>
					<div class="edit-<?php 
echo $comment['id'];
?>
"></div>					
					<div class="c-wrap"></div>
					</div>
				</div>
				<br />
			</div>
		<?
		if (is_array($comment['children'])) {
			if ($sets['dir']['comments_tree']) {		
				$num = count($comment['children']);
				foreach ($comment['children'] as $child) {
					output_comment($child,$number.'.'.$num--);
				}
			}
			else {
				$num = 0;
				foreach ($comment['children'] as $child) output_comment($child,$number.'.'.++$num);
			}
		}
	}