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.016)
11 //print diabook-version for debugging
12 $diabook_version = "Diabook-aerith (Version: 1.016)";
13 $a->page['htmlhead'] .= sprintf('<script "%s" ></script>', $diabook_version);
16 //change css on network and profilepages
21 * prints last community activity
23 function diabook_aerith_community_info(){
25 //right_aside at networkpages
28 $aside['$lastusers_title'] = t('Last users');
29 $aside['$lastusers_items'] = array();
31 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
32 $order = " ORDER BY `register_date` DESC ";
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 ",
40 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
44 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
45 $entry = replace_macros($tpl,array(
47 '$profile-link' => $profile_link,
48 '$photo' => $rr[$photo],
49 '$alt-text' => $rr['name'],
51 $aside['$lastusers_items'][] = $entry;
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%%'
65 ORDER BY `T1`.`created` DESC
67 $a->get_baseurl(),$a->get_baseurl()
71 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
72 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
74 //var_dump($rr['verb'],$rr['object-type']); killme();
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');
82 $post_type = t('status');
86 if ($rr['resource-id']){
87 $post_type = t('photo');
88 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
91 $post_type = t('status');
94 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
96 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
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`,
110 WHERE `user`.`uid` = `photo`.`uid`
111 AND `user`.`blockwall`=0
112 AND `user`.`hidewall`=0
113 ORDER BY `photo`.`edited` DESC
115 dbesc(t('Contact Photos')),
116 dbesc(t('Profile Photos'))
119 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
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';
124 $entry = replace_macros($tpl,array(
126 '$profile-link' => $photo_page,
127 '$photo' => $photo_url,
128 '$alt-text' => $rr['username']." : ".$rr['desc'],
131 $aside['$photos_items'][] = $entry;
135 $fostitJS = "javascript: (function() {
136 the_url = '".$a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/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));
137 a_funct = function() {
138 if (!window.open(the_url, 'fpostit', 'location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300')) location.href = the_url};
139 if (/Firefox/.test(navigator.userAgent)) {setTimeout(a_funct, 0)}
140 else {a_funct()}})()" ;
142 $aside['$fostitJS'] = $fostitJS;
147 $nv['title'] = Array("", t('Find Friends'), "", "");
148 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
149 $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
150 $nv['match'] = Array('match', t('Similar Interests'), "", "");
151 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
152 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
154 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
155 <span class="sbox_l"></span>
157 <input type="text" name="search" size="13" maxlength="50">
159 <span class="sbox_r" id="srch_clear"></span>';
165 $page = '<div id="page-sidebar-right_aside" class="widget">
166 <div class="title tool">
167 <h3>'.t("Community Pages").'<a id="close_pages_icon" onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
168 <div id="sidebar-page-list"><ul>';
172 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
173 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
174 ORDER BY `name` ASC",
175 intval($a->user['uid'])
180 // Look if the profile is a community page
181 foreach($contacts as $contact) {
182 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
188 foreach($contacts as $contact) {
189 $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">'.
190 $contact["name"]."</a></li>";
192 $page .= '</ul></div></div>';
193 //if (sizeof($contacts) > 0)
195 $aside['$page'] = $page;
200 $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
202 $aside['$helpers'] = $helpers;
204 //connectable services
205 $con_services = array();
206 $con_services['title'] = Array("", t('Connect Services'), "", "");
208 $aside['$con_services'] = $con_services;
209 //end connectable services
212 $postit['title'] = Array("", t('PostIt to Friendica'), t('Post to Friendica'), "");
213 $postit['text'] = Array("", t(' from anywhere by bookmarking this Link.'), "", "");
215 $aside['$postit'] = $postit;
219 $url = $a->get_baseurl($ssl_state);
220 $aside['$url'] = $url;
222 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
223 $a->page['right_aside'] = replace_macros($tpl, $aside);
228 //profile_side at networkpages
229 if ($a->argv[0] === "network" && local_user()){
234 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
237 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
238 'name' => $a->user['username'],
240 $ps = array('usermenu'=>array());
241 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
242 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
243 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));
244 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
245 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
246 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
247 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
248 $ps['usermenu']['pgroups'] = Array('http://dir.friendika.com/directory/forum', t('Community Pages'), "", "");
250 $tpl = get_markup_template('profile_side.tpl');
252 $a->page['aside'] .= replace_macros($tpl, array(
253 '$userinfo' => $userinfo,
259 $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'];
261 if($ccCookie != "8") {
263 diabook_aerith_community_info();
266 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-network.css";
272 //right_aside at profile pages
273 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
274 if($ccCookie != "8") {
276 diabook_aerith_community_info();
279 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-profile.css";
283 //tabs at right_aside on settings page
284 if ($a->argv[0] === "settings"){
288 'label' => t('Account settings'),
289 'url' => $a->get_baseurl(true).'/settings',
290 'sel' => (($a->argc == 1)?'active':''),
293 'label' => t('Display settings'),
294 'url' => $a->get_baseurl(true).'/settings/display',
295 'sel' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
298 'label' => t('Edit/Manage Profiles'),
299 'url' => $a->get_baseurl(true).'/profiles',
302 'label' => t('Connector settings'),
303 'url' => $a->get_baseurl(true).'/settings/connectors',
304 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
307 'label' => t('Plugin settings'),
308 'url' => $a->get_baseurl(true).'/settings/addon',
309 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
312 'label' => t('Connections'),
313 'url' => $a->get_baseurl(true) . '/settings/oauth',
314 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
317 'label' => t('Export personal data'),
318 'url' => $a->get_baseurl(true) . '/uexport',
322 $tabtpl = file_get_contents(dirname(__file__).'/rs_common_tabs.tpl') ;
323 $a->page['aside'] = replace_macros($tabtpl, array(
329 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-settings.css";
335 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
337 //load jquery.cookie.js
338 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/js/jquery.cookie.js";
339 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $cookieJS);
341 //load jquery.ae.image.resize.js
342 $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/js/jquery.ae.image.resize.js";
343 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
346 //comment-edit-wrapper on photo_view
347 if ($a->argv[0].$a->argv[2] === "photos"."image"){
349 $a->page['htmlhead'] .= '
353 $(".comment-edit-form").css("display","table");
360 $a->page['htmlhead'] .= '
364 $("a.lightbox").fancybox(); // Select all links with lightbox class
369 $a->page['htmlhead'] .= '
372 $(document).ready(function() {
373 $("iframe").each(function(){
374 var ifr_source = $(this).attr("src");
375 var wmode = "wmode=transparent";
376 if(ifr_source.indexOf("?") != -1) {
377 var getQString = ifr_source.split("?");
378 var oldString = getQString[1];
379 var newString = getQString[0];
380 $(this).attr("src",newString+"?"+wmode+"&"+oldString);
382 else $(this).attr("src",ifr_source+"?"+wmode);
388 function yt_iframe() {
390 $("iframe").load(function() {
391 var ifr_src = $(this).contents().find("body iframe").attr("src");
392 $("iframe").contents().find("body iframe").attr("src", ifr_src+"&wmode=transparent");
399 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
400 $a->page['htmlhead'] .= '
404 $(".oembed.photo img").aeImageResize({height: 400, width: 400});
409 if($ccCookie != "8") {
410 $a->page['htmlhead'] .= '
412 $("right_aside").ready(function(){
414 if($.cookie("close_pages") == "1")
416 document.getElementById( "close_pages" ).style.display = "none";
419 if($.cookie("close_helpers") == "1")
421 document.getElementById( "close_helpers" ).style.display = "none";
424 if($.cookie("close_services") == "1")
426 document.getElementById( "close_services" ).style.display = "none";
429 if($.cookie("close_friends") == "1")
431 document.getElementById( "close_friends" ).style.display = "none";
434 if($.cookie("close_postit") == "1")
436 document.getElementById( "close_postit" ).style.display = "none";
439 if($.cookie("close_lastusers") == "1")
441 document.getElementById( "close_lastusers" ).style.display = "none";
444 if($.cookie("close_lastphotos") == "1")
446 document.getElementById( "close_lastphotos" ).style.display = "none";
449 if($.cookie("close_lastlikes") == "1")
451 document.getElementById( "close_lastlikes" ).style.display = "none";
456 function close_pages(){
457 document.getElementById( "close_pages" ).style.display = "none";
458 $.cookie("close_pages","1", { expires: 365, path: "/" });
461 function close_helpers(){
462 document.getElementById( "close_helpers" ).style.display = "none";
463 $.cookie("close_helpers","1", { expires: 365, path: "/" });
466 function close_services(){
467 document.getElementById( "close_services" ).style.display = "none";
468 $.cookie("close_services","1", { expires: 365, path: "/" });
471 function close_friends(){
472 document.getElementById( "close_friends" ).style.display = "none";
473 $.cookie("close_friends","1", { expires: 365, path: "/" });
476 function close_postit(){
477 document.getElementById( "close_postit" ).style.display = "none";
478 $.cookie("close_postit","1", { expires: 365, path: "/" });
481 function close_lastusers(){
482 document.getElementById( "close_lastusers" ).style.display = "none";
483 $.cookie("close_lastusers","1", { expires: 365, path: "/" });
486 function close_lastphotos(){
487 document.getElementById( "close_lastphotos" ).style.display = "none";
488 $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
491 function close_lastlikes(){
492 document.getElementById( "close_lastlikes" ).style.display = "none";
493 $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
497 $a->page['htmlhead'] .= '
499 function restore_boxes(){
500 $.cookie("close_pages","2", { expires: 365, path: "/" });
501 $.cookie("close_helpers","2", { expires: 365, path: "/" });
502 $.cookie("close_services","2", { expires: 365, path: "/" });
503 $.cookie("close_friends","2", { expires: 365, path: "/" });
504 $.cookie("close_postit","2", { expires: 365, path: "/" });
505 $.cookie("close_lastusers","2", { expires: 365, path: "/" });
506 $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
507 $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
508 alert("Right-hand column was restored. Please refresh your browser");
512 $a->page['htmlhead'] .= '
514 <script type="text/javascript">
515 function insertFormatting(BBcode,id) {
517 var tmpStr = $("#comment-edit-text-" + id).val();
518 if(tmpStr == "Kommentar") {
520 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
521 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
522 openMenu("comment-edit-submit-wrapper-" + id);
525 textarea = document.getElementById("comment-edit-text-" +id);
526 if (document.selection) {
528 selected = document.selection.createRange();
529 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
530 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
531 var start = textarea.selectionStart;
532 var end = textarea.selectionEnd;
533 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);