]> git.mxchange.org Git - friendica.git/blob - view/theme/diabook/theme.php
diabook-theme: add "Earth Layers"-box at right_side
[friendica.git] / view / theme / diabook / theme.php
1 <?php
2
3 /*
4  * Name: Diabook
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.026)
7  * Author: 
8  */
9
10 $a = get_app();
11
12
13 function diabook_init(&$a) {
14         
15 //print diabook-version for debugging
16 $diabook_version = "Diabook (Version: 1.026)";
17 $a->page['htmlhead'] .= sprintf('<META NAME="theme" CONTENT="%s"/>', $diabook_version);
18
19 //change css on network and profilepages
20 $cssFile = null;
21
22 $resolution=false;
23 $resolution = get_pconfig(local_user(), "diabook", "resolution");
24 if ($resolution===false) $resolution="normal";
25
26 //Add META viewport tag respecting the resolution to header for tablets
27 if ($resolution=="wide") {
28   $a->page['htmlhead'] .= '<meta name="viewport" content="width=1200" />';
29 } else {
30   $a->page['htmlhead'] .= '<meta name="viewport" content="width=980" />';
31 }
32
33
34 $color = false;
35 $site_color = get_config("diabook", "color" );
36 if (local_user()) {$color = get_pconfig(local_user(), "diabook", "color");}
37 if ($color===false) $color=$site_color;
38 if ($color===false) $color="diabook";
39
40 if ($color=="diabook") $color_path = "/";
41 if ($color=="aerith") $color_path = "/diabook-aerith/";
42 if ($color=="blue") $color_path = "/diabook-blue/";
43 if ($color=="red") $color_path = "/diabook-red/";
44 if ($color=="pink") $color_path = "/diabook-pink/";
45 if ($color=="green") $color_path = "/diabook-green/";
46 if ($color=="dark") $color_path = "/diabook-dark/";
47
48         
49         //profile_side at networkpages
50         if ($a->argv[0] === "network" && local_user()){
51
52         // USER MENU
53         if(local_user()) {
54                 
55                 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
56                                 
57                 $userinfo = array(
58                                         'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
59                                         'name' => $a->user['username'],
60                                 );      
61                 $ps = array('usermenu'=>array());
62                 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
63                 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
64                 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));                                
65                 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
66                 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
67                 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
68                 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
69                 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", "");
70
71                 $tpl = get_markup_template('profile_side.tpl');
72
73                 $a->page['aside'] = replace_macros($tpl, array(
74                                 '$userinfo' => $userinfo,
75                                 '$ps' => $ps,
76                         )).$a->page['aside'];
77
78         }
79         
80         $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_mapquery'] + $_COOKIE['close_profiles'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_twitter'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes'];
81         
82         if($ccCookie != "10") {
83         // COMMUNITY
84         diabook_community_info();
85
86         // CUSTOM CSS
87         if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network.css";}
88         if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network-wide.css";}
89         }
90         }
91
92
93
94         //right_aside at profile pages
95         if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
96         if($ccCookie != "10") {
97         // COMMUNITY
98         diabook_community_info();
99         
100         // CUSTOM CSS
101         if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile.css";}
102         if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile-wide.css";}
103         
104         }
105         }
106         
107         //js scripts
108         //load jquery.cookie.js
109         $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.cookie.js";
110         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s"></script>', $cookieJS);
111         
112         //load jquery.ae.image.resize.js
113         $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.ae.image.resize.js";
114         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
115         
116         //load jquery.ui.js
117         if($ccCookie != "10") {
118         $jqueryuiJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery-ui-1.8.20.custom.min.js";
119         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $jqueryuiJS);
120         }       
121         
122         //load jquery.twitter.search.js
123         if($_COOKIE['close_twitter'] != "1") {
124         $twitterJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.twitter.search.js";
125         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $twitterJS);
126         }
127         
128         //load jquery.mapquery.js
129
130         if($_COOKIE['close_mapquery'] != "1") {
131         $mqtmplJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.tmpl.js";
132         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $mqtmplJS);
133         $mapqueryJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.core.js";
134         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $mapqueryJS);
135         $openlayersJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/OpenLayers.js";
136         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $openlayersJS);
137         $mqmouseposJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js";
138         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $mqmouseposJS);
139         $mousewheelJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mousewheel.js";
140         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $mousewheelJS);
141         
142         }
143         
144         $a->page['htmlhead'] .= '
145         <script>
146         
147          $(function() {
148                 $("a.lightbox").fancybox(); // Select all links with lightbox class
149                 $("a.#twittersettings-link").fancybox({onClosed: function() { $("#twittersettings").attr("style","display: none;");}} ); 
150            $("a.#mapcontrol-link").fancybox({onClosed: function() { $("#mapcontrol").attr("style","display: none;");}} ); 
151                 });
152            
153          $(window).load(function() {
154                 var footer_top = $(document).height() - 30;
155                 $("div#footerbox").attr("style", "border-top: 1px solid #D2D2D2; width: 70%;right: 15%;position: absolute;top:"+footer_top+"px;");
156          });
157         </script>';
158         //check if mapquerybox is active and print
159
160         if($_COOKIE['close_mapquery'] != "1") {
161                 $ELZoom=false;
162                 $ELPosX=false;
163                 $ELPosy=false;
164                 $site_ELZoom = get_config("diabook", "ELZoom" );
165                 $site_ELPosX = get_config("diabook", "ELPosX" );
166                 $site_ELPosY = get_config("diabook", "ELPosY" );
167                 $ELZoom = get_pconfig(local_user(), "diabook", "ELZoom");
168                 $ELPosX = get_pconfig(local_user(), "diabook", "ELPosX");
169                 $ELPosY = get_pconfig(local_user(), "diabook", "ELPosY");
170                 if ($ELZoom===false) $ELZoom=$site_ELZoom;
171                 if ($ELPosX===false) $ELPosX=$site_ELPosX;
172                 if ($ELPosY===false) $ELPosY=$site_ELPosY;
173                 if ($ELZoom===false) $ELZoom="0";       
174                 if ($ELPosX===false) $ELPosX="0";               
175                 if ($ELPosY===false) $ELPosY="0";                       
176                 $a->page['htmlhead'] .= '
177                 <script>
178                 
179     $(document).ready(function() {
180     $("#map").mapQuery({
181         layers:[{         //add layers to your map; you need to define at least one to be able to see anything on the map
182             type:"osm"  //add a layer of the type osm (OpenStreetMap)
183             }],
184         center:({zoom:'.$ELZoom.',position:['.$ELPosX.','.$ELPosY.']}),
185        });
186     
187     });
188          
189     function open_mapcontrol() {
190                 $("div#mapcontrol").attr("style","display: block;width:900px;height:600px;");
191                 $("#map2").mapQuery({layers:[{type:"osm"}],
192                                                                                                 center:({zoom:'.$ELZoom.',position:['.$ELPosX.','.$ELPosY.']})}); 
193                                                                         
194                 $("#mouseposition").mqMousePosition({
195         map: "#map2",
196         x:"lon",
197         y:"lat",
198         precision:2
199                 }); 
200                 
201         
202         map = $("#map2").mapQuery().data("mapQuery");
203         textarea = document.getElementById("mapzoom");
204         
205         
206                 $("#map2").bind("mousewheel", function(event, delta) {
207                 if (delta > 0 || delta < 0){
208                          textarea.value = map.center().zoom; }
209                         });
210         
211                 };
212                 </script>';
213         }
214         //check if twitterbox is active and print
215         if($_COOKIE['close_twitter'] != "1") {
216                 $TSearchTerm=false;
217                 $site_TSearchTerm = get_config("diabook", "TSearchTerm" );
218                 $TSearchTerm = get_pconfig(local_user(), "diabook", "TSearchTerm");
219                 if ($TSearchTerm===false) $TSearchTerm=$site_TSearchTerm;
220                 if ($TSearchTerm===false) $TSearchTerm="friendica";             
221                 $a->page['htmlhead'] .= '
222                 <script>
223                 $(function() {
224                 $("#twitter").twitterSearch({               
225                 term: "'.$TSearchTerm.'",
226                 animInSpeed: 250,
227                 bird:    false, 
228                 avatar:  false, 
229                 colorExterior: "#fff",
230                 timeout: 10000          });
231                 });
232                 function open_twittersettings() {
233                 $("div#twittersettings").attr("style","display: block;");
234                 };
235                 </script>';}
236                         
237         //check if community_home-plugin is activated and change css
238         $nametocheck = "communityhome";
239         $r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck));
240         if(count($r) == "1") {
241         
242         $a->page['htmlhead'] .= '
243         <script>
244         $(document).ready(function() {
245         $("div#login-submit-wrapper").attr("style","padding-top: 120px;");
246         
247         });
248         </script>';     
249         }
250         //comment-edit-wrapper on photo_view
251         if ($a->argv[0].$a->argv[2] === "photos"."image"){
252         $a->page['htmlhead'] .= '
253         <script>
254                 $(function(){
255                 $(".comment-edit-form").css("display","table");
256                         });
257     </script>';
258         }
259         //restore right hand col at settingspage
260         if($a->argv[0] === "settings" && local_user()) {
261         $a->page['htmlhead'] .= ' 
262         <script>
263         function restore_boxes(){
264         $.cookie("close_pages","2", { expires: 365, path: "/" });
265         $.cookie("close_mapquery","2", { expires: 365, path: "/" });
266         $.cookie("close_helpers","2", { expires: 365, path: "/" });
267         $.cookie("close_profiles","2", { expires: 365, path: "/" });
268         $.cookie("close_services","2", { expires: 365, path: "/" });
269         $.cookie("close_friends","2", { expires: 365, path: "/" });
270         $.cookie("close_twitter","2", { expires: 365, path: "/" });
271         $.cookie("close_lastusers","2", { expires: 365, path: "/" });
272         $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
273         $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
274         $.cookie("Boxorder",null, { expires: 365, path: "/" });
275         alert("Right-hand column was restored. Please refresh your browser");
276    }
277         </script>';}
278         
279         if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
280         $a->page['htmlhead'] .= '
281         <script>
282
283         $(function() {
284         $(".oembed.photo img").aeImageResize({height: 400, width: 400});
285         });
286         </script>';
287         
288         if($ccCookie != "10") {
289         $a->page['htmlhead'] .= '
290         <script>
291         $("right_aside").ready(function(){
292         
293         if($.cookie("close_pages") == "1") 
294                 {
295                 document.getElementById( "close_pages" ).style.display = "none";
296                         };
297                         
298         if($.cookie("close_mapquery") == "1") 
299                 {
300                 document.getElementById( "close_mapquery" ).style.display = "none";
301                         };
302                         
303         if($.cookie("close_profiles") == "1") 
304                 {
305                 document.getElementById( "close_profiles" ).style.display = "none";
306                         };
307         
308         if($.cookie("close_helpers") == "1") 
309                 {
310                 document.getElementById( "close_helpers" ).style.display = "none";
311                         };
312                         
313         if($.cookie("close_services") == "1") 
314                 {
315                 document.getElementById( "close_services" ).style.display = "none";
316                         };
317                         
318         if($.cookie("close_friends") == "1") 
319                 {
320                 document.getElementById( "close_friends" ).style.display = "none";
321                         };
322         
323         if($.cookie("close_twitter") == "1") 
324                 {
325                 document.getElementById( "close_twitter" ).style.display = "none";
326                         };      
327                         
328         if($.cookie("close_lastusers") == "1") 
329                 {
330                 document.getElementById( "close_lastusers" ).style.display = "none";
331                         };
332                         
333         if($.cookie("close_lastphotos") == "1") 
334                 {
335                 document.getElementById( "close_lastphotos" ).style.display = "none";
336                         };
337                         
338         if($.cookie("close_lastlikes") == "1") 
339                 {
340                 document.getElementById( "close_lastlikes" ).style.display = "none";
341                         };}
342
343         );
344
345         function close_pages(){
346          document.getElementById( "close_pages" ).style.display = "none";
347         $.cookie("close_pages","1", { expires: 365, path: "/" });
348         };
349         
350         function close_mapquery(){
351          document.getElementById( "close_mapquery" ).style.display = "none";
352         $.cookie("close_mapquery","1", { expires: 365, path: "/" });
353         };
354  
355         function close_profiles(){
356         document.getElementById( "close_profiles" ).style.display = "none";
357         $.cookie("close_profiles","1", { expires: 365, path: "/" });
358         };
359  
360         function close_helpers(){
361         document.getElementById( "close_helpers" ).style.display = "none";
362         $.cookie("close_helpers","1", { expires: 365, path: "/" });
363         };
364
365         function close_services(){
366         document.getElementById( "close_services" ).style.display = "none";
367         $.cookie("close_services","1", { expires: 365, path: "/" });
368         };
369  
370         function close_friends(){
371          document.getElementById( "close_friends" ).style.display = "none";
372          $.cookie("close_friends","1", { expires: 365, path: "/" });
373          };
374  
375         function close_twitter(){
376         document.getElementById( "close_twitter" ).style.display = "none";
377          $.cookie("close_twitter","1", { expires: 365, path: "/" });
378         };
379  
380         function close_lastusers(){
381          document.getElementById( "close_lastusers" ).style.display = "none";
382         $.cookie("close_lastusers","1", { expires: 365, path: "/" });
383          };
384
385         function close_lastphotos(){
386         document.getElementById( "close_lastphotos" ).style.display = "none";
387          $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
388          };
389  
390         function close_lastlikes(){
391          document.getElementById( "close_lastlikes" ).style.display = "none";
392          $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
393          };
394         </script>';}
395         }
396         //end js scripts
397
398         // custom css
399         if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
400
401         //footer
402         $tpl = get_markup_template('footer.tpl');
403         $a->page['footer'] .= replace_macros($tpl, array());
404         
405         //
406         js_diabook_footer();
407 }
408
409
410  function diabook_community_info() {
411         $a = get_app();
412         // comunity_profiles
413         if($_COOKIE['close_profiles'] != "1") {
414         $aside['$comunity_profiles_title'] = t('Community Profiles');
415         $aside['$comunity_profiles_items'] = array();
416         $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id 
417                           where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
418         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
419         if(count($r)) {
420                 $photo = 'photo';
421                 foreach($r as $rr) {
422                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
423                         $entry = replace_macros($tpl,array(
424                                 '$id' => $rr['id'],
425                                 '$profile-link' => zrl($rr['url']),
426                                 '$photo' => $rr[$photo],
427                                 '$alt-text' => $rr['name'],
428                         ));
429                         $aside['$comunity_profiles_items'][] = $entry;
430                 }
431         }}
432         
433         // last 12 users
434         if($_COOKIE['close_lastusers'] != "1") {
435         $aside['$lastusers_title'] = t('Last users');
436         $aside['$lastusers_items'] = array();
437         $sql_extra = "";
438         $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
439         $order = " ORDER BY `register_date` DESC ";
440
441         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
442                         FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 
443                         WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
444                 0,
445                 9
446         );
447         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
448         if(count($r)) {
449                 $photo = 'thumb';
450                 foreach($r as $rr) {
451                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
452                         $entry = replace_macros($tpl,array(
453                                 '$id' => $rr['id'],
454                                 '$profile-link' => $profile_link,
455                                 '$photo' => $rr[$photo],
456                                 '$alt-text' => $rr['name'],
457                         ));
458                         $aside['$lastusers_items'][] = $entry;
459                 }
460         }}
461         
462         // last 10 liked items
463         if($_COOKIE['close_lastlikes'] != "1") {
464         $aside['$like_title'] = t('Last likes');
465         $aside['$like_items'] = array();
466         $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM 
467                         (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` 
468                                 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
469                         INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri` 
470                         WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
471                         GROUP BY `uri`
472                         ORDER BY `T1`.`created` DESC
473                         LIMIT 0,5",
474                         $a->get_baseurl(),$a->get_baseurl()
475                         );
476
477         foreach ($r as $rr) {
478                 $author  = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
479                 $objauthor =  '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
480                 
481                 //var_dump($rr['verb'],$rr['object-type']); killme();
482                 switch($rr['verb']){
483                         case 'http://activitystrea.ms/schema/1.0/post':
484                                 switch ($rr['object-type']){
485                                         case 'http://activitystrea.ms/schema/1.0/event':
486                                                 $post_type = t('event');
487                                                 break;
488                                         default:
489                                                 $post_type = t('status');
490                                 }
491                                 break;
492                         default:
493                                 if ($rr['resource-id']){
494                                         $post_type = t('photo');
495                                         $m=array();     preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
496                                         $rr['plink'] = $m[1];
497                                 } else {
498                                         $post_type = t('status');
499                                 }
500                 }
501                 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
502
503                 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
504                 
505         }}
506         
507         // last 12 photos
508         if($_COOKIE['close_photos'] != "1") {
509         $aside['$photos_title'] = t('Last photos');
510         $aside['$photos_items'] = array();
511         $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM 
512                                 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo` 
513                                         WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
514                                                 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
515                                 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
516                                 `user` 
517                                 WHERE `user`.`uid` = `photo`.`uid`
518                                 AND `user`.`blockwall`=0
519                                 AND `user`.`hidewall`=0
520                                 ORDER BY `photo`.`edited` DESC
521                                 LIMIT 0, 9",
522                                 dbesc(t('Contact Photos')),
523                                 dbesc(t('Profile Photos'))
524                                 );
525                 if(count($r)) {
526                 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
527                 foreach($r as $rr) {
528                         $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
529                         $photo_url = $a->get_baseurl() . '/photo/' .  $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
530                 
531                         $entry = replace_macros($tpl,array(
532                                 '$id' => $rr['id'],
533                                 '$profile-link' => $photo_page,
534                                 '$photo' => $photo_url,
535                                 '$alt-text' => $rr['username']." : ".$rr['desc'],
536                         ));
537
538                         $aside['$photos_items'][] = $entry;
539                 }
540         }}
541         
542    //right_aside FIND FRIENDS
543    if($_COOKIE['close_friends'] != "1") {
544         if(local_user()) {
545         $nv = array();
546         $nv['title'] = Array("", t('Find Friends'), "", "");
547         $nv['directory'] = Array('directory', t('Local Directory'), "", "");
548         $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
549         $nv['match'] = Array('match', t('Similar Interests'), "", "");
550         $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
551         $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
552         
553         $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
554                                                 <span class="sbox_l"></span>
555                                                 <span class="sbox">
556                                                 <input type="text" name="search" size="13" maxlength="50">
557                                                 </span>
558                                                 <span class="sbox_r" id="srch_clear"></span>';
559         
560         $aside['$nv'] = $nv;
561         }}
562    
563    //Community_Pages at right_aside
564    if($_COOKIE['close_pages'] != "1") {
565    if(local_user()) {
566    $page = '
567                         <h3 style="margin-top:0px;">'.t("Community Pages").'<a id="close_pages_icon"  onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
568                         <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">';
569
570         $pagelist = array();
571
572         $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
573                         WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
574                         ORDER BY `name` ASC",
575                         intval($a->user['uid'])
576         );
577
578         $pageD = array();
579
580         // Look if the profile is a community page
581         foreach($contacts as $contact) {
582                 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
583         };
584         
585
586         $contacts = $pageD;
587
588         foreach($contacts as $contact) {
589                 $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">'.
590                                 $contact["name"]."</a></li>";
591         }
592         $page .= '</ul></div>';
593         //if (sizeof($contacts) > 0)
594                 $aside['$page'] = $page;        
595         }}
596   //END Community Page  
597   
598    //mapquery
599
600   if($_COOKIE['close_mapquery'] != "1") {
601    $mapquery = array();
602         $mapquery['title'] = Array("", "<a id='mapcontrol-link' href='#mapcontrol' style='text-decoration:none;' onclick='open_mapcontrol(); return false;'>".t('Earth Layers')."</a>", "", "");
603         $aside['$mapquery'] = $mapquery;
604         $ELZoom = get_pconfig(local_user(), 'diabook', 'ELZoom' );
605         $ELPosX = get_pconfig(local_user(), 'diabook', 'ELPosX' );
606         $ELPosY = get_pconfig(local_user(), 'diabook', 'ELPosY' );
607         $aside['$sub'] = t('Submit');
608         $aside['$ELZoom'] = array('diabook_ELZoom', t('Set zoomfactor for Earth Layer'), $ELZoom, '', $ELZoom);
609         $aside['$ELPosX'] = array('diabook_ELPosX', t('Set longitude (X) for Earth Layer'), $ELPosX, '', $ELPosX);      
610         $aside['$ELPosY'] = array('diabook_ELPosY', t('Set latitude (Y) for Earth Layer'), $ELPosY, '', $ELPosY);       
611         $baseurl = $a->get_baseurl($ssl_state); 
612         $aside['$baseurl'] = $baseurl;
613         if (isset($_POST['diabook-settings-map-sub']) && $_POST['diabook-settings-map-sub']!=''){       
614                 set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']);
615                 set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']);       
616                 set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']);               
617                 header("Location: network");
618                 }
619         }
620    //end mapquery
621    
622   //helpers
623   if($_COOKIE['close_helpers'] != "1") {
624    $helpers = array();
625         $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
626         $aside['$helpers'] = $helpers;
627         }
628    //end helpers
629    //connectable services
630    if($_COOKIE['close_services'] != "1") {
631    $con_services = array();
632         $con_services['title'] = Array("", t('Connect Services'), "", "");
633         $aside['$con_services'] = $con_services;
634         }
635    //end connectable services
636    //twitter
637    if($_COOKIE['close_twitter'] != "1") {
638    $twitter = array();
639         $twitter['title'] = Array("", "<a id='twittersettings-link' href='#twittersettings' style='text-decoration:none;' onclick='open_twittersettings(); return false;'>".t('Last Tweets')."</a>", "", "");
640         $aside['$twitter'] = $twitter;
641         $TSearchTerm = get_pconfig(local_user(), 'diabook', 'TSearchTerm' );
642         $aside['$sub'] = t('Submit');
643         $aside['$TSearchTerm'] = array('diabook_TSearchTerm', t('Set twitter search term'), $TSearchTerm, '', $TSearchTerm);
644         $baseurl = $a->get_baseurl($ssl_state); 
645         $aside['$baseurl'] = $baseurl;
646         if (isset($_POST['diabook-settings-sub']) && $_POST['diabook-settings-sub']!=''){       
647                 set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']);     
648                 header("Location: network");
649                 }
650         }
651    //end twitter
652    $close = t('Close');
653    $aside['$close'] = $close;
654    //get_baseurl
655    $url = $a->get_baseurl($ssl_state);   
656    $aside['$url'] = $url;
657         //print right_aside
658         $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
659         $a->page['right_aside'] = replace_macros($tpl, $aside);
660         
661  }
662
663  function js_diabook_footer() {
664         /** @purpose insert stuff in bottom of page
665          */
666         $a = get_app();
667         $baseurl = $a->get_baseurl($ssl_state);
668         $bottom['$baseurl'] = $baseurl;
669         $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');
670         $a->page['footer'] = $a->page['footer'].replace_macros($tpl, $bottom);
671  }
672
673