/** * Returns a human-readable list of annotations on a particular entity. * * @param int $entity_guid The entity GUID * @param string $name The name of the kind of annotation * @param int $limit The number of annotations to display at once * @param true|false $asc Whether or not the annotations are displayed in ascending order. (Default: true) * @return string HTML (etc) version of the annotation list */ function list_annotations($entity_guid, $name = "", $limit = 25, $asc = true) { if ($asc) { $asc = "asc"; } else { $asc = "desc"; } $count = count_annotations($entity_guid, "", "", $name); $offset = (int) get_input("annoff", 0); $annotations = get_annotations($entity_guid, "", "", $name, "", "", $limit, $offset, $asc); return elgg_view_annotation_list($annotations, $count, $offset, $limit); }
if ($item->annotation_id != 0 || !$object) { return true; } $comment_count = $object->countComments(); $options = array('guid' => $object->getGUID(), 'annotation_name' => 'generic_comment', 'limit' => 3, 'order_by' => 'n_table.time_created desc'); $comments = elgg_get_annotations($options); if ($comments) { // why is this reversing it? because we're asking for the 3 latest // comments by sorting desc and limiting by 3, but we want to display // these comments with the latest at the bottom. $comments = array_reverse($comments); ?> <span class="elgg-river-comments-tab"><?php echo elgg_echo('comments'); ?> </span> <?php echo elgg_view_annotation_list($comments, array('list_class' => 'elgg-river-comments')); if ($comment_count > count($comments)) { $num_more_comments = $comment_count - count($comments); $url = $object->getURL(); $params = array('href' => $url, 'text' => elgg_echo('river:comments:more', array($num_more_comments))); $link = elgg_view('output/url', $params); echo "<div class=\"elgg-river-more\">{$link}</div>"; } } // inline comment form $form_vars = array('id' => "comments-add-{$object->getGUID()}", 'class' => 'hidden'); $body_vars = array('entity' => $object, 'inline' => true); echo elgg_view_form('comments/add', $form_vars, $body_vars);
<?php $item = $vars['item']; if ($item->action_type !== 'create') { return true; } $object = $vars['item']->getObjectEntity(); $replies_options = array('guid' => $object->getGUID(), 'annotation_name' => 'group_topic_post', 'limit' => 3, 'order_by' => 'n_table.time_created desc'); $replies = elgg_get_annotations($replies_options); if ($replies) { // why is this reversing it? because we're asking for the 3 latest // replies by sorting desc and limiting by 3, but we want to display // these replies with the latest at the bottom. $replies = array_reverse($replies); $replies_options['count'] = TRUE; $reply_count = elgg_get_annotations($replies_options); // If greater that 3 replies, link to the rest of them if ($reply_count > count($replies)) { $link = elgg_view('output/url', array('href' => $object->getURL(), 'text' => elgg_echo('river:replies:all', array($reply_count)))); echo elgg_view_image_block(elgg_view_icon('speech-bubble-alt'), $link, array('class' => 'elgg-river-participation')); } // Display the latest echo elgg_view_annotation_list($replies, array('list_class' => 'elgg-river-replies', 'item_class' => 'elgg-river-participation')); } if ($object->canAnnotate(0, 'group_topic_post')) { // inline reply form $form_vars = array('id' => "groups-reply-{$object->getGUID()}", 'class' => 'elgg-form-small elgg-river-participation'); $body_vars = array('entity' => $object, 'inline' => true); echo elgg_view_form('discussion/reply/save', $form_vars, $body_vars); }
<?php $entity = elgg_extract('entity', $vars, FALSE); $options = array('guid' => $entity->guid, 'annotation_name' => 'votes'); $annotations = elgg_get_annotations($options); if ($annotations) { echo elgg_view_annotation_list($annotations); } else { echo elgg_echo('proposals:votes:no_comments'); }
<?php /** * River item footer */ $item = $vars['item']; $object = $item->getObjectEntity(); // annotations do not have comments if (!$object || $item->annotation_id) { return true; } $comment_count = $object->countComments(); $comments = elgg_get_annotations(array('guid' => $object->getGUID(), 'annotation_name' => 'generic_comment', 'limit' => 3, 'order_by' => 'n_table.time_created desc')); if ($comments) { // why is this reversing it? because we're asking for the 3 latest // comments by sorting desc and limiting by 3, but we want to display // these comments with the latest at the bottom. $comments = array_reverse($comments); if ($comment_count > count($comments)) { $link = elgg_view('output/url', array('href' => $object->getURL(), 'text' => elgg_echo('river:comments:all', array($comment_count)))); echo elgg_view_image_block(elgg_view_icon('speech-bubble-alt'), $link, array('class' => 'elgg-river-participation')); } echo elgg_view_annotation_list($comments, array('list_class' => 'elgg-river-comments', 'item_class' => 'elgg-river-participation')); } if ($object->canAnnotate(0, 'generic_comment')) { // inline comment form echo elgg_view_form('comments/add', array('id' => "comments-add-{$object->getGUID()}", 'class' => 'elgg-river-participation elgg-form-small'), array('entity' => $object, 'inline' => true)); }
} elseif ($solution_time < time() + 24 * 60 * 60) { $solution_class .= " question-solution-time-due"; } $answer_text .= "<span class='" . $solution_class . "'>" . elgg_view("output/date", array("value" => $question->solution_time)) . "</span>"; } if ($full) { $subtitle = "{$poster_text} {$date} {$answers_link} {$categories}"; $params = array("entity" => $question, "title" => false, "metadata" => $metadata, "subtitle" => $subtitle, "tags" => $tags); $list_body = elgg_view("object/elements/summary", $params); $list_body .= elgg_view("output/longtext", array("value" => $question->description)); $comment_count = $question->countComments(); $comment_options = array("guid" => $question->getGUID(), "annotation_name" => "generic_comment", "limit" => false); $comments = elgg_get_annotations($comment_options); if ($comments) { $list_body .= "<span class='elgg-river-comments-tab'>" . elgg_echo("comments") . "</span>"; $list_body .= elgg_view_annotation_list($comments, array("list_class" => "elgg-river-comments")); } // show a comment form like in the river $body_vars = array("entity" => $question, "inline" => true); $list_body .= "<div class='elgg-river-item hidden' id='comments-add-" . $question->getGUID() . "'>"; $list_body .= elgg_view_form("comments/add", array(), $body_vars); $list_body .= "</div>"; echo elgg_view_image_block($poster_icon, $list_body); } else { // brief view $title_text = ""; if ($question->getCorrectAnswer() && !$workflow) { $title_text = elgg_view_icon("checkmark", "mrs question-listing-checkmark"); } $title_text .= elgg_get_excerpt($question->title, 100); if ($workflow) {
* * @uses $vars['annotation'] */ $annotation = $vars['annotation']; $owner = get_entity($annotation->owner_guid); if (!$owner) { return true; } $icon = elgg_view_entity_icon($owner, 'tiny'); $owner_link = "<a href=\"{$owner->getURL()}\">{$owner->name}</a>"; $menu = elgg_view_menu('annotation', array('annotation' => $annotation, 'sort_by' => 'priority', 'class' => 'elgg-menu-hz float-alt')); $text = elgg_view("output/longtext", array("value" => elgg_echo('proposals:votes:' . $annotation->value))); $friendlytime = elgg_view_friendly_time($annotation->time_created); $options = array('guid' => $annotation->entity_guid, 'metastring_owner_guid' => $annotation->owner_guid, 'annotation_name' => 'vote_comments'); $comments = elgg_get_annotations($options); $total_comments = count($comments); if ($total_comments) { $comments_text = elgg_view_annotation_list($comments); } $body = <<<HTML <div class="mbn"> \t{$menu} \t{$owner_link} \t<span class="elgg-subtext"> \t\t{$friendlytime} \t</span> \t{$text} \t{$comments_text} </div> HTML; echo elgg_view_image_block($icon, $body);