2012-03-23 08:18:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Page
|
2012-03-24 10:29:17 +00:00
|
|
|
* Description: Shows lists of community pages (improved performance over 'pages')
|
2012-03-23 08:18:45 +00:00
|
|
|
* Version: 1.0
|
|
|
|
* Author: Mike Macgirvin <mike@macgirvin.com>
|
|
|
|
* based on pages plugin by
|
|
|
|
* Author: Michael Vogel <ike@piratenpartei.de>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
function page_install() {
|
|
|
|
register_hook('page_end', 'addon/page/page.php', 'page_page_end');
|
|
|
|
}
|
|
|
|
|
|
|
|
function page_uninstall() {
|
|
|
|
unregister_hook('page_end', 'addon/page/page.php', 'page_page_end');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function page_getpage($uid) {
|
|
|
|
|
|
|
|
|
|
|
|
$pagelist = array();
|
|
|
|
|
2012-03-23 08:44:24 +00:00
|
|
|
$contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
|
2012-05-03 01:11:53 +00:00
|
|
|
WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
|
|
|
|
order by name asc ",
|
2012-03-23 08:18:45 +00:00
|
|
|
intval($uid)
|
|
|
|
);
|
|
|
|
|
|
|
|
$page = array();
|
|
|
|
|
|
|
|
// Look if the profile is a community page
|
|
|
|
foreach($contacts as $contact) {
|
2012-03-23 08:44:24 +00:00
|
|
|
$page[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
|
2012-03-23 08:18:45 +00:00
|
|
|
}
|
|
|
|
return($page);
|
|
|
|
}
|
|
|
|
|
|
|
|
function page_page_end($a,&$b) {
|
|
|
|
// Only move on if if it's the "network" module and there is a logged on user
|
|
|
|
if (($a->module != "network") OR ($a->user['uid'] == 0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
$page = '<div id="page-sidebar" class="widget">
|
|
|
|
<div class="title tool">
|
2012-03-30 12:35:55 +00:00
|
|
|
<h3>'.t("Forums").'</h3></div>
|
2012-03-23 08:18:45 +00:00
|
|
|
<div id="sidebar-page-list"><ul>';
|
|
|
|
|
2012-05-03 03:33:45 +00:00
|
|
|
|
2012-03-23 08:18:45 +00:00
|
|
|
$contacts = page_getpage($a->user['uid']);
|
|
|
|
|
2012-05-03 03:33:45 +00:00
|
|
|
$total_shown = 0;
|
|
|
|
$more = false;
|
|
|
|
|
2012-03-23 08:18:45 +00:00
|
|
|
foreach($contacts as $contact) {
|
2012-03-24 10:29:17 +00:00
|
|
|
$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">'.
|
2012-03-23 08:18:45 +00:00
|
|
|
$contact["name"]."</a></li>";
|
2012-05-03 03:33:45 +00:00
|
|
|
$total_shown ++;
|
|
|
|
if($total_shown == 6) {
|
|
|
|
$more = true;
|
|
|
|
$page .= '</ul><div id="hide-comments-page-widget" class="fakelink" onclick="showHideComments(\'page-widget\');" >' . t('show more')
|
|
|
|
. '</div><div id="collapsed-comments-page-widget" style="display: none;" ><ul>';
|
|
|
|
}
|
2012-03-23 08:18:45 +00:00
|
|
|
}
|
2012-05-03 03:33:45 +00:00
|
|
|
if($more)
|
|
|
|
$page .= '</div>';
|
2012-03-23 08:18:45 +00:00
|
|
|
$page .= "</ul></div></div>";
|
|
|
|
if (sizeof($contacts) > 0)
|
|
|
|
$a->page['aside'] = $page . $a->page['aside'];
|
|
|
|
}
|
2012-05-03 01:11:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|