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' => 'duepuntozero',
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;
145 //right_aside FIND FRIENDS
148 $nv['directory'] = Array('directory', t('Directory'), "", "");
149 $nv['match'] = Array('match', t('Similar Interests'), "", "");
150 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
151 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
153 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
154 <span class="sbox_l"></span>
156 <input type="text" name="search" size="13" maxlength="50">
158 <span class="sbox_r" id="srch_clear"></span>';
165 $page = '<div id="page-sidebar-right_aside" class="widget">
166 <div class="title tool">
167 <h3>'.t("Community Pages").'<a id="close_pages_icon" onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
168 <div id="sidebar-page-list"><ul>';
172 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
173 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d",
174 intval($a->user['uid'])
179 // Look if the profile is a community page
180 foreach($contacts as $contact) {
181 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
187 foreach($contacts as $contact) {
188 $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">'.
189 $contact["name"]."</a></li>";
191 $page .= '</ul></div></div>';
192 //if (sizeof($contacts) > 0)
194 $aside['$page'] = $page;
199 $url = $a->get_baseurl($ssl_state);
200 $aside['$url'] = $url;
202 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
203 $a->page['right_aside'] = replace_macros($tpl, $aside);
211 //profile_side at networkpages
212 if ($a->argv[0] === "network" && local_user()){
217 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
220 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
221 'name' => $a->user['username'],
223 $ps = array('usermenu'=>array());
224 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
225 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
226 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));
227 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
228 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
229 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
230 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
231 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", "");
233 $tpl = get_markup_template('profile_side.tpl');
235 $a->page['aside'] .= replace_macros($tpl, array(
236 '$userinfo' => $userinfo,
242 $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_postit'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes'];
244 if($ccCookie != "8") {
246 diabook_community_info();
249 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-network.css";
255 //right_aside at profile pages
256 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
257 if($ccCookie != "8") {
259 diabook_community_info();
262 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-profile.css";
268 //tabs at right_aside on settings page
269 if ($a->argv[0] === "settings"){
273 'label' => t('Account settings'),
274 'url' => $a->get_baseurl(true).'/settings',
275 'sel' => (($a->argc == 1)?'active':''),
278 'label' => t('Display settings'),
279 'url' => $a->get_baseurl(true).'/settings/display',
280 'sel' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
283 'label' => t('Edit/Manage Profiles'),
284 'url' => $a->get_baseurl(true).'/profiles',
287 'label' => t('Connector settings'),
288 'url' => $a->get_baseurl(true).'/settings/connectors',
289 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
292 'label' => t('Plugin settings'),
293 'url' => $a->get_baseurl(true).'/settings/addon',
294 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
297 'label' => t('Connections'),
298 'url' => $a->get_baseurl(true) . '/settings/oauth',
299 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
302 'label' => t('Export personal data'),
303 'url' => $a->get_baseurl(true) . '/uexport',
307 $tabtpl = file_get_contents(dirname(__file__).'/rs_common_tabs.tpl') ;
308 $a->page['aside'] = replace_macros($tabtpl, array(
314 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-settings.css";
319 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
321 //load jquery.cookie.js
322 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/js/jquery.cookie.js";
323 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" />', $cookieJS);
327 $a->page['htmlhead'] .= <<< EOT
331 $('a.lightbox').fancybox(); // Select all links with lightbox class
338 $("right_aside").ready(function(){
340 if($.cookie('close_pages') == '1')
342 document.getElementById( "close_pages" ).style.display = "none";
345 if($.cookie('close_helpers') == '1')
347 document.getElementById( "close_helpers" ).style.display = "none";
350 if($.cookie('close_services') == '1')
352 document.getElementById( "close_services" ).style.display = "none";
355 if($.cookie('close_friends') == '1')
357 document.getElementById( "close_friends" ).style.display = "none";
360 if($.cookie('close_postit') == '1')
362 document.getElementById( "close_postit" ).style.display = "none";
365 if($.cookie('close_lastusers') == '1')
367 document.getElementById( "close_lastusers" ).style.display = "none";
370 if($.cookie('close_lastphotos') == '1')
372 document.getElementById( "close_lastphotos" ).style.display = "none";
375 if($.cookie('close_lastlikes') == '1')
377 document.getElementById( "close_lastlikes" ).style.display = "none";
382 function close_pages(){
383 document.getElementById( "close_pages" ).style.display = "none";
384 $.cookie('close_pages','1', { expires: 365, path: '/' });
387 function close_helpers(){
388 document.getElementById( "close_helpers" ).style.display = "none";
389 $.cookie('close_helpers','1', { expires: 365, path: '/' });
392 function close_services(){
393 document.getElementById( "close_services" ).style.display = "none";
394 $.cookie('close_services','1', { expires: 365, path: '/' });
397 function close_friends(){
398 document.getElementById( "close_friends" ).style.display = "none";
399 $.cookie('close_friends','1', { expires: 365, path: '/' });
402 function close_postit(){
403 document.getElementById( "close_postit" ).style.display = "none";
404 $.cookie('close_postit','1', { expires: 365, path: '/' });
407 function close_lastusers(){
408 document.getElementById( "close_lastusers" ).style.display = "none";
409 $.cookie('close_lastusers','1', { expires: 365, path: '/' });
412 function close_lastphotos(){
413 document.getElementById( "close_lastphotos" ).style.display = "none";
414 $.cookie('close_lastphotos','1', { expires: 365, path: '/' });
417 function close_lastlikes(){
418 document.getElementById( "close_lastlikes" ).style.display = "none";
419 $.cookie('close_lastlikes','1', { expires: 365, path: '/' });
424 function restore_boxes(){
425 $.cookie('close_pages','2', { expires: 365, path: '/' });
426 $.cookie('close_helpers','2', { expires: 365, path: '/' });
427 $.cookie('close_services','2', { expires: 365, path: '/' });
428 $.cookie('close_friends','2', { expires: 365, path: '/' });
429 $.cookie('close_postit','2', { expires: 365, path: '/' });
430 $.cookie('close_lastusers','2', { expires: 365, path: '/' });
431 $.cookie('close_lastphotos','2', { expires: 365, path: '/' });
432 $.cookie('close_lastlikes','2', { expires: 365, path: '/' });
433 alert('Right-hand column was restored. Please refresh your browser');