]> git.mxchange.org Git - friendica.git/blob - view/theme/diabook/theme.php
f6c9dd7c1ae61e289b202ceab22f3a6d58ae9e9e
[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.025)
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.025)";
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 != "9") {
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         $_COOKIE['close_mapquery'] = "1";
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         $mqzoomsliderJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.mapquery.mqZoomSlider.js";
140         $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $mqzoomsliderJS);
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         $_COOKIE['close_mapquery'] = "1";
160         if($_COOKIE['close_mapquery'] != "1") {
161                 $a->page['htmlhead'] .= '
162                 <script>
163                 
164     $(document).ready(function() {
165     $("#map").mapQuery({
166         layers:[{         //add layers to your map; you need to define at least one to be able to see anything on the map
167             type:"osm"  //add a layer of the type osm (OpenStreetMap)
168             }],
169         center:({zoom:8,position:[11.7,52.2]}),
170        });
171     
172     });
173          
174     function open_mapcontrol() {
175                 $("div#mapcontrol").attr("style","display: block;width:900px;height:600px;");
176                 $("#map2").mapQuery({layers:[{type:"osm"}],
177                                                                                                 center:({zoom:8,position:[11.7,52.2]})}); 
178                                                                         
179                 $("#mouseposition").mqMousePosition({
180         map: "#map2",
181         x:"lon",
182         y:"lat",
183         precision:2
184                 }); 
185                 
186         
187         map = $("#map2").mapQuery().data("mapQuery");
188                 alert(map.center().zoom);
189                 
190         
191                 };
192                 </script>';
193         }
194         //check if twitterbox is active and print
195         if($_COOKIE['close_twitter'] != "1") {
196                 $TSearchTerm=false;
197                 $site_TSearchTerm = get_config("diabook", "TSearchTerm" );
198                 $TSearchTerm = get_pconfig(local_user(), "diabook", "TSearchTerm");
199                 if ($TSearchTerm===false) $TSearchTerm=$site_TSearchTerm;
200                 if ($TSearchTerm===false) $TSearchTerm="friendica";             
201                 $a->page['htmlhead'] .= '
202                 <script>
203                 $(function() {
204                 $("#twitter").twitterSearch({               
205                 term: "'.$TSearchTerm.'",
206                 animInSpeed: 250,
207                 bird:    false, 
208                 avatar:  false, 
209                 colorExterior: "#fff",
210                 timeout: 10000          });
211                 });
212                 function open_twittersettings() {
213                 $("div#twittersettings").attr("style","display: block;");
214                 };
215                 </script>';}
216                         
217         //check if community_home-plugin is activated and change css
218         $nametocheck = "communityhome";
219         $r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck));
220         if(count($r) == "1") {
221         
222         $a->page['htmlhead'] .= '
223         <script>
224         $(document).ready(function() {
225         $("div#login-submit-wrapper").attr("style","padding-top: 120px;");
226         
227         });
228         </script>';     
229         }
230         //comment-edit-wrapper on photo_view
231         if ($a->argv[0].$a->argv[2] === "photos"."image"){
232         $a->page['htmlhead'] .= '
233         <script>
234                 $(function(){
235                 $(".comment-edit-form").css("display","table");
236                         });
237     </script>';
238         }
239         //restore right hand col at settingspage
240         if($a->argv[0] === "settings" && local_user()) {
241         $a->page['htmlhead'] .= ' 
242         <script>
243         function restore_boxes(){
244         $.cookie("close_pages","2", { expires: 365, path: "/" });
245         $.cookie("close_mapquery","2", { expires: 365, path: "/" });
246         $.cookie("close_helpers","2", { expires: 365, path: "/" });
247         $.cookie("close_profiles","2", { expires: 365, path: "/" });
248         $.cookie("close_services","2", { expires: 365, path: "/" });
249         $.cookie("close_friends","2", { expires: 365, path: "/" });
250         $.cookie("close_twitter","2", { expires: 365, path: "/" });
251         $.cookie("close_lastusers","2", { expires: 365, path: "/" });
252         $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
253         $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
254         $.cookie("Boxorder",null, { expires: 365, path: "/" });
255         alert("Right-hand column was restored. Please refresh your browser");
256    }
257         </script>';}
258         
259         if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
260         $a->page['htmlhead'] .= '
261         <script>
262
263         $(function() {
264         $(".oembed.photo img").aeImageResize({height: 400, width: 400});
265         });
266         </script>';
267         
268         if($ccCookie != "9") {
269         $a->page['htmlhead'] .= '
270         <script>
271         $("right_aside").ready(function(){
272         
273         if($.cookie("close_pages") == "1") 
274                 {
275                 document.getElementById( "close_pages" ).style.display = "none";
276                         };
277                         
278         if($.cookie("close_mapquery") == "1") 
279                 {
280                 document.getElementById( "close_mapquery" ).style.display = "none";
281                         };
282                         
283         if($.cookie("close_profiles") == "1") 
284                 {
285                 document.getElementById( "close_profiles" ).style.display = "none";
286                         };
287         
288         if($.cookie("close_helpers") == "1") 
289                 {
290                 document.getElementById( "close_helpers" ).style.display = "none";
291                         };
292                         
293         if($.cookie("close_services") == "1") 
294                 {
295                 document.getElementById( "close_services" ).style.display = "none";
296                         };
297                         
298         if($.cookie("close_friends") == "1") 
299                 {
300                 document.getElementById( "close_friends" ).style.display = "none";
301                         };
302         
303         if($.cookie("close_twitter") == "1") 
304                 {
305                 document.getElementById( "close_twitter" ).style.display = "none";
306                         };      
307                         
308         if($.cookie("close_lastusers") == "1") 
309                 {
310                 document.getElementById( "close_lastusers" ).style.display = "none";
311                         };
312                         
313         if($.cookie("close_lastphotos") == "1") 
314                 {
315                 document.getElementById( "close_lastphotos" ).style.display = "none";
316                         };
317                         
318         if($.cookie("close_lastlikes") == "1") 
319                 {
320                 document.getElementById( "close_lastlikes" ).style.display = "none";
321                         };}
322
323         );
324
325         function close_pages(){
326          document.getElementById( "close_pages" ).style.display = "none";
327         $.cookie("close_pages","1", { expires: 365, path: "/" });
328         };
329         
330         function close_mapquery(){
331          document.getElementById( "close_mapquery" ).style.display = "none";
332         $.cookie("close_mapquery","1", { expires: 365, path: "/" });
333         };
334  
335         function close_profiles(){
336         document.getElementById( "close_profiles" ).style.display = "none";
337         $.cookie("close_profiles","1", { expires: 365, path: "/" });
338         };
339  
340         function close_helpers(){
341         document.getElementById( "close_helpers" ).style.display = "none";
342         $.cookie("close_helpers","1", { expires: 365, path: "/" });
343         };
344
345         function close_services(){
346         document.getElementById( "close_services" ).style.display = "none";
347         $.cookie("close_services","1", { expires: 365, path: "/" });
348         };
349  
350         function close_friends(){
351          document.getElementById( "close_friends" ).style.display = "none";
352          $.cookie("close_friends","1", { expires: 365, path: "/" });
353          };
354  
355         function close_twitter(){
356         document.getElementById( "close_twitter" ).style.display = "none";
357          $.cookie("close_twitter","1", { expires: 365, path: "/" });
358         };
359  
360         function close_lastusers(){
361          document.getElementById( "close_lastusers" ).style.display = "none";
362         $.cookie("close_lastusers","1", { expires: 365, path: "/" });
363          };
364
365         function close_lastphotos(){
366         document.getElementById( "close_lastphotos" ).style.display = "none";
367          $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
368          };
369  
370         function close_lastlikes(){
371          document.getElementById( "close_lastlikes" ).style.display = "none";
372          $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
373          };
374         </script>';}
375         }
376         //end js scripts
377
378         // custom css
379         if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
380
381         //footer
382         $tpl = get_markup_template('footer.tpl');
383         $a->page['footer'] .= replace_macros($tpl, array());
384         
385         //
386         js_diabook_footer();
387 }
388
389
390  function diabook_community_info() {
391         $a = get_app();
392         // comunity_profiles
393         if($_COOKIE['close_profiles'] != "1") {
394         $aside['$comunity_profiles_title'] = t('Community Profiles');
395         $aside['$comunity_profiles_items'] = array();
396         $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id 
397                           where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
398         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
399         if(count($r)) {
400                 $photo = 'photo';
401                 foreach($r as $rr) {
402                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
403                         $entry = replace_macros($tpl,array(
404                                 '$id' => $rr['id'],
405                                 '$profile-link' => zrl($rr['url']),
406                                 '$photo' => $rr[$photo],
407                                 '$alt-text' => $rr['name'],
408                         ));
409                         $aside['$comunity_profiles_items'][] = $entry;
410                 }
411         }}
412         
413         // last 12 users
414         if($_COOKIE['close_lastusers'] != "1") {
415         $aside['$lastusers_title'] = t('Last users');
416         $aside['$lastusers_items'] = array();
417         $sql_extra = "";
418         $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
419         $order = " ORDER BY `register_date` DESC ";
420
421         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
422                         FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 
423                         WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
424                 0,
425                 9
426         );
427         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
428         if(count($r)) {
429                 $photo = 'thumb';
430                 foreach($r as $rr) {
431                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
432                         $entry = replace_macros($tpl,array(
433                                 '$id' => $rr['id'],
434                                 '$profile-link' => $profile_link,
435                                 '$photo' => $rr[$photo],
436                                 '$alt-text' => $rr['name'],
437                         ));
438                         $aside['$lastusers_items'][] = $entry;
439                 }
440         }}
441         
442         // last 10 liked items
443         if($_COOKIE['close_lastlikes'] != "1") {
444         $aside['$like_title'] = t('Last likes');
445         $aside['$like_items'] = array();
446         $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM 
447                         (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` 
448                                 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
449                         INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri` 
450                         WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
451                         GROUP BY `uri`
452                         ORDER BY `T1`.`created` DESC
453                         LIMIT 0,5",
454                         $a->get_baseurl(),$a->get_baseurl()
455                         );
456
457         foreach ($r as $rr) {
458                 $author  = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
459                 $objauthor =  '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
460                 
461                 //var_dump($rr['verb'],$rr['object-type']); killme();
462                 switch($rr['verb']){
463                         case 'http://activitystrea.ms/schema/1.0/post':
464                                 switch ($rr['object-type']){
465                                         case 'http://activitystrea.ms/schema/1.0/event':
466                                                 $post_type = t('event');
467                                                 break;
468                                         default:
469                                                 $post_type = t('status');
470                                 }
471                                 break;
472                         default:
473                                 if ($rr['resource-id']){
474                                         $post_type = t('photo');
475                                         $m=array();     preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
476                                         $rr['plink'] = $m[1];
477                                 } else {
478                                         $post_type = t('status');
479                                 }
480                 }
481                 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
482
483                 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
484                 
485         }}
486         
487         // last 12 photos
488         if($_COOKIE['close_photos'] != "1") {
489         $aside['$photos_title'] = t('Last photos');
490         $aside['$photos_items'] = array();
491         $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM 
492                                 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo` 
493                                         WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
494                                                 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
495                                 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
496                                 `user` 
497                                 WHERE `user`.`uid` = `photo`.`uid`
498                                 AND `user`.`blockwall`=0
499                                 AND `user`.`hidewall`=0
500                                 ORDER BY `photo`.`edited` DESC
501                                 LIMIT 0, 9",
502                                 dbesc(t('Contact Photos')),
503                                 dbesc(t('Profile Photos'))
504                                 );
505                 if(count($r)) {
506                 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
507                 foreach($r as $rr) {
508                         $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
509                         $photo_url = $a->get_baseurl() . '/photo/' .  $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
510                 
511                         $entry = replace_macros($tpl,array(
512                                 '$id' => $rr['id'],
513                                 '$profile-link' => $photo_page,
514                                 '$photo' => $photo_url,
515                                 '$alt-text' => $rr['username']." : ".$rr['desc'],
516                         ));
517
518                         $aside['$photos_items'][] = $entry;
519                 }
520         }}
521         
522    //right_aside FIND FRIENDS
523    if($_COOKIE['close_friends'] != "1") {
524         if(local_user()) {
525         $nv = array();
526         $nv['title'] = Array("", t('Find Friends'), "", "");
527         $nv['directory'] = Array('directory', t('Local Directory'), "", "");
528         $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
529         $nv['match'] = Array('match', t('Similar Interests'), "", "");
530         $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
531         $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
532         
533         $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
534                                                 <span class="sbox_l"></span>
535                                                 <span class="sbox">
536                                                 <input type="text" name="search" size="13" maxlength="50">
537                                                 </span>
538                                                 <span class="sbox_r" id="srch_clear"></span>';
539         
540         $aside['$nv'] = $nv;
541         }}
542    
543    //Community_Pages at right_aside
544    if($_COOKIE['close_pages'] != "1") {
545    if(local_user()) {
546    $page = '
547                         <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>
548                         <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">';
549
550         $pagelist = array();
551
552         $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
553                         WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
554                         ORDER BY `name` ASC",
555                         intval($a->user['uid'])
556         );
557
558         $pageD = array();
559
560         // Look if the profile is a community page
561         foreach($contacts as $contact) {
562                 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
563         };
564         
565
566         $contacts = $pageD;
567
568         foreach($contacts as $contact) {
569                 $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">'.
570                                 $contact["name"]."</a></li>";
571         }
572         $page .= '</ul></div>';
573         //if (sizeof($contacts) > 0)
574                 $aside['$page'] = $page;        
575         }}
576   //END Community Page  
577   
578    //mapquery
579    $_COOKIE['close_mapquery'] = "1";
580   if($_COOKIE['close_mapquery'] != "1") {
581    $mapquery = array();
582         $mapquery['title'] = Array("", "<a id='mapcontrol-link' href='#mapcontrol' style='text-decoration:none;' onclick='open_mapcontrol(); return false;'>".t('Earth View')."</a>", "", "");
583         $aside['$mapquery'] = $mapquery;
584         }
585    //end mapquery
586    
587   //helpers
588   if($_COOKIE['close_helpers'] != "1") {
589    $helpers = array();
590         $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
591         $aside['$helpers'] = $helpers;
592         }
593    //end helpers
594    //connectable services
595    if($_COOKIE['close_services'] != "1") {
596    $con_services = array();
597         $con_services['title'] = Array("", t('Connect Services'), "", "");
598         $aside['$con_services'] = $con_services;
599         }
600    //end connectable services
601    //twitter
602    if($_COOKIE['close_twitter'] != "1") {
603    $twitter = array();
604         $twitter['title'] = Array("", "<a id='twittersettings-link' href='#twittersettings' style='text-decoration:none;' onclick='open_twittersettings(); return false;'>".t('Last Tweets')."</a>", "", "");
605         $aside['$twitter'] = $twitter;
606         $TSearchTerm = get_pconfig(local_user(), 'diabook', 'TSearchTerm' );
607         $aside['$sub'] = t('Submit');
608         $aside['$TSearchTerm'] = array('diabook_TSearchTerm', t('Set twitter search term'), $TSearchTerm, '', $TSearchTerm);
609         $baseurl = $a->get_baseurl($ssl_state); 
610         $aside['$baseurl'] = $baseurl;
611         if (isset($_POST['diabook-settings-sub']) && $_POST['diabook-settings-sub']!=''){       
612                 set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']);     
613                 header("Location: network");
614                 }
615         }
616    //end twitter
617    $close = t('Close');
618    $aside['$close'] = $close;
619    //get_baseurl
620    $url = $a->get_baseurl($ssl_state);   
621    $aside['$url'] = $url;
622         //print right_aside
623         $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
624         $a->page['right_aside'] = replace_macros($tpl, $aside);
625         
626  }
627
628  function js_diabook_footer() {
629         /** @purpose insert stuff in bottom of page
630          */
631         $a = get_app();
632         $baseurl = $a->get_baseurl($ssl_state);
633         $bottom['$baseurl'] = $baseurl;
634         $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');
635         $a->page['footer'] = $a->page['footer'].replace_macros($tpl, $bottom);
636  }
637
638