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


PHP comment::count方法代码示例

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


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

示例1: comment

$args->course = $course;
$args->cm = $cm;
$args->area = $area;
$args->itemid = $itemid;
$args->client_id = $client_id;
$args->component = $component;
$manager = new comment($args);
echo $OUTPUT->header();
// send headers
// process ajax request
switch ($action) {
    case 'add':
        if ($manager->can_post()) {
            $result = $manager->add($content);
            if (!empty($result) && is_object($result)) {
                $result->count = $manager->count();
                $result->client_id = $client_id;
                echo json_encode($result);
                die;
            }
        }
        break;
    case 'delete':
        $comment_record = $DB->get_record('comments', array('id' => $commentid));
        if ($manager->can_delete($commentid) || $comment_record->userid == $USER->id) {
            if ($manager->delete($commentid)) {
                $result = array('client_id' => $client_id, 'commentid' => $commentid);
                echo json_encode($result);
                die;
            }
        }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:comment_ajax.php

示例2: flush

}
$data = '';
if (file_exists("cache/{$id}/comments.{$pid}.cache")) {
    $data = $cache->load("cache/{$id}/comments.{$pid}.cache");
}
if ($data !== false && $data != "" && $got_permission === false) {
    echo $data;
    flush();
} else {
    if ($got_permission === false) {
        ob_start();
    }
    //Pagination starts here with dependencies. No need to change this usually... :3
    $comment = new comment();
    $misc = new misc();
    $count = $comment->count($id, $_GET['page'], $_GET['s']);
    echo "{$count} ";
    if ($count > 1) {
        print "comments";
    } else {
        print "comment";
    }
    echo '<a href="#" id="ci" onclick="showHideIgnored(' . $id . ',\'ci\'); return false;"> (0 hidden)</a><br />';
    //List comments... Could this be better off as a function to use here and on the comment list page? :S
    $query = "SELECT SQL_NO_CACHE id, comment, user, posted_at, score, spam FROM {$comment_table} WHERE post_id='{$id}' ORDER BY posted_at ASC LIMIT {$page}, {$limit}";
    $result = $db->query($query);
    $ccount = 0;
    while ($row = $result->fetch_assoc()) {
        echo '<div id="c' . $row['id'] . '" style="display:inline;"><br /><a href="index.php?page=account_profile&amp;uname=' . $row['user'] . '">' . $row['user'] . '</a><br /><b>Posted on ' . date('Y-m-d H:i:s', $row['posted_at']) . ' Score: <a id="sc' . $row['id'] . '">' . $row['score'] . '</a> (vote <a href="#" onclick="Javascript:vote(\'' . $id . '\', \'' . $row['id'] . '\', \'up\'); return false;">Up</a>/<a href="#" onclick="Javascript:vote(\'' . $id . '\', \'' . $row['id'] . '\', \'down\'); return false;">Down</a>)&nbsp;&nbsp;&nbsp;';
        ?>
			(<?php 
开发者ID:xfirespeed,项目名称:TyP-Gallery,代码行数:31,代码来源:post_view.php

示例3: deletephoto

            if ($updateData['albums_id']) {
                $updateAdd = array('photos_total' => 1, 'comment_num' => $pic_info['comment_num'], 'comment_total' => $pic_info['comment_total']);
                $updateDrop = array('photos_total' => -1, 'comment_num' => -$pic_info['comment_num'], 'comment_total' => -$pic_info['comment_total']);
                if ($pic_info['state']) {
                    $updateAdd['photos_num'] = 1;
                    $updateDrop['photos_num'] = -1;
                }
                $this->api->update('albums', $updateDrop, array('id' => $pic_info['albums_id']), true);
                $this->api->update('albums', $updateAdd, array('id' => $updateData['albums_id']), true);
                $this->api->update('comment', array('albums_id' => $updateData['albums_id']), array('photo_id' => $id));
                $this->api->update('praise', array('albums_id' => $updateData['albums_id'], array('photo_id' => $id)));
            }
            $this->addItem($result);
        }
        $this->output();
    }
    public function deletephoto()
    {
        $id = trim(urldecode($this->input['id']));
        $query = "update " . DB_PREFIX . "photos set isdrop=1 where id in ({$id})";
        $this->addItem($this->core->query_sql($query));
        $this->output();
    }
    /**
	 * 删除照片数据
	 */
    public function delete()
    {
        $id = trim(urldecode($this->input['id']));
        $id_arr = explode(',', $id);
        $ids = array_filter($id_arr, 'filter_arr');
        $id = implode(',', $ids);
        if (empty($id)) {
            $this->errorOutput(PARAM_WRONG);
        }
        //查询自己发布的数据
        $photos_info = $this->api->show(array('count' => -1, 'condition' => array('id' => $id, 'user_id' => $this->user['user_id'])));
        if (!$photos_info) {
            $this->errorOutput(FAILED);
        }
        $photo_ids = $audit_ids = array();
        foreach ($photos_info as $photo) {
            $photo_ids[$photo['id']] = $photo['id'];
            //所有的
            if ($photo['state'] == 1) {
                $audit_ids[$photo['id']] = $photo['id'];
                //已审核
            }
            $albums_id = $photo['albums_id'];
        }
        $dropPicNum = count($audit_ids);
        //删除的已审核的照片数
        $dropTotalPic = count($photo_ids);
        //删除的所有的照片数
        $photo_ids = implode(',', $photo_ids);
        $audit_ids = implode(',', $audit_ids);
        if ($audit_ids) {
            //查询有效的评论数
            include_once CUR_CONF_PATH . 'lib/comment.class.php';
            $commentApi = new comment();
            $comment_num = $commentApi->count(array('photo_id' => $audit_ids, 'state' => 3));
            $comment_total = $commentApi->count(array('photo_id' => $audit_ids));
            //删除照片下的评论
            $this->api->update('comment', array('isdrop' => 1), array('photo_id' => $audit_ids));
            //删除照片下的赞
            $this->api->update('praise', array('isdrop' => 1), array('photo_id' => $audit_ids));
        }
        if ($photo_ids) {
开发者ID:h3len,项目名称:Project,代码行数:68,代码来源:photos.php

示例4: display_browse

 /**
  *
  */
 public function display_browse($entry, $options = array())
 {
     global $DB, $CFG;
     $field = $this->_field;
     $fieldid = $field->id;
     $df = $field->get_df();
     // Only for existing entries.
     if (!($entry->id > 0)) {
         return '';
     }
     $str = '';
     require_once "{$CFG->dirroot}/comment/lib.php";
     $cmt = new stdClass();
     $cmt->context = $df->context;
     $cmt->courseid = $df->course->id;
     $cmt->cm = $df->cm;
     $cmt->itemid = $entry->id;
     $cmt->component = 'mod_dataform';
     $cmt->area = $field->name;
     $cmt->showcount = isset($options['showcount']) ? $options['showcount'] : true;
     if (!empty($options['count'])) {
         $comment = new comment($cmt);
         $str = $comment->count();
     } else {
         foreach ($options as $key => $val) {
             $cmt->{$key} = $val;
         }
         $comment = new comment($cmt);
         $str = $comment->output(true);
     }
     return $str;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:35,代码来源:renderer.php

示例5: comment

    $args->area = $area;
    $args->itemid = $itemid;
    $args->client_id = $client_id;
    $args->component = $component;
    // only for comments in frontpage
    $args->ignore_permission = $ignore_permission;
    $manager = new comment($args);
} else {
    die;
}
// process ajax request
switch ($action) {
    case 'add':
        $result = $manager->add($content);
        if (!empty($result) && is_object($result)) {
            $result->count = $manager->count();
            $result->client_id = $client_id;
            echo json_encode($result);
        }
        break;
    case 'delete':
        $result = $manager->delete($commentid);
        if ($result === true) {
            echo json_encode(array('client_id' => $client_id, 'commentid' => $commentid));
        }
        break;
    case 'get':
    default:
        $result = array();
        $comments = $manager->get_comments($page);
        $result['list'] = $comments;
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:comment_ajax.php


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