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 //profile_side at networkpages
16 if($is_url = preg_match ("/\bnetwork\b/i", $_SERVER['REQUEST_URI'])) {
19 $nav['usermenu']=array();
26 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
29 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
30 'name' => $a->user['username'],
33 $ps['usermenu'][status] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
34 $ps['usermenu'][profile] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
35 $ps['usermenu'][photos] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
36 $ps['usermenu'][events] = Array('events/', t('Events'), "", t('Your events'));
37 $ps['usermenu'][notes] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
38 $ps['usermenu'][community] = Array('community/', t('Community'), "", "");
41 $tpl = get_markup_template('profile_side.tpl');
43 $a->page['aside'] .= replace_macros($tpl, array(
44 '$userinfo' => $userinfo,
50 //right_aside at networkpages
53 $aside['$lastusers_title'] = t('Last users');
54 $aside['$lastusers_items'] = array();
56 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
57 $order = " ORDER BY `register_date` DESC ";
59 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
60 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
61 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
65 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
69 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
70 $entry = replace_macros($tpl,array(
72 '$profile-link' => $profile_link,
73 '$photo' => $rr[$photo],
74 '$alt-text' => $rr['name'],
76 $aside['$lastusers_items'][] = $entry;
80 // last 10 liked items
81 $aside['$like_title'] = t('Last likes');
82 $aside['$like_items'] = array();
83 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
84 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
85 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
86 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
87 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
89 ORDER BY `T1`.`created` DESC
91 $a->get_baseurl(),$a->get_baseurl()
95 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
96 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
98 //var_dump($rr['verb'],$rr['object-type']); killme();
100 case 'http://activitystrea.ms/schema/1.0/post':
101 switch ($rr['object-type']){
102 case 'http://activitystrea.ms/schema/1.0/event':
103 $post_type = t('event');
106 $post_type = t('status');
110 if ($rr['resource-id']){
111 $post_type = t('photo');
112 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
113 $rr['plink'] = $m[1];
115 $post_type = t('status');
118 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
120 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
124 $aside['$photos_title'] = t('Last photos');
125 $aside['$photos_items'] = array();
126 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
127 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
128 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
129 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
130 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
132 WHERE `user`.`uid` = `photo`.`uid`
133 AND `user`.`blockwall`=0
134 ORDER BY `photo`.`edited` DESC
136 dbesc(t('Contact Photos')),
137 dbesc(t('Profile Photos'))
140 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
142 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
143 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
145 $entry = replace_macros($tpl,array(
147 '$profile-link' => $photo_page,
148 '$photo' => $photo_url,
149 '$alt-text' => $rr['username']." : ".$rr['desc'],
152 $aside['$photos_items'][] = $entry;
157 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
158 $a->page['right_aside'] = replace_macros($tpl, $aside);
162 //right_aside at profile pages
164 if($is_url = preg_match ("/\bprofile\b/i", $_SERVER['REQUEST_URI'])) {
168 $aside['$lastusers_title'] = t('Last users');
169 $aside['$lastusers_items'] = array();
171 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
172 $order = " ORDER BY `register_date` DESC ";
174 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
175 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
176 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
180 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
184 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
185 $entry = replace_macros($tpl,array(
187 '$profile-link' => $profile_link,
188 '$photo' => $rr[$photo],
189 '$alt-text' => $rr['name'],
191 $aside['$lastusers_items'][] = $entry;
195 // last 10 liked items
196 $aside['$like_title'] = t('Last likes');
197 $aside['$like_items'] = array();
198 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
199 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
200 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
201 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
202 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
204 ORDER BY `T1`.`created` DESC
206 $a->get_baseurl(),$a->get_baseurl()
209 foreach ($r as $rr) {
210 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
211 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
213 //var_dump($rr['verb'],$rr['object-type']); killme();
215 case 'http://activitystrea.ms/schema/1.0/post':
216 switch ($rr['object-type']){
217 case 'http://activitystrea.ms/schema/1.0/event':
218 $post_type = t('event');
221 $post_type = t('status');
225 if ($rr['resource-id']){
226 $post_type = t('photo');
227 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
228 $rr['plink'] = $m[1];
230 $post_type = t('status');
233 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
235 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
239 $aside['$photos_title'] = t('Last photos');
240 $aside['$photos_items'] = array();
241 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
242 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
243 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
244 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
245 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
247 WHERE `user`.`uid` = `photo`.`uid`
248 AND `user`.`blockwall`=0
249 ORDER BY `photo`.`edited` DESC
251 dbesc(t('Contact Photos')),
252 dbesc(t('Profile Photos'))
255 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
257 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
258 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
260 $entry = replace_macros($tpl,array(
262 '$profile-link' => $photo_page,
263 '$photo' => $photo_url,
264 '$alt-text' => $rr['username']." : ".$rr['desc'],
267 $aside['$photos_items'][] = $entry;
272 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
273 $a->page['right_aside'] = replace_macros($tpl, $aside);
278 $a->page['htmlhead'] .= <<< EOT
283 $('html').click(function() {
284 $('#nav-contacts-linkmenu').removeClass('selected');
285 document.getElementById( "nav-contacts-menu" ).style.display = "none";
288 $('#nav-contacts-linkmenu').click(function(event){
289 event.stopPropagation();
293 $('html').click(function() {
294 $('#nav-messages-linkmenu').removeClass('selected');
295 document.getElementById( "nav-messages-menu" ).style.display = "none";
298 $('#nav-messages-linkmenu').click(function(event){
299 event.stopPropagation();
303 $('html').click(function() {
304 $('#nav-notifications-linkmenu').removeClass('selected');
305 document.getElementById( "nav-notifications-menu" ).style.display = "none";
308 $('#nav-notifications-linkmenu').click(function(event){
309 event.stopPropagation();
313 $('html').click(function() {
314 $('#nav-user-linkmenu').removeClass('selected');
315 document.getElementById( "nav-user-menu" ).style.display = "none";
318 $('#nav-user-linkmenu').click(function(event){
319 event.stopPropagation();
323 $('html').click(function() {
324 $('#nav-site-linkmenu').removeClass('selected');
325 document.getElementById( "nav-site-menu" ).style.display = "none";
328 $('#nav-site-linkmenu').click(function(event){
329 event.stopPropagation();
332 $('html').click(function() {
333 $('#nav-apps-link').removeClass('selected');
334 document.getElementById( "nav-apps-menu" ).style.display = "none";
337 $('#nav-apps-link').click(function(event){
338 event.stopPropagation();
342 $('a.lightbox').fancybox(); // Select all links with lightbox class