]> git.mxchange.org Git - friendica.git/blob - view/theme/diabook/diabook-blue/theme.php
diabook-themes: theme-settings: add "colour scheme"-option, add diabook-pink and...
[friendica.git] / view / theme / diabook / diabook-blue / theme.php
1 <?php
2
3 /*
4  * Name: Diabook-blue
5  * Description: Diabook-blue: 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-blue (Version: 1.020)";
13 $a->page['htmlhead'] .= sprintf('<script "%s" ></script>', $diabook_version);
14
15 //change css on network and profilepages
16 $cssFile = null;
17 $resolution=false;
18 $resolution = get_pconfig(local_user(), "diabook-blue", "resolution");
19 if ($resolution===false) $resolution="normal";
20
21 /**
22  * prints last community activity
23  */
24 function diabook_blue_community_info(){
25         $a = get_app();
26
27         // last 12 users
28         $aside['$lastusers_title'] = t('Last users');
29         $aside['$lastusers_items'] = array();
30         $sql_extra = "";
31         $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
32         $order = " ORDER BY `register_date` DESC ";
33
34         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
35                         FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 
36                         WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
37                 0,
38                 9
39         );
40         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
41         if(count($r)) {
42                 $photo = 'thumb';
43                 foreach($r as $rr) {
44                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
45                         $entry = replace_macros($tpl,array(
46                                 '$id' => $rr['id'],
47                                 '$profile-link' => $profile_link,
48                                 '$photo' => $rr[$photo],
49                                 '$alt-text' => $rr['name'],
50                         ));
51                         $aside['$lastusers_items'][] = $entry;
52                 }
53         }
54         
55         
56         // last 10 liked items
57         $aside['$like_title'] = t('Last likes');
58         $aside['$like_items'] = array();
59         $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM 
60                         (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` 
61                                 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
62                         INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri` 
63                         WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
64                         GROUP BY `uri`
65                         ORDER BY `T1`.`created` DESC
66                         LIMIT 0,5",
67                         $a->get_baseurl(),$a->get_baseurl()
68                         );
69
70         foreach ($r as $rr) {
71                 $author  = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
72                 $objauthor =  '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
73                 
74                 //var_dump($rr['verb'],$rr['object-type']); killme();
75                 switch($rr['verb']){
76                         case 'http://activitystrea.ms/schema/1.0/post':
77                                 switch ($rr['object-type']){
78                                         case 'http://activitystrea.ms/schema/1.0/event':
79                                                 $post_type = t('event');
80                                                 break;
81                                         default:
82                                                 $post_type = t('status');
83                                 }
84                                 break;
85                         default:
86                                 if ($rr['resource-id']){
87                                         $post_type = t('photo');
88                                         $m=array();     preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
89                                         $rr['plink'] = $m[1];
90                                 } else {
91                                         $post_type = t('status');
92                                 }
93                 }
94                 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
95
96                 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
97                 
98         }
99         
100         
101         // last 12 photos
102         $aside['$photos_title'] = t('Last photos');
103         $aside['$photos_items'] = array();
104         $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM 
105                                 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo` 
106                                         WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
107                                                 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
108                                 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
109                                 `user` 
110                                 WHERE `user`.`uid` = `photo`.`uid`
111                                 AND `user`.`blockwall`=0
112                                 AND `user`.`hidewall`=0
113                                 ORDER BY `photo`.`edited` DESC
114                                 LIMIT 0, 9",
115                                 dbesc(t('Contact Photos')),
116                                 dbesc(t('Profile Photos'))
117                                 );
118                 if(count($r)) {
119                 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
120                 foreach($r as $rr) {
121                         $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
122                         $photo_url = $a->get_baseurl() . '/photo/' .  $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
123                 
124                         $entry = replace_macros($tpl,array(
125                                 '$id' => $rr['id'],
126                                 '$profile-link' => $photo_page,
127                                 '$photo' => $photo_url,
128                                 '$alt-text' => $rr['username']." : ".$rr['desc'],
129                         ));
130
131                         $aside['$photos_items'][] = $entry;
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_blue_community_info();
250         
251         // CUSTOM CSS
252         if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/style-network.css";}
253         if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/style-network-wide.css";}
254         }
255 }
256
257
258
259 //right_aside at profile pages
260 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
261         if($ccCookie != "7") {
262         // COMMUNITY
263         diabook_blue_community_info();
264         
265         // CUSTOM CSS
266         if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/style-profile.css";}
267         if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/style-profile-wide.css";}
268         }
269 }
270
271
272 // custom css
273 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
274
275 //load jquery.cookie.js
276 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/js/jquery.cookie.js";
277 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $cookieJS);
278
279 //load jquery.ae.image.resize.js
280 $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/js/jquery.ae.image.resize.js";
281 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
282
283 //load jquery.autogrow-textarea.js
284 $autogrowJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/js/jquery.autogrow.textarea.js";
285 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $autogrowJS);
286
287 //js scripts
288 //comment-edit-wrapper on photo_view
289 if ($a->argv[0].$a->argv[2] === "photos"."image"){
290
291 $a->page['htmlhead'] .= '
292 <script>
293         $(function(){
294         
295                 $(".comment-edit-form").css("display","table");
296                         
297                         });
298     </script>';
299         
300 }
301
302
303 $a->page['htmlhead'] .= '
304
305 <script>
306  $(function() {
307         $("a.lightbox").fancybox(); // Select all links with lightbox class
308  });
309   
310  </script>';
311  
312 $a->page['htmlhead'] .= '
313
314 <script type="text/javascript">
315
316 function tautogrow(id){
317                 $("textarea#comment-edit-text-" +id).autogrow();        
318         };
319  </script>';
320
321 $a->page['htmlhead'] .= '
322  <script>
323  
324 $(document).ready(function() {
325     $("iframe").each(function(){
326         var ifr_source = $(this).attr("src");
327         var wmode = "wmode=transparent";
328         if(ifr_source.indexOf("?") != -1) {
329             var getQString = ifr_source.split("?");
330             var oldString = getQString[1];
331             var newString = getQString[0];
332             $(this).attr("src",newString+"?"+wmode+"&"+oldString);
333         }
334         else $(this).attr("src",ifr_source+"?"+wmode);
335     });
336       
337
338 });
339
340 function yt_iframe() {
341         
342         $("iframe").load(function() { 
343         var ifr_src = $(this).contents().find("body iframe").attr("src");
344         $("iframe").contents().find("body iframe").attr("src", ifr_src+"&wmode=transparent");
345     });
346
347         };
348   
349  </script>';
350
351
352 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
353 $a->page['htmlhead'] .= '
354 <script>
355
356  $(function() {
357         $(".oembed.photo img").aeImageResize({height: 400, width: 400});
358   });
359 </script>';
360
361
362         if($ccCookie != "7") {
363 $a->page['htmlhead'] .= '
364 <script>
365 $("right_aside").ready(function(){
366         
367         if($.cookie("close_pages") == "1") 
368                 {
369                 document.getElementById( "close_pages" ).style.display = "none";
370                         };
371         
372         if($.cookie("close_helpers") == "1") 
373                 {
374                 document.getElementById( "close_helpers" ).style.display = "none";
375                         };
376                         
377         if($.cookie("close_services") == "1") 
378                 {
379                 document.getElementById( "close_services" ).style.display = "none";
380                         };
381                         
382         if($.cookie("close_friends") == "1") 
383                 {
384                 document.getElementById( "close_friends" ).style.display = "none";
385                         };
386         
387                         
388         if($.cookie("close_lastusers") == "1") 
389                 {
390                 document.getElementById( "close_lastusers" ).style.display = "none";
391                         };
392                         
393         if($.cookie("close_lastphotos") == "1") 
394                 {
395                 document.getElementById( "close_lastphotos" ).style.display = "none";
396                         };
397                         
398         if($.cookie("close_lastlikes") == "1") 
399                 {
400                 document.getElementById( "close_lastlikes" ).style.display = "none";
401                         };}
402
403 );
404
405 function close_pages(){
406  document.getElementById( "close_pages" ).style.display = "none";
407  $.cookie("close_pages","1", { expires: 365, path: "/" });
408  };
409  
410 function close_helpers(){
411  document.getElementById( "close_helpers" ).style.display = "none";
412   $.cookie("close_helpers","1", { expires: 365, path: "/" });
413  };
414
415 function close_services(){
416  document.getElementById( "close_services" ).style.display = "none";
417  $.cookie("close_services","1", { expires: 365, path: "/" });
418  };
419  
420 function close_friends(){
421  document.getElementById( "close_friends" ).style.display = "none";
422  $.cookie("close_friends","1", { expires: 365, path: "/" });
423  };
424  
425 function close_lastusers(){
426  document.getElementById( "close_lastusers" ).style.display = "none";
427  $.cookie("close_lastusers","1", { expires: 365, path: "/" });
428  };
429
430 function close_lastphotos(){
431  document.getElementById( "close_lastphotos" ).style.display = "none";
432  $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
433  };
434  
435 function close_lastlikes(){
436  document.getElementById( "close_lastlikes" ).style.display = "none";
437  $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
438  };
439 </script>';}
440
441 $a->page['htmlhead'] .= ' 
442 <script>
443 function restore_boxes(){
444         $.cookie("close_pages","2", { expires: 365, path: "/" });
445         $.cookie("close_helpers","2", { expires: 365, path: "/" });
446         $.cookie("close_services","2", { expires: 365, path: "/" });
447         $.cookie("close_friends","2", { expires: 365, path: "/" });
448         $.cookie("close_lastusers","2", { expires: 365, path: "/" });
449         $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
450         $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
451         alert("Right-hand column was restored. Please refresh your browser");
452   }
453 </script>';}
454
455 $a->page['htmlhead'] .= ' 
456
457 <script type="text/javascript">
458 function insertFormatting(comment,BBcode,id) {
459         
460                 var tmpStr = $("#comment-edit-text-" + id).val();
461                 if(tmpStr == comment) {
462                         tmpStr = "";
463                         $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
464                         $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
465                         openMenu("comment-edit-submit-wrapper-" + id);
466                                                                                         }
467
468         textarea = document.getElementById("comment-edit-text-" +id);
469         if (document.selection) {
470                 textarea.focus();
471                 selected = document.selection.createRange();
472                 if (BBcode == "url"){
473                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
474                         } else                  
475                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
476         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
477                 var start = textarea.selectionStart;
478                 var end = textarea.selectionEnd;
479                 if (BBcode == "url"){
480                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
481                         } else
482                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
483         }
484         return true;
485 }
486 </script> ';