]> git.mxchange.org Git - friendica-addons.git/blob - page/page.php
Smileypack - fix multilingual regex headache.
[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                         order by name asc ",
29                         intval($uid)
30         );
31
32         $page = array();
33
34         // Look if the profile is a community page
35         foreach($contacts as $contact) {
36                 $page[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
37         }
38         return($page);
39 }
40
41 function page_page_end($a,&$b) {
42         // Only move on if if it's the "network" module and there is a logged on user
43         if (($a->module != "network") OR ($a->user['uid'] == 0))
44                 return;
45
46         $page = '<div id="page-sidebar" class="widget">
47                         <div class="title tool">
48                         <h3>'.t("Forums").'</h3></div>
49                         <div id="sidebar-page-list"><ul>';
50
51
52         $contacts = page_getpage($a->user['uid']);
53
54         $total_shown = 0;
55         $more = false;
56
57         foreach($contacts as $contact) {
58                 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" title="' . $contact['url'] . '" class="label" target="external-link">'.
59                                 $contact["name"]."</a></li>";
60                 $total_shown ++;
61                 if($total_shown == 6) {
62                         $more = true;
63                         $page .= '</ul><div id="hide-comments-page-widget" class="fakelink" onclick="showHideComments(\'page-widget\');" >' . t('show more') 
64                                 . '</div><div id="collapsed-comments-page-widget" style="display: none;" ><ul>';
65                 } 
66         }
67         if($more)
68                 $page .= '</div>';
69         $page .= "</ul></div></div>";
70         if (sizeof($contacts) > 0)
71                 $a->page['aside'] = $page . $a->page['aside'];
72 }
73
74
75