diabook boxes: use a common hide/show form entry definition

This commit is contained in:
Hans Meine 2012-10-16 13:42:18 +02:00
parent 2d614b6700
commit d0775be2e2
2 changed files with 56 additions and 103 deletions

View file

@ -7,8 +7,8 @@
function theme_content(&$a){ function theme_content(&$a){
if(!local_user()) if(!local_user())
return; return;
$font_size = get_pconfig(local_user(), 'diabook', 'font_size' ); $font_size = get_pconfig(local_user(), 'diabook', 'font_size' );
$line_height = get_pconfig(local_user(), 'diabook', 'line_height' ); $line_height = get_pconfig(local_user(), 'diabook', 'line_height' );
$resolution = get_pconfig(local_user(), 'diabook', 'resolution' ); $resolution = get_pconfig(local_user(), 'diabook', 'resolution' );
@ -27,24 +27,24 @@ function theme_content(&$a){
$close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers' ); $close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers' );
$close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos' ); $close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos' );
$close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes' ); $close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes' );
return diabook_form($a,$font_size, $line_height, $resolution, $color, $TSearchTerm, $ELZoom, $ELPosX, $ELPosY, $close_pages, $close_mapquery, $close_profiles, $close_helpers, $close_services, $close_friends, $close_twitter, $close_lastusers, $close_lastphotos, $close_lastlikes); return diabook_form($a,$font_size, $line_height, $resolution, $color, $TSearchTerm, $ELZoom, $ELPosX, $ELPosY, $close_pages, $close_mapquery, $close_profiles, $close_helpers, $close_services, $close_friends, $close_twitter, $close_lastusers, $close_lastphotos, $close_lastlikes);
} }
function theme_post(&$a){ function theme_post(&$a){
if(! local_user()) if(! local_user())
return; return;
if (isset($_POST['diabook-settings-submit'])){ if (isset($_POST['diabook-settings-submit'])){
set_pconfig(local_user(), 'diabook', 'font_size', $_POST['diabook_font_size']); set_pconfig(local_user(), 'diabook', 'font_size', $_POST['diabook_font_size']);
set_pconfig(local_user(), 'diabook', 'line_height', $_POST['diabook_line_height']); set_pconfig(local_user(), 'diabook', 'line_height', $_POST['diabook_line_height']);
set_pconfig(local_user(), 'diabook', 'resolution', $_POST['diabook_resolution']); set_pconfig(local_user(), 'diabook', 'resolution', $_POST['diabook_resolution']);
set_pconfig(local_user(), 'diabook', 'color', $_POST['diabook_color']); set_pconfig(local_user(), 'diabook', 'color', $_POST['diabook_color']);
set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']); set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']);
set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']); set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']);
set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']); set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']);
set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']); set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']);
set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']); set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']);
set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']); set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']);
set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']); set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']);
@ -56,7 +56,7 @@ function theme_post(&$a){
set_pconfig(local_user(), 'diabook', 'close_lastusers', $_POST['diabook_close_lastusers']); set_pconfig(local_user(), 'diabook', 'close_lastusers', $_POST['diabook_close_lastusers']);
set_pconfig(local_user(), 'diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']); set_pconfig(local_user(), 'diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']);
set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']); set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']);
} }
} }
@ -65,8 +65,8 @@ function theme_admin(&$a){
$font_size = get_config('diabook', 'font_size' ); $font_size = get_config('diabook', 'font_size' );
$line_height = get_config('diabook', 'line_height' ); $line_height = get_config('diabook', 'line_height' );
$resolution = get_config('diabook', 'resolution' ); $resolution = get_config('diabook', 'resolution' );
$color = get_config('diabook', 'color' ); $color = get_config('diabook', 'color' );
$TSearchTerm = get_config('diabook', 'TSearchTerm' ); $TSearchTerm = get_config('diabook', 'TSearchTerm' );
$ELZoom = get_config('diabook', 'ELZoom' ); $ELZoom = get_config('diabook', 'ELZoom' );
$ELPosX = get_config('diabook', 'ELPosX' ); $ELPosX = get_config('diabook', 'ELPosX' );
$ELPosY = get_config('diabook', 'ELPosY' ); $ELPosY = get_config('diabook', 'ELPosY' );
@ -80,7 +80,7 @@ function theme_admin(&$a){
$close_lastusers = get_config('diabook', 'close_lastusers' ); $close_lastusers = get_config('diabook', 'close_lastusers' );
$close_lastphotos = get_config('diabook', 'close_lastphotos' ); $close_lastphotos = get_config('diabook', 'close_lastphotos' );
$close_lastlikes = get_config('diabook', 'close_lastlikes' ); $close_lastlikes = get_config('diabook', 'close_lastlikes' );
return diabook_form($a,$font_size, $line_height, $resolution, $color, $TSearchTerm, $ELZoom, $ELPosX, $ELPosY, $close_pages, $close_mapquery, $close_profiles, $close_helpers, $close_services, $close_friends, $close_twitter, $close_lastusers, $close_lastphotos, $close_lastlikes); return diabook_form($a,$font_size, $line_height, $resolution, $color, $TSearchTerm, $ELZoom, $ELPosX, $ELPosY, $close_pages, $close_mapquery, $close_profiles, $close_helpers, $close_services, $close_friends, $close_twitter, $close_lastusers, $close_lastphotos, $close_lastlikes);
} }
@ -103,7 +103,7 @@ function theme_admin_post(&$a){
set_config('diabook', 'close_lastusers', $_POST['diabook_close_lastusers']); set_config('diabook', 'close_lastusers', $_POST['diabook_close_lastusers']);
set_config('diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']); set_config('diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']);
set_config('diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']); set_config('diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']);
} }
} }
@ -112,79 +112,41 @@ function diabook_form(&$a, $font_size, $line_height, $resolution, $color, $TSear
$line_heights = array( $line_heights = array(
"1.3"=>"1.3", "1.3"=>"1.3",
"---"=>"---", "---"=>"---",
"1.6"=>"1.6", "1.6"=>"1.6",
"1.5"=>"1.5", "1.5"=>"1.5",
"1.4"=>"1.4", "1.4"=>"1.4",
"1.2"=>"1.2", "1.2"=>"1.2",
"1.1"=>"1.1", "1.1"=>"1.1",
); );
$font_sizes = array( $font_sizes = array(
'14'=>'14', '14'=>'14',
"---"=>"---", "---"=>"---",
"16"=>"16", "16"=>"16",
"15"=>"15", "15"=>"15",
'13.5'=>'13.5', '13.5'=>'13.5',
'13'=>'13', '13'=>'13',
'12.5'=>'12.5', '12.5'=>'12.5',
'12'=>'12', '12'=>'12',
); );
$resolutions = array( $resolutions = array(
'normal'=>'normal', 'normal'=>'normal',
'wide'=>'wide', 'wide'=>'wide',
); );
$colors = array( $colors = array(
'diabook'=>'diabook', 'diabook'=>'diabook',
'aerith'=>'aerith', 'aerith'=>'aerith',
'blue'=>'blue', 'blue'=>'blue',
'green'=>'green', 'green'=>'green',
'pink'=>'pink', 'pink'=>'pink',
'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',
);
$t = file_get_contents( dirname(__file__). "/theme_settings.tpl" ); $t = file_get_contents( dirname(__file__). "/theme_settings.tpl" );
$o .= replace_macros($t, array( $o .= replace_macros($t, array(
'$submit' => t('Submit'), '$submit' => t('Submit'),
@ -193,21 +155,21 @@ function diabook_form(&$a, $font_size, $line_height, $resolution, $color, $TSear
'$font_size' => array('diabook_font_size', t('Set font-size for posts and comments'), $font_size, '', $font_sizes), '$font_size' => array('diabook_font_size', t('Set font-size for posts and comments'), $font_size, '', $font_sizes),
'$line_height' => array('diabook_line_height', t('Set line-height for posts and comments'), $line_height, '', $line_heights), '$line_height' => array('diabook_line_height', t('Set line-height for posts and comments'), $line_height, '', $line_heights),
'$resolution' => array('diabook_resolution', t('Set resolution for middle column'), $resolution, '', $resolutions), '$resolution' => array('diabook_resolution', t('Set resolution for middle column'), $resolution, '', $resolutions),
'$color' => array('diabook_color', t('Set color scheme'), $color, '', $colors), '$color' => array('diabook_color', t('Set color scheme'), $color, '', $colors),
'$TSearchTerm' => array('diabook_TSearchTerm', t('Set twitter search term'), $TSearchTerm, '', $TSearchTerm), '$TSearchTerm' => array('diabook_TSearchTerm', t('Set twitter search term'), $TSearchTerm, '', $TSearchTerm),
'$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

@ -626,28 +626,19 @@ if ($color=="dark") $color_path = "/diabook-dark/";
$close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers' ); $close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers' );
$close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos' ); $close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos' );
$close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes' ); $close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes' );
$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;