function getCommentView($entry, $skin, $inputBlock = true, $page = 1, $count = null, $listBlock = true) { global $contentContainer; static $dressCommentBlock = false; $context = Model_Context::getInstance(); if (is_null($count)) { if ($context->getProperty('skin.commentsOnEntry')) { $count = $context->getProperty('skin.commentsOnEntry'); } else { $count = 15; } } if (!isset($entry)) { $entry['id'] = 0; } $blogid = getBlogId(); importlib("model.common.setting"); importlib("model.blog.entry"); importlib("model.blog.comment"); importlib('blogskin'); $authorized = doesHaveOwnership(); $useAjaxBlock = $context->getProperty('blog.useAjaxComment', true); $useMicroformat = $context->getProperty('blog.useMicroformat', 3); $fn = ''; $fn_nickname = ''; if ($useMicroformat > 1) { $fn = 'class="fn url nickname" '; $fn_nickname = 'class="fn nickname" '; } if ($entry['id'] > 0) { $prefix1 = 'rp'; $isComment = true; } else { $prefix1 = 'guest'; $isComment = false; } $commentView = $isComment ? $skin->comment : $skin->guest; $commentItemsView = ''; if ($listBlock === true) { if ($isComment == false) { global $comments; if (!isset($comments)) { list($comments, $paging) = getCommentsWithPagingForGuestbook($blogid, $context->getProperty('suri.page'), $context->getProperty('skin.commentsOnGuestbook')); } foreach ($comments as $key => $value) { if ($value['secret'] == 1) { if (!$authorized) { if (!doesHaveOpenIDPriv($value)) { $comments[$key]['name'] = _text('비밀방문자'); $comments[$key]['homepage'] = ''; $comments[$key]['comment'] = _text('관리자만 볼 수 있는 방명록입니다.'); } else { $comments[$key]['name'] = _text('비밀방문자') . ' ' . $comments[$key]['name']; } } } } } else { if ($useAjaxBlock) { list($comments, $paging) = getCommentsWithPagingByEntryId($blogid, $entry['id'], $page, $count, 'loadComment', '(' . $entry['id'] . ',', ',true,true);return false;', null, $context->getProperty('skin.sortCommentsBy', 'ASC')); } else { $comments = getComments($entry['id'], $context->getProperty('skin.sortCommentsBy', 'ASC')); } } if (empty($skin->dressCommentBlock)) { if ($dressCommentBlock) { if ($isComment) { $skin->commentGuest = $dressCommentBlock; } else { $skin->guestGuest = $dressCommentBlock; } } else { if ($isComment) { $dressCommentBlock = $skin->commentGuest = addOpenIDPannel($skin->commentGuest, 'rp'); } else { $dressCommentBlock = $skin->guestGuest = addOpenIDPannel($skin->guestGuest, 'guest'); } } $skin->dressCommentBlock = true; } /// Dressing comments foreach ($comments as $commentItem) { $commentItemView = $isComment ? $skin->commentItem : $skin->guestItem; $commentSubItemsView = ''; $subComments = getCommentComments($commentItem['id'], $commentItem); foreach ($subComments as $commentSubItem) { $commentSubItemView = $isComment ? $skin->commentSubItem : $skin->guestSubItem; $commentSubItem['name'] = htmlspecialchars($commentSubItem['name']); $commentSubItem['comment'] = htmlspecialchars($commentSubItem['comment']); $rp_class = $prefix1 . '_general'; if ($blogid == $commentSubItem['replier']) { $rp_class = $prefix1 . '_admin'; } else { if ($commentSubItem['secret'] == 1) { $rp_class = $prefix1 . '_secret'; if ($authorized) { $commentSubItem['comment'] = '<span class="hiddenCommentTag_content">' . _text('[비밀댓글]') . '</span> ' . $commentSubItem['comment']; } else { $rp_class .= ' hiddenComment'; $commentSubItem['name'] = '<span class="hiddenCommentTag_name">' . _text('비밀방문자') . '</span>' . (doesHaveOpenIDPriv($commentSubItem) ? ' ' . $commentSubItem['name'] : ''); } } } dress($prefix1 . '_rep_class', $rp_class, $commentSubItemView); if (dress($prefix1 . '_rep_id', ($entry['id'] == 0 ? 'guestbook' : 'comment') . $commentSubItem['id'], $commentSubItemView) == false) { $commentSubItemView = "<a id=\"comment{$commentSubItem['id']}\"></a>" . $commentSubItemView; } if (empty($commentSubItem['homepage']) || $commentSubItem['secret'] == 1 && !doesHaveOwnership()) { dress($prefix1 . '_rep_name', fireEvent($isComment ? 'ViewCommenter' : 'ViewGuestCommenter', "<span {$fn_nickname}>" . $commentSubItem['name'] . "</span>", $commentSubItem), $commentSubItemView); } else { dress($prefix1 . '_rep_name', fireEvent($isComment ? 'ViewCommenter' : 'ViewGuestCommenter', '<a ' . $fn . 'rel="external nofollow" href="' . htmlspecialchars(addProtocolSense($commentSubItem['homepage'])) . '" onclick="return openLinkInNewWindow(this)">' . $commentSubItem['name'] . '</a>', $commentSubItem), $commentSubItemView); } $contentContainer["{$prefix1}_{$commentSubItem['id']}"] = fireEvent($isComment ? 'ViewCommentContent' : 'ViewGuestCommentContent', nl2br(addLinkSense($commentSubItem['comment'], ' onclick="return openLinkInNewWindow(this)"')), $commentSubItem); dress($prefix1 . '_rep_desc', setTempTag("{$prefix1}_{$commentSubItem['id']}"), $commentSubItemView); dress($prefix1 . '_rep_date', fireEvent($isComment ? 'ViewCommentDate' : 'ViewGuestCommentDate', Timestamp::format5($commentSubItem['written']), $commentSubItem['written']), $commentSubItemView); dress($prefix1 . '_rep_link', $context->getProperty('uri.blog') . "/" . ($entry['id'] == 0 ? "guestbook/{$commentItem['id']}#guestbook{$commentSubItem['id']}" : ($context->getProperty('blog.useSloganOnPost') ? "entry/" . URL::encode($entry['slogan'], $context->getProperty('service.useEncodedURL')) : $entry['id']) . "#comment{$commentSubItem['id']}"), $commentSubItemView); dress($prefix1 . '_rep_onclick_delete', "deleteComment({$commentSubItem['id']}); return false;", $commentSubItemView); $commentSubItemsView .= $commentSubItemView; } $commentSubContainer = $isComment ? $skin->commentSubContainer : $skin->guestSubContainer; dress($isComment ? 'rp2_rep' : 'guest_reply_rep', $commentSubItemsView, $commentSubContainer); if (count($subComments) > 0) { dress($isComment ? 'rp2_container' : 'guest_reply_container', $commentSubContainer, $commentItemView); } $commentItem['name'] = htmlspecialchars($commentItem['name']); $commentItem['comment'] = htmlspecialchars($commentItem['comment']); $rp_class = $prefix1 . '_general'; if ($blogid == $commentItem['replier']) { $rp_class = $prefix1 . '_admin'; } else { if ($commentItem['secret'] == 1) { $rp_class = $prefix1 . '_secret'; if ($authorized) { $commentItem['comment'] = '<span class="hiddenCommentTag_content">' . _text('[비밀댓글]') . '</span> ' . $commentItem['comment']; } else { $rp_class .= ' hiddenComment'; $commentItem['name'] = '<span class="hiddenCommentTag_name">' . _text('비밀방문자') . '</span>' . (doesHaveOpenIDPriv($commentItem) ? ' ' . $commentItem['name'] : ''); } } } dress($prefix1 . '_rep_class', $rp_class, $commentItemView); if (dress($prefix1 . '_rep_id', ($entry['id'] == 0 ? 'guestbook' : 'comment') . $commentItem['id'], $commentItemView) == false) { $commentItemView = "<a id=\"comment{$commentItem['id']}\"></a>" . $commentItemView; } if (empty($commentItem['homepage']) || $commentItem['secret'] == 1 && !doesHaveOwnership()) { dress($prefix1 . '_rep_name', fireEvent($isComment ? 'ViewCommenter' : 'ViewGuestCommenter', "<span {$fn_nickname}>" . $commentItem['name'] . "</span>", $commentItem), $commentItemView); } else { dress($prefix1 . '_rep_name', fireEvent($isComment ? 'ViewCommenter' : 'ViewGuestCommenter', '<a ' . $fn . 'rel="external nofollow" href="' . htmlspecialchars(addProtocolSense($commentItem['homepage'])) . '" onclick="return openLinkInNewWindow(this)">' . $commentItem['name'] . '</a>', $commentItem), $commentItemView); } $contentContainer["{$prefix1}_{$commentItem['id']}"] = fireEvent($isComment ? 'ViewCommentContent' : 'ViewGuestCommentContent', nl2br(addLinkSense($commentItem['comment'], ' onclick="return openLinkInNewWindow(this)"')), $commentItem); dress($prefix1 . '_rep_desc', setTempTag("{$prefix1}_{$commentItem['id']}"), $commentItemView); dress($prefix1 . '_rep_date', fireEvent($isComment ? 'ViewCommentDate' : 'ViewGuestCommentDate', Timestamp::format5($commentItem['written']), $commentItem['written']), $commentItemView); if (!$context->getProperty('blog.acceptComments', true) || $prefix1 == 'guest' && $authorized != true && $context->getProperty('blog.allowWriteDblCommentOnGuestbook') == 0) { $doubleCommentPermissionScript = 'alert(\'' . _text('댓글을 사용할 수 없습니다.') . '\'); return false;'; } else { $doubleCommentPermissionScript = ''; } dress($prefix1 . '_rep_onclick_reply', $doubleCommentPermissionScript . "commentComment({$commentItem['id']}); return false", $commentItemView); dress($prefix1 . '_rep_onclick_delete', "deleteComment({$commentItem['id']});return false", $commentItemView); dress($prefix1 . '_rep_link', $context->getProperty('uri.blog') . "/" . ($entry['id'] == 0 ? "guestbook/{$commentItem['id']}#guestbook{$commentItem['id']}" : ($context->getProperty('blog.useSloganOnPost') ? "entry/" . URL::encode($entry['slogan'], $context->getProperty('service.useEncodedURL')) : $entry['id']) . "?commentId=" . $commentItem['id'] . "#comment{$commentItem['id']}"), $commentItemView); $commentItemsView .= $commentItemView; } /// Merging comments with its paging links. $commentContainer = $isComment ? $skin->commentContainer : $skin->guestContainer; dress($isComment ? 'rp_rep' : 'guest_rep', $commentItemsView, $commentContainer); if (count($comments) > 0) { if ($isComment && $useAjaxBlock) { $pagingView = Paging::getPagingView($paging, $skin->paging, $skin->pagingItem, false, 'onclick'); } else { $pagingView = ''; } dress($prefix1 . '_container', "<div id=\"entry" . $entry['id'] . "CommentList\">" . $commentContainer . $pagingView . "</div>", $commentView); } } else { dress($prefix1 . '_container', '', $commentView); } /// Comment write block if ($inputBlock == true) { if (!empty($entry['acceptcomment'])) { $acceptcomment = $entry['acceptcomment']; } else { $pool = DBModel::getInstance(); $pool->reset('Entries'); $pool->setQualifier('blogid', 'equals', $blogid); $pool->setQualifier('id', 'equals', $entry['id']); $pool->setQualifier('draft', 'equals', 0); $acceptcomment = $pool->getCell('acceptcomment'); } $useForm = false; $openid_identity = Acl::getIdentity('openid'); if ($isComment) { if (!($skin->commentForm == '')) { $commentRrevView = $commentView; /// Comment Lists. $commentView = $skin->commentForm; /// Comment write block. $useForm = true; } } else { if (!($skin->guestForm == '')) { $commentRrevView = $commentView; $commentView = $skin->guestForm; $useForm = true; } } $default_guestname = ''; $default_homepage = ''; if (doesHaveOwnership() || $isComment && $acceptcomment == 1 && Setting::getBlogSettingGlobal('acceptComments', 1) || $isComment == false || $useForm == false) { $commentMemberView = $isComment ? $skin->commentMember : $skin->guestMember; if (!doesHaveMembership()) { $commentGuestView = $isComment ? $skin->commentGuest : $skin->guestGuest; dress($prefix1 . '_input_name', 'name', $commentGuestView); dress($prefix1 . '_input_password', 'password', $commentGuestView); dress($prefix1 . '_input_homepage', 'homepage', $commentGuestView); if (!empty($_POST["name_{$entry['id']}"])) { $guestName = htmlspecialchars($_POST["name_{$entry['id']}"]); } else { if (!empty($_SESSION['openid']['nickname'])) { $guestName = htmlspecialchars($_SESSION['openid']['nickname']); } else { if (!empty($_COOKIE[$context->getProperty('service.cookie_prefix') . 'guestName'])) { $guestName = htmlspecialchars($_COOKIE[$context->getProperty('service.cookie_prefix') . 'guestName']); } else { $guestName = ''; } } } dress('guest_name', $guestName, $commentGuestView); if (!empty($_POST["homepage_{$entry['id']}"]) && $_POST["homepage_{$entry['id']}"] != 'http://') { if (strpos($_POST["homepage_{$entry['id']}"], 'http://') === 0) { $guestHomepage = htmlspecialchars($_POST["homepage_{$entry['id']}"]); } else { $guestHomepage = 'http://' . htmlspecialchars($_POST["homepage_{$entry['id']}"]); } } else { if (!empty($_SESSION['openid']['homepage'])) { $guestHomepage = htmlspecialchars($_SESSION['openid']['homepage']); } else { if (!empty($_COOKIE[$context->getProperty('service.cookie_prefix') . 'guestHomepage'])) { $guestHomepage = htmlspecialchars($_COOKIE[$context->getProperty('service.cookie_prefix') . 'guestHomepage']); } else { $guestHomepage = 'http://'; } } } dress('guest_homepage', $guestHomepage, $commentGuestView); dress($prefix1 . ($isComment ? '_guest' : '_form'), $commentGuestView, $commentMemberView); } dress($prefix1 . '_input_is_secret', 'secret', $commentMemberView); dress($prefix1 . '_member', $commentMemberView, $commentView); dress($prefix1 . '_input_comment', 'comment', $commentView); dress($prefix1 . '_onclick_submit', "addComment(this, {$entry['id']}); return false;", $commentView); dress($prefix1 . '_textarea_body', 'comment', $commentView); dress($prefix1 . '_textarea_body_value', '', $commentView); } else { if ($useForm == true) { $commentView = ''; } } if ($useForm == true) { dress($prefix1 . '_input_form', "<form id=\"entry" . $entry['id'] . "WriteComment\" method=\"post\" action=\"" . $context->getProperty('uri.blog') . "/comment/add/{$entry['id']}\" onsubmit=\"return false\" style=\"margin: 0\">" . $commentView . '</form>', $commentRrevView); $commentView = $commentRrevView; } else { $commentView = "<form id=\"entry" . $entry['id'] . "WriteComment\" method=\"post\" action=\"" . $context->getProperty('uri.blog') . "/comment/add/{$entry['id']}\" onsubmit=\"return false\" style=\"margin: 0\">" . $commentView . '</form>'; } } else { dress($prefix1 . '_input_form', "", $commentView); } /// Adding feed links. dress('article_rep_rp_atomurl', $context->getProperty('uri.default') . '/atom/comment/' . $entry['id'], $commentView); dress('article_rep_rp_rssurl', $context->getProperty('uri.default') . '/rss/comment/' . $entry['id'], $commentView); return $commentView; }
function getRecentGuestbook($blogid, $count = false) { $context = Model_Context::getInstance(); $comments = array(); $pool = DBModel::getInstance(); $pool->init("Comments"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("entry", "eq", 0); $pool->setQualifier("isfiltered", "eq", 0); $pool->setOrder("written", "desc"); $pool->setLimit($count != false ? $count : $context->getProperty('skin.commentsOnRecent')); if ($result = $pool->getAll()) { foreach ($result as $comment) { if ($comment['secret'] == 1 && !doesHaveOwnership()) { if (!doesHaveOpenIDPriv($comment)) { $comment['name'] = ''; $comment['homepage'] = ''; $comment['comment'] = _text('관리자만 볼 수 있는 댓글입니다.'); } } array_push($comments, $comment); } } return $comments; }
function getRecentGuestbook($blogid, $count = false) { global $skinSetting, $database; $comments = array(); $sql = "SELECT r.*\n\t\tFROM\n\t\t\t{$database['prefix']}Comments r\n\t\tWHERE\n\t\t\tr.blogid = {$blogid} AND r.entry = 0 AND r.isfiltered = 0\n\t\tORDER BY\n\t\t\tr.written\n\t\tDESC LIMIT " . ($count != false ? $count : $skinSetting['commentsOnRecent']); if ($result = POD::queryAll($sql)) { foreach ($result as $comment) { if ($comment['secret'] == 1 && !doesHaveOwnership()) { if (!doesHaveOpenIDPriv($comment)) { $comment['name'] = ''; $comment['homepage'] = ''; $comment['comment'] = _text('관리자만 볼 수 있는 댓글입니다.'); } } array_push($comments, $comment); } } return $comments; }
function getRecentGuestbook($blogid, $count = false) { $ctx = Model_Context::getInstance(); $comments = array(); $sql = "SELECT r.*\n\t\tFROM\n\t\t\t" . $ctx->getProperty('database.prefix') . "Comments r\n\t\tWHERE\n\t\t\tr.blogid = {$blogid} AND r.entry = 0 AND r.isfiltered = 0\n\t\tORDER BY\n\t\t\tr.written\n\t\tDESC LIMIT " . ($count != false ? $count : $ctx->getProperty('skin.commentsOnRecent')); if ($result = POD::queryAll($sql)) { foreach ($result as $comment) { if ($comment['secret'] == 1 && !doesHaveOwnership()) { if (!doesHaveOpenIDPriv($comment)) { $comment['name'] = ''; $comment['homepage'] = ''; $comment['comment'] = _text('관리자만 볼 수 있는 댓글입니다.'); } } array_push($comments, $comment); } } return $comments; }