5 * Description: Diabook: report bugs and request here: http://pad.toktan.org/p/diabook or contact me : thomas_bierey@friendica.eu
10 $a->theme_info = array(
11 'extends' => 'diabook',
14 //change css on network and profilepages
19 * prints last community activity
24 function diabook_community_info(){
26 //right_aside at networkpages
29 $aside['$lastusers_title'] = t('Last users');
30 $aside['$lastusers_items'] = array();
32 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
33 $order = " ORDER BY `register_date` DESC ";
35 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
36 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
37 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
41 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
45 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
46 $entry = replace_macros($tpl,array(
48 '$profile-link' => $profile_link,
49 '$photo' => $rr[$photo],
50 '$alt-text' => $rr['name'],
52 $aside['$lastusers_items'][] = $entry;
57 // last 10 liked items
58 $aside['$like_title'] = t('Last likes');
59 $aside['$like_items'] = array();
60 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
61 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
62 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
63 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
64 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
66 ORDER BY `T1`.`created` DESC
68 $a->get_baseurl(),$a->get_baseurl()
72 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
73 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
75 //var_dump($rr['verb'],$rr['object-type']); killme();
77 case 'http://activitystrea.ms/schema/1.0/post':
78 switch ($rr['object-type']){
79 case 'http://activitystrea.ms/schema/1.0/event':
80 $post_type = t('event');
83 $post_type = t('status');
87 if ($rr['resource-id']){
88 $post_type = t('photo');
89 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
92 $post_type = t('status');
95 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
97 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
103 $aside['$photos_title'] = t('Last photos');
104 $aside['$photos_items'] = array();
105 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
106 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
107 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
108 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
109 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
111 WHERE `user`.`uid` = `photo`.`uid`
112 AND `user`.`blockwall`=0
113 AND `user`.`hidewall`=0
114 ORDER BY `photo`.`edited` DESC
116 dbesc(t('Contact Photos')),
117 dbesc(t('Profile Photos'))
120 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
122 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
123 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
125 $entry = replace_macros($tpl,array(
127 '$profile-link' => $photo_page,
128 '$photo' => $photo_url,
129 '$alt-text' => $rr['username']." : ".$rr['desc'],
132 $aside['$photos_items'][] = $entry;
136 $fostitJS = "javascript: (function() {
137 the_url = '".$a->get_baseurl($ssl_state)."/view/theme/diabook/fpostit/fpostit.php?url=' + encodeURIComponent(window.location.href) + '&title=' + encodeURIComponent(document.title) + '&text=' + encodeURIComponent(''+(window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text));
138 a_funct = function() {
139 if (!window.open(the_url, 'fpostit', 'location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300')) location.href = the_url};
140 if (/Firefox/.test(navigator.userAgent)) {setTimeout(a_funct, 0)}
141 else {a_funct()}})()" ;
143 $aside['$fostitJS'] = $fostitJS;
146 $page = '<div id="page-sidebar-right_aside" class="widget">
147 <div class="title tool">
148 <h3>'.t("Community Pages").'</h3></div>
149 <div id="sidebar-page-list"><ul>';
153 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
154 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d",
155 intval($a->user['uid'])
160 // Look if the profile is a community page
161 foreach($contacts as $contact) {
162 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
168 foreach($contacts as $contact) {
169 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" style="margin-top: 2px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
170 $contact["name"]."</a></li>";
172 $page .= '</ul></div></div>';
173 if (sizeof($contacts) > 0)
175 $aside['$page'] = $page;
179 $url = $a->get_baseurl($ssl_state);
180 $aside['$url'] = $url;
182 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
183 $a->page['right_aside'] = replace_macros($tpl, $aside);
191 //profile_side at networkpages
192 if ($a->argv[0] === "network" && local_user()){
197 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
200 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
201 'name' => $a->user['username'],
203 $ps = array('usermenu'=>array());
204 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
205 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
206 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
207 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
208 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
209 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
210 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Public Groups'), "", "");
212 $tpl = get_markup_template('profile_side.tpl');
214 $a->page['aside'] .= replace_macros($tpl, array(
215 '$userinfo' => $userinfo,
222 diabook_community_info();
225 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-network.css";
231 //right_aside at profile pages
232 if ($a->argv[0] === "profile"){
235 diabook_community_info();
238 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-profile.css";
244 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
248 $a->page['htmlhead'] .= <<< EOT
252 $('a.lightbox').fancybox(); // Select all links with lightbox class