aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Suggestions.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-15 18:31:34 -0700
committerzotlabs <mike@macgirvin.com>2017-03-15 18:31:34 -0700
commit9cb9608209ab5f9fb123acc82a563ba54c450db1 (patch)
treecac1d07e7d04498ed2a555b3d8c3e89cd51b2634 /Zotlabs/Widget/Suggestions.php
parentb20062efa6052e29b8d2d2a42ca966837db1c29f (diff)
downloadvolse-hubzilla-9cb9608209ab5f9fb123acc82a563ba54c450db1.tar.gz
volse-hubzilla-9cb9608209ab5f9fb123acc82a563ba54c450db1.tar.bz2
volse-hubzilla-9cb9608209ab5f9fb123acc82a563ba54c450db1.zip
convert more widgets to classes
Diffstat (limited to 'Zotlabs/Widget/Suggestions.php')
-rw-r--r--Zotlabs/Widget/Suggestions.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Suggestions.php b/Zotlabs/Widget/Suggestions.php
new file mode 100644
index 000000000..5fb3d3e8b
--- /dev/null
+++ b/Zotlabs/Widget/Suggestions.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+require_once('include/socgraph.php');
+
+
+class Suggestions {
+
+ function widget($arr) {
+
+ if((! local_channel()) || (! feature_enabled(local_channel(),'suggest')))
+ return '';
+
+
+ $r = suggestion_query(local_channel(),get_observer_hash(),0,20);
+
+ if(! $r) {
+ return;
+ }
+
+ $arr = array();
+
+ // Get two random entries from the top 20 returned.
+ // We'll grab the first one and the one immediately following.
+ // This will throw some entropy intot he situation so you won't
+ // be looking at the same two mug shots every time the widget runs
+
+ $index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
+
+ for($x = $index; $x <= ($index+1); $x ++) {
+ $rr = $r[$x];
+ if(! $rr['xchan_url'])
+ break;
+
+ $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
+
+ $arr[] = array(
+ 'url' => chanlink_url($rr['xchan_url']),
+ 'profile' => $rr['xchan_url'],
+ 'name' => $rr['xchan_name'],
+ 'photo' => $rr['xchan_photo_m'],
+ 'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'],
+ 'conntxt' => t('Connect'),
+ 'connlnk' => $connlnk,
+ 'ignore' => t('Ignore/Hide')
+ );
+ }
+
+ $o = replace_macros(get_markup_template('suggest_widget.tpl'),array(
+ '$title' => t('Suggestions'),
+ '$more' => t('See more...'),
+ '$entries' => $arr
+ ));
+
+ return $o;
+ }
+}