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)
11 //print diabook-version for debugging
12 $diabook_version = "Diabook-aerith (Version: 1.020)";
13 $a->page['htmlhead'] .= sprintf('<script "%s" ></script>', $diabook_version);
16 //change css on network and profilepages
19 $resolution = get_pconfig(local_user(), "diabook-aerith", "resolution");
20 if ($resolution===false) $resolution="normal";
23 * prints last community activity
25 function diabook_aerith_community_info(){
29 $aside['$lastusers_title'] = t('Last users');
30 $aside['$lastusers_items'] = array();
32 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
33 $order = " ORDER BY `register_date` DESC ";
35 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
36 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
37 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
41 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
45 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
46 $entry = replace_macros($tpl,array(
48 '$profile-link' => $profile_link,
49 '$photo' => $rr[$photo],
50 '$alt-text' => $rr['name'],
52 $aside['$lastusers_items'][] = $entry;
57 // last 10 liked items
58 $aside['$like_title'] = t('Last likes');
59 $aside['$like_items'] = array();
60 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
61 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
62 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
63 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
64 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
66 ORDER BY `T1`.`created` DESC
68 $a->get_baseurl(),$a->get_baseurl()
72 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
73 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
75 //var_dump($rr['verb'],$rr['object-type']); killme();
77 case 'http://activitystrea.ms/schema/1.0/post':
78 switch ($rr['object-type']){
79 case 'http://activitystrea.ms/schema/1.0/event':
80 $post_type = t('event');
83 $post_type = t('status');
87 if ($rr['resource-id']){
88 $post_type = t('photo');
89 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
92 $post_type = t('status');
95 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
97 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
103 $aside['$photos_title'] = t('Last photos');
104 $aside['$photos_items'] = array();
105 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
106 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
107 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
108 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
109 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
111 WHERE `user`.`uid` = `photo`.`uid`
112 AND `user`.`blockwall`=0
113 AND `user`.`hidewall`=0
114 ORDER BY `photo`.`edited` DESC
116 dbesc(t('Contact Photos')),
117 dbesc(t('Profile Photos'))
120 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
122 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
123 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
125 $entry = replace_macros($tpl,array(
127 '$profile-link' => $photo_page,
128 '$photo' => $photo_url,
129 '$alt-text' => $rr['username']." : ".$rr['desc'],
132 $aside['$photos_items'][] = $entry;
141 $nv['title'] = Array("", t('Find Friends'), "", "");
142 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
143 $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
144 $nv['match'] = Array('match', t('Similar Interests'), "", "");
145 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
146 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
148 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
149 <span class="sbox_l"></span>
151 <input type="text" name="search" size="13" maxlength="50">
153 <span class="sbox_r" id="srch_clear"></span>';
159 $page = '<div id="page-sidebar-right_aside" class="widget">
160 <div class="title tool">
161 <h3>'.t("Community Pages").'<a id="close_pages_icon" onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
162 <div id="sidebar-page-list"><ul>';
166 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
167 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
168 ORDER BY `name` ASC",
169 intval($a->user['uid'])
174 // Look if the profile is a community page
175 foreach($contacts as $contact) {
176 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
182 foreach($contacts as $contact) {
183 $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">'.
184 $contact["name"]."</a></li>";
186 $page .= '</ul></div></div>';
187 //if (sizeof($contacts) > 0)
189 $aside['$page'] = $page;
194 $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
196 $aside['$helpers'] = $helpers;
198 //connectable services
199 $con_services = array();
200 $con_services['title'] = Array("", t('Connect Services'), "", "");
202 $aside['$con_services'] = $con_services;
203 //end connectable services
207 $url = $a->get_baseurl($ssl_state);
208 $aside['$url'] = $url;
210 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
211 $a->page['right_aside'] = replace_macros($tpl, $aside);
216 //profile_side at networkpages
217 if ($a->argv[0] === "network" && local_user()){
222 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
225 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
226 'name' => $a->user['username'],
228 $ps = array('usermenu'=>array());
229 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
230 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
231 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));
232 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
233 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
234 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
235 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
236 $ps['usermenu']['pgroups'] = Array('http://dir.friendika.com/directory/forum', t('Community Pages'), "", "");
238 $tpl = get_markup_template('profile_side.tpl');
240 $a->page['aside'] .= replace_macros($tpl, array(
241 '$userinfo' => $userinfo,
247 $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes'];
249 if($ccCookie != "7") {
251 diabook_aerith_community_info();
254 if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-network.css";}
255 if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-network-wide.css";}
261 //right_aside at profile pages
262 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
263 if($ccCookie != "7") {
265 diabook_aerith_community_info();
268 if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-profile.css";}
269 if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/style-profile-wide.css";}
276 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
278 //load jquery.cookie.js
279 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/js/jquery.cookie.js";
280 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $cookieJS);
282 //load jquery.ae.image.resize.js
283 $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/js/jquery.ae.image.resize.js";
284 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
286 //load jquery.autogrow-textarea.js
287 $autogrowJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-aerith/js/jquery.autogrow.textarea.js";
288 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $autogrowJS);
291 //comment-edit-wrapper on photo_view
292 if ($a->argv[0].$a->argv[2] === "photos"."image"){
294 $a->page['htmlhead'] .= '
298 $(".comment-edit-form").css("display","table");
305 $a->page['htmlhead'] .= '
309 $("a.lightbox").fancybox(); // Select all links with lightbox class
314 $a->page['htmlhead'] .= '
316 <script type="text/javascript">
318 function tautogrow(id){
319 $("textarea#comment-edit-text-" +id).autogrow();
323 $a->page['htmlhead'] .= '
326 $(document).ready(function() {
327 $("iframe").each(function(){
328 var ifr_source = $(this).attr("src");
329 var wmode = "wmode=transparent";
330 if(ifr_source.indexOf("?") != -1) {
331 var getQString = ifr_source.split("?");
332 var oldString = getQString[1];
333 var newString = getQString[0];
334 $(this).attr("src",newString+"?"+wmode+"&"+oldString);
336 else $(this).attr("src",ifr_source+"?"+wmode);
342 function yt_iframe() {
344 $("iframe").load(function() {
345 var ifr_src = $(this).contents().find("body iframe").attr("src");
346 $("iframe").contents().find("body iframe").attr("src", ifr_src+"&wmode=transparent");
353 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
354 $a->page['htmlhead'] .= '
358 $(".oembed.photo img").aeImageResize({height: 400, width: 400});
363 if($ccCookie != "7") {
364 $a->page['htmlhead'] .= '
366 $("right_aside").ready(function(){
368 if($.cookie("close_pages") == "1")
370 document.getElementById( "close_pages" ).style.display = "none";
373 if($.cookie("close_helpers") == "1")
375 document.getElementById( "close_helpers" ).style.display = "none";
378 if($.cookie("close_services") == "1")
380 document.getElementById( "close_services" ).style.display = "none";
383 if($.cookie("close_friends") == "1")
385 document.getElementById( "close_friends" ).style.display = "none";
389 if($.cookie("close_lastusers") == "1")
391 document.getElementById( "close_lastusers" ).style.display = "none";
394 if($.cookie("close_lastphotos") == "1")
396 document.getElementById( "close_lastphotos" ).style.display = "none";
399 if($.cookie("close_lastlikes") == "1")
401 document.getElementById( "close_lastlikes" ).style.display = "none";
406 function close_pages(){
407 document.getElementById( "close_pages" ).style.display = "none";
408 $.cookie("close_pages","1", { expires: 365, path: "/" });
411 function close_helpers(){
412 document.getElementById( "close_helpers" ).style.display = "none";
413 $.cookie("close_helpers","1", { expires: 365, path: "/" });
416 function close_services(){
417 document.getElementById( "close_services" ).style.display = "none";
418 $.cookie("close_services","1", { expires: 365, path: "/" });
421 function close_friends(){
422 document.getElementById( "close_friends" ).style.display = "none";
423 $.cookie("close_friends","1", { expires: 365, path: "/" });
427 function close_lastusers(){
428 document.getElementById( "close_lastusers" ).style.display = "none";
429 $.cookie("close_lastusers","1", { expires: 365, path: "/" });
432 function close_lastphotos(){
433 document.getElementById( "close_lastphotos" ).style.display = "none";
434 $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
437 function close_lastlikes(){
438 document.getElementById( "close_lastlikes" ).style.display = "none";
439 $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
443 $a->page['htmlhead'] .= '
445 function restore_boxes(){
446 $.cookie("close_pages","2", { expires: 365, path: "/" });
447 $.cookie("close_helpers","2", { expires: 365, path: "/" });
448 $.cookie("close_services","2", { expires: 365, path: "/" });
449 $.cookie("close_friends","2", { expires: 365, path: "/" });
450 $.cookie("close_lastusers","2", { expires: 365, path: "/" });
451 $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
452 $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
453 alert("Right-hand column was restored. Please refresh your browser");
457 $a->page['htmlhead'] .= '
459 <script type="text/javascript">
460 function insertFormatting(comment,BBcode,id) {
462 var tmpStr = $("#comment-edit-text-" + id).val();
463 if(tmpStr == comment) {
465 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
466 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
467 openMenu("comment-edit-submit-wrapper-" + id);
470 textarea = document.getElementById("comment-edit-text-" +id);
471 if (document.selection) {
473 selected = document.selection.createRange();
474 if (BBcode == "url"){
475 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
477 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
478 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
479 var start = textarea.selectionStart;
480 var end = textarea.selectionEnd;
481 if (BBcode == "url"){
482 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
484 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);