Diff for /loncom/interface/lonindexer.pm between versions 1.76 and 1.84

version 1.76, 2003/09/23 00:26:10 version 1.84, 2003/12/30 20:47:23
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 # YEAR=1999  
 # 5/21/99, 5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer)  
 # 11/23 Gerd Kortemeyer  
 # YEAR=2000  
 # 07/20-08/04 H.K. Ng  
 # YEAR=2001  
 # 05/9-05/19/2001 H. K. Ng  
 # 05/21/2001 H. K. Ng  
 # 05/23/2001 H. K. Ng  
 # 6/26,7/8 H. K. Ng  
 # 8/14 H. K. Ng  
 # 11/30 Matthew Hall  
 # YEAR=2002  
 # 6/29/2002 H. K. Ng  
 #  
 ###  ###
   
 ###############################################################################  ###############################################################################
Line 61  package Apache::lonindexer; Line 46  package Apache::lonindexer;
 use strict;  use strict;
 use Apache::lonnet();  use Apache::lonnet();
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::lonhtmlcommon();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::lonmeta;  use Apache::lonmeta;
 use Apache::File;  use Apache::File;
   use Apache::lonlocal;
 use GDBM_File;  use GDBM_File;
   
 # ---------------------------------------- variables used throughout the module  # ---------------------------------------- variables used throughout the module
Line 117  sub handler { Line 104  sub handler {
     # Get the parameters from the query string      # Get the parameters from the query string
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
      ['catalogmode','launch','acts','mode','form','element',       ['catalogmode','launch','acts','mode','form','element',
               'only','omit']);                'only','omit','titleelement']);
     #-------------------------------------------------------------------      #-------------------------------------------------------------------
     my $closebutton='';      my $closebutton='';
     my $groupimportbutton='';      my $groupimportbutton='';
Line 149  sub handler { Line 136  sub handler {
  '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.   '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
  ' border="0" /></td>';   ' border="0" /></td>';
     $colspan=" colspan='2' ";      $colspan=" colspan='2' ";
               my $cl=&mt('Close');
             $closebutton=<<END;              $closebutton=<<END;
 <input type="button" name="close" value='CLOSE' onClick="self.close()">  <input type="button" name="close" value='$cl' onClick="self.close()">
 END  END
         }          }
  elsif ($ENV{'form.catalogmode'} eq 'groupimport') {   elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
Line 158  END Line 146  END
  '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.   '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
  ' border="0" /></td>';   ' border="0" /></td>';
     $colspan=" colspan='2' ";      $colspan=" colspan='2' ";
       my $cl=&mt('Close');
               my $gi=&mt('Group Import');
             $closebutton=<<END;              $closebutton=<<END;
 <input type="button" name="close" value='CLOSE' onClick="self.close()">  <input type="button" name="close" value='$cl' onClick="self.close()">
 END  END
             $groupimportbutton=<<END;              $groupimportbutton=<<END;
 <input type="button" name="groupimport" value='GROUP IMPORT'  <input type="button" name="groupimport" value='$gi'
 onClick="javascript:select_group()">  onClick="javascript:select_group()">
 END  END
         }          }
Line 175  END Line 165  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.titleelement',\%ENV,'form.titleelement');
  &setvalues(\%hash,'form.omit'   ,\%ENV,'form.omit'   );   &setvalues(\%hash,'form.only'        ,\%ENV,'form.only'   );
    &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 190  END Line 181  END
         }          }
                   
  my $mode = $ENV{'form.mode'};   my $mode = $ENV{'form.mode'};
  my ($form,$element);   my ($form,$element,$titleelement);
  if ($mode eq 'edit' || $mode eq 'parmset') {   if ($mode eq 'edit' || $mode eq 'parmset') {
     $form    = $ENV{'form.form'};      $form         = $ENV{'form.form'};
     $element = $ENV{'form.element'};      $element      = $ENV{'form.element'};
       $titleelement = $ENV{'form.titleelement'};
  }   }
  &Apache::lonxml::debug("mode=$mode form=$form element=$element");   &Apache::lonxml::debug("mode=$mode form=$form element=$element
                                   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 244  END Line 237  END
 // mode = $mode  // mode = $mode
 function select_data(title,url) {  function select_data(title,url) {
     changeURL(url);      changeURL(url);
       changeTitle(title);
     self.close();      self.close();
 }  }
   
Line 258  function changeURL(val) { Line 252  function changeURL(val) {
     alert("The file you selected is: "+val);      alert("The file you selected is: "+val);
     }      }
 }  }
   
 END  END
                   if (!$titleelement) {
       $catalogmodefunctions.='function changeTitle(val) {}';
    } else {
       $catalogmodefunctions.=<<END;
   function changeTitle(val) {
       if (window.opener.document) {
       window.opener.document.forms["$form"].elements["$titleelement"].value=val;
       } else {
       alert("The title of the file you selected is: "+val);
       }
   }
   END
                   }
             } elsif ($mode eq 'parmset') {              } elsif ($mode eq 'parmset') {
                 my $location = "/adm/groupsort?catalogmode=interactive&";                  my $location = "/adm/groupsort?catalogmode=interactive&";
                 $location .= "form=$form&element=$element&mode=parmset&acts=";                  $location .= "form=$form&element=$element&mode=parmset&acts=";
Line 399  $r->print(&Apache::loncommon::bodytag('B Line 405  $r->print(&Apache::loncommon::bodytag('B
 # ------------------------------- 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
    my %lt=&Apache::lonlocal::texthash(
      'ti' => 'Title',
      'si' => 'Size',
      'la' => 'Last access',
      'lm' => 'Last modified',
      'st' => 'Statistics',
      'au' => 'Author',
      'kw' => 'Keywords',
      'ln' => 'Language',
      'sr' => 'Show resource',
      'av' => 'All versions',
      'ud' => 'Update Display'
      );
           my $Displayfileattributes=&mt('Display file attributes');
  $r->print(<<END);   $r->print(<<END);
 <form method="post" name="fileattr" action="$uri"  <form method="post" name="fileattr" action="$uri"
  enctype="application/x-www-form-urlencoded">   enctype="application/x-www-form-urlencoded">
 <b><font color="#666666">Display file attributes</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] /> Title</td>  <td><input type="checkbox" name="attr0" value="1" $attrchk[0] /> $lt{'ti'}</td>
 <td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Size</td>  <td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> $lt{'si'}</td>
 <td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last access</td>  <td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> $lt{'la'}</td>
 <td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Last modified</td>  <td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> $lt{'lm'}</td>
 <td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> Statistics</td></tr><tr>  <td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> $lt{'st'}</td>
 <td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Author</td>  </tr><tr>
 <td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Keywords</td>  <td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> $lt{'au'}</td>
 <td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> Language</td>  <td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> $lt{'kw'}</td>
 <td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> Show Resource</td>  <td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> $lt{'ln'}</td>
 <td><input type="checkbox" name="attr9" value="1" $attrchk[9] /> All versions</td>  <td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> $lt{'sr'}</td>
   <td><input type="checkbox" name="attr9" value="1" $attrchk[9] /> $lt{'av'}</td>
 <td>&nbsp;</td>  <td>&nbsp;</td>
 </tr></table>  </tr></table>
 <input type="hidden" name="dirPointer" value="on" />  <input type="hidden" name="dirPointer" value="on" />
 <input type="hidden" name="acts" value="" />  <input type="hidden" name="acts" value="" />
 <input type="submit" name="attrs" value="Update Display" />  <input type="submit" name="attrs" value="$lt{'ud'}" />
 $closebutton  $closebutton
 $groupimportbutton  $groupimportbutton
 </form>  </form>
 END  END
   # ---------------------------------------------------------------- Bread crumbs
           $r->print(&Apache::lonhtmlcommon::crumbs($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 431  END Line 453  END
 #        $r->print(&writedebug("Only:@Only")) if (@Only);  #        $r->print(&writedebug("Only:@Only")) if (@Only);
         $r->print("<table width='100\%' border=0><tr><td bgcolor=#777777>\n");          $r->print("<table width='100\%' border=0><tr><td bgcolor=#777777>\n");
  $r->print("<table width='100\%' border=0><tr bgcolor=$titleclr>\n");   $r->print("<table width='100\%' border=0><tr bgcolor=$titleclr>\n");
  $r->print("<td $colspan><b>Name</b></td>\n");   $r->print("<td $colspan><b>".&mt('Name')."</b></td>\n");
  $r->print("<td><b>Title</b></td>\n")    $r->print("<td><b>".&mt('Title')."</b></td>\n") 
     if ($hash{'display_attrs_0'} == 1);      if ($hash{'display_attrs_0'} == 1);
  $r->print("<td align=right><b>Size (bytes) ".   $r->print("<td align=right><b>".&mt("Size")." (".&mt("bytes").") ".
   "</b></td>\n") if ($hash{'display_attrs_1'} == 1);    "</b></td>\n") if ($hash{'display_attrs_1'} == 1);
  $r->print("<td><b>Last accessed</b></td>\n")    $r->print("<td><b>".&mt("Last accessed")."</b></td>\n") 
     if ($hash{'display_attrs_2'} == 1);      if ($hash{'display_attrs_2'} == 1);
  $r->print("<td><b>Last modified</b></td>\n")   $r->print("<td><b>".&mt("Last modified")."</b></td>\n")
     if ($hash{'display_attrs_3'} == 1);      if ($hash{'display_attrs_3'} == 1);
  $r->print("<td><b>Author(s)</b></td>\n")   $r->print("<td><b>".&mt("Author(s)")."</b></td>\n")
     if ($hash{'display_attrs_4'} == 1);      if ($hash{'display_attrs_4'} == 1);
  $r->print("<td><b>Keywords</b></td>\n")   $r->print("<td><b>".&mt("Keywords")."</b></td>\n")
     if ($hash{'display_attrs_5'} == 1);      if ($hash{'display_attrs_5'} == 1);
  $r->print("<td><b>Language</b></td>\n")   $r->print("<td><b>".&mt("Language")."</b></td>\n")
     if ($hash{'display_attrs_6'} == 1);      if ($hash{'display_attrs_6'} == 1);
  $r->print("<td><b>Resource</b></td>\n")   $r->print("<td><b>".&mt("Resource")."</b></td>\n")
     if ($hash{'display_attrs_7'} == 1);      if ($hash{'display_attrs_7'} == 1);
  $r->print("<td><b>Usage Statistics <br />(Courses/Network Hits)</b></td>\n")   $r->print("<td><b>".&mt("Usage Statistics")." <br />(".
     &mt("Courses/Network Hits").")</b></td>\n")
     if ($hash{'display_attrs_8'} == 1);      if ($hash{'display_attrs_8'} == 1);
  $r->print('</tr>');   $r->print('</tr>');
   
Line 586  sub get_list { Line 609  sub get_list {
     my @list;      my @list;
     (my $luri = $uri) =~ s/\//_/g;      (my $luri = $uri) =~ s/\//_/g;
   
     if ($ENV{'form.attrs'} eq 'Update Display') {      if ($ENV{'form.attrs'} eq &mt('Update Display')) {
  foreach (keys %hash) {   foreach (keys %hash) {
     delete $hash{$_} if ($_ =~ /^dirlist_files_/);      delete $hash{$_} if ($_ =~ /^dirlist_files_/);
     }      }
Line 649  sub match_ext { Line 672  sub match_ext {
     push @trimlist,$line;      push @trimlist,$line;
  }   }
     }      }
     @trimlist = sort (@trimlist);      @trimlist = sort {uc($a) cmp uc($b)} (@trimlist);
     return @trimlist;      return @trimlist;
 }  }
   
Line 665  sub display_line { Line 688  sub display_line {
     my @pathcom = split (/\//,$filecom[0]);      my @pathcom = split (/\//,$filecom[0]);
     my $listname = $pathcom[scalar(@pathcom)-1];      my $listname = $pathcom[scalar(@pathcom)-1];
     my $fnptr = $filecom[3]&$dirptr;      my $fnptr = $filecom[3]&$dirptr;
     my $msg = 'View '.$filecom[0].' resources';      my $msg = &mt('View').' '.$filecom[0].' '.&mt('resources');
     $msg = 'Close '.$filecom[0].' directory' if $diropen eq 'opened';      $msg = &mt('Close').' '.$filecom[0].' '.&mt('directory') if $diropen eq 'opened';
   
     my $tabtag='</td>';      my $tabtag='</td>';
     my $i=0;      my $i=0;
Line 695  sub display_line { Line 718  sub display_line {
  $r->print ('<input src="'.$iconpath.'arrow_up.gif"');   $r->print ('<input src="'.$iconpath.'arrow_up.gif"');
  $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.   $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
    "\n");     "\n");
  $r->print("Up $tabtag</tr></form>\n");   $r->print(&mt("Up")." $tabtag</tr></form>\n");
  return OK;   return OK;
     }      }
 # Do we have permission to look at this?  # Do we have permission to look at this?
Line 720  sub display_line { Line 743  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 ");   $r->print (&mt("Domain")." - $listname ");
  if ($Apache::lonnet::domaindescription{$listname}) {   if ($Apache::lonnet::domaindescription{$listname}) {
     $r->print("(".$Apache::lonnet::domaindescription{$listname}.      $r->print("(".$Apache::lonnet::domaindescription{$listname}.
       ")");        ")");
Line 758  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 769  sub display_line { Line 793  sub display_line {
             return OK if ($skip > 0);              return OK if ($skip > 0);
         }          }
  # Set the icon for the file   # Set the icon for the file
  my $iconname = "unknown.gif";   my $iconname = &Apache::loncommon::icon($listname);
  my $embstyle = &Apache::loncommon::fileembstyle($curfext);  
  # The unless conditional that follows is a bit of overkill  
  $iconname = $curfext.".gif" unless  
     (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');  
  #  
  $r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>");   $r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>");
  my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list;   my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list;
  my $title;   my $title;
Line 830  sub display_line { Line 849  sub display_line {
       ".gif border='0' />\n") if $rem > 0;        ".gif border='0' />\n") if $rem > 0;
  }   }
   
  $r->print("<img src=$iconpath$iconname border='0' />\n");   $r->print("<img src='$iconname' border='0' />\n");
  $r->print (" <a href=\"javascript:openWindow('".$filelink.   $r->print (" <a href=\"javascript:openWindow('".$filelink.
    "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".     "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".
    " TARGET=_self>$listname</a> ");     " TARGET=_self>$listname</a> ");
Line 906  sub display_line { Line 925  sub display_line {
   
 # -- display directory  # -- display directory
     if ($fnptr == $dirptr) {      if ($fnptr == $dirptr) {
  my @file_ext = split (/\./,$listname);  
  my $curfext = $file_ext[scalar(@file_ext)-1];  
  my $curdir = $startdir.$filecom[0].'/';   my $curdir = $startdir.$filecom[0].'/';
  my $anchor = $curdir;   my $anchor = $curdir;
  $anchor =~ s/\///g;   $anchor =~ s/\///g;

Removed from v.1.76  
changed lines
  Added in v.1.84


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