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