コード例 #1
1
ファイル: functions.inc.php プロジェクト: khanhnnvn/OKMS
function list_comments_without_right($pid, $c = null)
{
    //Return list of comments by post ID without normal rights
    $output = '';
    $default = DEFAULT_AVATAR;
    $post = post_load($pid);
    $comments = comments_load_by_pid($pid);
    usort($comments, 'sort_comment_date_ascend');
    $count = $c == null ? count($comments) : $c;
    $output .= '<div class="comments" id="comments_pid_' . $pid . '" style="display: none">';
    for ($i = 0; $i < $count; $i++) {
        if (isset($comments[$i])) {
            $user = user_load($comments[$i]['User_ID']);
            $comid = $comments[$i]['Comment_ID'];
            $comment_vote = comment_vote_load($comid, $_SESSION['uid']);
            $email = $user['User_Mail'];
            $size = 30;
            $grav_url = $comments[$i]['Comment_Hide_Name'] == 0 && user_existed($comments[$i]['User_ID']) ? "http://0.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "?d=" . $default . "&s=" . $size : $default;
            $output .= '<div class="comment">';
            $output .= '<a class="author" href="?p=user/' . $user['User_Username'] . '"><img src="' . $grav_url . '" width="30px"/></a>';
            $output .= '<div class="comment_right_detail">';
            $output .= '<div class="name' . ($user['Role_ID'] == 3 ? ' lecturer' : '') . '">' . ($comments[$i]['Comment_Hide_Name'] == 0 && user_existed($comments[$i]['User_ID']) ? isset($user['User_Fullname']) ? $user['User_Fullname'] : $user['User_Username'] : '******') . '</div>';
            $output .= '<div class="date">' . ago($comments[$i]['Comment_Created']) . ($comments[$i]['Comment_Edited'] != 0 ? ' - edited: ' . ago($comments[$i]['Comment_Edited']) : '') . '</div>';
            $output .= '<p>' . $comments[$i]['Comment_Body'] . '</p>';
            $output .= '<a title="Like this comment" class="button disabled like" id="comment_like_comid_' . $comid . '">' . count_comment_likes($comid) . ' Like' . (count_comment_likes($comid) == 0 || count_comment_likes($comid) == 1 ? '' : 's') . '</a>';
            $output .= '<a title="Dislike this comment" class="button disabled dislike" id="comment_dislike_comid_' . $comid . '">' . count_comment_dislikes($comid) . ' Dislike' . (count_comment_dislikes($comid) == 0 || count_comment_dislikes($comid) == 1 ? '' : 's') . '</a>';
            $output .= '</div>';
            $output .= '</div>';
        }
    }
    $output .= '</div>';
    return $output;
}
コード例 #2
0
ファイル: search.php プロジェクト: khanhnnvn/OKMS
        while ($row = mysql_fetch_assoc($result)) {
            $posts[] = $row;
        }
    }
    if ($cid != 0) {
        $posts = array_filter($posts, array(new Filter($cid), 'filter_cid'));
    }
    sort($posts);
    usort($posts, 'sort_post_date_descend');
    if (count($posts) == 0) {
        print '<span style="padding: 15px;">There is no result</span>';
    } else {
        $count = count($posts) < 5 ? count($posts) : 5;
        print '<span style="padding: 15px;">' . count($posts) . ' result' . (count($posts) == 1 ? '' : 's') . '</span>';
        print '<ul id="suggestions">';
        for ($i = 0; $i < $count; $i++) {
            if (isset($posts[$i]['Post_ID'])) {
                $user = user_load($posts[$i]['User_ID']);
                print '<li class="suggestion' . ($i == 0 ? ' first' : '') . '"><a class="post_title' . ($i == 0 ? ' first' : '') . '" href="?p=question/' . $posts[$i]['Post_URL'] . '">' . $posts[$i]['Post_Title'] . '</a><br/><span class=post_author>' . (isset($posts[$i]['Post_Hide_Name']) && $posts[$i]['Post_Hide_Name'] == 1 || !user_existed($posts[$i]['User_ID']) ? 'Anonymous' : (isset($user['User_Fullname']) ? $user['User_Fullname'] : $user['User_Username'])) . '</span></li>';
            }
        }
        print count($posts) > 5 ? '<li class="suggestion"><a id="all_results">Show all results</a></li>' : '';
        print '</ul>';
    }
}
?>
<script type="text/javascript">
$("#all_results").click(function(){
	$("#search_bar > form").submit();
});
</script>