[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Wed Aug 7 20:54:48 EDT 2013
raeburn Thu Aug 8 00:54:48 2013 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface domainprefs.pm
Log:
- For 2.11
- Backport 1.200, 1.201, 1.202.
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.21 loncom/interface/domainprefs.pm:1.160.6.22
--- loncom/interface/domainprefs.pm:1.160.6.21 Sun Aug 4 00:39:09 2013
+++ loncom/interface/domainprefs.pm Thu Aug 8 00:54:47 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.21 2013/08/04 00:39:09 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.22 2013/08/08 00:54:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1123,17 +1123,7 @@
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
my (%is_custom,%designs);
- my %defaults = (
- img => $defaultdesign{$role.'.img'},
- font => $defaultdesign{$role.'.font'},
- fontmenu => $defaultdesign{$role.'.fontmenu'},
- );
- foreach my $item (@bgs) {
- $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
- }
- foreach my $item (@links) {
- $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
- }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
if ($settings->{$role}->{'img'} ne '') {
@@ -1194,6 +1184,44 @@
return $datatable;
}
+sub role_defaults {
+ my ($role,$bgs,$links,$images,$logintext) = @_;
+ my %defaults;
+ unless ((ref($bgs) eq 'ARRAY') && (ref($links) eq 'ARRAY') && (ref($images) eq 'ARRAY')) {
+ return %defaults;
+ }
+ my %defaultdesign = %Apache::loncommon::defaultdesign;
+ if ($role eq 'login') {
+ %defaults = (
+ font => $defaultdesign{$role.'.font'},
+ );
+ if (ref($logintext) eq 'ARRAY') {
+ foreach my $item (@{$logintext}) {
+ $defaults{'logintext'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ }
+ foreach my $item (@{$images}) {
+ $defaults{'showlogo'}{$item} = 1;
+ }
+ } else {
+ %defaults = (
+ img => $defaultdesign{$role.'.img'},
+ font => $defaultdesign{$role.'.font'},
+ fontmenu => $defaultdesign{$role.'.fontmenu'},
+ );
+ }
+ foreach my $item (@{$bgs}) {
+ $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ foreach my $item (@{$links}) {
+ $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ foreach my $item (@{$images}) {
+ $defaults{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ return %defaults;
+}
+
sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
$images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_;
@@ -1220,11 +1248,11 @@
} else {
$datatable .= '<td> </td>';
}
- $current_color = $designs->{'fontmenu'} ?
- $designs->{'fontmenu'} : $defaults->{'fontmenu'};
+ $current_color = $designs->{'fontmenu'} ?
+ $designs->{'fontmenu'} : $defaults->{'fontmenu'};
$datatable .= '<td><span class="LC_nobreak">'.
'<input class="colorchooser" type="text" size="10" name="'
- .$role.'_fontmenu"'.
+ .$role.'_fontmenu"'.
' value="'.$current_color.'" /> '.
' </td></tr>';
}
@@ -1241,7 +1269,7 @@
&login_header_options($img,$role,$defaults,$is_custom,$choices);
$logincolors =
&login_text_colors($img,$role,$logintext,$phase,$choices,
- $designs);
+ $designs,$defaults);
} elsif ($img ne 'domlogo') {
$datatable.= &logo_display_options($img,$defaults,$designs);
}
@@ -1320,12 +1348,12 @@
$datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
$showfile,$fullsize,$role,$img,$imgfile,$logincolors);
} else {
- $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
- &mt('Upload:');
+ $datatable .= '<td> </td><td class="LC_left_item">'.
+ &mt('Upload:').'<br />';
}
} else {
- $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
- &mt('Upload:');
+ $datatable .= '<td> </td><td class="LC_left_item">'.
+ &mt('Upload:').'<br />';
}
if ($switchserver) {
$datatable .= &mt('Upload to library server: [_1]',$switchserver);
@@ -1355,8 +1383,8 @@
'<table border="0"><tr>';
foreach my $item (@{$bgs}) {
- $datatable .= '<td align="center">';
- my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
+ $datatable .= '<td align="center">'.$choices->{$item};
+ my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
if ($designs->{'bgs'}{$item}) {
$datatable .= ' ';
}
@@ -1382,9 +1410,8 @@
$datatable .= '<td class="LC_right_item">'.
'<table border="0"><tr>';
foreach my $item (@{$links}) {
- my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
- $datatable .= '<td align="center">'."\n";
-
+ my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
+ $datatable .= '<td align="center">'.$choices->{$item}."\n";
if ($designs->{'links'}{$item}) {
$datatable.=' ';
}
@@ -1442,17 +1469,13 @@
}
sub login_text_colors {
- my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
+ my ($img,$role,$logintext,$phase,$choices,$designs,$defaults) = @_;
my $color_menu = '<table border="0"><tr>';
foreach my $item (@{$logintext}) {
- my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'logintext'}{$item});
- $color_menu .= '<td align="center">'.$link;
- if ($designs->{'logintext'}{$item}) {
- $color_menu .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'logintext'}{$item}.';"> </span>';
- }
- $color_menu .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.
- $designs->{'logintext'}{$item}.'" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" /></td>'.
- '<td> </td>';
+ $color_menu .= '<td align="center">'.$choices->{$item};
+ my $color = $designs->{'logintext'}{$item} ? $designs->{'logintext'}{$item} : $defaults->{'logintext'}{$item};
+ $color_menu .= '<br /><input type="text" class="colorchooser" size="8" name="'.$role.'_'.$item.'" value="'.$color.
+ '" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" /></td>';
}
$color_menu .= '</tr></table><br />';
return $color_menu;
@@ -1484,20 +1507,12 @@
$role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
'</label> '.&mt('Replace:').'</span><br />';
} else {
- $output .= '<td valign="bottom">'.$logincolors.&mt('Upload:').'<br />';
+ $output .= '<td valign="middle">'.$logincolors.&mt('Upload:').'<br />';
}
}
return $output;
}
-sub color_pick {
- my ($phase,$role,$item,$desc,$curcol) = @_;
- my $link = '<a href="javascript:pjump('."'color_custom','".$desc.
- "','".$curcol."','".$role.'_'.$item."','parmform.pres','psub'".
- ');">'.$desc.'</a>';
- return $link;
-}
-
sub print_quotas {
my ($dom,$settings,$rowtotal,$action) = @_;
my $context;
@@ -5038,7 +5053,7 @@
links => "Link colors",
images => "Images",
font => "Font color",
- fontmenu => "Font Menu",
+ fontmenu => "Font menu",
pgbg => "Page",
tabbg => "Header",
sidebg => "Border",
@@ -5090,24 +5105,45 @@
my @images;
my $servadm = $r->dir_config('lonAdmEMail');
my $errors;
+ my %defaults;
foreach my $role (@{$roles}) {
if ($role eq 'login') {
%choices = &login_choices();
@logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
- $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
if ($role eq 'login') {
@images = ('img','logo','domlogo','login');
@bgs = ('pgbg','mainbg','sidebg');
} else {
@images = ('img');
- @bgs = ('pgbg','tabbg','sidebg');
+ @bgs = ('pgbg','tabbg','sidebg');
+ }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
+ unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
+ }
+ if ($role eq 'login') {
+ foreach my $item (@logintext) {
+ unless ($env{'form.'.$role.'_'.$item} eq $defaults{'logintext'}{$item}) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
+ }
+ } else {
+ unless($env{'form.'.$role.'_fontmenu'} eq $defaults{'fontmenu'}) {
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
+ }
}
- $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
- foreach my $item (@bgs, at links, at logintext) {
- $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ foreach my $item (@bgs) {
+ unless ($env{'form.'.$role.'_'.$item} eq $defaults{'bgs'}{$item} ) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
+ }
+ foreach my $item (@links) {
+ unless ($env{'form.'.$role.'_'.$item} eq $defaults{'links'}{$item}) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
}
my ($configuserok,$author_ok,$switchserver) =
&config_check($dom,$confname,$servadm);
More information about the LON-CAPA-cvs
mailing list