]> git.mxchange.org Git - friendica.git/blob - mod/allfriends.php
template-rework: let common friends and allfriends use viewcontact_template.tpl
[friendica.git] / mod / allfriends.php
1 <?php
2
3 require_once('include/socgraph.php');
4
5 function allfriends_content(&$a) {
6
7         $o = '';
8         if(! local_user()) {
9                 notice( t('Permission denied.') . EOL);
10                 return;
11         }
12
13         if($a->argc > 1)
14                 $cid = intval($a->argv[1]);
15
16         if(! $cid)
17                 return;
18
19         $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
20                 intval($cid),
21                 intval(local_user())
22         );
23
24         $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
25                 '$name'  => htmlentities($c[0]['name']),
26                 '$photo' => $c[0]['photo'],
27                 'url'    => z_root() . '/contacts/' . $cid
28         ));
29
30         if(! x($a->page,'aside'))
31                 $a->page['aside'] = '';
32         $a->page['aside'] .= $vcard_widget;
33
34         if(! count($c))
35                 return;
36
37
38         $r = all_friends(local_user(),$cid);
39
40         if(! count($r)) {
41                 $o .= t('No friends to display.');
42                 return $o;
43         }
44
45         $id = 0;
46
47         foreach($r as $rr) {
48
49                 $entry = array(
50                         'url' => $rr['url'],
51                         'itemurl' => $rr['url'],
52                         'name' => htmlentities($rr['name']),
53                         'thumb' => $rr['photo'],
54                         'img_hover' => htmlentities($rr['name']),
55                         'tags' => '',
56                         'id' => ++$id,
57                 );
58                 $entries[] = $entry;
59         }
60
61         $tpl = get_markup_template('viewcontact_template.tpl');
62
63         $o .= replace_macros($tpl,array(
64                 '$title' => sprintf( t('Friends of %s'), htmlentities($c[0]['name'])),
65                 '$contacts' => $entries,
66         ));
67
68 //      $o .= paginate($a);
69         return $o;
70 }