--- loncom/interface/domainprefs.pm 2008/01/04 17:47:51 1.40
+++ loncom/interface/domainprefs.pm 2008/01/16 20:42:48 1.41
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.40 2008/01/04 17:47:51 raeburn Exp $
+# $Id: domainprefs.pm,v 1.41 2008/01/16 20:42:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -247,7 +247,7 @@ sub handler {
my @ids=&Apache::lonnet::current_machine_ids();
if (!grep(/^\Q$primarylibserv\E$/,@ids)) {
my %designhash = &Apache::loncommon::get_domainconf($dom);
- my @loginimages = ('img','logo','domlogo');
+ my @loginimages = ('img','logo','domlogo','login');
my $custom_img_count = 0;
foreach my $img (@loginimages) {
if ($designhash{$dom.'.login.'.$img} ne '') {
@@ -568,10 +568,12 @@ sub print_footer {
sub print_login {
my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
my %choices = &login_choices();
- my ($catalogon,$catalogoff,$adminmailon,$adminmailoff);
+ my ($catalogon,$catalogoff,$adminmailon,$adminmailoff,$loginheader);
$catalogon = ' checked="checked" ';
$adminmailoff = ' checked="checked" ';
- my @images = ('img','logo','domlogo');
+ $loginheader = 'image';
+ my @images = ('img','logo','domlogo','login');
+ my @logintext = ('textcol','bgcol');
my @bgs = ('pgbg','mainbg','sidebg');
my @links = ('link','alink','vlink');
my %designhash = &Apache::loncommon::get_domainconf($dom);
@@ -586,6 +588,9 @@ sub print_login {
foreach my $item (@bgs) {
$defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
}
+ foreach my $item (@logintext) {
+ $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
+ }
foreach my $item (@links) {
$defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
}
@@ -604,6 +609,15 @@ sub print_login {
$is_custom{$item} = 1;
}
}
+ foreach my $item (@logintext) {
+ if ($settings->{$item} ne '') {
+ $designs{'logintext'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ if ($settings->{'loginheader'} ne '') {
+ $loginheader = $settings->{'loginheader'};
+ }
if ($settings->{'font'} ne '') {
$designs{'font'} = $settings->{'font'};
$is_custom{'font'} = 1;
@@ -646,7 +660,8 @@ sub print_login {
}
my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
logo => 'Institution Logo',
- domlogo => 'Domain Logo');
+ domlogo => 'Domain Logo',
+ login => 'Login box');
my $itemcount = 1;
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable =
@@ -667,7 +682,7 @@ sub print_login {
'';
$itemcount ++;
- $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
+ $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);
$datatable .= '';
return $datatable;
}
@@ -680,6 +695,9 @@ sub login_choices {
img => "Header",
logo => "Main Logo",
domlogo => "Domain Logo",
+ login => "Log-in Header",
+ textcol => "Text color",
+ bgcol => "Box color",
bgs => "Background colors",
links => "Link colors",
font => "Font color",
@@ -767,7 +785,7 @@ sub print_rolecolors {
sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
- $images,$bgs,$links,$alt_text,$rowtotal) = @_;
+ $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable = '
'.
''.$choices->{'font'}.' | ';
@@ -789,13 +807,19 @@ sub display_color_options {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= '
'.
''.$choices->{$img}.' | ';
- my ($imgfile, $img_import);
+ my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
if ($designs->{$img} ne '') {
$imgfile = $designs->{$img};
$img_import = ($imgfile =~ m{^/adm/});
} else {
$imgfile = $defaults->{$img};
}
+ if ($img eq 'login') {
+ $login_hdr_pick = &login_header_options($img,$role,$defaults,$is_custom,$choices,
+ $loginheader);
+ $logincolors =
+ &login_text_colors($img,$role,$logintext,$phase,$choices,$designs);
+ }
if ($imgfile) {
my ($showfile,$fullsize);
if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
@@ -856,23 +880,12 @@ sub display_color_options {
$fullsize = $imgfile;
}
}
- $datatable.= '';
- if (!$is_custom->{$img}) {
- $datatable .= &mt('Default in use:').' ';
- }
- if ($img_import) {
- $datatable.= '';
- }
- $datatable.= ' | ';
- if ($is_custom->{$img}) {
- $datatable.=' '.&mt('Replace:').' ';
- } else {
- $datatable.=' | '.&mt('Upload:').' ';
+ $datatable .= ' | ';
+ if ($img eq 'login') {
+ $datatable .= $login_hdr_pick;
}
+ $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
+ $showfile,$fullsize,$role,$img,$imgfile,$logincolors);
} else {
$datatable .= ' | '.
&mt('Upload:');
@@ -912,7 +925,7 @@ sub display_color_options {
$datatable .= ' ';
}
$datatable .= '
| ';
+ '" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" />';
}
$datatable .= '
';
$itemcount ++;
@@ -946,6 +959,79 @@ sub display_color_options {
return $datatable;
}
+sub login_header_options {
+ my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
+ my $image_checked = ' checked="checked" ';
+ my $text_checked = ' ';
+ if ($loginheader eq 'text') {
+ $image_checked = ' ';
+ $text_checked = ' checked="checked" ';
+ }
+ my $output = ' '.
+ '
'."\n";
+ if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
+ $output .= &mt('Text default(s)').':
';
+ if (!$is_custom->{'textcol'}) {
+ $output .= $choices->{'textcol'}.': '.$defaults->{'logintext'}{'textcol'}.
+ ' ';
+ }
+ if (!$is_custom->{'bgcol'}) {
+ $output .= $choices->{'bgcol'}.': '.
+ ' ';
+ }
+ $output .= '
';
+ }
+ $output .='
';
+ return $output;
+}
+
+sub login_text_colors {
+ my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
+ my $color_menu = '
';
+ return $color_menu;
+}
+
+sub image_changes {
+ my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
+ my $output;
+ if (!$is_custom) {
+ if ($img eq 'login') {
+ $output .= &mt('Default image:').'
';
+ } else {
+ $output .= &mt('Default in use:').'
';
+ }
+ }
+ if ($img_import) {
+ $output .= '';
+ }
+ $output .= '';
+ if ($is_custom) {
+ $output .= ''.$logincolors.' '.&mt('Replace:').' ';
+ } else {
+ $output .= ' | '.$logincolors.&mt('Upload:').' ';
+ }
+ return $output;
+}
+
sub color_pick {
my ($phase,$role,$item,$desc,$curcol) = @_;
my $link = ' 'Display course catalog',
- adminmail => 'Display administrator E-mail address');
+ adminmail => 'Display administrator E-mail address',
+ loginheader => 'Log-in box header');
my @offon = ('off','on');
my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
$loginhash{login}{coursecatalog} = $env{'form.coursecatalog'};
$loginhash{login}{adminmail} = $env{'form.adminmail'};
+ $loginhash{login}{loginheader} = $env{'form.loginheader'};
if (ref($colchanges{'login'}) eq 'HASH') {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
@@ -1825,10 +1932,23 @@ sub modify_login {
($env{'form.adminmail'} eq '1')) {
$changes{'adminmail'} = 1;
}
+ if (($domconfig{'login'}{'loginheader'} eq 'text') &&
+ ($env{'form.loginheader'} eq 'image')) {
+ $changes{'loginheader'} = 1;
+ } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
+ $domconfig{'login'}{'loginheader'} eq 'image') &&
+ ($env{'form.loginheader'} eq 'text')) {
+ $changes{'loginheader'} = 1;
+ }
if (keys(%changes) > 0 || $colchgtext) {
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
$resulttext = &mt('Changes made:').'';
foreach my $item (sort(keys(%changes))) {
- $resulttext .= '- '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
';
+ if ($item eq 'loginheader') {
+ $resulttext .= '- '.&mt("$title{$item} set to $env{'form.loginheader'}").'
';
+ } else {
+ $resulttext .= '- '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
';
+ }
}
$resulttext .= $colchgtext.' ';
} else {
@@ -1872,6 +1992,7 @@ sub modify_rolecolors {
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
$resulttext = &display_colorchgs($dom,\%changes,$roles,
$rolehash{'rolecolors'});
} else {
@@ -1893,22 +2014,24 @@ sub modify_colors {
my (%changes,%choices);
my @bgs = ('pgbg','mainbg','sidebg');
my @links = ('link','alink','vlink');
+ my @logintext;
my @images;
my $servadm = $r->dir_config('lonAdmEMail');
my $errors;
foreach my $role (@{$roles}) {
if ($role eq 'login') {
%choices = &login_choices();
+ @logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
}
if ($role eq 'login') {
- @images = ('img','logo','domlogo');
+ @images = ('img','logo','domlogo','login');
} else {
@images = ('img');
}
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
- foreach my $item (@bgs,@links) {
+ foreach my $item (@bgs,@links,@logintext) {
$confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
}
my ($configuserok,$author_ok,$switchserver,%currroles);
@@ -2032,20 +2155,31 @@ sub modify_colors {
}
}
}
+ foreach my $item (@logintext) {
+ if ($domconfig->{$role}{$item} ne '') {
+ if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
+ $changes{$role}{'logintext'}{$item} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{$item}) {
+ $changes{$role}{'logintext'}{$item} = 1;
+ }
+ }
+ }
} else {
&default_change_checker($role,\@images,\@links,\@bgs,
- $confhash,\%changes);
+ \@logintext,$confhash,\%changes);
}
} else {
&default_change_checker($role,\@images,\@links,\@bgs,
- $confhash,\%changes);
+ \@logintext,$confhash,\%changes);
}
}
return ($errors,%changes);
}
sub default_change_checker {
- my ($role,$images,$links,$bgs,$confhash,$changes) = @_;
+ my ($role,$images,$links,$bgs,$logintext,$confhash,$changes) = @_;
foreach my $item (@{$links}) {
if ($confhash->{$role}{$item}) {
$changes->{$role}{'links'}{$item} = 1;
@@ -2056,6 +2190,11 @@ sub default_change_checker {
$changes->{$role}{'bgs'}{$item} = 1;
}
}
+ foreach my $item (@{$logintext}) {
+ if ($confhash->{$role}{$item}) {
+ $changes->{$role}{'logintext'}{$item} = 1;
+ }
+ }
foreach my $img (@{$images}) {
if ($env{'form.'.$role.'_del_'.$img}) {
$confhash->{$role}{$img} = '';
@@ -2070,7 +2209,6 @@ sub default_change_checker {
sub display_colorchgs {
my ($dom,$changes,$roles,$confhash) = @_;
my (%choices,$resulttext);
- &Apache::loncommon::devalidate_domconfig_cache($dom);
if (!grep(/^login$/,@{$roles})) {
$resulttext = &mt('Changes made:').' ';
}
|