]> git.mxchange.org Git - friendica-addons.git/blob - page/page.php
584ac55647f4d70f6dcb424899b85220d098596d
[friendica-addons.git] / page / page.php
1 <?php
2 /**
3  * Name: Page
4  * Description: Shows lists of community pages (improved performance over 'pages)
5  * Version: 1.0
6  * Author: Mike Macgirvin <mike@macgirvin.com>
7  * based on pages plugin by
8  * Author: Michael Vogel <ike@piratenpartei.de>
9  *
10  */
11
12 function page_install() {
13         register_hook('page_end', 'addon/page/page.php', 'page_page_end');
14 }
15
16 function page_uninstall() {
17         unregister_hook('page_end', 'addon/page/page.php', 'page_page_end');
18 }
19
20
21 function page_getpage($uid) {
22
23
24         $pagelist = array();
25
26         $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
27                         WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d",
28                         intval($uid)
29         );
30
31         $page = array();
32
33         // Look if the profile is a community page
34         foreach($contacts as $contact) {
35                 $page[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
36         }
37         return($page);
38 }
39
40 function page_page_end($a,&$b) {
41         // Only move on if if it's the "network" module and there is a logged on user
42         if (($a->module != "network") OR ($a->user['uid'] == 0))
43                 return;
44
45         $page = '<div id="page-sidebar" class="widget">
46                         <div class="title tool">
47                         <h3>'.t("Community Pages").'</h3></div>
48                         <div id="sidebar-page-list"><ul>';
49
50         $contacts = page_getpage($a->user['uid']);
51
52         foreach($contacts as $contact) {
53                 $page .= '<li style="list-style-type: none;" class="tool"><img height="16" width="16" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" class="label" target="external-link">'.
54                                 $contact["name"]."</a></li>";
55         }
56         $page .= "</ul></div></div>";
57         if (sizeof($contacts) > 0)
58                 $a->page['aside'] = $page . $a->page['aside'];
59 }
60 ?>