--- loncom/interface/domainprefs.pm 2007/12/16 17:48:18 1.36 +++ loncom/interface/domainprefs.pm 2008/02/15 17:02:31 1.42 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.36 2007/12/16 17:48:18 raeburn Exp $ +# $Id: domainprefs.pm,v 1.42 2008/02/15 17:02:31 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 '') { @@ -281,11 +281,24 @@ sub handler { ' /> '. '
'); + ' />'.&mt('Display using: ')."\n".
' '.
@@ -555,10 +568,24 @@ sub print_footer {
sub print_login {
my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
my %choices = &login_choices();
- my ($catalogon,$catalogoff,$adminmailon,$adminmailoff);
- $catalogon = ' checked="checked" ';
- $adminmailoff = ' checked="checked" ';
- my @images = ('img','logo','domlogo');
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'adminmail' => 'off',
+ );
+ my @toggles = ('coursecatalog','adminmail');
+ my (%checkedon,%checkedoff);
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($defaultchecked{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+ my $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);
@@ -573,17 +600,21 @@ 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};
}
if (ref($settings) eq 'HASH') {
- if ($settings->{'coursecatalog'} eq '0') {
- $catalogoff = $catalogon;
- $catalogon = ' ';
- }
- if ($settings->{'adminmail'} eq '1') {
- $adminmailon = $adminmailoff;
- $adminmailoff = ' ';
+ foreach my $item (@toggles) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
}
foreach my $item (@images) {
if ($settings->{$item} ne '') {
@@ -591,6 +622,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;
@@ -633,28 +673,23 @@ 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 =
- ' ';
- $itemcount ++;
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .= ''.$choices{'coursecatalog'}.
- ' '.
- ' '.
- ' '.
- ''.
- ' ';
- $itemcount ++;
- $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
+ my ($css_class,$datatable);
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.$choices{'adminmail'}.' '.
- ''.
- ' '.
- ' ';
+ $itemcount ++;
+ }
+ $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;
}
@@ -667,6 +702,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",
@@ -754,7 +792,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{$item}.
+ ' '.
+ ' '.
+ ''.
' '.$choices->{'font'}.' ';
@@ -776,13 +814,19 @@ sub display_color_options {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.
' ';
$itemcount ++;
@@ -915,6 +966,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 = ' '.
+ ''.$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)/([^/]+)$-) {
@@ -823,25 +867,32 @@ sub display_color_options {
}
}
if ($showfile) {
- $showfile = &Apache::loncommon::lonhttpdurl($showfile);
- $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
- $datatable.= '';
- if (!$is_custom->{$img}) {
- $datatable .= &mt('Default in use:').' ';
- if ($is_custom->{$img}) {
- $datatable.='
';
- }
- if ($img_import) {
- $datatable.= '';
- }
- $datatable.= ' '.&mt('Replace:').'
';
- } else {
- $datatable.=''.&mt('Upload:').'
';
+ if ($showfile =~ m{^/(adm|res)/}) {
+ if ($showfile =~ m{^/res/}) {
+ my $local_showfile =
+ &Apache::lonnet::filelocation('',$showfile);
+ &Apache::lonnet::repcopy($local_showfile);
+ }
+ $showfile = &Apache::loncommon::lonhttpdurl($showfile);
+ }
+ if ($imgfile) {
+ if ($imgfile =~ m{^/(adm|res)/}) {
+ if ($imgfile =~ m{^/res/}) {
+ my $local_imgfile =
+ &Apache::lonnet::filelocation('',$imgfile);
+ &Apache::lonnet::repcopy($local_imgfile);
+ }
+ $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
+ } else {
+ $fullsize = $imgfile;
+ }
}
+ $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 .= ' ';
+ '" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" />';
}
$datatable .= '
'.
&mt('Upload:');
@@ -881,7 +932,7 @@ sub display_color_options {
$datatable .= ' ';
}
$datatable .= '
'."\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 = '';
+ foreach my $item (@{$logintext}) {
+ my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'logintext'}{$item});
+ $color_menu .= ' '.$link;
+ if ($designs->{'logintext'}{$item}) {
+ $color_menu .= ' ';
+ }
+ $color_menu .= ' '.
+ ' ';
+ }
+ $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 .= '