Diff for /loncom/interface/lonindexer.pm between versions 1.46 and 1.57

version 1.46, 2002/07/02 21:08:24 version 1.57, 2003/01/20 16:41:13
Line 90  my @Omit = (); Line 90  my @Omit = ();
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     $r->content_type('text/html');      $r->content_type('text/html');
       &Apache::loncommon::no_cache($r);
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
     $fnum=0;      $fnum=0;
Line 130  sub handler { Line 131  sub handler {
     my $diropendb =       my $diropendb = 
  "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db";   "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db";
   
     if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {      if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
  if ($ENV{'form.launch'} eq '1') {   if ($ENV{'form.launch'} eq '1') {
     &start_fresh_session();      &start_fresh_session();
         }          }
 # -------------------- refresh environment with user database values (in %hash)  # -------------------- refresh environment with user database values (in %hash)
  if ($hash{'mode_catalog'} eq 'interactive') {   &setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode'   );
     $ENV{'form.catalogmode'}='interactive';  
  }  
  if ($hash{'mode_catalog'} eq 'groupimport') {  
     $ENV{'form.catalogmode'}='groupimport';  
  }  
   
 # --------------------- define extra fields and buttons in case of special mode  # --------------------- define extra fields and buttons in case of special mode
  if ($ENV{'form.catalogmode'} eq 'interactive') {   if ($ENV{'form.catalogmode'} eq 'interactive') {
     $hash{'mode_catalog'}='interactive';  
     $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.      $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
  '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.   '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
  ' border="0" /></td>';   ' border="0" /></td>';
Line 154  sub handler { Line 149  sub handler {
 END  END
         }          }
  elsif ($ENV{'form.catalogmode'} eq 'groupimport') {   elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
     $hash{'mode_catalog'}='groupimport';  
     $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.      $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
  '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.   '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
  ' border="0" /></td>';   ' border="0" /></td>';
Line 176  END Line 170  END
  # $element is the name of the element in $formname which receives   # $element is the name of the element in $formname which receives
  #       the URL.   #       the URL.
  # &Apache::lonxml::debug('Checking mode, form, element');   # &Apache::lonxml::debug('Checking mode, form, element');
  &setvalues(\%hash,'form_mode'   ,\%ENV,'form.mode'   );   &setvalues(\%hash,'form.mode'   ,\%ENV,'form.mode'   );
  &setvalues(\%hash,'form_form'   ,\%ENV,'form.form'   );   &setvalues(\%hash,'form.form'   ,\%ENV,'form.form'   );
  &setvalues(\%hash,'form_element',\%ENV,'form.element');   &setvalues(\%hash,'form.element',\%ENV,'form.element');
  &setvalues(\%hash,'form_only'   ,\%ENV,'form.only'   );   &setvalues(\%hash,'form.only'   ,\%ENV,'form.only'   );
  &setvalues(\%hash,'form_omit'   ,\%ENV,'form.omit'   );   &setvalues(\%hash,'form.omit'   ,\%ENV,'form.omit'   );
   
         # Deal with 'omit' and 'only'           # Deal with 'omit' and 'only' 
         if (exists $ENV{'form.omit'}) {          if (exists $ENV{'form.omit'}) {
Line 333  function gothere(val) { Line 327  function gothere(val) {
 </script>  </script>
   
 </head>  </head>
 <body bgcolor="#FFFFFF">  
 ENDHEADER  ENDHEADER
   $r->print(&Apache::loncommon::bodytag('Browse Resources'));
 # - Evaluate actions from previous page (both cumulatively and chronologically)  # - Evaluate actions from previous page (both cumulatively and chronologically)
         if ($ENV{'form.catalogmode'} eq 'groupimport') {          if ($ENV{'form.catalogmode'} eq 'groupimport') {
     my $acts=$ENV{'form.acts'};      my $acts=$ENV{'form.acts'};
Line 378  ENDHEADER Line 371  ENDHEADER
     }      }
  }   }
   
 # ---------------------------------------------------------------- output title  
  $r->print(  
 '<h2><font color="#339933">The Learning<i>Online</i> Network with CAPA '.  
   'Network Directory Browser</font></h2>'."\n");  
 # ---------------------------------- get state of file attributes to be showing  # ---------------------------------- get state of file attributes to be showing
  if ($ENV{'form.attrs'} ne '') {   if ($ENV{'form.attrs'} ne '') {
     for (my $i=0; $i<=7; $i++) {      for (my $i=0; $i<=8; $i++) {
  delete $hash{'display_attrs_'.$i};   delete $hash{'display_attrs_'.$i};
  if ($ENV{'form.attr'.$i} == 1) {   if ($ENV{'form.attr'.$i} == 1) {
     $attrchk[$i] = 'checked';      $attrchk[$i] = 'checked';
Line 392  ENDHEADER Line 381  ENDHEADER
  }   }
     }      }
  } else {   } else {
     for (my $i=0; $i<=7; $i++) {      for (my $i=0; $i<=8; $i++) {
  $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;   $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
     }      }
  }   }
Line 406  ENDHEADER Line 395  ENDHEADER
 <td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Size</td>  <td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Size</td>
 <td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last access</td>  <td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last access</td>
 <td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Last modified</td>  <td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Last modified</td>
 </tr><tr>  <td rowspan="2"><input type="checkbox" name="attr8" value="1" $attrchk[8] /> Show Resource</td></tr><tr>
 <td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Author</td>  <td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Author</td>
 <td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Keywords</td>  <td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Keywords</td>
 <td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> Language</td>  <td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> Language</td>
Line 443  END Line 432  END
     if ($hash{'display_attrs_5'} == 1);      if ($hash{'display_attrs_5'} == 1);
  $r->print("<td><b>Language</b></td>\n")   $r->print("<td><b>Language</b></td>\n")
     if ($hash{'display_attrs_6'} == 1);      if ($hash{'display_attrs_6'} == 1);
    $r->print("<td><b>Resource</b></td>\n")
       if ($hash{'display_attrs_8'} == 1);
  $r->print('</tr>');   $r->print('</tr>');
   
 # ----------------- read in what directories have previously been set to "open"  # ----------------- read in what directories have previously been set to "open"
Line 525  sub scanDir { Line 516  sub scanDir {
     my %dupdirs = %dirs;      my %dupdirs = %dirs;
     my @list=&get_list($r,$startdir);      my @list=&get_list($r,$startdir);
     foreach my $line (@list) {      foreach my $line (@list) {
  my ($strip,$dom,$foo,$testdir,$foo)=split(/\&/,$line,5);    my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5); 
  next if $strip =~ /.*\.meta$/;   next if $strip =~ /.*\.meta$/;
  my (@fileparts) = split(/\./,$strip);   my (@fileparts) = split(/\./,$strip);
  if ($hash{'display_attrs_7'} != 1) {   if ($hash{'display_attrs_7'} != 1) {
Line 550  sub scanDir { Line 541  sub scanDir {
     while (my ($key,$val)= each %dupdirs) {      while (my ($key,$val)= each %dupdirs) {
  if ($key eq $compuri and $val eq "open") {   if ($key eq $compuri and $val eq "open") {
     $diropen = "opened";      $diropen = "opened";
     delete $dupdirs{key},$dirs{$key};      delete($dupdirs{$key});
       delete($dirs{$key});
  }   }
     }      }
  }   }
Line 636  sub match_ext { Line 628  sub match_ext {
 # ------------------------------- displays one line in appropriate table format  # ------------------------------- displays one line in appropriate table format
 sub display_line {  sub display_line {
     my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_;      my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_;
     my (@pathfn, $fndir, $fnptr);      my (@pathfn, $fndir);
     my $dirptr=16384;      my $dirptr=16384;
     my $fileclr="#ffffe6";      my $fileclr="#ffffe6";
     my $iconpath= $r->dir_config('lonIconsURL') . '/';      my $iconpath= $r->dir_config('lonIconsURL') . '/';
Line 695  sub display_line { Line 687  sub display_line {
  $r->print ('<a href="javascript:gothere(\''.$filecom[0].   $r->print ('<a href="javascript:gothere(\''.$filecom[0].
    '/\')"><img src="'.$iconpath.'server.gif"');     '/\')"><img src="'.$iconpath.'server.gif"');
  $r->print (' border="0" /></a>'."\n");   $r->print (' border="0" /></a>'."\n");
  $r->print("Domain - $listname $tabtag</tr></form>\n");   $r->print("Domain - $listname (".
         $Apache::lonnet::domaindescription{$listname}.") $tabtag</tr></form>\n");
  return OK;   return OK;
   
 # display user directory  # display user directory
Line 723  sub display_line { Line 716  sub display_line {
   
 # display file  # display file
     if ($fnptr == 0 and $filecom[3] ne '') {      if ($fnptr == 0 and $filecom[3] ne '') {
    my $filelink = $startdir.$filecom[0];
    return OK if (!&Apache::lonnet::allowed('bre',$filelink));
  my @file_ext = split (/\./,$listname);   my @file_ext = split (/\./,$listname);
  my $curfext = $file_ext[-1];   my $curfext = $file_ext[-1];
         if (@Omit) {          if (@Omit) {
Line 740  sub display_line { Line 735  sub display_line {
  $iconname = $curfext.".gif" unless   $iconname = $curfext.".gif" unless
     (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');      (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');
  #   #
  my $filelink = $startdir.$filecom[0];  
  $r->print("<tr bgcolor=$fileclr><td nowrap valign='bottom'>");   $r->print("<tr bgcolor=$fileclr><td nowrap valign='bottom'>");
  my $metafile = grep /^$filecom[0]\.meta\&/, @list;   my $metafile = grep /^$filecom[0]\.meta\&/, @list;
  my $title;   my $title;
Line 842  sub display_line { Line 836  sub display_line {
     $r->print('<td valign=bottom> '.($lang eq '' ? '&nbsp;' : $lang).      $r->print('<td valign=bottom> '.($lang eq '' ? '&nbsp;' : $lang).
       " </td>\n");        " </td>\n");
  }   }
           if ($hash{'display_attrs_8'} == 1) {
               my $output='';
               my $embstyle=&Apache::loncommon::fileembstyle($curfext);
       if ($embstyle eq 'ssi') {
          $output=&Apache::lonnet::ssi($filelink);
                  $output=~s/^.*\<body[^\>]*\>//si;
                  $output=~s/\<\/body\s*\>.*$//si;
                  $output='<font size="-2">'.$output.'</font>';
      } elsif ($embstyle eq 'img') {
                  $output='<img src="'.$filelink.'" />';
              }
      $r->print('<td valign=bottom> '.($output eq '' ? '&nbsp;':$output).
         " </td>\n");
           }
  $r->print("</tr>\n");   $r->print("</tr>\n");
     }      }
   
Line 901  sub begin_form { Line 909  sub begin_form {
   
 # --------- settings whenever the user causes the indexer window to be launched  # --------- settings whenever the user causes the indexer window to be launched
 sub start_fresh_session {  sub start_fresh_session {
     delete $hash{'mode_catalog'};      delete $hash{'form.catalogmode'};
     delete $hash{'form_mode'};      delete $hash{'form.mode'};
     delete $hash{'form_form'};      delete $hash{'form.form'};
     delete $hash{'form_element'};      delete $hash{'form.element'};
     delete $hash{'form_omit'};      delete $hash{'form.omit'};
     delete $hash{'form_only'};      delete $hash{'form.only'};
     foreach (keys %hash) {      foreach (keys %hash) {
  if ($_ =~ /^pre_/) {          delete $hash{$_} if (/^(pre_|store)/);
     delete $hash{$_};  
  }  
  if ($_ =~ /^store/) {  
     delete $hash{$_};  
  }  
     }      }
 }  }
   
Line 932  sub setvalues { Line 935  sub setvalues {
   
 1;  1;
   
   sub cleanup {
       if (tied(%hash)){
    &Apache::lonnet::logthis('Cleanup indexer: hash');
           unless (untie(%hash)) {
       &Apache::lonnet::logthis('Failed cleanup indexer: hash');
           }
       }
   }
   
 =head1 NAME  =head1 NAME
   
 Apache::lonindexer - mod_perl module for cross server filesystem browsing  Apache::lonindexer - mod_perl module for cross server filesystem browsing

Removed from v.1.46  
changed lines
  Added in v.1.57


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