[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm /interface domainprefs.pm loncommon.pm

raeburn raeburn at source.lon-capa.org
Sat Jan 15 15:21:06 EST 2022


raeburn		Sat Jan 15 20:21:06 2022 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncommon.pm 
    /loncom/auth	lonlogin.pm 
  Log:
  - Domain config for alt attributes for banner, main logo, and domain logo
    used on log-in page.
  - Add id attributes to img tags. 
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.401 loncom/interface/domainprefs.pm:1.402
--- loncom/interface/domainprefs.pm:1.401	Thu Dec 30 02:39:01 2021
+++ loncom/interface/domainprefs.pm	Sat Jan 15 20:21:06 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.401 2021/12/30 02:39:01 raeburn Exp $
+# $Id: domainprefs.pm,v 1.402 2022/01/15 20:21:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1357,6 +1357,7 @@
             }
         }
         my @images = ('img','logo','domlogo','login');
+        my @alttext = ('img','logo','domlogo');
         my @logintext = ('textcol','bgcol');
         my @bgs = ('pgbg','mainbg','sidebg');
         my @links = ('link','alink','vlink');
@@ -1398,6 +1399,13 @@
                     $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
                 }
             }
+            foreach my $item (@alttext) {
+                if (ref($settings->{'alttext'}) eq 'HASH') {
+                    if ($settings->{'alttext'}->{$item} ne '') {
+                        $designs{'alttext'}{$item} = $settings->{'alttext'}{$item};
+                    }
+                }
+            }
             foreach my $item (@logintext) {
                 if ($settings->{$item} ne '') {
                     $designs{'logintext'}{$item} = $settings->{$item};
@@ -1707,6 +1715,7 @@
             current       => "Current",
             samllanding   => "Dual login?",
             samloptions   => "Options",
+            alttext       => "Alt text",
         );
     return %choices;
 }
@@ -2052,7 +2061,7 @@
         $css_class = $itemcount%2?' class="LC_odd_row"':'';
         $datatable .= '<tr'.$css_class.'>'.
                       '<td>'.$choices->{$img};
-        my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
+        my ($imgfile,$img_import,$login_hdr_pick,$logincolors,$alttext);
         if ($role eq 'login') {
             if ($img eq 'login') {
                 $login_hdr_pick =
@@ -2060,8 +2069,13 @@
                 $logincolors =
                     &login_text_colors($img,$role,$logintext,$phase,$choices,
                                        $designs,$defaults);
-            } elsif ($img ne 'domlogo') {
-                $datatable.= &logo_display_options($img,$defaults,$designs);
+            } else {
+                if ($img ne 'domlogo') {
+                    $datatable.= &logo_display_options($img,$defaults,$designs);
+                }
+                if (ref($designs->{'alttext'}) eq 'HASH') {
+                    $alttext = $designs->{'alttext'}{$img};
+                }
             }
         }
         $datatable .= '</td>';
@@ -2153,6 +2167,11 @@
                 $datatable .=' <input type="file" name="'.$role.'_'.$img.'" />';
             }
         }
+        if (($role eq 'login') && ($img ne 'login')) {
+            $datatable .= (' ' x2).' <span class="LC_nobreak"><label>'.$choices->{'alttext'}.':'.
+                          '<input type="text" name="'.$role.'_alt_'.$img.'" size="10" value="'.$alttext.'" />'.
+                          '</label></span>';
+        }
         $datatable .= '</td></tr>';
     }
     $itemcount ++;
@@ -12856,13 +12875,18 @@
             $domconfig->{$role} = {};
         }
         foreach my $img (@images) {
-            if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {  
-                if (defined($env{'form.login_showlogo_'.$img})) {
-                    $confhash->{$role}{'showlogo'}{$img} = 1;
-                } else { 
-                    $confhash->{$role}{'showlogo'}{$img} = 0;
+            if ($role eq 'login') {
+                if (($img eq 'img') || ($img eq 'logo')) {  
+                    if (defined($env{'form.login_showlogo_'.$img})) {
+                        $confhash->{$role}{'showlogo'}{$img} = 1;
+                    } else { 
+                        $confhash->{$role}{'showlogo'}{$img} = 0;
+                    }
                 }
-            } 
+                if ($env{'form.login_alt_'.$img} ne '') {
+                    $confhash->{$role}{'alttext'}{$img} = $env{'form.login_alt_'.$img};
+                }
+            }
 	    if ( ! $env{'form.'.$role.'_'.$img.'.filename'} 
 		 && !defined($domconfig->{$role}{$img})
 		 && !$env{'form.'.$role.'_del_'.$img}
@@ -12937,15 +12961,29 @@
                             $changes{$role}{'images'}{$img} = 1;
                         } 
                     }
-                    if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
-                        if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
-                            if ($confhash->{$role}{'showlogo'}{$img} ne 
-                                $domconfig->{$role}{'showlogo'}{$img}) {
-                                $changes{$role}{'showlogo'}{$img} = 1; 
+                    if ($role eq 'login') {
+                        if (($img eq 'logo') || ($img eq 'img')) {
+                            if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
+                                if ($confhash->{$role}{'showlogo'}{$img} ne 
+                                    $domconfig->{$role}{'showlogo'}{$img}) {
+                                    $changes{$role}{'showlogo'}{$img} = 1; 
+                                }
+                            } else {
+                                if ($confhash->{$role}{'showlogo'}{$img} == 0) {
+                                    $changes{$role}{'showlogo'}{$img} = 1;
+                                }
                             }
-                        } else {
-                            if ($confhash->{$role}{'showlogo'}{$img} == 0) {
-                                $changes{$role}{'showlogo'}{$img} = 1;
+                        }
+                        if ($img ne 'login') {
+                            if (ref($domconfig->{$role}{'alttext'}) eq 'HASH') {
+                                if ($confhash->{$role}{'alttext'}{$img} ne
+                                    $domconfig->{$role}{'alttext'}{$img}) {
+                                    $changes{$role}{'alttext'}{$img} = 1;
+                                }
+                            } else {
+                                if ($confhash->{$role}{'alttext'}{$img} ne '') {
+                                    $changes{$role}{'alttext'}{$img} = 1;
+                                }
                             }
                         }
                     }
@@ -13056,6 +13094,11 @@
             if ($confhash->{$role}{'showlogo'}{$img} == 0) {
                 $changes->{$role}{'showlogo'}{$img} = 1;
             }
+            if (ref($confhash->{$role}{'alttext'}) eq 'HASH') {
+                if ($confhash->{$role}{'alttext'}{$img} ne '') {
+                    $changes->{$role}{'alttext'}{$img} = 1;
+                }
+            }
         }
     }
     if ($confhash->{$role}{'font'}) {
@@ -13094,6 +13137,13 @@
                             } else {
                                 $resulttext .= '<li>'.&mt("$choices{$item} set to not be displayed").'</li>';
                             }
+                        } elsif (($role eq 'login') && ($key eq 'alttext')) {
+                            if ($confhash->{$role}{$key}{$item} ne '') {
+                                $resulttext .= '<li>'.&mt("$choices{$key for $choices{$item} set to [_1].",
+                                               $confhash->{$role}{$key}{$item}).'</li>';
+                            } else {
+                                $resulttext .= '<li>'.&mt("$choices{$key} for $choices{$item} deleted.").'</li>';
+                            }
                         } elsif ($confhash->{$role}{$item} eq '') {
                             $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
                         } else {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1373 loncom/interface/loncommon.pm:1.1374
--- loncom/interface/loncommon.pm:1.1373	Fri Dec 24 00:48:30 2021
+++ loncom/interface/loncommon.pm	Sat Jan 15 20:21:06 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1373 2021/12/24 00:48:30 raeburn Exp $
+# $Id: loncommon.pm,v 1.1374 2022/01/15 20:21:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5941,8 +5941,12 @@
 		&Apache::lonnet::repcopy($local_name);
 	    }
 	   $imgsrc = &lonhttpdurl($imgsrc);
-        } 
-        return '<img src="'.$imgsrc.'" alt="'.$domain.'" />';
+        }
+        my $alttext = $domain;
+        if ($designhash{$domain.'.login.alttext_domlogo'} ne '') {
+            $alttext = $designhash{$domain.'.login.alttext_domlogo'};
+        }
+        return '<img src="'.$imgsrc.'" alt="'.$alttext.'" id="lclogindomlogo" />';
     } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
         return &Apache::lonnet::domain($domain,'description');
     } else {
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.193 loncom/auth/lonlogin.pm:1.194
--- loncom/auth/lonlogin.pm:1.193	Wed Nov  3 01:04:02 2021
+++ loncom/auth/lonlogin.pm	Sat Jan 15 20:21:06 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.193 2021/11/03 01:04:02 raeburn Exp $
+# $Id: lonlogin.pm,v 1.194 2022/01/15 20:21:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -812,10 +812,14 @@
 LFORM
 
     if ($showbanner) {
+        my $alttext = &Apache::loncommon::designparm('login.alttext_img',$domain);
+        if ($alttext eq '') {
+            $alttext = 'The Learning Online Network with CAPA';
+        }
         $r->print(<<HEADER);
 <!-- The LON-CAPA Header -->
 <div style="background:$pgbg;margin:0;width:100%;">
-  <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
+  <img src="$img" border="0" alt="$alttext" class="LC_maxwidth" id="lcloginbanner" />
 </div>
 HEADER
     }
@@ -858,7 +862,8 @@
         }
         my $ssohref;
         if ($samlssoimg ne '') {
-            $ssohref = '<a href="'.$ssologin.'" title="'.$samltooltip.'"><img src="'.$samlssoimg.'" alt="'.$samlssoalt.'" /></a>';
+            $ssohref = '<a href="'.$ssologin.'" title="'.$samltooltip.'">'.
+                       '<img src="'.$samlssoimg.'" alt="'.$samlssoalt.'" id="lcssobutton" /></a>';
         } else {
             $ssohref = '<a href="'.$ssologin.'">'.$samlssotext.'</a>';
         }
@@ -913,7 +918,8 @@
 ENDLOGIN
     $r->print('</div><div>'."\n");
     if ($showmainlogo) {
-        $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
+        my $alttext = &Apache::loncommon::designparm('login.alttext_logo',$domain); 
+        $r->print(' <img src="'.$logo.'" alt="'.$alttext.'" class="LC_maxwidth" id="lcloginmainlogo" />'."\n");
     }
 $r->print(<<ENDTOP);
 $announcements


More information about the LON-CAPA-cvs mailing list