Diff for /loncom/interface/loncommon.pm between versions 1.47 and 1.52

version 1.47, 2002/07/22 14:25:40 version 1.52, 2002/08/08 19:27:35
Line 80  package Apache::loncommon; Line 80  package Apache::loncommon;
 use strict;  use strict;
 use Apache::lonnet();  use Apache::lonnet();
 use GDBM_File;  use GDBM_File;
 use POSIX qw(strftime);  use POSIX qw(strftime mktime);
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::lonmsg();  use Apache::lonmsg();
 my $readit;  my $readit;
Line 242  of the element the selection from the se Line 242  of the element the selection from the se
 ###############################################################  ###############################################################
 sub browser_and_searcher_javascript {  sub browser_and_searcher_javascript {
     return <<END;      return <<END;
     var editbrowser;      var editbrowser = null;
     function openbrowser(formname,elementname,only,omit) {      function openbrowser(formname,elementname,only,omit) {
         var url = '/res/?';          var url = '/res/?';
         if (editbrowser == null) {          if (editbrowser == null) {
Line 439  END Line 439  END
   
 =pod  =pod
   
 =item help_open_topic($topic, $stayOnPage, $width, $height)  =item help_open_topic($topic, $text, $stayOnPage, $width, $height)
   
 Returns a string corresponding to an HTML link to the given help $topic, where $topic corresponds to the name of a .tex file in /home/httpd/html/adm/help/tex, with underscores replaced by spaces.  Returns a string corresponding to an HTML link to the given help $topic, where $topic corresponds to the name of a .tex file in /home/httpd/html/adm/help/tex, with underscores replaced by spaces.
   
   $text will optionally be linked to the same topic, allowing you to link text in addition to the graphic. If you do not want to link text, but wish to specify one of the later parameters, pass an empty string.
   
 $stayOnPage is a value that will be interpreted as a boolean. If true, the link will not open a new window. If false, the link will open a new window using Javascript. (Default is false.)  $stayOnPage is a value that will be interpreted as a boolean. If true, the link will not open a new window. If false, the link will open a new window using Javascript. (Default is false.)
   
 $width and $height are optional numerical parameters that will override the width and height of the popped up window, which may be useful for certain help topics with big pictures included.  $width and $height are optional numerical parameters that will override the width and height of the popped up window, which may be useful for certain help topics with big pictures included.
Line 450  $width and $height are optional numerica Line 452  $width and $height are optional numerica
 =cut  =cut
   
 sub help_open_topic {  sub help_open_topic {
     my ($topic, $stayOnPage, $width, $height) = @_;      my ($topic, $text, $stayOnPage, $width, $height) = @_;
       $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);      $stayOnPage = 0 if (not defined $stayOnPage);
     $width = 350 if (not defined $width);      $width = 350 if (not defined $width);
     $height = 400 if (not defined $height);      $height = 400 if (not defined $height);
     my $filename = $topic;      my $filename = $topic;
     $filename =~ s/ /_/g;      $filename =~ s/ /_/g;
   
     my $template;      my $template = "";
       my $link;
   
     if (!$stayOnPage)      if (!$stayOnPage)
     {      {
         $template = <<"ENDTEMPLATE";   $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height'))";
 <a href="javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,s  
 crollbars=1,width=$width,height=$height'))"><image  
   src="/adm/help/gif/smallHelp.gif"  
   border="0" alt="(Help: $topic)"></a>  
 ENDTEMPLATE  
     }      }
     else      else
     {      {
         $template = <<"ENDTEMPLATE";   $link = "/adm/help/${filename}.hlp";
 <a href="/adm/help/${filename}.hlp"><image  
   src="/adm/help/gif/smallHelp.gif"  
   border="0" alt="(Help: $topic)"></a>  
 ENDTEMPLATE  
     }      }
   
       # Add the text
       if ($text ne "")
       {
    $template .= "<a href=\"$link\">$text</a> ";
       }
   
       # Add the graphic
       $template .= <<"ENDTEMPLATE";
   <a href="$link"><image src="/adm/help/gif/smallHelp.gif" border="0" alt="(Help: $topic)"></a>
   ENDTEMPLATE
   
     return $template;      return $template;
   
 }  }
Line 552  sub select_dom_form { Line 558  sub select_dom_form {
   
 =pod  =pod
   
 =item get_home_servers($domain)  =item get_library_servers($domain)
   
 Returns a hash which contains keys like '103l3' and values like   Returns a hash which contains keys like '103l3' and values like 
 'kirk.lite.msu.edu'.  All of the keys will be for machines in the  'kirk.lite.msu.edu'.  All of the keys will be for machines in the
Line 561  given $domain. Line 567  given $domain.
 =cut  =cut
   
 #-------------------------------------------  #-------------------------------------------
 sub get_home_servers {  sub get_library_servers {
     my $domain = shift;      my $domain = shift;
     my %home_servers;      my %library_servers;
     foreach (keys(%Apache::lonnet::libserv)) {      foreach (keys(%Apache::lonnet::libserv)) {
         if ($Apache::lonnet::hostdom{$_} eq $domain) {          if ($Apache::lonnet::hostdom{$_} eq $domain) {
             $home_servers{$_} = $Apache::lonnet::hostname{$_};              $library_servers{$_} = $Apache::lonnet::hostname{$_};
         }          }
     }      }
     return %home_servers;      return %library_servers;
 }  }
   
 #-------------------------------------------  #-------------------------------------------
Line 586  returns a string which contains an <opti Line 592  returns a string which contains an <opti
 #-------------------------------------------  #-------------------------------------------
 sub home_server_option_list {  sub home_server_option_list {
     my $domain = shift;      my $domain = shift;
     my %servers = &get_home_servers($domain);      my %servers = &get_library_servers($domain);
     my $result = '';      my $result = '';
     foreach (sort keys(%servers)) {      foreach (sort keys(%servers)) {
         $result.=          $result.=
Line 1087  sub get_previous_attempt { Line 1093  sub get_previous_attempt {
  } else {   } else {
   $value=$lasthash{$_};    $value=$lasthash{$_};
  }   }
  if ($_ =~/$regexp$/) {$value = &$gradesub($value)}   if ($_ =~/$regexp$/ && (defined &$gradesub)) {$value = &$gradesub($value)}
  $prevattempts.='<td>'.$value.'&nbsp;</td>';   $prevattempts.='<td>'.$value.'&nbsp;</td>';
       }        }
       $prevattempts.='</tr></table></td></tr></table>';        $prevattempts.='</tr></table></td></tr></table>';
Line 1145  sub get_student_answers { Line 1151  sub get_student_answers {
   
 ###############################################  ###############################################
   
   
   sub timehash {
       my @ltime=localtime(shift);
       return ( 'seconds' => $ltime[0],
                'minutes' => $ltime[1],
                'hours'   => $ltime[2],
                'day'     => $ltime[3],
                'month'   => $ltime[4]+1,
                'year'    => $ltime[5]+1900,
                'weekday' => $ltime[6],
                'dayyear' => $ltime[7]+1,
                'dlsav'   => $ltime[8] );
   }
   
   sub maketime {
       my %th=@_;
       return POSIX::mktime(
           ($th{'seconds'},$th{'minutes'},$th{'hours'},
            $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'}));
   }
   
   
   sub findallcourses {
       my %courses=();
       my $now=time;
       foreach (keys %ENV) {
    if ($_=~/^user\.role\.\w+\.\/(\w+)\/(\w+)/) {
       my ($starttime,$endtime)=$ENV{$_};
               my $active=1;
               if ($starttime) {
    if ($now<$starttime) { $active=0; }
               }
               if ($endtime) {
                   if ($now>$endtime) { $active=0; }
               }
               if ($active) { $courses{$1.'_'.$2}=1; }
           }
       }
       return keys %courses;
   }
   
 ###############################################  ###############################################
   
 sub get_unprocessed_cgi {  sub get_unprocessed_cgi {

Removed from v.1.47  
changed lines
  Added in v.1.52


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>