]> git.mxchange.org Git - friendica.git/blob - view/theme/diabook/theme.php
diabook-themes: fixed css for settings aside-links
[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.017)
7  * Author: 
8  */
9
10
11 //print diabook-version for debugging
12 $diabook_version = "Diabook (Version: 1.017)";
13 $a->page['htmlhead'] .= sprintf('<script "%s" ></script>', $diabook_version);
14
15 //change css on network and profilepages
16 $cssFile = null;
17
18
19 /**
20  * prints last community activity
21  */
22
23
24  
25 function diabook_community_info(){
26         $a = get_app();
27
28
29         // last 12 users
30         $aside['$lastusers_title'] = t('Last users');
31         $aside['$lastusers_items'] = array();
32         $sql_extra = "";
33         $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
34         $order = " ORDER BY `register_date` DESC ";
35
36         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
37                         FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 
38                         WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
39                 0,
40                 9
41         );
42         $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
43         if(count($r)) {
44                 $photo = 'thumb';
45                 foreach($r as $rr) {
46                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
47                         $entry = replace_macros($tpl,array(
48                                 '$id' => $rr['id'],
49                                 '$profile-link' => $profile_link,
50                                 '$photo' => $rr[$photo],
51                                 '$alt-text' => $rr['name'],
52                         ));
53                         $aside['$lastusers_items'][] = $entry;
54                 }
55         }
56         
57         
58         // last 10 liked items
59         $aside['$like_title'] = t('Last likes');
60         $aside['$like_items'] = array();
61         $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM 
62                         (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` 
63                                 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
64                         INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri` 
65                         WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
66                         GROUP BY `uri`
67                         ORDER BY `T1`.`created` DESC
68                         LIMIT 0,5",
69                         $a->get_baseurl(),$a->get_baseurl()
70                         );
71
72         foreach ($r as $rr) {
73                 $author  = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
74                 $objauthor =  '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
75                 
76                 //var_dump($rr['verb'],$rr['object-type']); killme();
77                 switch($rr['verb']){
78                         case 'http://activitystrea.ms/schema/1.0/post':
79                                 switch ($rr['object-type']){
80                                         case 'http://activitystrea.ms/schema/1.0/event':
81                                                 $post_type = t('event');
82                                                 break;
83                                         default:
84                                                 $post_type = t('status');
85                                 }
86                                 break;
87                         default:
88                                 if ($rr['resource-id']){
89                                         $post_type = t('photo');
90                                         $m=array();     preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
91                                         $rr['plink'] = $m[1];
92                                 } else {
93                                         $post_type = t('status');
94                                 }
95                 }
96                 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
97
98                 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
99                 
100         }
101         
102         
103         // last 12 photos
104         $aside['$photos_title'] = t('Last photos');
105         $aside['$photos_items'] = array();
106         $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM 
107                                 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo` 
108                                         WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
109                                                 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
110                                 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
111                                 `user` 
112                                 WHERE `user`.`uid` = `photo`.`uid`
113                                 AND `user`.`blockwall`=0
114                                 AND `user`.`hidewall`=0
115                                 ORDER BY `photo`.`edited` DESC
116                                 LIMIT 0, 9",
117                                 dbesc(t('Contact Photos')),
118                                 dbesc(t('Profile Photos'))
119                                 );
120                 if(count($r)) {
121                 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
122                 foreach($r as $rr) {
123                         $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
124                         $photo_url = $a->get_baseurl() . '/photo/' .  $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
125                 
126                         $entry = replace_macros($tpl,array(
127                                 '$id' => $rr['id'],
128                                 '$profile-link' => $photo_page,
129                                 '$photo' => $photo_url,
130                                 '$alt-text' => $rr['username']." : ".$rr['desc'],
131                         ));
132
133                         $aside['$photos_items'][] = $entry;
134                 }
135         }
136         
137         $fostitJS = "javascript: (function() {
138                                         the_url = '".$a->get_baseurl($ssl_state)."/view/theme/diabook/fpostit/fpostit.php?url=' + encodeURIComponent(window.location.href) + '&title=' + encodeURIComponent(document.title) + '&text=' + encodeURIComponent(''+(window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text));
139                                                 a_funct = function() {
140                                                         if (!window.open(the_url, 'fpostit', 'location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300')) location.href = the_url};
141                                                         if (/Firefox/.test(navigator.userAgent)) {setTimeout(a_funct, 0)} 
142                                                         else {a_funct()}})()" ;
143   
144    $aside['$fostitJS'] = $fostitJS;
145    
146    //right_aside FIND FRIENDS
147         if(local_user()) {
148         $nv = array();
149         $nv['title'] = Array("", t('Find Friends'), "", "");
150         $nv['directory'] = Array('directory', t('Local Directory'), "", "");
151         $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
152         $nv['match'] = Array('match', t('Similar Interests'), "", "");
153         $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
154         $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
155         
156         $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
157                                                 <span class="sbox_l"></span>
158                                                 <span class="sbox">
159                                                 <input type="text" name="search" size="13" maxlength="50">
160                                                 </span>
161                                                 <span class="sbox_r" id="srch_clear"></span>';
162         
163         $aside['$nv'] = $nv;
164         };
165    
166    //Community Page
167    if(local_user()) {
168    $page = '<div id="page-sidebar-right_aside" class="widget">
169                         <div class="title tool">
170                         <h3>'.t("Community Pages").'<a id="close_pages_icon"  onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
171                         <div id="sidebar-page-list"><ul>';
172
173         $pagelist = array();
174
175         $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
176                         WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
177                         ORDER BY `name` ASC",
178                         intval($a->user['uid'])
179         );
180
181         $pageD = array();
182
183         // Look if the profile is a community page
184         foreach($contacts as $contact) {
185                 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
186         };
187         
188
189         $contacts = $pageD;
190
191         foreach($contacts as $contact) {
192                 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" style="margin-top: 2px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
193                                 $contact["name"]."</a></li>";
194         }
195         $page .= '</ul></div></div>';
196         //if (sizeof($contacts) > 0)
197                 
198                 $aside['$page'] = $page;        
199         }
200   //END Community Page  
201   //helpers
202    $helpers = array();
203         $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
204         
205         $aside['$helpers'] = $helpers;
206    //end helpers
207    //connectable services
208    $con_services = array();
209         $con_services['title'] = Array("", t('Connect Services'), "", "");
210         
211         $aside['$con_services'] = $con_services;
212    //end connectable services
213    //postit
214    $postit = array();
215         $postit['title'] = Array("", t('PostIt to Friendica'), t('Post to Friendica'), "");
216         $postit['text'] = Array("", t(' from anywhere by bookmarking this Link.'), "", "");
217         
218         $aside['$postit'] = $postit;
219    //end postit
220   
221    //get_baseurl
222    $url = $a->get_baseurl($ssl_state);   
223    $aside['$url'] = $url;
224
225         $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
226         $a->page['right_aside'] = replace_macros($tpl, $aside);
227         
228         
229         
230         
231 }
232
233
234 //profile_side at networkpages
235 if ($a->argv[0] === "network" && local_user()){
236
237         // USER MENU
238         if(local_user()) {
239                 
240                 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
241                                 
242                 $userinfo = array(
243                                         'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
244                                         'name' => $a->user['username'],
245                                 );      
246                 $ps = array('usermenu'=>array());
247                 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
248                 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
249                 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));                                
250                 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
251                 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
252                 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
253                 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
254                 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", "");
255
256                 $tpl = get_markup_template('profile_side.tpl');
257
258                 $a->page['aside'] .= replace_macros($tpl, array(
259                                 '$userinfo' => $userinfo,
260                                 '$ps' => $ps,
261                         ));
262
263         }
264         
265         $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_postit'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes'];
266         
267         if($ccCookie != "8") {
268         // COMMUNITY
269         diabook_community_info();
270         
271         // CUSTOM CSS
272         $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-network.css";
273         }
274 }
275
276
277
278 //right_aside at profile pages
279 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
280         if($ccCookie != "8") {
281         // COMMUNITY
282         diabook_community_info();
283         
284         // CUSTOM CSS
285         $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-profile.css";
286         
287         
288         }
289 }
290
291 // custom css
292 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
293
294 //load jquery.cookie.js
295 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.cookie.js";
296 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s"></script>', $cookieJS);
297
298 //load jquery.ae.image.resize.js
299 $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.ae.image.resize.js";
300 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
301
302
303 //js scripts
304 //comment-edit-wrapper on photo_view
305 if ($a->argv[0].$a->argv[2] === "photos"."image"){
306
307 $a->page['htmlhead'] .= '
308 <script>
309         $(function(){
310         
311                 $(".comment-edit-form").css("display","table");
312                         
313                         });
314     </script>';
315         
316 }
317
318 $a->page['htmlhead'] .= '
319
320 <script>
321  $(function() {
322         $("a.lightbox").fancybox(); // Select all links with lightbox class
323  });
324    
325  </script>';
326  
327  
328 $a->page['htmlhead'] .= '
329  <script>
330  
331 $(document).ready(function() {
332     $("iframe").each(function(){
333         var ifr_source = $(this).attr("src");
334         var wmode = "wmode=transparent";
335         if(ifr_source.indexOf("?") != -1) {
336             var getQString = ifr_source.split("?");
337             var oldString = getQString[1];
338             var newString = getQString[0];
339             $(this).attr("src",newString+"?"+wmode+"&"+oldString);
340         }
341         else $(this).attr("src",ifr_source+"?"+wmode);
342     });
343       
344
345 });
346
347 function yt_iframe() {
348         
349         $("iframe").load(function() { 
350         var ifr_src = $(this).contents().find("body iframe").attr("src");
351         $("iframe").contents().find("body iframe").attr("src", ifr_src+"&wmode=transparent");
352     });
353
354         };
355   
356  </script>';
357  
358
359 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
360 $a->page['htmlhead'] .= '
361 <script>
362
363  $(function() {
364         $(".oembed.photo img").aeImageResize({height: 400, width: 400});
365   });
366 </script>';
367
368
369         if($ccCookie != "8") {
370 $a->page['htmlhead'] .= '
371 <script>
372 $("right_aside").ready(function(){
373         
374         if($.cookie("close_pages") == "1") 
375                 {
376                 document.getElementById( "close_pages" ).style.display = "none";
377                         };
378         
379         if($.cookie("close_helpers") == "1") 
380                 {
381                 document.getElementById( "close_helpers" ).style.display = "none";
382                         };
383                         
384         if($.cookie("close_services") == "1") 
385                 {
386                 document.getElementById( "close_services" ).style.display = "none";
387                         };
388                         
389         if($.cookie("close_friends") == "1") 
390                 {
391                 document.getElementById( "close_friends" ).style.display = "none";
392                         };
393         
394         if($.cookie("close_postit") == "1") 
395                 {
396                 document.getElementById( "close_postit" ).style.display = "none";
397                         };
398                         
399         if($.cookie("close_lastusers") == "1") 
400                 {
401                 document.getElementById( "close_lastusers" ).style.display = "none";
402                         };
403                         
404         if($.cookie("close_lastphotos") == "1") 
405                 {
406                 document.getElementById( "close_lastphotos" ).style.display = "none";
407                         };
408                         
409         if($.cookie("close_lastlikes") == "1") 
410                 {
411                 document.getElementById( "close_lastlikes" ).style.display = "none";
412                         };}
413
414 );
415
416 function close_pages(){
417  document.getElementById( "close_pages" ).style.display = "none";
418  $.cookie("close_pages","1", { expires: 365, path: "/" });
419  };
420  
421 function close_helpers(){
422  document.getElementById( "close_helpers" ).style.display = "none";
423   $.cookie("close_helpers","1", { expires: 365, path: "/" });
424  };
425
426 function close_services(){
427  document.getElementById( "close_services" ).style.display = "none";
428  $.cookie("close_services","1", { expires: 365, path: "/" });
429  };
430  
431 function close_friends(){
432  document.getElementById( "close_friends" ).style.display = "none";
433  $.cookie("close_friends","1", { expires: 365, path: "/" });
434  };
435
436 function close_postit(){
437  document.getElementById( "close_postit" ).style.display = "none";
438  $.cookie("close_postit","1", { expires: 365, path: "/" });
439  };
440  
441 function close_lastusers(){
442  document.getElementById( "close_lastusers" ).style.display = "none";
443  $.cookie("close_lastusers","1", { expires: 365, path: "/" });
444  };
445
446 function close_lastphotos(){
447  document.getElementById( "close_lastphotos" ).style.display = "none";
448  $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
449  };
450  
451 function close_lastlikes(){
452  document.getElementById( "close_lastlikes" ).style.display = "none";
453  $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
454  };
455 </script>';}
456
457 $a->page['htmlhead'] .= ' 
458 <script>
459 function restore_boxes(){
460         $.cookie("close_pages","2", { expires: 365, path: "/" });
461         $.cookie("close_helpers","2", { expires: 365, path: "/" });
462         $.cookie("close_services","2", { expires: 365, path: "/" });
463         $.cookie("close_friends","2", { expires: 365, path: "/" });
464         $.cookie("close_postit","2", { expires: 365, path: "/" });
465         $.cookie("close_lastusers","2", { expires: 365, path: "/" });
466         $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
467         $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
468         alert("Right-hand column was restored. Please refresh your browser");
469   }
470 </script>';}
471
472 $a->page['htmlhead'] .= ' 
473
474 <script type="text/javascript">
475 function insertFormatting(BBcode,id) {
476         
477                 var tmpStr = $("#comment-edit-text-" + id).val();
478                 if(tmpStr == "Kommentar") {
479                         tmpStr = "";
480                         $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
481                         $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
482                         openMenu("comment-edit-submit-wrapper-" + id);
483                                                                                         }
484
485         textarea = document.getElementById("comment-edit-text-" +id);
486         if (document.selection) {
487                 textarea.focus();
488                 selected = document.selection.createRange();
489                 if (BBcode == "url"){
490                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
491                         } else                  
492                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
493         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
494                 var start = textarea.selectionStart;
495                 var end = textarea.selectionEnd;
496                 if (BBcode == "url"){
497                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
498                         } else
499                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
500         }
501         return true;
502 }
503 </script> ';