From fa93114804801bceabea06570e8eee602167600a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 3 Oct 2017 11:37:45 +0200 Subject: some basic work on mod common --- Zotlabs/Module/Common.php | 31 +++++++++++++++---------------- view/tpl/common_friends.tpl | 24 +++++++++++++----------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Zotlabs/Module/Common.php b/Zotlabs/Module/Common.php index 2f3c57267..eebc56d2b 100644 --- a/Zotlabs/Module/Common.php +++ b/Zotlabs/Module/Common.php @@ -25,7 +25,7 @@ class Common extends \Zotlabs\Web\Controller { } - function get() { + function get() { $o = ''; @@ -34,38 +34,37 @@ class Common extends \Zotlabs\Web\Controller { $observer_hash = get_observer_hash(); - if(! perm_is_allowed(\App::$profile['profile_uid'],$observer_hash,'view_contacts')) { notice( t('Permission denied.') . EOL); return; } - $o .= '

' . t('Common connections') . '

'; - $t = count_common_friends(\App::$profile['profile_uid'],$observer_hash); if(! $t) { notice( t('No connections in common.') . EOL); - return $o; + return; } $r = common_friends(\App::$profile['profile_uid'],$observer_hash); if($r) { - - $tpl = get_markup_template('common_friends.tpl'); - foreach($r as $rr) { - $o .= replace_macros($tpl,array( - '$url' => $rr['xchan_url'], - '$name' => $rr['xchan_name'], - '$photo' => $rr['xchan_photo_m'], - '$tags' => '' - )); + $items[] = [ + 'url' => $rr['xchan_url'], + 'name' => $rr['xchan_name'], + 'photo' => $rr['xchan_photo_m'], + 'tags' => '' + ]; } - - $o .= cleardiv(); } + + $tpl = get_markup_template('common_friends.tpl'); + + $o = replace_macros($tpl, [ + '$title' => t('View Common Connections'), + '$items' => $items + ]); return $o; } diff --git a/view/tpl/common_friends.tpl b/view/tpl/common_friends.tpl index fa2cf5a13..b99075210 100755 --- a/view/tpl/common_friends.tpl +++ b/view/tpl/common_friends.tpl @@ -1,15 +1,17 @@
-
- - {{$name}} - +
+

{{$title}}

-
-
- {{$name}} +
+ {{foreach $items as $item}} +
+ + {{$item.name}} + +
+ {{$item.name}} +
+
+ {{/foreach}}
- {{if $note}} -
{{$note}}
- {{/if}} -
-- cgit v1.2.3