当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::from_db方法代码示例

本文整理汇总了PHP中Comment::from_db方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::from_db方法的具体用法?PHP Comment::from_db怎么用?PHP Comment::from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::from_db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: print_result

function print_result()
{
    global $response, $page_size;
    if ($response['ids']) {
        $rows = min($response['rows'], 1000);
        foreach ($response['ids'] as $id) {
            switch ($_REQUEST['w']) {
                case 'posts':
                    $obj = Post::from_db($id);
                    break;
                case 'comments':
                    $obj = Comment::from_db($id);
                    break;
                case 'links':
                default:
                    $obj = Link::from_db($id);
            }
            if (!$obj) {
                continue;
            }
            $obj->basic_summary = true;
            switch ($_REQUEST['w']) {
                case 'posts':
                    $obj->print_summary(800);
                    break;
                case 'comments':
                    if ($obj->type == 'admin' && !$current_user->admin) {
                        continue;
                    }
                    // link_object
                    $obj->print_summary(800);
                    break;
                case 'links':
                default:
                    $obj->print_summary();
            }
        }
    }
    do_pages($rows, $page_size);
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:40,代码来源:search.php

示例2: save_comment

function save_comment($comment, $link)
{
    global $db, $current_user, $globals, $site_key;
    $data = array();
    if ($comment->id == 0) {
        $res = Comment::save_from_post($link, false);
        // New comment
    } else {
        $res = check_and_save($comment, $link);
        // Edit, others requirements
    }
    if (is_a($res, "Comment", false)) {
        $comment = Comment::from_db($res->id);
        $comment->link_object = $link;
        $data['html'] = $comment->print_summary(null, true, true);
        $data['error'] = '';
    } else {
        $data['html'] = '';
        $data['error'] = $res;
    }
    echo json_encode($data);
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:22,代码来源:comment_ajax.php

示例3: get_comment

function get_comment($id)
{
    global $globals;
    $comment = Comment::from_db($id);
    if (!$comment) {
        return false;
    }
    $obj = array();
    $obj['id'] = (int) $comment->id;
    $obj['date'] = (int) $comment->date;
    $obj['votes'] = intval($comment->votes);
    $obj['karma'] = intval($comment->karma);
    $obj['link_id'] = (int) $comment->link_id;
    $obj['order'] = (int) $comment->order;
    $obj['user'] = $comment->username;
    //$obj['content'] = $comment->to_html($comment->content);
    $obj['content'] = html_entity_decode($comment->content);
    return $obj;
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:19,代码来源:list.php

示例4: switch

echo '<div id="newswrap">'."\n";
$link->print_summary();

switch ($tab_option) {
case 1:
case 2:
	echo '<div class="comments">';

	if($tab_option == 1) do_comment_pages($link->comments, $current_page);

	$comments = $db->get_col("SELECT SQL_CACHE comment_id FROM comments WHERE comment_link_id=$link->id ORDER BY $order_field $limit");
	if ($comments) {
		echo '<ol class="comments-list">';
		foreach($comments as $comment_id) {
			if (($comment = Comment::from_db($comment_id))) {
				echo '<li>';
				$comment->print_summary($link, 2500, true);
				echo '</li>';
			}
			echo "\n";
		}
		echo "</ol>\n";
	}

	if($tab_option == 1) do_comment_pages($link->comments, $current_page);
	Comment::print_form($link);
	echo '</div>' . "\n";

	// Highlight a comment if it is referenced by the URL.
	// currently double border, width must be 3 at least
开发者ID:rasomu,项目名称:chuza,代码行数:30,代码来源:story.php

示例5: print_answers

function print_answers($id, $level, $visited = false)
{
    // Print answers to the comment
    global $db, $page_size;
    if (!$visited) {
        $visited = array();
        $visited[] = $id;
    }
    $printed = array();
    $sql = "SELECT conversation_from FROM conversations, comments WHERE conversation_type='comment' and conversation_to = {$id} and comment_id = conversation_from ORDER BY conversation_from asc LIMIT {$page_size}";
    $answers = $db->get_col($sql);
    if ($answers) {
        $type = 'comment';
        echo '<div style="padding-left: 6%">' . "\n";
        echo '<ol class="comments-list">';
        foreach ($answers as $dbanswer) {
            if (in_array($dbanswer, $visited)) {
                continue;
            }
            $answer = Comment::from_db($dbanswer);
            $answer->url = $answer->get_relative_individual_permalink();
            echo '<li>';
            $answer->print_summary($link);
            if ($level > 0) {
                $res = print_answers($answer->id, $level - 1, array_merge($visited, $answers));
                $visited = array_merge($visited, $res);
            }
            $printed[] = $answer->id;
            $visited[] = $answer->id;
            echo '</li>';
        }
        echo "</ol>\n";
        echo '</div>' . "\n";
        if ($level == 0) {
            $ids = implode(',', $printed);
            Haanga::Load('get_total_answers_by_ids.html', compact('type', 'ids'));
        }
    }
    return $printed;
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:40,代码来源:comment.php

示例6: print_comment_list

function print_comment_list($comments, $user)
{
    global $globals, $current_user;
    $comment = new Comment();
    $timestamp_read = 0;
    $last_link = 0;
    $ids = array();
    foreach ($comments as $dbcomment) {
        $comment = Comment::from_db($dbcomment->comment_id);
        // Don't show admin comment if it's her own profile.
        if ($comment->type == 'admin' && !$current_user->admin && $user->id == $comment->author) {
            continue;
        }
        if ($last_link != $dbcomment->link_id) {
            $link = Link::from_db($dbcomment->link_id, null, false);
            // Read basic
            echo '<h4>';
            echo '<a href="' . $link->get_permalink() . '">' . $link->title . '</a>';
            echo ' [' . $link->comments . ']';
            echo '</h4>';
            $last_link = $link->id;
        }
        if ($comment->date > $timestamp_read) {
            $timestamp_read = $comment->date;
        }
        echo '<ol class="comments-list">';
        echo '<li>';
        $comment->link_object = $link;
        $comment->print_summary(2000, false);
        echo '</li>';
        echo "</ol>\n";
        $ids[] = $comment->id;
    }
    Haanga::Load('get_total_answers_by_ids.html', array('type' => 'comment', 'ids' => implode(',', $ids)));
    // Return the timestamp of the most recent comment
    return $timestamp_read;
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:37,代码来源:user.php

示例7: in

if ($previous) {
    $extra = "AND comment_id not in ({$previous})";
}
$now = intval(time() / 60) * 60;
$coef = 0.8;
$min_karma = $globals['comment_highlight_karma'] * 2;
$min_value = $globals['comment_highlight_karma'];
$min_length = 400;
$sql_value = "comment_karma*(1-({$now}-unix_timestamp(comment_date))*{$coef}/({$hours}*3600)) as value";
$where_value = "comment_karma*(1-({$now}-unix_timestamp(comment_date))*{$coef}/({$hours}*3600)) > {$min_value}";
$sql = "select comment_id, karma, {$sql_value} from comments, sub_statuses where id = {$my_id} AND status in ('published') AND comment_date > date_sub(now(), interval {$hours} hour) and LENGTH(comment_content) > {$min_length} and comment_karma > {$min_karma} AND {$where_value} AND comment_link_id = link {$extra} order by value desc limit 1";
$res = $db->get_row($sql);
if (!$res) {
    exit(0);
}
$comment = Comment::from_db($res->comment_id);
if (!$comment) {
    exit(2);
}
$image = false;
if ($comment->media_size > 0) {
    $media = new Upload('comment', $comment->id);
    if ($media->read()) {
        $image = $media->pathname();
        $maxlen -= 24;
    }
}
$url = $globals[scheme] . '//' . get_server_name() . $comment->get_relative_individual_permalink();
syslog(LOG_INFO, "Meneame, posting comment {$url}");
//  Store in cache
if ($previous) {
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:31,代码来源:post_best_comment.php

示例8: foreach

     if (isset($all[$id])) {
         foreach ($all[$id] as $e) {
             $leaves[$e] = true;
         }
     }
 }
 if (isset($leaves[$id])) {
     unset($leaves[$id]);
 }
 //$obj->basic_summary = true;
 switch ($type) {
     case 'posts':
         $obj = Post::from_db($id);
         break;
     case 'comments':
         $obj = Comment::from_db($id);
         break;
 }
 if (!$obj || $obj->type == 'admin' && !$current_user->admin) {
     continue;
 }
 if ($obj->author == $id1) {
     echo '<div style="margin-top: -10;margin-left: 10px; width:70%">';
 } else {
     echo '<div style="margin-top: -10;margin-left:30%">';
 }
 $obj->print_summary();
 echo "</div>\n";
 $thread[] = $id;
 if ($show_thread) {
     continue;
开发者ID:manelio,项目名称:woolr,代码行数:31,代码来源:between.php

示例9: preg_split

}
if (!empty($_GET['id'])) {
    $keys = preg_split('/-/', $_GET['id'], -1, PREG_SPLIT_NO_EMPTY);
    if (count($keys) == 2) {
        $link = intval($keys[0]);
        $order = intval($keys[1]);
        $id = $db->get_var("select comment_id from comments where comment_link_id={$link} and comment_order={$order}");
        if (!$id > 0) {
            die;
        }
    } else {
        $id = intval($keys[0]);
    }
} else {
    die;
}
$comment = Comment::from_db($id);
if (!$comment) {
    die;
}
echo '<div class="comment-body">';
if ($comment->type != 'admin') {
    if ($comment->avatar) {
        echo '<img class="avatar" src="' . get_avatar_url($comment->author, $comment->avatar, 40) . '" width="40" height="40" alt="avatar" style="float:left; margin: 0 5px 4px 0;"/>';
    }
    echo '<strong><span style="color:#3D72C3">' . $comment->username . '</span></strong>, karma: ' . $comment->karma . '<br/>';
} else {
    echo '<strong>' . get_server_name() . '</strong><br/>';
}
$comment->print_text(1000);
echo '</div>';
开发者ID:brainsqueezer,项目名称:fffff,代码行数:31,代码来源:get_comment_tooltip.php

示例10: check_redirect_to_feedburner

if (!$search) {
    check_redirect_to_feedburner();
}
/****
	END WARNING ******/
if (!empty($sql)) {
    $comments = $db->get_col($sql);
}
if (!$comments && $if_modified) {
    header('HTTP/1.1 304 Not Modified');
    exit;
}
do_header($title);
if ($comments) {
    foreach ($comments as $comment_id) {
        $comment = Comment::from_db($comment_id);
        if (!$comment) {
            continue;
        }
        $link = Link::from_db($comment->link);
        if (!$link) {
            continue;
        }
        $comment->link_permalink = $link->get_permalink();
        if ($comment->type == 'admin') {
            if ($individual_user) {
                continue;
            } else {
                $comment->username = get_server_name();
            }
        }
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:31,代码来源:comments_rss2.php

示例11: intval

<?php

// The source code packaged with this file is Free Software, Copyright (C) 2005-2011 by
// Ricardo Galli <gallir at gmail dot com>and Menéame Comunicacions
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
// Use the alternate server for api, if it exists
//$globals['alternate_db_server'] = 'backend';
include '../config.php';
$id = intval($_GET['id']);
if (!$id) {
    die;
}
// Print answers to the comment
$sql = "SELECT conversation_from as comment_id FROM conversations, comments WHERE conversation_type='comment' and conversation_to = {$id} and comment_id = conversation_from ORDER BY conversation_from asc";
$res = $db->get_col($sql);
if ($res) {
    header('Content-Type: text/html; charset=UTF-8');
    foreach ($res as $answer) {
        $comment = Comment::from_db($answer);
        $comment->basic_summary = true;
        $comment->not_ignored = true;
        $comment->prefix_id = "{$id}-";
        // This a trick in order not to confuse with other ids
        $comment->print_summary(false, 2500);
        echo "\n";
    }
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:30,代码来源:get_comment_answers.php

示例12: get_highlighted_comment

function get_highlighted_comment($obj)
{
    // Read the object for printing the summary
    $self = Comment::from_db($obj->id);
    $self->link_id = $obj->link_id;
    $self->link_permalink = $obj->link_url;
    // Simplify text of the comment
    $self->prepare_summary_text(1000);
    if ($self->is_truncated) {
        $self->txt_content .= '...';
        $self->is_truncated = false;
    }
    $self->media_size = 0;
    $self->vote = $obj->vote;
    $self->can_edit = false;
    return $self;
}
开发者ID:manelio,项目名称:woolr,代码行数:17,代码来源:story.php

示例13: do_best_comments

do_best_comments();
do_vertical_tags('published');
echo '</div>' . "\n";
/*** END SIDEBAR ***/
echo '<div id="newswrap">' . "\n";
echo '<div class="topheading"><h2>' . _('comentarios más valorados 24 horas') . '</h2></div>';
$last_link = 0;
$counter = 0;
echo '<div class="comments">';
$min_date = date("Y-m-d H:00:00", time() - 86000);
//  about 24 hours
$comments = $db->get_results("SELECT comment_id, link_id FROM comments, links WHERE comment_date > '{$min_date}' and link_id=comment_link_id ORDER BY comment_karma desc, link_id asc limit 25");
if ($comments) {
    foreach ($comments as $dbcomment) {
        $link = Link::from_db($dbcomment->link_id, null, false);
        $comment = Comment::from_db($dbcomment->comment_id);
        if ($last_link != $link->id) {
            echo '<h3>';
            echo '<a href="' . $link->get_relative_permalink() . '">' . $link->title . '</a>';
            echo '</h3>';
        }
        echo '<ol class="comments-list">';
        echo '<li>';
        $comment->print_summary($link, 2000, false);
        echo '</li>';
        if ($last_link != $link->id) {
            $last_link = $link->id;
            $counter++;
        }
        echo "</ol>\n";
    }
开发者ID:manelio,项目名称:woolr,代码行数:31,代码来源:topcomments.php

示例14: clean_input_string

$fields = clean_input_string($_GET['fields']);
// It has to remove parenthesis
if (empty($_GET['what'])) {
    $what = 'link';
} else {
    $what = $_GET['what'];
}
$object = false;
switch ($what) {
    case 'link':
    case 'links':
        $object = Link::from_db($id, null, false);
        break;
    case 'comment':
    case 'comments':
        $object = Comment::from_db($id);
        break;
    case 'post':
    case 'posts':
        $object = Post::from_db($id);
        break;
}
if (!$object) {
    die;
}
$output = new stdClass();
foreach (preg_split('/,/', $fields, 10, PREG_SPLIT_NO_EMPTY) as $f) {
    if (!in_array($f, $forbidden) && property_exists($object, $f)) {
        $output->{$f} = $object->{$f};
    }
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:31,代码来源:info.php

示例15: get_qanda

function get_qanda($link)
{
    include_once mnminclude . 'commenttree.php';
    global $db;
    $results = array();
    $a_ids = $db->get_col("select comment_id from comments where comment_link_id = {$link->id} and comment_user_id = {$link->author} order by comment_id asc");
    if ($a_ids) {
        foreach ($a_ids as $a_id) {
            $a = Comment::from_db($a_id);
            $qa = new CommentQA($a);
            $q_ids = $db->get_col("select conversation_to from conversations where conversation_type = 'comment' and conversation_from = {$a_id} and conversation_to > 0 order by conversation_to asc");
            if ($q_ids) {
                foreach ($q_ids as $q_id) {
                    $q = Comment::from_db($q_id);
                    $qa->add_question($q);
                }
            }
            $results[] = $qa;
        }
    }
    return $results;
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:22,代码来源:story.php


注:本文中的Comment::from_db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。