5 * Description: Diabook: report bugs and request here: http://pad.toktan.org/p/diabook or contact me : thomas_bierey@friendica.eu
6 * Version: (Version: 1.027)
13 function diabook_init(&$a) {
15 //print diabook-version for debugging
16 $diabook_version = "Diabook (Version: 1.027)";
17 $a->page['htmlhead'] .= sprintf('<META NAME=generator CONTENT="%s"/>', $diabook_version);
19 //init css on network and profilepages
23 load_config("diabook");
24 load_pconfig(local_user(), "diabook");
26 //get statuses of boxes at right-hand-column
28 $site_close_pages = get_config("diabook", "close_pages" );
29 if (local_user()) {$close_pages = get_pconfig(local_user(), "diabook", "close_pages");}
30 if ($close_pages===false) $close_pages=$site_close_pages;
31 if ($close_pages===false) $close_pages="1";
33 $close_profiles = false;
34 $site_close_profiles = get_config("diabook", "close_profiles" );
35 if (local_user()) {$close_profiles = get_pconfig(local_user(), "diabook", "close_profiles");}
36 if ($close_profiles===false) $close_profiles=$site_close_profiles;
37 if ($close_profiles===false) $close_profiles="0";
39 $close_helpers = false;
40 $site_close_helpers = get_config("diabook", "close_helpers" );
41 if (local_user()) {$close_helpers = get_pconfig(local_user(), "diabook", "close_helpers");}
42 if ($close_helpers===false) $close_helpers=$site_close_helpers;
43 if ($close_helpers===false) $close_helpers="0";
45 $close_services = false;
46 $site_close_services = get_config("diabook", "close_services" );
47 if (local_user()) {$close_services = get_pconfig(local_user(), "diabook", "close_services");}
48 if ($close_services===false) $close_services=$site_close_services;
49 if ($close_services===false) $close_services="0";
51 $close_friends = false;
52 $site_close_friends = get_config("diabook", "close_friends" );
53 if (local_user()) {$close_friends = get_pconfig(local_user(), "diabook", "close_friends");}
54 if ($close_friends===false) $close_friends=$site_close_friends;
55 if ($close_friends===false) $close_friends="0";
57 $close_lastusers = false;
58 $site_close_lastusers = get_config("diabook", "close_lastusers" );
59 if (local_user()) {$close_lastusers = get_pconfig(local_user(), "diabook", "close_lastusers");}
60 if ($close_lastusers===false) $close_lastusers=$site_close_lastusers;
61 if ($close_lastusers===false) $close_lastusers="0";
63 $close_lastphotos = false;
64 $site_close_lastphotos = get_config("diabook", "close_lastphotos" );
65 if (local_user()) {$close_lastphotos = get_pconfig(local_user(), "diabook", "close_lastphotos");}
66 if ($close_lastphotos===false) $close_lastphotos=$site_close_lastphotos;
67 if ($close_lastphotos===false) $close_lastphotos="0";
69 $close_lastlikes = false;
70 $site_close_lastlikes = get_config("diabook", "close_lastlikes" );
71 if (local_user()) {$close_lastlikes = get_pconfig(local_user(), "diabook", "close_lastlikes");}
72 if ($close_lastlikes===false) $close_lastlikes=$site_close_lastlikes;
73 if ($close_lastlikes===false) $close_lastlikes="0";
75 $close_twitter = false;
76 $site_close_twitter = get_config("diabook", "close_twitter" );
77 if (local_user()) {$close_twitter = get_pconfig(local_user(), "diabook", "close_twitter");}
78 if ($close_twitter===false) $close_twitter=$site_close_twitter;
79 if ($close_twitter===false) $close_twitter="1";
81 $close_mapquery = false;
82 $site_close_mapquery = get_config("diabook", "close_mapquery" );
83 if (local_user()) {$close_mapquery = get_pconfig(local_user(), "diabook", "close_mapquery");}
84 if ($close_mapquery===false) $close_mapquery=$site_close_mapquery;
85 if ($close_mapquery===false) $close_mapquery="1";
87 //get resolution (wide/normal)
89 $resolution = get_pconfig(local_user(), "diabook", "resolution");
90 if ($resolution===false) $resolution="normal";
92 //Add META viewport tag respecting the resolution to header for tablets
93 if ($resolution=="wide") {
94 $a->page['htmlhead'] .= '<meta name="viewport" content="width=1200" />';
96 $a->page['htmlhead'] .= '<meta name="viewport" content="width=980" />';
100 $site_color = get_config("diabook", "color" );
101 if (local_user()) {$color = get_pconfig(local_user(), "diabook", "color");}
102 if ($color===false) $color=$site_color;
103 if ($color===false) $color="diabook";
105 if ($color=="diabook") $color_path = "/";
106 if ($color=="aerith") $color_path = "/diabook-aerith/";
107 if ($color=="blue") $color_path = "/diabook-blue/";
108 if ($color=="red") $color_path = "/diabook-red/";
109 if ($color=="pink") $color_path = "/diabook-pink/";
110 if ($color=="green") $color_path = "/diabook-green/";
111 if ($color=="dark") $color_path = "/diabook-dark/";
114 //build personal menue at lefthand-col (id="profile_side") and boxes at right-hand-col at networkpages
115 if ($a->argv[0] === "network" && local_user()){
120 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
123 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
124 'name' => $a->user['username'],
126 $ps = array('usermenu'=>array());
127 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
128 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
129 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));
130 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
131 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
132 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
133 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
134 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", "");
136 $tpl = get_markup_template('profile_side.tpl');
138 $a->page['aside'] = replace_macros($tpl, array(
139 '$userinfo' => $userinfo,
141 )).$a->page['aside'];
145 $ccCookie = $close_pages + $close_mapquery + $close_profiles + $close_helpers + $close_services + $close_friends + $close_twitter + $close_lastusers + $close_lastphotos + $close_lastlikes;
146 //if all boxes closed, dont build right-hand-col and dont use special css
147 if($ccCookie != "10") {
149 diabook_community_info();
152 if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network.css";}
153 if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network-wide.css";}
159 //build boxes at right_aside at profile pages
160 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
161 if($ccCookie != "10") {
163 diabook_community_info();
166 if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile.css";}
167 if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile-wide.css";}
172 //write js-scripts to the head-section:
173 //load jquery.cookie.js
174 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.cookie.js";
175 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s"></script>', $cookieJS);
176 //load jquery.ae.image.resize.js
177 $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.ae.image.resize.min.js";
178 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $imageresizeJS);
180 if($ccCookie != "10") {
181 $jqueryuiJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery-ui-1.8.20.custom.min.js";
182 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $jqueryuiJS);
183 $jqueryuicssJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/jquery-ui-1.8.20.custom.css";
184 $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $jqueryuicssJS);
186 //load jquery.twitter.search.js
187 if($close_twitter != "1") {
188 $twitterJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.twitter.search.js";
189 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $twitterJS);
191 //load jquery.mapquery.js
192 if($close_mapquery != "1") {
193 $mqtmplJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.tmpl.js";
194 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqtmplJS);
195 $mapqueryJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.core.js";
196 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mapqueryJS);
197 $openlayersJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/OpenLayers.js";
198 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $openlayersJS);
199 $mqmouseposJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js";
200 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqmouseposJS);
201 $mousewheelJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mousewheel.js";
202 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mousewheelJS);
203 $mqlegendJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.legend.js";
204 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqlegendJS);
205 $mqlayermanagerJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.mqLayerManager.js";
206 $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqlayermanagerJS);
209 $a->page['htmlhead'] .= '
212 $("a.lightbox").fancybox(); // Select all links with lightbox class
213 $("a#twittersettings-link").fancybox({onClosed: function() { $("#twittersettings").attr("style","display: none;");}} );
214 $("a#mapcontrol-link").fancybox({onClosed: function() { $("#mapcontrol").attr("style","display: none;");}} );
215 $("a#closeicon").fancybox({onClosed: function() { $("#boxsettings").attr("style","display: none;");}} );
218 $(window).load(function() {
219 var footer_top = $(document).height() - 30;
220 $("div#footerbox").attr("style", "border-top: 1px solid #D2D2D2; width: 70%;right: 15%;position: absolute;top:"+footer_top+"px;");
224 //check if mapquerybox is active and print
225 if($close_mapquery != "1") {
229 $site_ELZoom = get_config("diabook", "ELZoom" );
230 $site_ELPosX = get_config("diabook", "ELPosX" );
231 $site_ELPosY = get_config("diabook", "ELPosY" );
232 $ELZoom = get_pconfig(local_user(), "diabook", "ELZoom");
233 $ELPosX = get_pconfig(local_user(), "diabook", "ELPosX");
234 $ELPosY = get_pconfig(local_user(), "diabook", "ELPosY");
235 if ($ELZoom===false) $ELZoom=$site_ELZoom;
236 if ($ELPosX===false) $ELPosX=$site_ELPosX;
237 if ($ELPosY===false) $ELPosY=$site_ELPosY;
238 if ($ELZoom===false) $ELZoom="0";
239 if ($ELPosX===false) $ELPosX="0";
240 if ($ELPosY===false) $ELPosY="0";
241 $a->page['htmlhead'] .= '
246 layers:[{ //add layers to your map; you need to define at least one to be able to see anything on the map
247 type:"osm" //add a layer of the type osm (OpenStreetMap)
249 center:({zoom:'.$ELZoom.',position:['.$ELPosX.','.$ELPosY.']}),
254 function open_mapcontrol() {
255 $("div#mapcontrol").attr("style","display: block;width:900px;height:900px;");
256 $("#map2").mapQuery({
257 layers:[{type:"osm", label:"OpenStreetMap" },
258 {type:"wms", label:"Population density 2010", legend:{url:"http://mapserver.edugis.nl/cgi-bin/mapserv?map=maps/edugis/cache/population.map&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=Bevolkingsdichtheid_2010&format=image/png"}, url:"http://t1.edugis.nl/tiles/tilecache.py?map=maps/edugis/cache/population.map",
259 layers:"Bevolkingsdichtheid_2010" },
261 label:"OpenLayers WMS",
262 url:"http://labs.metacarta.com/wms/vmap0",
264 center:({zoom:'.$ELZoom.',position:['.$ELPosX.','.$ELPosY.']})});
266 $("#mouseposition").mqMousePosition({
273 $("#layermanager").mqLayerManager({map:"#map2"});
274 $( "div#layermanager" ).accordion({header: ".mq-layermanager-element-header"});
275 $(".mq-layermanager-element-content").attr("style", "");
277 map = $("#map2").mapQuery().data("mapQuery");
278 textarea = document.getElementById("id_diabook_ELZoom");
279 textarea.value = "'.$ELZoom.'";
280 $("#map2").bind("mousewheel", function(event, delta) {
281 if (delta > 0 && textarea.value < 18){
282 textarea.value = textarea.value - delta*-1; }
283 if (delta < 0 && textarea.value > "0"){
284 textarea.value = textarea.value - delta*-1; }
289 //check if twitterbox is active and print
290 if($close_twitter != "1") {
292 $site_TSearchTerm = get_config("diabook", "TSearchTerm" );
293 $TSearchTerm = get_pconfig(local_user(), "diabook", "TSearchTerm");
294 if ($TSearchTerm===false) $TSearchTerm=$site_TSearchTerm;
295 if ($TSearchTerm===false) $TSearchTerm="friendica";
296 $a->page['htmlhead'] .= '
299 $("#twitter").twitterSearch({
300 term: "'.$TSearchTerm.'",
304 colorExterior: "#fff",
307 function open_twittersettings() {
308 $("div#twittersettings").attr("style","display: block;");
312 //check if community_home-plugin is activated and change css.. we need this, that the submit-wrapper doesn't overlay the login-panel if communityhome-plugin is active
313 $nametocheck = "communityhome";
314 $r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck));
315 if(count($r) == "1" && $a->argv[0] === "home" ) {
317 $a->page['htmlhead'] .= '
320 $("div#login-submit-wrapper").attr("style","padding-top: 120px;");
324 //comment-edit-wrapper on photo_view... we need this to workaround a global bug in photoview, where the comment-box is between the last comment the the comment before the last
325 if ($a->argv[0].$a->argv[2] === "photos"."image"){
326 $a->page['htmlhead'] .= '
329 $(".comment-edit-form").css("display","table");
333 //restore (only) the order right hand col at settingspage
334 if($a->argv[0] === "settings" && local_user()) {
335 $a->page['htmlhead'] .= '
337 function restore_boxes(){
338 $.cookie("Boxorder",null, { expires: 365, path: "/" });
339 alert("Boxorder at right-hand column was restored. Please refresh your browser");
343 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
344 $a->page['htmlhead'] .= '
347 $(".oembed.photo img").aeImageResize({height: 400, width: 400});
351 if($ccCookie != "10") {
352 $a->page['htmlhead'] .= '
354 $("right_aside").ready(function(){
358 document.getElementById( "close_pages" ).style.display = "none";
361 if('.$close_mapquery.')
363 document.getElementById( "close_mapquery" ).style.display = "none";
366 if('.$close_profiles.')
368 document.getElementById( "close_profiles" ).style.display = "none";
371 if('.$close_helpers.')
373 document.getElementById( "close_helpers" ).style.display = "none";
376 if('.$close_services.')
378 document.getElementById( "close_services" ).style.display = "none";
381 if('.$close_friends.')
383 document.getElementById( "close_friends" ).style.display = "none";
386 if('.$close_twitter.')
388 document.getElementById( "close_twitter" ).style.display = "none";
391 if('.$close_lastusers.')
393 document.getElementById( "close_lastusers" ).style.display = "none";
396 if('.$close_lastphotos.')
398 document.getElementById( "close_lastphotos" ).style.display = "none";
401 if('.$close_lastlikes.')
403 document.getElementById( "close_lastlikes" ).style.display = "none";
413 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
416 $tpl = get_markup_template('footer.tpl');
417 $a->page['footer'] .= replace_macros($tpl, array());
424 function diabook_community_info() {
427 $close_pages = false;
428 $site_close_pages = get_config("diabook", "close_pages" );
429 if (local_user()) {$close_pages = get_pconfig(local_user(), "diabook", "close_pages");}
430 if ($close_pages===false) $close_pages=$site_close_pages;
431 if ($close_pages===false) $close_pages="1";
433 $close_profiles = false;
434 $site_close_profiles = get_config("diabook", "close_profiles" );
435 if (local_user()) {$close_profiles = get_pconfig(local_user(), "diabook", "close_profiles");}
436 if ($close_profiles===false) $close_profiles=$site_close_profiles;
437 if ($close_profiles===false) $close_profiles="0";
439 $close_helpers = false;
440 $site_close_helpers = get_config("diabook", "close_helpers" );
441 if (local_user()) {$close_helpers = get_pconfig(local_user(), "diabook", "close_helpers");}
442 if ($close_helpers===false) $close_helpers=$site_close_helpers;
443 if ($close_helpers===false) $close_helpers="0";
445 $close_services = false;
446 $site_close_services = get_config("diabook", "close_services" );
447 if (local_user()) {$close_services = get_pconfig(local_user(), "diabook", "close_services");}
448 if ($close_services===false) $close_services=$site_close_services;
449 if ($close_services===false) $close_services="0";
451 $close_friends = false;
452 $site_close_friends = get_config("diabook", "close_friends" );
453 if (local_user()) {$close_friends = get_pconfig(local_user(), "diabook", "close_friends");}
454 if ($close_friends===false) $close_friends=$site_close_friends;
455 if ($close_friends===false) $close_friends="0";
457 $close_lastusers = false;
458 $site_close_lastusers = get_config("diabook", "close_lastusers" );
459 if (local_user()) {$close_lastusers = get_pconfig(local_user(), "diabook", "close_lastusers");}
460 if ($close_lastusers===false) $close_lastusers=$site_close_lastusers;
461 if ($close_lastusers===false) $close_lastusers="0";
463 $close_lastphotos = false;
464 $site_close_lastphotos = get_config("diabook", "close_lastphotos" );
465 if (local_user()) {$close_lastphotos = get_pconfig(local_user(), "diabook", "close_lastphotos");}
466 if ($close_lastphotos===false) $close_lastphotos=$site_close_lastphotos;
467 if ($close_lastphotos===false) $close_lastphotos="0";
469 $close_lastlikes = false;
470 $site_close_lastlikes = get_config("diabook", "close_lastlikes" );
471 if (local_user()) {$close_lastlikes = get_pconfig(local_user(), "diabook", "close_lastlikes");}
472 if ($close_lastlikes===false) $close_lastlikes=$site_close_lastlikes;
473 if ($close_lastlikes===false) $close_lastlikes="0";
475 $close_twitter = false;
476 $site_close_twitter = get_config("diabook", "close_twitter" );
477 if (local_user()) {$close_twitter = get_pconfig(local_user(), "diabook", "close_twitter");}
478 if ($close_twitter===false) $close_twitter=$site_close_twitter;
479 if ($close_twitter===false) $close_twitter="1";
481 $close_mapquery = false;
482 $site_close_mapquery = get_config("diabook", "close_mapquery" );
483 if (local_user()) {$close_mapquery = get_pconfig(local_user(), "diabook", "close_mapquery");}
484 if ($close_mapquery===false) $close_mapquery=$site_close_mapquery;
485 if ($close_mapquery===false) $close_mapquery="1";
489 if($close_profiles != "1") {
490 $aside['$comunity_profiles_title'] = t('Community Profiles');
491 $aside['$comunity_profiles_items'] = array();
492 $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id
493 where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
494 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
498 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
499 $entry = replace_macros($tpl,array(
501 '$profile-link' => zrl($rr['url']),
502 '$photo' => $rr[$photo],
503 '$alt-text' => $rr['name'],
505 $aside['$comunity_profiles_items'][] = $entry;
510 if($close_lastusers != "1") {
511 $aside['$lastusers_title'] = t('Last users');
512 $aside['$lastusers_items'] = array();
514 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
515 $order = " ORDER BY `register_date` DESC ";
517 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
518 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
519 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
523 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
527 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
528 $entry = replace_macros($tpl,array(
530 '$profile-link' => $profile_link,
531 '$photo' => $rr[$photo],
532 '$alt-text' => $rr['name'],
534 $aside['$lastusers_items'][] = $entry;
538 // last 10 liked items
539 if($close_lastlikes != "1") {
540 $aside['$like_title'] = t('Last likes');
541 $aside['$like_items'] = array();
542 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
543 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
544 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
545 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
546 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
548 ORDER BY `T1`.`created` DESC
550 $a->get_baseurl(),$a->get_baseurl()
553 foreach ($r as $rr) {
554 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
555 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
557 //var_dump($rr['verb'],$rr['object-type']); killme();
559 case 'http://activitystrea.ms/schema/1.0/post':
560 switch ($rr['object-type']){
561 case 'http://activitystrea.ms/schema/1.0/event':
562 $post_type = t('event');
565 $post_type = t('status');
569 if ($rr['resource-id']){
570 $post_type = t('photo');
571 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
572 $rr['plink'] = $m[1];
574 $post_type = t('status');
577 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
579 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
584 if($close_lastphotos != "1") {
585 $aside['$photos_title'] = t('Last photos');
586 $aside['$photos_items'] = array();
587 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
588 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
589 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
590 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
591 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
593 WHERE `user`.`uid` = `photo`.`uid`
594 AND `user`.`blockwall`=0
595 AND `user`.`hidewall`=0
596 ORDER BY `photo`.`edited` DESC
598 dbesc(t('Contact Photos')),
599 dbesc(t('Profile Photos'))
602 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
604 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
605 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
607 $entry = replace_macros($tpl,array(
609 '$profile-link' => $photo_page,
610 '$photo' => $photo_url,
611 '$alt-text' => $rr['username']." : ".$rr['desc'],
614 $aside['$photos_items'][] = $entry;
618 //right_aside FIND FRIENDS
619 if($close_friends != "1") {
622 $nv['title'] = Array("", t('Find Friends'), "", "");
623 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
624 $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
625 $nv['match'] = Array('match', t('Similar Interests'), "", "");
626 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
627 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
629 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
630 <span class="sbox_l"></span>
632 <input type="text" name="search" size="13" maxlength="50">
634 <span class="sbox_r" id="srch_clear"></span>';
639 //Community_Pages at right_aside
640 if($close_pages != "1") {
643 <h3 style="margin-top:0px;">'.t("Community Pages").'<a id="closeicon" href="#boxsettings" onClick="open_boxsettings(); return false;" style="text-decoration:none;" class="icon close_box" title="'.t("Settings").'"></a></h3>
644 <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">';
648 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
649 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
650 ORDER BY `name` ASC",
651 intval($a->user['uid'])
656 // Look if the profile is a community page
657 foreach($contacts as $contact) {
658 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
664 foreach($contacts as $contact) {
665 $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; word-wrap: break-word; width: 132px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
666 $contact["name"]."</a></li>";
668 $page .= '</ul></div>';
669 //if (sizeof($contacts) > 0)
670 $aside['$page'] = $page;
676 if($close_mapquery != "1") {
678 $mapquery['title'] = Array("", "<a id='mapcontrol-link' href='#mapcontrol' style='text-decoration:none;' onclick='open_mapcontrol(); return false;'>".t('Earth Layers')."</a>", "", "");
679 $aside['$mapquery'] = $mapquery;
680 $ELZoom = get_pconfig(local_user(), 'diabook', 'ELZoom' );
681 $ELPosX = get_pconfig(local_user(), 'diabook', 'ELPosX' );
682 $ELPosY = get_pconfig(local_user(), 'diabook', 'ELPosY' );
683 $aside['$ELZoom'] = array('diabook_ELZoom', t('Set zoomfactor for Earth Layers'), $ELZoom, '', $ELZoom);
684 $aside['$ELPosX'] = array('diabook_ELPosX', t('Set longitude (X) for Earth Layers'), $ELPosX, '', $ELPosX);
685 $aside['$ELPosY'] = array('diabook_ELPosY', t('Set latitude (Y) for Earth Layers'), $ELPosY, '', $ELPosY);
686 if (isset($_POST['diabook-settings-map-sub']) && $_POST['diabook-settings-map-sub']!=''){
687 set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']);
688 set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']);
689 set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']);
690 header("Location: network");
696 if($close_helpers != "1") {
698 $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
699 $aside['$helpers'] = $helpers;
702 //connectable services
703 if($close_services != "1") {
704 $con_services = array();
705 $con_services['title'] = Array("", t('Connect Services'), "", "");
706 $aside['$con_services'] = $con_services;
708 //end connectable services
710 if($close_twitter != "1") {
712 $twitter['title'] = Array("", "<a id='twittersettings-link' href='#twittersettings' style='text-decoration:none;' onclick='open_twittersettings(); return false;'>".t('Last Tweets')."</a>", "", "");
713 $aside['$twitter'] = $twitter;
714 $TSearchTerm = get_pconfig(local_user(), 'diabook', 'TSearchTerm' );
715 $aside['$TSearchTerm'] = array('diabook_TSearchTerm', t('Set twitter search term'), $TSearchTerm, '', $TSearchTerm);
716 $baseurl = $a->get_baseurl($ssl_state);
717 $aside['$baseurl'] = $baseurl;
718 if (isset($_POST['diabook-settings-sub']) && $_POST['diabook-settings-sub']!=''){
719 set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']);
720 header("Location: network");
724 if($ccCookie != "10") {
725 $close_pages = get_pconfig(local_user(), 'diabook', 'close_pages' );
726 $close_mapquery = get_pconfig(local_user(), 'diabook', 'close_mapquery' );
727 $close_profiles = get_pconfig(local_user(), 'diabook', 'close_profiles' );
728 $close_helpers = get_pconfig(local_user(), 'diabook', 'close_helpers' );
729 $close_services = get_pconfig(local_user(), 'diabook', 'close_services' );
730 $close_friends = get_pconfig(local_user(), 'diabook', 'close_friends' );
731 $close_twitter = get_pconfig(local_user(), 'diabook', 'close_twitter' );
732 $close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers' );
733 $close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos' );
734 $close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes' );
735 $close_pagesC = array('1'=>t("don't show"), '0'=>t("show"),);
736 $close_mapqueryC = array('1'=>t("don't show"), '0'=>t("show"),);
737 $close_profilesC = array('1'=>t("don't show"), '0'=>t("show"),);
738 $close_helpersC = array('1'=>t("don't show"), '0'=>t("show"),);
739 $close_servicesC = array('1'=>t("don't show"), '0'=>t("show"),);
740 $close_friendsC = array('1'=>t("don't show"), '0'=>t("show"),);
741 $close_twitterC = array('1'=>t("don't show"), '0'=>t("show"),);
742 $close_lastusersC = array('1'=>t("don't show"), '0'=>t("show"),);
743 $close_lastphotosC = array('1'=>t("don't show"), '0'=>t("show"),);
744 $close_lastlikesC = array('1'=>t("don't show"), '0'=>t("show"),);
745 $boxsettings['title'] = Array("", t('Show/hide boxes at right-hand column:'), "", "");
746 $aside['$boxsettings'] = $boxsettings;
747 $aside['$close_pages'] = array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_pagesC);
748 $aside['$close_mapquery'] = array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_mapqueryC);
749 $aside['$close_profiles'] = array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_profilesC);
750 $aside['$close_helpers'] = array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_helpersC);
751 $aside['$close_services'] = array('diabook_close_services', t('Connect Services'), $close_services, '', $close_servicesC);
752 $aside['$close_friends'] = array('diabook_close_friends', t('Find Friends'), $close_friends, '', $close_friendsC);
753 $aside['$close_twitter'] = array('diabook_close_twitter', t('Last Tweets'), $close_twitter, '', $close_twitterC);
754 $aside['$close_lastusers'] = array('diabook_close_lastusers', t('Last users'), $close_lastusers, '', $close_lastusersC);
755 $aside['$close_lastphotos'] = array('diabook_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_lastphotosC);
756 $aside['$close_lastlikes'] = array('diabook_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_lastlikesC);
757 $aside['$sub'] = t('Submit');
758 $baseurl = $a->get_baseurl($ssl_state);
759 $aside['$baseurl'] = $baseurl;
760 if (isset($_POST['diabook-settings-box-sub']) && $_POST['diabook-settings-box-sub']!=''){
761 set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']);
762 set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']);
763 set_pconfig(local_user(), 'diabook', 'close_profiles', $_POST['diabook_close_profiles']);
764 set_pconfig(local_user(), 'diabook', 'close_helpers', $_POST['diabook_close_helpers']);
765 set_pconfig(local_user(), 'diabook', 'close_services', $_POST['diabook_close_services']);
766 set_pconfig(local_user(), 'diabook', 'close_friends', $_POST['diabook_close_friends']);
767 set_pconfig(local_user(), 'diabook', 'close_twitter', $_POST['diabook_close_twitter']);
768 set_pconfig(local_user(), 'diabook', 'close_lastusers', $_POST['diabook_close_lastusers']);
769 set_pconfig(local_user(), 'diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']);
770 set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']);
773 $close = t('Settings');
774 $aside['$close'] = $close;
776 $url = $a->get_baseurl($ssl_state);
777 $aside['$url'] = $url;
779 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
780 $a->page['right_aside'] = replace_macros($tpl, $aside);
784 function js_diabook_footer() {
785 /** @purpose insert stuff in bottom of page
788 $baseurl = $a->get_baseurl($ssl_state);
789 $bottom['$baseurl'] = $baseurl;
790 $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');
791 $a->page['footer'] = $a->page['footer'].replace_macros($tpl, $bottom);