aboutsummaryrefslogtreecommitdiff
path: root/views/default/widgets/friends
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/widgets/friends')
-rw-r--r--views/default/widgets/friends/content.php25
-rw-r--r--views/default/widgets/friends/edit.php52
2 files changed, 77 insertions, 0 deletions
diff --git a/views/default/widgets/friends/content.php b/views/default/widgets/friends/content.php
new file mode 100644
index 000000000..98814c244
--- /dev/null
+++ b/views/default/widgets/friends/content.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Friend widget display view
+ *
+ */
+
+// owner of the widget
+$owner = $vars['entity']->getOwnerEntity();
+
+// the number of friends to display
+$num = (int) $vars['entity']->num_display;
+
+// get the correct size
+$size = $vars['entity']->icon_size;
+
+if (elgg_instanceof($owner, 'user')) {
+ $html = $owner->listFriends('', $num, array(
+ 'size' => $size,
+ 'list_type' => 'gallery',
+ 'pagination' => false
+ ));
+ if ($html) {
+ echo $html;
+ }
+}
diff --git a/views/default/widgets/friends/edit.php b/views/default/widgets/friends/edit.php
new file mode 100644
index 000000000..c7e6b06ff
--- /dev/null
+++ b/views/default/widgets/friends/edit.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Friend widget options
+ *
+ */
+
+// set default value for display number
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 12;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 50, 100),
+);
+$display_dropdown = elgg_view('input/dropdown', $params);
+
+
+// handle upgrade to 1.7.2 from previous versions
+if ($vars['entity']->icon_size == 1) {
+ $vars['entity']->icon_size = 'small';
+} elseif ($vars['entity']->icon_size == 2) {
+ $vars['entity']->icon_size = 'tiny';
+}
+
+// set default value for icon size
+if (!isset($vars['entity']->icon_size)) {
+ $vars['entity']->icon_size = 'small';
+}
+
+$params = array(
+ 'name' => 'params[icon_size]',
+ 'value' => $vars['entity']->icon_size,
+ 'options_values' => array(
+ 'small' => elgg_echo('friends:small'),
+ 'tiny' => elgg_echo('friends:tiny'),
+ ),
+);
+$size_dropdown = elgg_view('input/dropdown', $params);
+
+
+?>
+<p>
+ <?php echo elgg_echo('friends:num_display'); ?>:
+ <?php echo $display_dropdown; ?>
+</p>
+
+<p>
+ <?php echo elgg_echo('friends:icon_size'); ?>:
+ <?php echo $size_dropdown; ?>
+</p>