aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/river.php2
-rw-r--r--languages/en.php7
-rw-r--r--views/default/widgets/river_widget/content.php27
-rw-r--r--views/default/widgets/river_widget/edit.php45
4 files changed, 81 insertions, 0 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index c0100bb81..50663c966 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -534,6 +534,8 @@ function elgg_river_init() {
elgg_register_page_handler('activity', 'elgg_river_page_handler');
$item = new ElggMenuItem('activity', elgg_echo('activity'), 'activity');
elgg_register_menu_item('site', $item);
+
+ add_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/languages/en.php b/languages/en.php
index 6ccdbaecb..ab4abc00b 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -411,6 +411,13 @@ $english = array(
'riveritem:single:user' => 'a user',
'riveritem:plural:user' => 'some users',
'river:ingroup' => 'to the group %s',
+ 'river:none' => 'No activity',
+
+ 'river:widget:title' => "Activity",
+ 'river:widget:description' => "Display latest activity",
+ 'river:widget:type' => "Type of activity",
+ 'river:widgets:friends' => 'Friends activity',
+ 'river:widgets:all' => 'All site activity',
/**
* Notifications
diff --git a/views/default/widgets/river_widget/content.php b/views/default/widgets/river_widget/content.php
new file mode 100644
index 000000000..427fd92bf
--- /dev/null
+++ b/views/default/widgets/river_widget/content.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Activity widget content view
+ */
+
+$num = (int) $vars['entity']->num_display;
+
+$options = array(
+ 'limit' => $num,
+ 'pagination' => false,
+);
+
+if (elgg_in_context('profile')) {
+ $options['subject_guid'] = elgg_get_page_owner_guid();
+} else {
+ if ($vars['entity']->content_type == 'friends') {
+ $options['relationship_guid'] = elgg_get_logged_in_user_guid();
+ $options['relationship'] = 'friend';
+ }
+}
+
+$content = elgg_list_river($options);
+if (!$content) {
+ $content = elgg_echo('river:none');
+}
+
+echo $content;
diff --git a/views/default/widgets/river_widget/edit.php b/views/default/widgets/river_widget/edit.php
new file mode 100644
index 000000000..e0351e883
--- /dev/null
+++ b/views/default/widgets/river_widget/edit.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Edit settings for river widget
+ */
+
+// dashboard widget has type parameter
+if (elgg_in_context('dashboard')) {
+ if (!isset($vars['entity']->content_type)) {
+ $vars['entity']->content_type = 'friends';
+ }
+ $params = array(
+ 'name' => 'params[content_type]',
+ 'value' => $vars['entity']->content_type,
+ 'options_values' => array(
+ 'friends' => elgg_echo('river:widgets:friends'),
+ 'all' => elgg_echo('river:widgets:all'),
+ ),
+ );
+ $type_dropdown = elgg_view('input/dropdown', $params);
+ ?>
+ <div>
+ <?php echo elgg_echo('river:widget:type'); ?>:
+ <?php echo $type_dropdown; ?>
+ </div>
+ <?php
+}
+
+
+// set default value for number to display
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 8;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(5, 8, 10, 12, 15, 20),
+);
+$num_dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<div>
+ <?php echo elgg_echo('widget:numbertodisplay'); ?>:
+ <?php echo $num_dropdown; ?>
+</div>