From 67471bb534a1d40df58e6bbaa4d1a2eb7869933d Mon Sep 17 00:00:00 2001 From: tommy tomson Date: Wed, 2 May 2012 14:33:04 +0200 Subject: [PATCH] diabook-theme: tryied to improve performance a bit --- view/theme/diabook/bottom.tpl | 101 ++++++ view/theme/diabook/theme.php | 648 ++++++++++++++-------------------- 2 files changed, 371 insertions(+), 378 deletions(-) create mode 100644 view/theme/diabook/bottom.tpl diff --git a/view/theme/diabook/bottom.tpl b/view/theme/diabook/bottom.tpl new file mode 100644 index 000000000..8eb71b7dd --- /dev/null +++ b/view/theme/diabook/bottom.tpl @@ -0,0 +1,101 @@ + + diff --git a/view/theme/diabook/theme.php b/view/theme/diabook/theme.php index f9be99759..de003b27d 100755 --- a/view/theme/diabook/theme.php +++ b/view/theme/diabook/theme.php @@ -3,13 +3,20 @@ /* * Name: Diabook * Description: Diabook: report bugs and request here: http://pad.toktan.org/p/diabook or contact me : thomas_bierey@friendica.eu - * Version: (Version: 1.024) + * Version: (Version: 1.025) * Author: */ +$a = get_app(); +$a->theme_info = array( + 'family' => 'diabook', + 'version' => '1.025' +); +function diabook_init(&$a) { + //print diabook-version for debugging -$diabook_version = "Diabook (Version: 1.024)"; +$diabook_version = "Diabook (Version: 1.025)"; $a->page['htmlhead'] .= sprintf('', $diabook_version); //change css on network and profilepages @@ -34,16 +41,259 @@ if ($color=="green") $color_path = "/diabook-green/"; if ($color=="dark") $color_path = "/diabook-dark/"; -/** - * prints last community activity - */ + //profile_side at networkpages + if ($a->argv[0] === "network" && local_user()){ + + // USER MENU + if(local_user()) { + + $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); + + $userinfo = array( + 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"), + 'name' => $a->user['username'], + ); + $ps = array('usermenu'=>array()); + $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations')); + $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page')); + $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts')); + $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); + $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events')); + $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos')); + $ps['usermenu']['community'] = Array('community/', t('Community'), "", ""); + $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", ""); + + $tpl = get_markup_template('profile_side.tpl'); + + $a->page['aside'] = replace_macros($tpl, array( + '$userinfo' => $userinfo, + '$ps' => $ps, + )).$a->page['aside']; + + } + + $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_profiles'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_twitter'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes']; + + if($ccCookie != "9") { + // COMMUNITY + diabook_community_info(); + + // CUSTOM CSS + if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network.css";} + if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network-wide.css";} + } + } + + //right_aside at profile pages + if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){ + if($ccCookie != "9") { + // COMMUNITY + diabook_community_info(); + + // CUSTOM CSS + if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile.css";} + if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile-wide.css";} + + } + } + + //js scripts + //load jquery.cookie.js + $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.cookie.js"; + $a->page['htmlhead'] .= sprintf('', $cookieJS); + + //load jquery.ae.image.resize.js + $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.ae.image.resize.js"; + $a->page['htmlhead'] .= sprintf('', $imageresizeJS); + + //load jquery.twitter.search.js + $twitterJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.twitter.search.js"; + $a->page['htmlhead'] .= sprintf('', $twitterJS); + + $a->page['htmlhead'] .= ' + '; + //check if community_home-plugin is activated and change css + $nametocheck = "communityhome"; + $r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck)); + if(count($r) == "1") { + + $a->page['htmlhead'] .= ' + '; + } + //comment-edit-wrapper on photo_view + if ($a->argv[0].$a->argv[2] === "photos"."image"){ + $a->page['htmlhead'] .= ' + '; + } + //restore right hand col at settingspage + if($a->argv[0] === "settings" && local_user()) { + $a->page['htmlhead'] .= ' + ';} + + if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){ + $a->page['htmlhead'] .= ' + '; + + if($ccCookie != "9") { + $a->page['htmlhead'] .= ' + ';} + } + //end js scripts + + // custom css + if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('', $cssFile); + + //footer + $tpl = get_markup_template('footer.tpl'); + $a->page['footer'] .= replace_macros($tpl, array()); + + // + js_in_foot(); +} + + + function diabook_community_info() { $a = get_app(); - - // comunity_profiles $aside['$comunity_profilest_title'] = t('Community Profiles'); $aside['$comunity_profiles_items'] = array(); @@ -193,7 +443,7 @@ function diabook_community_info(){ $aside['$nv'] = $nv; }; - //Community Page + //Community_Pages at right_aside if(local_user()) { $page = '

'.t("Community Pages").'

@@ -223,404 +473,46 @@ function diabook_community_info(){ } $page .= ''; //if (sizeof($contacts) > 0) - $aside['$page'] = $page; } //END Community Page //helpers $helpers = array(); $helpers['title'] = Array("", t('Help or @NewHere ?'), "", ""); - $aside['$helpers'] = $helpers; //end helpers //connectable services $con_services = array(); $con_services['title'] = Array("", t('Connect Services'), "", ""); - $aside['$con_services'] = $con_services; //end connectable services - - //get_baseurl $url = $a->get_baseurl($ssl_state); $aside['$url'] = $url; - + //print right_aside $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl'); $a->page['right_aside'] = replace_macros($tpl, $aside); - - - -} + } - -//profile_side at networkpages -if ($a->argv[0] === "network" && local_user()){ - - // USER MENU - if(local_user()) { - - $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); - - $userinfo = array( - 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"), - 'name' => $a->user['username'], - ); - $ps = array('usermenu'=>array()); - $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations')); - $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page')); - $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts')); - $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); - $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events')); - $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos')); - $ps['usermenu']['community'] = Array('community/', t('Community'), "", ""); - $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", ""); - - $tpl = get_markup_template('profile_side.tpl'); - - $a->page['aside'] .= replace_macros($tpl, array( - '$userinfo' => $userinfo, - '$ps' => $ps, - )); - - } - - $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_profiles'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_twitter'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes']; - - if($ccCookie != "9") { - // COMMUNITY - diabook_community_info(); - - // CUSTOM CSS - if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network.css";} - if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network-wide.css";} - } -} + function js_in_foot() { + /** @purpose insert stuff in bottom of page + */ + $a = get_app(); + $baseurl = $a->get_baseurl($ssl_state); + $bottom['$baseurl'] = $baseurl; + $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl'); + $a->page['footer'] = $a->page['footer'].replace_macros($tpl, $bottom); + } -//right_aside at profile pages -if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){ - if($ccCookie != "9") { - // COMMUNITY - diabook_community_info(); - - // CUSTOM CSS - if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile.css";} - if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile-wide.css";} - - } -} -// custom css -if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('', $cssFile); -//footer -$tpl = get_markup_template('footer.tpl'); -$a->page['footer'] .= replace_macros($tpl, array()); -//load jquery.cookie.js -$cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.cookie.js"; -$a->page['htmlhead'] .= sprintf('', $cookieJS); -//load jquery.ae.image.resize.js -$imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.ae.image.resize.js"; -$a->page['htmlhead'] .= sprintf('', $imageresizeJS); - -//load jquery.autogrow-textarea.js -$autogrowJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.autogrow.textarea.js"; -$a->page['htmlhead'] .= sprintf('', $autogrowJS); - -//load jquery.twitter.search.js -$twitterJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.twitter.search.js"; -$a->page['htmlhead'] .= sprintf('', $twitterJS); - -//js scripts - -//check if community_home-plugin is activated and change css -$nametocheck = "communityhome"; -$r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck)); -if(count($r) == "1") { - -$a->page['htmlhead'] .= ' -'; -} - -//comment-edit-wrapper on photo_view -if ($a->argv[0].$a->argv[2] === "photos"."image"){ - -$a->page['htmlhead'] .= ' -'; -} - -$a->page['htmlhead'] .= ' - -'; -$a->page['htmlhead'] .= ' -'; -$a->page['htmlhead'] .= ' - '; - -if($a->argv[0] === "settings" && local_user()) { -$a->page['htmlhead'] .= ' -';} - - - -if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){ -$a->page['htmlhead'] .= ' -'; - - - if($ccCookie != "9") { -$a->page['htmlhead'] .= ' -';}} - -$a->page['htmlhead'] .= ' - - '; \ No newline at end of file