diff options
Diffstat (limited to 'views/default/river/elements')
-rw-r--r-- | views/default/river/elements/body.php | 67 | ||||
-rw-r--r-- | views/default/river/elements/image.php | 16 | ||||
-rw-r--r-- | views/default/river/elements/layout.php | 14 | ||||
-rw-r--r-- | views/default/river/elements/responses.php | 63 | ||||
-rw-r--r-- | views/default/river/elements/summary.php | 53 |
5 files changed, 213 insertions, 0 deletions
diff --git a/views/default/river/elements/body.php b/views/default/river/elements/body.php new file mode 100644 index 000000000..2cd7f2289 --- /dev/null +++ b/views/default/river/elements/body.php @@ -0,0 +1,67 @@ +<?php +/** + * Body of river item + * + * @uses $vars['item'] ElggRiverItem + * @uses $vars['summary'] Alternate summary (the short text summary of action) + * @uses $vars['message'] Optional message (usually excerpt of text) + * @uses $vars['attachments'] Optional attachments (displaying icons or other non-text data) + * @uses $vars['responses'] Alternate respones (comments, replies, etc.) + */ + +$item = $vars['item']; + +$menu = elgg_view_menu('river', array( + 'item' => $item, + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); + +// river item header +$timestamp = elgg_view_friendly_time($item->getPostedTime()); + +$summary = elgg_extract('summary', $vars, elgg_view('river/elements/summary', array('item' => $vars['item']))); +if ($summary === false) { + $subject = $item->getSubjectEntity(); + $summary = elgg_view('output/url', array( + 'href' => $subject->getURL(), + 'text' => $subject->name, + 'class' => 'elgg-river-subject', + 'is_trusted' => true, + )); +} + +$message = elgg_extract('message', $vars, false); +if ($message !== false) { + $message = "<div class=\"elgg-river-message\">$message</div>"; +} + +$attachments = elgg_extract('attachments', $vars, false); +if ($attachments !== false) { + $attachments = "<div class=\"elgg-river-attachments clearfix\">$attachments</div>"; +} + +$responses = elgg_view('river/elements/responses', $vars); +if ($responses) { + $responses = "<div class=\"elgg-river-responses\">$responses</div>"; +} + +$group_string = ''; +$object = $item->getObjectEntity(); +$container = $object->getContainerEntity(); +if ($container instanceof ElggGroup && $container->guid != elgg_get_page_owner_guid()) { + $group_link = elgg_view('output/url', array( + 'href' => $container->getURL(), + 'text' => $container->name, + 'is_trusted' => true, + )); + $group_string = elgg_echo('river:ingroup', array($group_link)); +} + +echo <<<RIVER +$menu +<div class="elgg-river-summary">$summary $group_string <span class="elgg-river-timestamp">$timestamp</span></div> +$message +$attachments +$responses +RIVER; diff --git a/views/default/river/elements/image.php b/views/default/river/elements/image.php new file mode 100644 index 000000000..6f6aeae65 --- /dev/null +++ b/views/default/river/elements/image.php @@ -0,0 +1,16 @@ +<?php +/** + * Elgg river image + * + * Displayed next to the body of each river item + * + * @uses $vars['item'] + */ + +$subject = $vars['item']->getSubjectEntity(); + +if (elgg_in_context('widgets')) { + echo elgg_view_entity_icon($subject, 'tiny'); +} else { + echo elgg_view_entity_icon($subject, 'small'); +} diff --git a/views/default/river/elements/layout.php b/views/default/river/elements/layout.php new file mode 100644 index 000000000..94622e272 --- /dev/null +++ b/views/default/river/elements/layout.php @@ -0,0 +1,14 @@ +<?php +/** + * Layout of a river item + * + * @uses $vars['item'] ElggRiverItem + */ + +$item = $vars['item']; + +echo elgg_view('page/components/image_block', array( + 'image' => elgg_view('river/elements/image', $vars), + 'body' => elgg_view('river/elements/body', $vars), + 'class' => 'elgg-river-item', +)); diff --git a/views/default/river/elements/responses.php b/views/default/river/elements/responses.php new file mode 100644 index 000000000..f6c32e142 --- /dev/null +++ b/views/default/river/elements/responses.php @@ -0,0 +1,63 @@ +<?php +/** + * River item footer + * + * @uses $vars['item'] ElggRiverItem + * @uses $vars['responses'] Alternate override for this item + */ + +// allow river views to override the response content +$responses = elgg_extract('responses', $vars, false); +if ($responses) { + echo $responses; + return true; +} + +$item = $vars['item']; +$object = $item->getObjectEntity(); + +// annotations do not have comments +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)), + 'is_trusted' => true, + ); + $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); diff --git a/views/default/river/elements/summary.php b/views/default/river/elements/summary.php new file mode 100644 index 000000000..416bc708b --- /dev/null +++ b/views/default/river/elements/summary.php @@ -0,0 +1,53 @@ +<?php +/** + * Short summary of the action that occurred + * + * @vars['item'] ElggRiverItem + */ + +$item = $vars['item']; + +$subject = $item->getSubjectEntity(); +$object = $item->getObjectEntity(); +$target = $object->getContainerEntity(); + +$subject_link = elgg_view('output/url', array( + 'href' => $subject->getURL(), + 'text' => $subject->name, + 'class' => 'elgg-river-subject', + 'is_trusted' => true, +)); + +$object_link = elgg_view('output/url', array( + 'href' => $object->getURL(), + 'text' => $object->title ? $object->title : $object->name, + 'class' => 'elgg-river-object', + 'is_trusted' => true, +)); + +$action = $item->action_type; +$type = $item->type; +$subtype = $item->subtype ? $item->subtype : 'default'; + +$container = $object->getContainerEntity(); +if ($container instanceof ElggGroup) { + $params = array( + 'href' => $container->getURL(), + 'text' => $container->name, + 'is_trusted' => true, + ); + $group_link = elgg_view('output/url', $params); + $group_string = elgg_echo('river:ingroup', array($group_link)); +} + +// check summary translation keys. +// will use the $type:$subtype if that's defined, otherwise just uses $type:default +$key = "river:$action:$type:$subtype"; +$summary = elgg_echo($key, array($subject_link, $object_link)); + +if ($summary == $key) { + $key = "river:$action:$type:default"; + $summary = elgg_echo($key, array($subject_link, $object_link)); +} + +echo $summary;
\ No newline at end of file |