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