Merge pull request #514 from hmeine/master

Cleanups in diabook theme code
This commit is contained in:
Thomas Willingham 2012-10-16 09:05:50 -07:00
commit 2940f25df9
2 changed files with 209 additions and 362 deletions

View file

@ -142,46 +142,8 @@ function diabook_form(&$a, $font_size, $line_height, $resolution, $color, $TSear
'red'=>'red', 'red'=>'red',
'dark'=>'dark', 'dark'=>'dark',
); );
$close_pagesC = array(
'0'=>'show', $close_or_not = array('1'=>t("don't show"), '0'=>t("show"),);
'1'=>'hide',
);
$close_mapqueryC = array(
'0'=>'show',
'1'=>'hide',
);
$close_profilesC = array(
'0'=>'show',
'1'=>'hide',
);
$close_helpersC = array(
'0'=>'show',
'1'=>'hide',
);
$close_servicesC = array(
'0'=>'show',
'1'=>'hide',
);
$close_friendsC = array(
'0'=>'show',
'1'=>'hide',
);
$close_twitterC = array(
'0'=>'show',
'1'=>'hide',
);
$close_lastusersC = array(
'0'=>'show',
'1'=>'hide',
);
$close_lastphotosC = array(
'0'=>'show',
'1'=>'hide',
);
$close_lastlikesC = array(
'0'=>'show',
'1'=>'hide',
);
@ -198,16 +160,16 @@ function diabook_form(&$a, $font_size, $line_height, $resolution, $color, $TSear
'$ELZoom' => array('diabook_ELZoom', t('Set zoomfactor for Earth Layer'), $ELZoom, '', $ELZoom), '$ELZoom' => array('diabook_ELZoom', t('Set zoomfactor for Earth Layer'), $ELZoom, '', $ELZoom),
'$ELPosX' => array('diabook_ELPosX', t('Set longitude (X) for Earth Layers'), $ELPosX, '', $ELPosX), '$ELPosX' => array('diabook_ELPosX', t('Set longitude (X) for Earth Layers'), $ELPosX, '', $ELPosX),
'$ELPosY' => array('diabook_ELPosY', t('Set latitude (Y) for Earth Layers'), $ELPosY, '', $ELPosY), '$ELPosY' => array('diabook_ELPosY', t('Set latitude (Y) for Earth Layers'), $ELPosY, '', $ELPosY),
'$close_pages' => array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_pagesC), '$close_pages' => array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_or_not),
'$close_mapquery' => array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_mapqueryC), '$close_mapquery' => array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_or_not),
'$close_profiles' => array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_profilesC), '$close_profiles' => array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_or_not),
'$close_helpers' => array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_helpersC), '$close_helpers' => array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_or_not),
'$close_services' => array('diabook_close_services', t('Connect Services'), $close_services, '', $close_servicesC), '$close_services' => array('diabook_close_services', t('Connect Services'), $close_services, '', $close_or_not),
'$close_friends' => array('diabook_close_friends', t('Find Friends'), $close_friends, '', $close_friendsC), '$close_friends' => array('diabook_close_friends', t('Find Friends'), $close_friends, '', $close_or_not),
'$close_twitter' => array('diabook_close_twitter', t('Last tweets'), $close_twitter, '', $close_twitterC), '$close_twitter' => array('diabook_close_twitter', t('Last tweets'), $close_twitter, '', $close_or_not),
'$close_lastusers' => array('diabook_close_lastusers', t('Last users'), $close_lastusers, '', $close_lastusersC), '$close_lastusers' => array('diabook_close_lastusers', t('Last users'), $close_lastusers, '', $close_or_not),
'$close_lastphotos' => array('diabook_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_lastphotosC), '$close_lastphotos' => array('diabook_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_or_not),
'$close_lastlikes' => array('diabook_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_lastlikesC), '$close_lastlikes' => array('diabook_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_or_not),
)); ));
return $o; return $o;
} }

View file

@ -9,6 +9,19 @@
$a = get_app(); $a = get_app();
function get_diabook_config($key, $default = false) {
if (local_user()) {
$result = get_pconfig(local_user(), "diabook", $key);
if ($result !== false)
return $result;
}
$result = get_config("diabook", $key);
if ($result !== false)
return $result;
return $default;
}
function diabook_init(&$a) { function diabook_init(&$a) {
@ -24,65 +37,16 @@ load_config("diabook");
load_pconfig(local_user(), "diabook"); load_pconfig(local_user(), "diabook");
//get statuses of boxes at right-hand-column //get statuses of boxes at right-hand-column
$close_pages = false; $close_pages = get_diabook_config( "close_pages", 1 );
$site_close_pages = get_config("diabook", "close_pages" ); $close_profiles = get_diabook_config( "close_profiles", 0 );
if (local_user()) {$close_pages = get_pconfig(local_user(), "diabook", "close_pages");} $close_helpers = get_diabook_config( "close_helpers", 0 );
if ($close_pages===false) $close_pages=$site_close_pages; $close_services = get_diabook_config( "close_services", 0 );
if ($close_pages===false) $close_pages="1"; $close_friends = get_diabook_config( "close_friends", 0 );
$close_lastusers = get_diabook_config( "close_lastusers", 0 );
$close_profiles = false; $close_lastphotos = get_diabook_config( "close_lastphotos", 0 );
$site_close_profiles = get_config("diabook", "close_profiles" ); $close_lastlikes = get_diabook_config( "close_lastlikes", 0 );
if (local_user()) {$close_profiles = get_pconfig(local_user(), "diabook", "close_profiles");} $close_twitter = get_diabook_config( "close_twitter", 1 );
if ($close_profiles===false) $close_profiles=$site_close_profiles; $close_mapquery = get_diabook_config( "close_mapquery", 1 );
if ($close_profiles===false) $close_profiles="0";
$close_helpers = false;
$site_close_helpers = get_config("diabook", "close_helpers" );
if (local_user()) {$close_helpers = get_pconfig(local_user(), "diabook", "close_helpers");}
if ($close_helpers===false) $close_helpers=$site_close_helpers;
if ($close_helpers===false) $close_helpers="0";
$close_services = false;
$site_close_services = get_config("diabook", "close_services" );
if (local_user()) {$close_services = get_pconfig(local_user(), "diabook", "close_services");}
if ($close_services===false) $close_services=$site_close_services;
if ($close_services===false) $close_services="0";
$close_friends = false;
$site_close_friends = get_config("diabook", "close_friends" );
if (local_user()) {$close_friends = get_pconfig(local_user(), "diabook", "close_friends");}
if ($close_friends===false) $close_friends=$site_close_friends;
if ($close_friends===false) $close_friends="0";
$close_lastusers = false;
$site_close_lastusers = get_config("diabook", "close_lastusers" );
if (local_user()) {$close_lastusers = get_pconfig(local_user(), "diabook", "close_lastusers");}
if ($close_lastusers===false) $close_lastusers=$site_close_lastusers;
if ($close_lastusers===false) $close_lastusers="0";
$close_lastphotos = false;
$site_close_lastphotos = get_config("diabook", "close_lastphotos" );
if (local_user()) {$close_lastphotos = get_pconfig(local_user(), "diabook", "close_lastphotos");}
if ($close_lastphotos===false) $close_lastphotos=$site_close_lastphotos;
if ($close_lastphotos===false) $close_lastphotos="0";
$close_lastlikes = false;
$site_close_lastlikes = get_config("diabook", "close_lastlikes" );
if (local_user()) {$close_lastlikes = get_pconfig(local_user(), "diabook", "close_lastlikes");}
if ($close_lastlikes===false) $close_lastlikes=$site_close_lastlikes;
if ($close_lastlikes===false) $close_lastlikes="0";
$close_twitter = false;
$site_close_twitter = get_config("diabook", "close_twitter" );
if (local_user()) {$close_twitter = get_pconfig(local_user(), "diabook", "close_twitter");}
if ($close_twitter===false) $close_twitter=$site_close_twitter;
if ($close_twitter===false) $close_twitter="1";
$close_mapquery = false;
$site_close_mapquery = get_config("diabook", "close_mapquery" );
if (local_user()) {$close_mapquery = get_pconfig(local_user(), "diabook", "close_mapquery");}
if ($close_mapquery===false) $close_mapquery=$site_close_mapquery;
if ($close_mapquery===false) $close_mapquery="1";
//get resolution (wide/normal) //get resolution (wide/normal)
$resolution=false; $resolution=false;
@ -96,11 +60,7 @@ if ($resolution=="wide") {
$a->page['htmlhead'] .= '<meta name="viewport" content="width=980" />'; $a->page['htmlhead'] .= '<meta name="viewport" content="width=980" />';
} }
//get colour-scheme //get colour-scheme
$color = false; $color = get_diabook_config( "color", "diabook" );
$site_color = get_config("diabook", "color" );
if (local_user()) {$color = get_pconfig(local_user(), "diabook", "color");}
if ($color===false) $color=$site_color;
if ($color===false) $color="diabook";
if ($color=="diabook") $color_path = "/"; if ($color=="diabook") $color_path = "/";
if ($color=="aerith") $color_path = "/diabook-aerith/"; if ($color=="aerith") $color_path = "/diabook-aerith/";
@ -223,21 +183,9 @@ if ($color=="dark") $color_path = "/diabook-dark/";
//check if mapquerybox is active and print //check if mapquerybox is active and print
if($close_mapquery != "1") { if($close_mapquery != "1") {
$ELZoom=false; $ELZoom = get_diabook_config( "ELZoom", 0 );
$ELPosX=false; $ELPosX = get_diabook_config( "ELPosX", 0);
$ELPosy=false; $ELPosY = get_diabook_config( "ELPosY", 0);
$site_ELZoom = get_config("diabook", "ELZoom" );
$site_ELPosX = get_config("diabook", "ELPosX" );
$site_ELPosY = get_config("diabook", "ELPosY" );
$ELZoom = get_pconfig(local_user(), "diabook", "ELZoom");
$ELPosX = get_pconfig(local_user(), "diabook", "ELPosX");
$ELPosY = get_pconfig(local_user(), "diabook", "ELPosY");
if ($ELZoom===false) $ELZoom=$site_ELZoom;
if ($ELPosX===false) $ELPosX=$site_ELPosX;
if ($ELPosY===false) $ELPosY=$site_ELPosY;
if ($ELZoom===false) $ELZoom="0";
if ($ELPosX===false) $ELPosX="0";
if ($ELPosY===false) $ELPosY="0";
$a->page['htmlhead'] .= ' $a->page['htmlhead'] .= '
<script> <script>
@ -288,11 +236,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
} }
//check if twitterbox is active and print //check if twitterbox is active and print
if($close_twitter != "1") { if($close_twitter != "1") {
$TSearchTerm=false; $TSearchTerm = get_diabook_config( "TSearchTerm", "friendica" );
$site_TSearchTerm = get_config("diabook", "TSearchTerm" );
$TSearchTerm = get_pconfig(local_user(), "diabook", "TSearchTerm");
if ($TSearchTerm===false) $TSearchTerm=$site_TSearchTerm;
if ($TSearchTerm===false) $TSearchTerm="friendica";
$a->page['htmlhead'] .= ' $a->page['htmlhead'] .= '
<script> <script>
$(function() { $(function() {
@ -424,66 +368,16 @@ if ($color=="dark") $color_path = "/diabook-dark/";
function diabook_community_info() { function diabook_community_info() {
$a = get_app(); $a = get_app();
$close_pages = false; $close_pages = get_diabook_config( "close_pages", 1 );
$site_close_pages = get_config("diabook", "close_pages" ); $close_profiles = get_diabook_config( "close_profiles", 0 );
if (local_user()) {$close_pages = get_pconfig(local_user(), "diabook", "close_pages");} $close_helpers = get_diabook_config( "close_helpers", 0 );
if ($close_pages===false) $close_pages=$site_close_pages; $close_services = get_diabook_config( "close_services", 0 );
if ($close_pages===false) $close_pages="1"; $close_friends = get_diabook_config( "close_friends", 0 );
$close_lastusers = get_diabook_config( "close_lastusers", 0 );
$close_profiles = false; $close_lastphotos = get_diabook_config( "close_lastphotos", 0 );
$site_close_profiles = get_config("diabook", "close_profiles" ); $close_lastlikes = get_diabook_config( "close_lastlikes", 0 );
if (local_user()) {$close_profiles = get_pconfig(local_user(), "diabook", "close_profiles");} $close_twitter = get_diabook_config( "close_twitter", 1 );
if ($close_profiles===false) $close_profiles=$site_close_profiles; $close_mapquery = get_diabook_config( "close_mapquery", 1 );
if ($close_profiles===false) $close_profiles="0";
$close_helpers = false;
$site_close_helpers = get_config("diabook", "close_helpers" );
if (local_user()) {$close_helpers = get_pconfig(local_user(), "diabook", "close_helpers");}
if ($close_helpers===false) $close_helpers=$site_close_helpers;
if ($close_helpers===false) $close_helpers="0";
$close_services = false;
$site_close_services = get_config("diabook", "close_services" );
if (local_user()) {$close_services = get_pconfig(local_user(), "diabook", "close_services");}
if ($close_services===false) $close_services=$site_close_services;
if ($close_services===false) $close_services="0";
$close_friends = false;
$site_close_friends = get_config("diabook", "close_friends" );
if (local_user()) {$close_friends = get_pconfig(local_user(), "diabook", "close_friends");}
if ($close_friends===false) $close_friends=$site_close_friends;
if ($close_friends===false) $close_friends="0";
$close_lastusers = false;
$site_close_lastusers = get_config("diabook", "close_lastusers" );
if (local_user()) {$close_lastusers = get_pconfig(local_user(), "diabook", "close_lastusers");}
if ($close_lastusers===false) $close_lastusers=$site_close_lastusers;
if ($close_lastusers===false) $close_lastusers="0";
$close_lastphotos = false;
$site_close_lastphotos = get_config("diabook", "close_lastphotos" );
if (local_user()) {$close_lastphotos = get_pconfig(local_user(), "diabook", "close_lastphotos");}
if ($close_lastphotos===false) $close_lastphotos=$site_close_lastphotos;
if ($close_lastphotos===false) $close_lastphotos="0";
$close_lastlikes = false;
$site_close_lastlikes = get_config("diabook", "close_lastlikes" );
if (local_user()) {$close_lastlikes = get_pconfig(local_user(), "diabook", "close_lastlikes");}
if ($close_lastlikes===false) $close_lastlikes=$site_close_lastlikes;
if ($close_lastlikes===false) $close_lastlikes="0";
$close_twitter = false;
$site_close_twitter = get_config("diabook", "close_twitter" );
if (local_user()) {$close_twitter = get_pconfig(local_user(), "diabook", "close_twitter");}
if ($close_twitter===false) $close_twitter=$site_close_twitter;
if ($close_twitter===false) $close_twitter="1";
$close_mapquery = false;
$site_close_mapquery = get_config("diabook", "close_mapquery" );
if (local_user()) {$close_mapquery = get_pconfig(local_user(), "diabook", "close_mapquery");}
if ($close_mapquery===false) $close_mapquery=$site_close_mapquery;
if ($close_mapquery===false) $close_mapquery="1";
// comunity_profiles // comunity_profiles
if($close_profiles != "1") { if($close_profiles != "1") {
@ -722,38 +616,29 @@ if ($color=="dark") $color_path = "/diabook-dark/";
} }
//end twitter //end twitter
if($ccCookie != "10") { if($ccCookie != "10") {
$close_pages = get_pconfig(local_user(), 'diabook', 'close_pages' ); $close_pages = get_diabook_config( "close_pages", 1 );
$close_mapquery = get_pconfig(local_user(), 'diabook', 'close_mapquery' ); $close_profiles = get_diabook_config( "close_profiles", 0 );
$close_profiles = get_pconfig(local_user(), 'diabook', 'close_profiles' ); $close_helpers = get_diabook_config( "close_helpers", 0 );
$close_helpers = get_pconfig(local_user(), 'diabook', 'close_helpers' ); $close_services = get_diabook_config( "close_services", 0 );
$close_services = get_pconfig(local_user(), 'diabook', 'close_services' ); $close_friends = get_diabook_config( "close_friends", 0 );
$close_friends = get_pconfig(local_user(), 'diabook', 'close_friends' ); $close_lastusers = get_diabook_config( "close_lastusers", 0 );
$close_twitter = get_pconfig(local_user(), 'diabook', 'close_twitter' ); $close_lastphotos = get_diabook_config( "close_lastphotos", 0 );
$close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers' ); $close_lastlikes = get_diabook_config( "close_lastlikes", 0 );
$close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos' ); $close_twitter = get_diabook_config( "close_twitter", 1 );
$close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes' ); $close_mapquery = get_diabook_config( "close_mapquery", 1 );
$close_pagesC = array('1'=>t("don't show"), '0'=>t("show"),); $close_or_not = array('1'=>t("don't show"), '0'=>t("show"),);
$close_mapqueryC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_profilesC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_helpersC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_servicesC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_friendsC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_twitterC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_lastusersC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_lastphotosC = array('1'=>t("don't show"), '0'=>t("show"),);
$close_lastlikesC = array('1'=>t("don't show"), '0'=>t("show"),);
$boxsettings['title'] = Array("", t('Show/hide boxes at right-hand column:'), "", ""); $boxsettings['title'] = Array("", t('Show/hide boxes at right-hand column:'), "", "");
$aside['$boxsettings'] = $boxsettings; $aside['$boxsettings'] = $boxsettings;
$aside['$close_pages'] = array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_pagesC); $aside['$close_pages'] = array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_or_not);
$aside['$close_mapquery'] = array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_mapqueryC); $aside['$close_mapquery'] = array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_or_not);
$aside['$close_profiles'] = array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_profilesC); $aside['$close_profiles'] = array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_or_not);
$aside['$close_helpers'] = array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_helpersC); $aside['$close_helpers'] = array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_or_not);
$aside['$close_services'] = array('diabook_close_services', t('Connect Services'), $close_services, '', $close_servicesC); $aside['$close_services'] = array('diabook_close_services', t('Connect Services'), $close_services, '', $close_or_not);
$aside['$close_friends'] = array('diabook_close_friends', t('Find Friends'), $close_friends, '', $close_friendsC); $aside['$close_friends'] = array('diabook_close_friends', t('Find Friends'), $close_friends, '', $close_or_not);
$aside['$close_twitter'] = array('diabook_close_twitter', t('Last Tweets'), $close_twitter, '', $close_twitterC); $aside['$close_twitter'] = array('diabook_close_twitter', t('Last Tweets'), $close_twitter, '', $close_or_not);
$aside['$close_lastusers'] = array('diabook_close_lastusers', t('Last users'), $close_lastusers, '', $close_lastusersC); $aside['$close_lastusers'] = array('diabook_close_lastusers', t('Last users'), $close_lastusers, '', $close_or_not);
$aside['$close_lastphotos'] = array('diabook_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_lastphotosC); $aside['$close_lastphotos'] = array('diabook_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_or_not);
$aside['$close_lastlikes'] = array('diabook_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_lastlikesC); $aside['$close_lastlikes'] = array('diabook_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_or_not);
$aside['$sub'] = t('Submit'); $aside['$sub'] = t('Submit');
$baseurl = $a->get_baseurl($ssl_state); $baseurl = $a->get_baseurl($ssl_state);
$aside['$baseurl'] = $baseurl; $aside['$baseurl'] = $baseurl;