Diff for /loncom/interface/lonindexer.pm between versions 1.86 and 1.91

version 1.86, 2004/01/05 15:02:43 version 1.91, 2004/02/05 03:47:04
Line 54  use Apache::lonlocal; Line 54  use Apache::lonlocal;
 use GDBM_File;  use GDBM_File;
   
 # ---------------------------------------- variables used throughout the module  # ---------------------------------------- variables used throughout the module
 my %hash; # tied to a user-specific gdbm file  my %hash; # global user-specific gdbm file
 my %dirs; # keys are directories, values are the open/close status  my %dirs; # keys are directories, values are the open/close status
 my %language; # has the reference information present in language.tab  my %language; # has the reference information present in language.tab
   
Line 116  sub handler { Line 116  sub handler {
     %hash = ();      %hash = ();
     {      {
  my %dbfile;   my %dbfile;
  if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {   if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_READER(),0640)) {
     while(my($key,$value)=each(%dbfile)) {      while(my($key,$value)=each(%dbfile)) {
  $hash{$key}=$value;   $hash{$key}=$value;
     }      }
Line 164  END Line 164  END
  #       selection is made.   #       selection is made.
  # $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');
Line 187  END Line 187  END
     $element      = $ENV{'form.element'};      $element      = $ENV{'form.element'};
     $titleelement = $ENV{'form.titleelement'};      $titleelement = $ENV{'form.titleelement'};
  }   }
  &Apache::lonxml::debug("mode=$mode form=$form element=$element   #&Apache::lonxml::debug("mode=$mode form=$form element=$element titleelement=$titleelement");
                                 titleelement=$titleelement");  
 # ------ set catalogmodefunctions to have extra needed javascript functionality  # ------ set catalogmodefunctions to have extra needed javascript functionality
  my $catalogmodefunctions='';   my $catalogmodefunctions='';
  if ($ENV{'form.catalogmode'} eq 'interactive' or   if ($ENV{'form.catalogmode'} eq 'interactive' or
Line 360  $r->print(&Apache::loncommon::bodytag('B Line 359  $r->print(&Apache::loncommon::bodytag('B
  $achash{$ref}=$ac;   $achash{$ref}=$ac;
  $ac++;   $ac++;
     }      }
     # sorting through the actions and changing the tied database hash      # sorting through the actions and changing the global database hash
     foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {      foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {
  my $key=$_;   my $key=$_;
  if ($ahash{$key} eq '1') {   if ($ahash{$key} eq '1') {
Line 389  $r->print(&Apache::loncommon::bodytag('B Line 388  $r->print(&Apache::loncommon::bodytag('B
  }   }
   
 # ---------------------------------- 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'}) {
     for (my $i=0; $i<=9; $i++) {      for (my $i=0; $i<=9; $i++) {
  delete $hash{'display_attrs_'.$i};   delete $hash{'display_attrs_'.$i};
  if ($ENV{'form.attr'.$i} == 1) {   if ($ENV{'form.attr'.$i} == 1) {
Line 402  $r->print(&Apache::loncommon::bodytag('B Line 401  $r->print(&Apache::loncommon::bodytag('B
  $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;   $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
     }      }
  }   }
   
 # ------------------------------- output state of file attributes to be showing  # ------------------------------- output state of file attributes to be showing
 #                                 All versions has to the last item  #                                 All versions has to the last item
 #                                 since it does not take an extra col  #                                 since it does not take an extra col
Line 424  $r->print(&Apache::loncommon::bodytag('B Line 424  $r->print(&Apache::loncommon::bodytag('B
  enctype="application/x-www-form-urlencoded">   enctype="application/x-www-form-urlencoded">
 <b><font color="#666666">$Displayfileattributes</font></b><br />  <b><font color="#666666">$Displayfileattributes</font></b><br />
 <table border=0><tr>  <table border=0><tr>
 <td><input type="checkbox" name="attr0" value="1" $attrchk[0] /> $lt{'ti'}</td>  <td><input type="checkbox" name="attr0" value="1" $attrchk[0] onClick="this.form.submit();" /> $lt{'ti'}</td>
 <td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> $lt{'si'}</td>  <td><input type="checkbox" name="attr1" value="1" $attrchk[1] onClick="this.form.submit();" /> $lt{'si'}</td>
 <td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> $lt{'la'}</td>  <td><input type="checkbox" name="attr2" value="1" $attrchk[2] onClick="this.form.submit();" /> $lt{'la'}</td>
 <td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> $lt{'lm'}</td>  <td><input type="checkbox" name="attr3" value="1" $attrchk[3] onClick="this.form.submit();" /> $lt{'lm'}</td>
 <td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> $lt{'st'}</td>  <td><input type="checkbox" name="attr8" value="1" $attrchk[8] onClick="this.form.submit();" /> $lt{'st'}</td>
 </tr><tr>  </tr><tr>
 <td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> $lt{'au'}</td>  <td><input type="checkbox" name="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $lt{'au'}</td>
 <td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> $lt{'kw'}</td>  <td><input type="checkbox" name="attr5" value="1" $attrchk[5] onClick="this.form.submit();" /> $lt{'kw'}</td>
 <td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> $lt{'ln'}</td>  <td><input type="checkbox" name="attr6" value="1" $attrchk[6] onClick="this.form.submit();" /> $lt{'ln'}</td>
 <td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> $lt{'sr'}</td>  <td><input type="checkbox" name="attr7" value="1" $attrchk[7] onClick="this.form.submit();" /> $lt{'sr'}</td>
 <td><input type="checkbox" name="attr9" value="1" $attrchk[9] /> $lt{'av'}</td>  <td><input type="checkbox" name="attr9" value="1" $attrchk[9] onClick="this.form.submit();" /> $lt{'av'}</td>
 <td>&nbsp;</td>  <td>&nbsp;</td>
 </tr></table>  </tr></table>
 <input type="hidden" name="dirPointer" value="on" />  <input type="hidden" name="attrs" value="1" />
   <input type="submit" name="updatedisplay" value="$lt{'ud'}" />
 <input type="hidden" name="acts" value="" />  <input type="hidden" name="acts" value="" />
 <input type="submit" name="attrs" value="$lt{'ud'}" />  $closebutton $groupimportbutton
 $closebutton  
 $groupimportbutton  
 </form>  
 END  END
 # ---------------------------------------------------------------- Bread crumbs  # ---------------------------------------------------------------- Bread crumbs
         $r->print(&Apache::lonhtmlcommon::crumbs($uri));          $r->print(&Apache::lonhtmlcommon::crumbs($uri,'','',
    (($ENV{'form.catalogmode'} eq 'groupimport')?
    'document.forms.fileattr':'')).
     &Apache::lonhtmlcommon::select_recent('residx','resrecent',
   'this.form.action=this.form.resrecent.options[this.form.resrecent.selectedIndex].value;this.form.submit();').
     '</form>');
 # ------------------------------------------------------ Remember where we were  # ------------------------------------------------------ Remember where we were
  &Apache::loncommon::storeresurl($uri);   &Apache::loncommon::storeresurl($uri);
    &Apache::lonhtmlcommon::store_recent('residx',$uri,$uri);
 # ----------------- output starting row to the indexed file/directory hierarchy  # ----------------- output starting row to the indexed file/directory hierarchy
         my $titleclr="#ddffff";          my $titleclr="#ddffff";
 #        $r->print(&initdebug());  #        $r->print(&initdebug());
Line 502  END Line 506  END
     }      }
  }   }
   
  my $bredir = $ENV{'form.dirPointer'};  
  my $toplevel;   my $toplevel;
  my $indent = 0;   my $indent = 0;
  $uri = $uri.'/' if $uri !~ /.*\/$/;   $uri = $uri.'/' if $uri !~ /.*\/$/;
   
  if ($bredir ne 'on') {    if ($ENV{'form.dirPointer'} ne 'on') {
     $hash{'top.level'} = $uri;       $hash{'top.level'} = $uri;
     $toplevel = $uri;       $toplevel = $uri;
     } else {
  } else {       $toplevel = $hash{'top.level'};
     $toplevel = $hash{'top.level'};    }
  }  
   
 # -------------------------------- if not at top level, provide an uplink arrow  # -------------------------------- if not at top level, provide an uplink arrow
  if ($toplevel ne '/res/'){   if ($toplevel ne '/res/'){
Line 538  END Line 540  END
   
 # --------------------------------------------------- end the output and return  # --------------------------------------------------- end the output and return
  $r->print('</body></html>'."\n");   $r->print('</body></html>'."\n");
 #    } else {  
 # $r->print('<html><head></head><body>Unable to tie hash to db '.  
 #  'file</body></html>');  
 # return OK;  
     }      }
     if(! $c->aborted()) {      if(! $c->aborted()) {
   # write back into the temporary file
  my %dbfile;   my %dbfile;
         if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {          if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {
             while (my($key,$value) = each(%hash)) {              while (my($key,$value) = each(%hash)) {
Line 562  sub scanDir { Line 561  sub scanDir {
     my $c = $r->connection();      my $c = $r->connection();
     my ($compuri,$curdir);      my ($compuri,$curdir);
     my $dirptr=16384;      my $dirptr=16384;
       my $obs;
     $indent++;      $indent++;
   
     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) {
         return if ($c->aborted());          return if ($c->aborted());
  my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5);    #This is a kludge, sorry aboot this
  next if $strip =~ /.*\.meta$/;   my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs)=split(/\&/,$line,15); 
    next if($strip =~ /.*\.meta$/ | $obs eq '1');
  my (@fileparts) = split(/\./,$strip);   my (@fileparts) = split(/\./,$strip);
  if ($hash{'display_attrs_9'} != 1) {   if ($hash{'display_attrs_9'} != 1) {
     if (scalar(@fileparts) >= 3) {      if (scalar(@fileparts) >= 3) {
Line 610  sub get_list { Line 610  sub get_list {
     my ($r,$uri)=@_;      my ($r,$uri)=@_;
     my @list;      my @list;
     (my $luri = $uri) =~ s/\//_/g;      (my $luri = $uri) =~ s/\//_/g;
       if ($ENV{'form.updatedisplay'}) {
     if ($ENV{'form.attrs'} eq &mt('Update Display')) {  
  foreach (keys %hash) {   foreach (keys %hash) {
     delete $hash{$_} if ($_ =~ /^dirlist_files_/);      delete $hash{$_} if ($_ =~ /^dirlist_files_/);
     }   }
     }      }
   
     if ($hash{'dirlist_files'.$luri}) {      if ($hash{'dirlist_files_'.$luri}) {
  @list = split(/\n/,$hash{'dirlist_files_'.$luri});   @list = split(/\n/,$hash{'dirlist_files_'.$luri});
     } else {      } else {
  @list = &Apache::lonnet::dirlist($uri);   @list = &Apache::lonnet::dirlist($uri);
  $hash{'dirlist_files_'.$luri} = join('\n',@list);   $hash{'dirlist_files_'.$luri} = join("\n",@list);
     }      }
     return @list=&match_ext($r,@list);      return @list=&match_ext($r,@list);
 }  }
Line 695  sub display_line { Line 694  sub display_line {
   
     my $tabtag='</td>';      my $tabtag='</td>';
     my $i=0;      my $i=0;
   
     while ($i<=8) {      while ($i<=8) {
  $tabtag=join('',$tabtag,"<td>&nbsp;</td>")   $tabtag=join('',$tabtag,"<td>&nbsp;</td>")
     if $hash{'display_attrs_'.$i} == 1;      if $hash{'display_attrs_'.$i} == 1;
Line 729  sub display_line { Line 727  sub display_line {
   
 # display domain  # display domain
     if ($filecom[1] eq 'domain') {      if ($filecom[1] eq 'domain') {
  $r->print ('<input type="hidden" name="dirPointer" value="on">'."\n")    $r->print ('<input type="hidden" name="dirPointer" value="on">'."\n")
     if ($ENV{'form.dirPointer'} eq "on");       if ($ENV{'form.dirPointer'} eq "on");
  $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");   $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
  $r->print("<td>");   $r->print("<td>");
  &begin_form ($r,$filecom[0]);   &begin_form ($r,$filecom[0]);
Line 783  sub display_line { Line 781  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];   my $filelink = $startdir.$filecom[0];
  next if &Apache::lonnet::metadata($filelink,'obsolete');  
  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 814  sub display_line { Line 811  sub display_line {
  }   }
         elsif ($ENV{'form.catalogmode'} eq 'groupimport') {          elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
     $title=$listname;      $title=$listname;
     $title = &Apache::lonnet::metadata($filelink,'title')      #$title = &Apache::lonnet::metadata($filelink,'title')
  if ($metafile == 1);   #if ($metafile == 1);
     $title=$listname unless $title;      $title=$listname unless $title;
     my $titleesc=&HTML::Entities::encode($title);      my $titleesc=&HTML::Entities::encode($title);
     $r->print("<form name='form$fnum'>\n");      $r->print("<form name='form$fnum'>\n");
Line 901  sub display_line { Line 898  sub display_line {
             my $output='';              my $output='';
             my $embstyle=&Apache::loncommon::fileembstyle($curfext);              my $embstyle=&Apache::loncommon::fileembstyle($curfext);
     if ($embstyle eq 'ssi') {      if ($embstyle eq 'ssi') {
        $output=&Apache::lonnet::ssi_body($filelink);   my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
                $output='<font size="-2">'.$output.'</font>';      '.tmp';
    if ((!$ENV{'form.updatedisplay'}) &&
       (-e $cache)) {
       open(FH,$cache);
       $output=join("\n",<FH>);
       close(FH);
    } else {
       $output=&Apache::lonnet::ssi_body($filelink);
       open(FH,">$cache");
       print FH $output;
       close(FH);
    }
    $output='<font size="-2">'.$output.'</font>';
    } elsif ($embstyle eq 'img') {     } elsif ($embstyle eq 'img') {
                $output='<img src="'.$filelink.'" />';                 $output='<img src="'.$filelink.'" />';
            } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) {             } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) {

Removed from v.1.86  
changed lines
  Added in v.1.91


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