本文整理汇总了PHP中ArtefactTypeComment::get_artefact_comments_for_view方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeComment::get_artefact_comments_for_view方法的具体用法?PHP ArtefactTypeComment::get_artefact_comments_for_view怎么用?PHP ArtefactTypeComment::get_artefact_comments_for_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeComment
的用法示例。
在下文中一共展示了ArtefactTypeComment::get_artefact_comments_for_view方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$result = '';
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
require_once get_config('docroot') . 'artefact/lib.php';
$artefact = $instance->get_artefact_instance($artefactid);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;
$configdata['viewid'] = $instance->get('view');
$configdata['blockid'] = $instance->get('id');
$result = $artefact->render_self($configdata);
$result = $result['html'];
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:blogpost:blogpost.tpl');
}
示例2: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
$configdata['simpledisplay'] = true;
// This can be either an image or profileicon. They both implement
// render_self
$result = '';
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
$artefact = $instance->get_artefact_instance($artefactid);
$result = $artefact->render_self($configdata);
$result = $result['html'];
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
}
示例3: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
// this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
$result = '';
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
$artefact = $instance->get_artefact_instance($artefactid);
if (!file_exists($artefact->get_path())) {
return;
}
$result = clean_html(file_get_contents($artefact->get_path()));
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:html:html.tpl');
}
示例4: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
// this will make sure to unserialize it for us
if (!isset($configdata['artefactid'])) {
return '';
}
$id = $configdata['artefactid'];
$image = $instance->get_artefact_instance($id);
$wwwroot = get_config('wwwroot');
$viewid = $instance->get('view');
if ($image instanceof ArtefactTypeProfileIcon) {
$src = $wwwroot . 'thumb.php?type=profileiconbyid&id=' . $id;
$description = $image->get('title');
} else {
$src = $wwwroot . 'artefact/file/download.php?file=' . $id . '&view=' . $viewid;
$description = $image->get('description');
}
if (!empty($configdata['width'])) {
$src .= '&maxwidth=' . $configdata['width'];
}
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($image, $view, $instance->get('id'), true, $editing);
$smarty = smarty_core();
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('url', $wwwroot . 'artefact/artefact.php?artefact=' . $id . '&view=' . $viewid);
$smarty->assign('src', $src);
$smarty->assign('description', $description);
$smarty->assign('showdescription', !empty($configdata['showdescription']) && !empty($description));
return $smarty->fetch('blocktype:image:image.tpl');
}
示例5: 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('note'), $viewid);
$information = ArtefactTypeFolder::append_view_url($artefact->get('description'), $viewid);
$literature = $configdata['literature'];
$smarty = smarty_core();
$smarty->assign('text', $text);
$smarty->assign('information', $information);
$smarty->assign('literature', $literature);
$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));
}
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('blockid', $instance->get('id'));
return $smarty->fetch('blocktype:eselmagraduation:content.tpl');
}
return '';
}
示例6: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$viewid = $instance->get('view');
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if (empty($artefactid)) {
return '';
}
$result = self::get_js_source();
require_once get_config('docroot') . 'artefact/lib.php';
$artefact = $instance->get_artefact_instance($artefactid);
$defaultwidth = get_config_plugin('blocktype', 'internalmedia', 'width') ? get_config_plugin('blocktype', 'internalmedia', 'width') : 300;
$defaultheight = get_config_plugin('blocktype', 'internalmedia', 'height') ? get_config_plugin('blocktype', 'internalmedia', 'height') : 300;
$width = !empty($configdata['width']) ? hsc($configdata['width']) : $defaultwidth;
$height = !empty($configdata['height']) ? hsc($configdata['height']) : $defaultheight;
$mimetype = $artefact->get('filetype');
$mimetypefiletypes = self::get_allowed_mimetype_filetypes();
if (!isset($mimetypefiletypes[$mimetype])) {
return get_string('typeremoved', 'blocktype.file/internalmedia');
}
$callbacks = self::get_all_filetype_players();
$result .= '<div class="mediaplayer-container center"><div class="mediaplayer">' . call_static_method('PluginBlocktypeInternalmedia', $callbacks[$mimetypefiletypes[$mimetype]], $artefact, $instance, $width, $height) . '</div></div>';
if ($artefactid) {
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:internalmedia:internalmedia.tpl');
}
示例7: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
$configdata = $instance->get('configdata');
$view = $instance->get('view');
$full = isset($configdata['full']) ? $configdata['full'] : false;
$results = array();
$smarty = smarty_core();
$smarty->assign('view', $view);
$viewownerdisplay = null;
// Display all posts, from all blogs, owned by this user
$tagsin = $tagsout = array();
$results = self::get_blog_posts_in_block($instance, $tagsin, $tagsout);
if ($tagsin || $tagsout) {
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('editing', $editing);
if ($editing) {
// Get list of blogs owned by this user to create the "Add new post" shortcut while editing
$viewowner = $instance->get_view()->get('owner');
if (!$viewowner || !($blogs = get_records_select_array('artefact', 'artefacttype = \'blog\' AND owner = ?', array($viewowner), 'title ASC', 'id, title'))) {
$blogs = array();
}
$smarty->assign('tagselect', implode(', ', $tagsin));
$smarty->assign('blogs', $blogs);
}
// if posts are not found with the selected tag, notify the user
if (!$results) {
$smarty->assign('badtag', implode(', ', $tagsin));
$smarty->assign('badnotag', implode(', ', $tagsout));
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
// update the view_artefact table so journal entries are accessible when this is the only block on the page
// referencing this journal
$dataobject = array('view' => $view, 'block' => $instance->get('id'));
require_once get_config('docroot') . 'lib/view.php';
$viewobj = new View($view);
require_once get_config('docroot') . 'artefact/lib.php';
safe_require('artefact', 'blog');
safe_require('artefact', 'comment');
foreach ($results as $result) {
$dataobject["artefact"] = $result->parent;
$result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
$result->displaydate = format_date(strtotime($result->ctime));
$artefact = new ArtefactTypeBlogpost($result->id);
// get comments for this post
$result->commentcount = count_records_select('artefact_comment_comment', "onartefact = {$result->id} AND private = 0 AND deletedby IS NULL");
$allowcomments = $artefact->get('allowcomments');
if (empty($result->commentcount) && empty($allowcomments)) {
$result->commentcount = null;
}
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $viewobj, null, false);
$result->comments = $comments;
// get all tags for this post
$taglist = get_records_array('artefact_tag', 'artefact', $result->id, "tag DESC");
foreach ($taglist as $t) {
$result->taglist[] = $t->tag;
}
if ($full) {
$rendered = $artefact->render_self(array('viewid' => $view, 'details' => true, 'blockid' => $instance->get('id')));
$result->html = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result->html .= '<script type="application/javascript">' . $rendered['javascript'] . '</script>';
}
}
}
// check if the user viewing the page is the owner of the selected tag
$owner = $results[0]->owner;
if ($USER->id != $owner) {
$viewownerdisplay = get_user_for_display($owner);
}
$smarty->assign('tagsin', $tagsin);
$smarty->assign('tagsout', $tagsout);
} else {
if (!self::get_chooseable_tags()) {
// error if block configuration fails
$smarty->assign('configerror', get_string('notagsavailableerror', 'blocktype.blog/taggedposts'));
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
} else {
// error if block configuration fails
$smarty->assign('configerror', get_string('configerror', 'blocktype.blog/taggedposts'));
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
}
// add any needed links to the tags
$tagstr = $tagomitstr = '';
foreach ($tagsin as $key => $tag) {
if ($key > 0) {
$tagstr .= ', ';
}
$tagstr .= $viewownerdisplay ? '"' . $tag . '"' : '"<a href="' . get_config('wwwroot') . 'tags.php?tag=' . $tag . '&sort=name&type=text">' . $tag . '</a>"';
}
if (!empty($tagsout)) {
foreach ($tagsout as $key => $tag) {
if ($key > 0) {
$tagomitstr .= ', ';
}
$tagomitstr .= $viewownerdisplay ? '"' . $tag . '"' : '"<a href="' . get_config('wwwroot') . 'tags.php?tag=' . $tag . '&sort=name&type=text">' . $tag . '</a>"';
}
}
$blockheading = get_string('blockheadingtags', 'blocktype.blog/taggedposts', count($tagsin), $tagstr);
//.........这里部分代码省略.........
示例8: 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, a.id 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) {
$params = array('id' => $file->attachment);
if (!empty($viewoptions['viewid'])) {
$params['viewid'] = $viewoptions['viewid'];
}
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', $params);
$data[$file->artefact]->files[] = $file;
}
}
if ($tags = ArtefactType::tags_from_id_list($postids)) {
foreach ($tags as &$at) {
$data[$at->artefact]->tags[] = $at->tag;
}
}
foreach ($data as &$post) {
// Format dates properly
if (is_null($viewoptions)) {
// My Blogs area: create forms for changing post status & deleting posts.
$post->changepoststatus = ArtefactTypeBlogpost::changepoststatus_form($post->id, $post->published);
$post->delete = ArtefactTypeBlogpost::delete_form($post->id, $post->title);
} else {
$by = $post->author ? display_default_name($post->author) : $post->authorname;
$post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime));
// Get comment counts
if (!empty($viewoptions['countcomments'])) {
safe_require('artefact', 'comment');
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewoptions['viewid']);
$artefact = artefact_instance_from_id($post->id);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false);
$post->commentcount = $commentcount;
$post->comments = $comments;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
// Ensure images in the post have the right viewid associated with them
if (!empty($viewoptions['viewid'])) {
safe_require('artefact', 'file');
$post->description = ArtefactTypeFolder::append_view_url($post->description, $viewoptions['viewid']);
}
}
$results['data'] = array_values($data);
return $results;
}