本文整理汇总了PHP中ArtefactTypeComment::count_comments方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeComment::count_comments方法的具体用法?PHP ArtefactTypeComment::count_comments怎么用?PHP ArtefactTypeComment::count_comments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeComment
的用法示例。
在下文中一共展示了ArtefactTypeComment::count_comments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
safe_require('artefact', 'file');
safe_require('artefact', 'comment');
$artefact = $instance->get_artefact_instance($configdata['artefactid']);
$viewid = $instance->get('view');
$text = ArtefactTypeFolder::append_view_url($artefact->get('description'), $viewid);
$smarty = smarty_core();
$smarty->assign('text', $text);
$attachments = $artefact->get_attachments();
if ($attachments) {
require_once get_config('docroot') . 'artefact/lib.php';
foreach ($attachments as &$attachment) {
$f = artefact_instance_from_id($attachment->id);
$attachment->size = $f->describe_size();
$attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
$attachment->viewpath = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($viewid) ? $viewid : 0);
$attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id;
if (isset($viewid)) {
$attachment->downloadpath .= '&view=' . $viewid;
}
}
$smarty->assign('attachments', $attachments);
$smarty->assign('count', count($attachments));
}
if ($artefact->get('allowcomments')) {
$commentcount = ArtefactTypeComment::count_comments(null, array($configdata['artefactid']));
$commentcount = isset($commentcount[$configdata['artefactid']]) ? $commentcount[$configdata['artefactid']]->comments : 0;
$artefacturl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $configdata['artefactid'];
$smarty->assign('artefacturl', $artefacturl);
$smarty->assign('commentcount', $commentcount);
}
return $smarty->fetch('blocktype:textbox:content.tpl');
}
return '';
}
示例2: get_posts
/**
* This function returns a list of posts in a given blog.
*
* @param integer
* @param integer
* @param integer
* @param array
*/
public static function get_posts($id, $limit, $offset, $viewoptions = null)
{
$results = array('limit' => $limit, 'offset' => $offset);
// If viewoptions is null, we're getting posts for the my blogs area,
// and we should get all posts & show drafts first. Otherwise it's a
// blog in a view, and we should only get published posts.
$from = "\n FROM {artefact} a LEFT JOIN {artefact_blog_blogpost} bp ON a.id = bp.blogpost\n WHERE a.artefacttype = 'blogpost' AND a.parent = ?";
if (!is_null($viewoptions)) {
if (isset($viewoptions['before'])) {
$from .= " AND a.ctime < '{$viewoptions['before']}'";
}
$from .= ' AND bp.published = 1';
}
$results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
$data = get_records_sql_assoc('
SELECT
a.id, a.title, a.description, a.author, a.authorname, ' . db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
a.locked, bp.published, a.allowcomments ' . $from . '
ORDER BY bp.published ASC, a.ctime DESC', array($id), $offset, $limit);
if (!$data) {
$results['data'] = array();
return $results;
}
// Get the attached files.
$postids = array_map(create_function('$a', 'return $a->id;'), $data);
$files = ArtefactType::attachments_from_id_list($postids);
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment));
$data[$file->artefact]->files[] = $file;
}
}
if ($tags = ArtefactType::tags_from_id_list($postids)) {
foreach ($tags as &$at) {
$data[$at->artefact]->tags[] = $at->tag;
}
}
// Get comment counts
if (!empty($viewoptions['countcomments'])) {
safe_require('artefact', 'comment');
$viewids = array();
$commentcounts = ArtefactTypeComment::count_comments($viewids, array_keys($data));
}
// Format dates properly
foreach ($data as &$post) {
if (is_null($viewoptions)) {
// My Blogs area: create forms for publishing & deleting posts.
if (!$post->published) {
$post->publish = ArtefactTypeBlogpost::publish_form($post->id);
}
$post->delete = ArtefactTypeBlogpost::delete_form($post->id);
} else {
$by = $post->author ? display_default_name($post->author) : $post->authorname;
$post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime));
if (isset($commentcounts)) {
$post->commentcount = isset($commentcounts[$post->id]) ? $commentcounts[$post->id]->comments : 0;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
}
$results['data'] = array_values($data);
return $results;
}
示例3: institution_view_stats_table
function institution_view_stats_table($limit, $offset, &$institutiondata)
{
global $USER;
if ($institutiondata['views'] != 0) {
$count = count_records_select('view', 'id IN (' . join(',', array_fill(0, $institutiondata['views'], '?')) . ') AND type != ?', array_merge($institutiondata['viewids'], array('dashboard')));
} else {
$count = 0;
}
$pagination = build_pagination(array('id' => 'stats_pagination', 'url' => get_config('wwwroot') . 'admin/users/statistics.php?institution=' . $institutiondata['name'] . '&type=views', 'jsonscript' => 'admin/users/statistics.json.php', 'datatable' => 'statistics_table', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'extradata' => array('institution' => $institutiondata['name']), 'setlimit' => true));
$result = array('count' => $count, 'tablerows' => '', 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript']);
if ($count < 1) {
return $result;
}
$viewdata = get_records_sql_assoc("SELECT\n v.id, v.title, v.owner, v.group, v.institution, v.visits, v.type, v.ownerformat, v.urlid\n FROM {view} v\n WHERE v.id IN (" . join(',', array_fill(0, $institutiondata['views'], '?')) . ") AND v.type != ?\n ORDER BY v.visits DESC, v.title, v.id", array_merge($institutiondata['viewids'], array('dashboard')), $offset, $limit);
require_once 'view.php';
require_once 'group.php';
View::get_extra_view_info($viewdata, false, false);
safe_require('artefact', 'comment');
$comments = ArtefactTypeComment::count_comments(array_keys($viewdata));
foreach ($viewdata as &$v) {
$v = (object) $v;
if ($v->owner) {
$v->ownername = display_name($v->user);
$v->ownerurl = profile_url($v->user);
} else {
$v->ownername = $v->sharedby;
if ($v->group) {
$v->ownerurl = group_homepage_url($v->groupdata);
} else {
if ($v->institution && $v->institution != 'mahara') {
$v->ownerurl = get_config('wwwroot') . 'institution/index.php?institution=' . $v->institution;
}
}
}
$v->comments = isset($comments[$v->id]) ? (int) $comments[$v->id]->comments : 0;
}
$csvfields = array('title', 'displaytitle', 'fullurl', 'owner', 'group', 'institution', 'ownername', 'ownerurl', 'visits', 'type', 'comments');
$USER->set_download_file(generate_csv($viewdata, $csvfields), 'viewstatistics.csv', 'text/csv');
$result['csv'] = true;
$smarty = smarty_core();
$smarty->assign('data', $viewdata);
$smarty->assign('offset', $offset);
$result['tablerows'] = $smarty->fetch('admin/viewstats.tpl');
return $result;
}
示例4: view_stats_table
function view_stats_table($limit, $offset)
{
$count = count_records_select('view', '(owner != 0 OR owner IS NULL) AND type != ?', array('dashboard'));
$pagination = build_pagination(array('id' => 'stats_pagination', 'url' => get_config('wwwroot') . 'admin/statistics.php?type=views', 'jsonscript' => 'admin/statistics.json.php', 'datatable' => 'statistics_table', 'count' => $count, 'limit' => $limit, 'offset' => $offset));
$result = array('count' => $count, 'tablerows' => '', 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript']);
if ($count < 1) {
return $result;
}
$viewdata = get_records_sql_assoc("SELECT\n v.id, v.title, v.owner, v.group, v.institution, v.visits,\n u.id AS userid, u.firstname, u.lastname,\n g.id AS groupid, g.name AS groupname,\n i.displayname AS institutionname\n FROM {view} v\n LEFT JOIN {usr} u ON v.owner = u.id\n LEFT JOIN {group} g ON v.group = g.id\n LEFT JOIN {institution} i ON v.institution = i.name\n WHERE (v.owner != 0 OR \"owner\" IS NULL) AND v.type != ?\n ORDER BY v.visits DESC, v.title, v.id", array('dashboard'), $offset, $limit);
safe_require('artefact', 'comment');
$comments = ArtefactTypeComment::count_comments(array_keys($viewdata));
foreach ($viewdata as &$v) {
if ($v->owner) {
$v->ownername = display_name($v->owner);
$v->ownerurl = 'user/view.php?id=' . $v->userid;
} else {
if ($v->group) {
$v->ownername = $v->groupname;
$v->ownerurl = 'group/view.php?id=' . $v->groupid;
} else {
if ($v->institution == 'mahara') {
$v->ownername = get_config('sitename');
} else {
if ($v->institution) {
$v->ownername = $v->institutionname;
}
}
}
}
$v->comments = isset($comments[$v->id]) ? (int) $comments[$v->id]->comments : 0;
}
$smarty = smarty_core();
$smarty->assign('data', $viewdata);
$smarty->assign('offset', $offset);
$result['tablerows'] = $smarty->fetch('admin/viewstats.tpl');
return $result;
}