aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Suggestions.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-15 18:31:34 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 11:47:58 +0200
commit477ed97c2fbfff903f9ebf0ffa7fba078eeac10f (patch)
tree4f7f44aaa5d64c67f3959d196c8c55ae100c79e0 /Zotlabs/Widget/Suggestions.php
parent242ef70a775a86050152c0aea9096ec1cd6d0312 (diff)
downloadvolse-hubzilla-477ed97c2fbfff903f9ebf0ffa7fba078eeac10f.tar.gz
volse-hubzilla-477ed97c2fbfff903f9ebf0ffa7fba078eeac10f.tar.bz2
volse-hubzilla-477ed97c2fbfff903f9ebf0ffa7fba078eeac10f.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;
+ }
+}