Diff for /loncom/interface/lonindexer.pm between versions 1.68 and 1.72

version 1.68, 2003/06/16 22:09:02 version 1.72, 2003/08/06 16:43:36
Line 62  use strict; Line 62  use strict;
 use Apache::lonnet();  use Apache::lonnet();
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
   use Apache::lonmeta;
 use Apache::File;  use Apache::File;
 use GDBM_File;  use GDBM_File;
   
Line 318  END Line 319  END
   
 <script type="text/javascript">  <script type="text/javascript">
 $catalogmodefunctions  $catalogmodefunctions
 function openWindow(url, wdwName, w, h, toolbar,scrollbar) {  function openWindow(url, wdwName, w, h, toolbar,scrollbar,locationbar) {
     var options = "width=" + w + ",height=" + h + ",";      var xpos = (screen.width-w)/2;
       xpos = (xpos < 0) ? '0' : xpos;
       var ypos = (screen.height-h)/2-30;
       ypos = (ypos < 0) ? '0' : ypos;
       var options = "width=" + w + ",height=" + h + ",screenx="+xpos+",screeny="+ypos+",";
     options += "resizable=yes,scrollbars="+scrollbar+",status=no,";      options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
     options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";      options += "menubar=no,toolbar="+toolbar+",location="+locationbar+",directories=no";
     var newWin = window.open(url, wdwName, options);      var newWin = window.open(url, wdwName, options);
     newWin.focus();      newWin.focus();
 }  }
Line 377  $r->print(&Apache::loncommon::bodytag('B Line 382  $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'} ne '') {
     for (my $i=0; $i<=8; $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) {
     $attrchk[$i] = 'checked';      $attrchk[$i] = 'checked';
Line 385  $r->print(&Apache::loncommon::bodytag('B Line 390  $r->print(&Apache::loncommon::bodytag('B
  }   }
     }      }
  } else {   } else {
     for (my $i=0; $i<=8; $i++) {      for (my $i=0; $i<=9; $i++) {
  $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
   #                                 since it does not take an extra col
  $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">
Line 399  $r->print(&Apache::loncommon::bodytag('B Line 406  $r->print(&Apache::loncommon::bodytag('B
 <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>
 <td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> All versions</td></tr><tr>  <td><input type="checkbox" name="attr8" value="1" $attrchk[8] /> Statistics</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>
 <td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> Show Resource</td>  <td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> Show Resource</td>
   <td><input type="checkbox" name="attr9" value="1" $attrchk[9] /> All versions</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="Review" />&nbsp;  <input type="submit" name="attrs" value="Update Display" />
 <input type="submit" name="attrs" value="Refresh" />  
 $closebutton  $closebutton
 $groupimportbutton  $groupimportbutton
 </form>  </form>
Line 439  END Line 446  END
     if ($hash{'display_attrs_6'} == 1);      if ($hash{'display_attrs_6'} == 1);
  $r->print("<td><b>Resource</b></td>\n")   $r->print("<td><b>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")
       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 535  sub scanDir { Line 544  sub scanDir {
  my ($strip,$dom,undef,$testdir,undef)=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_8'} != 1) {   if ($hash{'display_attrs_9'} != 1) {
     if (scalar(@fileparts) >= 3) {      if (scalar(@fileparts) >= 3) {
  my $fext = pop @fileparts;   my $fext = pop @fileparts;
  my $ov = pop @fileparts;   my $ov = pop @fileparts;
Line 545  sub scanDir { Line 554  sub scanDir {
  }   }
   
  if ($dom eq 'domain') {   if ($dom eq 'domain') {
     $compuri = join('',$strip,'/');  # dom list has /res/<domain name>      # dom list has full path /res/<domain name>/ already
     $curdir = $compuri;      $curdir='';
  } else {   } else {
     # user, dir & file have name only, i.e., w/o path      # user, dir & file have name only, i.e., w/o path
     $compuri = join('',$startdir,$strip,'/');      $compuri = join('',$startdir,$strip,'/');
Line 574  sub get_list { Line 583  sub get_list {
     my @list;      my @list;
     (my $luri = $uri) =~ s/\//_/g;      (my $luri = $uri) =~ s/\//_/g;
   
     if ($ENV{'form.attrs'} eq 'Refresh') {      if ($ENV{'form.attrs'} eq 'Update Display') {
  foreach (keys %hash) {   foreach (keys %hash) {
     delete $hash{$_} if ($_ =~ /^dirlist_files_/);      delete $hash{$_} if ($_ =~ /^dirlist_files_/);
     }      }
Line 659  sub display_line { Line 668  sub display_line {
     my $tabtag='</td>';      my $tabtag='</td>';
     my $i=0;      my $i=0;
   
     while ($i<=7) {      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;
  $i++;   $i++;
Line 669  sub display_line { Line 678  sub display_line {
   
 # display uplink arrow  # display uplink arrow
     if ($filecom[1] eq 'viewOneUp') {      if ($filecom[1] eq 'viewOneUp') {
  $r->print("<tr bgcolor=$fileclr>$extrafield");   $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
  $r->print("<td valign=$valign>\n");   $r->print("<td>\n");
  $r->print ('<form method="post" name="dirpathUP" action="'.$startdir.   $r->print ('<form method="post" name="dirpathUP" action="'.$startdir.
    '/" '.     '/" '.
    'onSubmit="return rep_dirpath(\'UP\','.     'onSubmit="return rep_dirpath(\'UP\','.
Line 694  sub display_line { Line 703  sub display_line {
     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 bgcolor=$fileclr>$extrafield");   $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
  $r->print("<td valign=$valign>");   $r->print("<td>");
  &begin_form ($r,$filecom[0].'/');   &begin_form ($r,$filecom[0].'/');
  my $anchor = $filecom[0].'/';   my $anchor = $filecom[0].'/';
  $anchor =~ s/\///g;   $anchor =~ s/\///g;
Line 719  sub display_line { Line 728  sub display_line {
 # display user directory  # display user directory
     }      }
     if ($filecom[1] eq 'user') {      if ($filecom[1] eq 'user') {
  $r->print("<tr bgcolor=$fileclr>$extrafield");   $r->print("<tr valign=$valign bgcolor=$fileclr>$extrafield");
  $r->print("<td valign=$valign nowrap>\n");   $r->print("<td nowrap>\n");
  my $curdir = $startdir.$filecom[0].'/';   my $curdir = $startdir.$filecom[0].'/';
  my $anchor = $curdir;   my $anchor = $curdir;
  $anchor =~ s/\///g;   $anchor =~ s/\///g;
Line 763  sub display_line { Line 772  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');
  #   #
  $r->print("<tr bgcolor=$fileclr><td nowrap valign='$valign'>");   $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;
         if ($ENV{'form.catalogmode'} eq 'interactive') {          if ($ENV{'form.catalogmode'} eq 'interactive') {
Line 777  sub display_line { Line 786  sub display_line {
                       $titleesc,"','",$filelink,"')\">");                        $titleesc,"','",$filelink,"')\">");
     $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".      $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".
       "\n");        "\n");
     $r->print("</td><td valign='$valign' nowrap>");      $r->print("</td><td nowrap>");
  }   }
         elsif ($ENV{'form.catalogmode'} eq 'groupimport') {          elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
     $title=$listname;      $title=$listname;
Line 796  sub display_line { Line 805  sub display_line {
     $r->print("<input type='hidden' name='title"."' ".      $r->print("<input type='hidden' name='title"."' ".
       "value='$titleesc'>\n");        "value='$titleesc'>\n");
     $r->print("</form>\n");      $r->print("</form>\n");
     $r->print("</td><td valign='$valign' nowrap>");      $r->print("</td><td nowrap>");
     $hash{"pre_${fnum}_link"}=$filelink;      $hash{"pre_${fnum}_link"}=$filelink;
     $hash{"pre_${fnum}_title"}=$titleesc;      $hash{"pre_${fnum}_title"}=$titleesc;
      $fnum++;       $fnum++;
Line 820  sub display_line { Line 829  sub display_line {
   
  $r->print("<img src=$iconpath$iconname border='0' />\n");   $r->print("<img src=$iconpath$iconname border='0' />\n");
  $r->print (" <a href=\"javascript:openWindow('".$filelink.   $r->print (" <a href=\"javascript:openWindow('".$filelink.
    "', 'metadatafile', '450', '500', 'no', 'yes')\";".     "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".
    " TARGET=_self>$listname</a> ");     " TARGET=_self>$listname</a> ");
   
  $r->print (" (<a href=\"javascript:openWindow('".$filelink.   $r->print (" (<a href=\"javascript:openWindow('".$filelink.
    ".meta', 'metadatafile', '400', '450', 'no', 'yes')\"; ".     ".meta', 'metadatafile', '500', '550', 'no', 'yes','no')\"; ".
    "TARGET=_self>metadata</a>) ") if ($metafile == 1);     "TARGET=_self>metadata</a>) ") if ($metafile == 1);
   
  $r->print("</td>\n");   $r->print("</td>\n");
  if ($hash{'display_attrs_0'} == 1) {   if ($hash{'display_attrs_0'} == 1) {
     my $title = &Apache::lonnet::metadata($filelink,'title')      my $title = &Apache::lonnet::gettitle($filelink,'title')
  if ($metafile == 1);   if ($metafile == 1);
     $r->print('<td valign=$valign> '.($title eq '' ? '&nbsp;' : $title).      $r->print('<td> '.($title eq '' ? '&nbsp;' : $title).
       ' </td>'."\n");        ' </td>'."\n");
  }   }
  $r->print('<td align=right valign=$valign> ',   $r->print('<td align=right> ',
   $filecom[8]," </td>\n")     $filecom[8]," </td>\n") 
     if $hash{'display_attrs_1'} == 1;      if $hash{'display_attrs_1'} == 1;
  $r->print('<td valign=$valign> '.   $r->print('<td> '.
   (localtime($filecom[9]))." </td>\n")     (localtime($filecom[9]))." </td>\n") 
     if $hash{'display_attrs_2'} == 1;      if $hash{'display_attrs_2'} == 1;
  $r->print('<td valign=$valign> '.   $r->print('<td> '.
   (localtime($filecom[10]))." </td>\n")     (localtime($filecom[10]))." </td>\n") 
     if $hash{'display_attrs_3'} == 1;      if $hash{'display_attrs_3'} == 1;
   
  if ($hash{'display_attrs_4'} == 1) {   if ($hash{'display_attrs_4'} == 1) {
     my $author = &Apache::lonnet::metadata($filelink,'author')      my $author = &Apache::lonnet::metadata($filelink,'author')
  if ($metafile == 1);   if ($metafile == 1);
     $r->print('<td valign=$valign> '.($author eq '' ? '&nbsp;' : $author).      $r->print('<td> '.($author eq '' ? '&nbsp;' : $author).
       " </td>\n");        " </td>\n");
  }   }
  if ($hash{'display_attrs_5'} == 1) {   if ($hash{'display_attrs_5'} == 1) {
     my $keywords = &Apache::lonnet::metadata($filelink,'keywords')      my $keywords = &Apache::lonnet::metadata($filelink,'keywords')
  if ($metafile == 1);   if ($metafile == 1);
     # $keywords = '&nbsp;' if (!$keywords);      # $keywords = '&nbsp;' if (!$keywords);
     $r->print('<td valign=$valign> '.($keywords eq '' ? '&nbsp;' : $keywords).      $r->print('<td> '.($keywords eq '' ? '&nbsp;' : $keywords).
       " </td>\n");        " </td>\n");
  }   }
  if ($hash{'display_attrs_6'} == 1) {   if ($hash{'display_attrs_6'} == 1) {
     my $lang = &Apache::lonnet::metadata($filelink,'language')      my $lang = &Apache::lonnet::metadata($filelink,'language')
  if ($metafile == 1);   if ($metafile == 1);
     $lang = &Apache::loncommon::languagedescription($lang);      $lang = &Apache::loncommon::languagedescription($lang);
     $r->print('<td valign=$valign> '.($lang eq '' ? '&nbsp;' : $lang).      $r->print('<td> '.($lang eq '' ? '&nbsp;' : $lang).
       " </td>\n");        " </td>\n");
  }   }
         if ($hash{'display_attrs_7'} == 1) {          if ($hash{'display_attrs_7'} == 1) {
Line 877  sub display_line { Line 886  sub display_line {
  $Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}.   $Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}.
                  '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';                   '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';
            }             }
    $r->print('<td valign=$valign> '.($output eq '' ? '&nbsp;':$output).     $r->print('<td> '.($output eq '' ? '&nbsp;':$output).
       " </td>\n");        " </td>\n");
         }          }
    if ($hash{'display_attrs_8'} == 1) {
       my (%stat) = &Apache::lonmeta::dynamicmeta($filelink) if ($metafile == 1);
       my $stat = (exists($stat{'course'}) ? $stat{'course'} : '').
    ((exists($stat{'course'}) || exists($stat{'count'})) ? '/' : '').
    (exists($stat{'count'}) ? $stat{'count'} : '');
       $r->print('<td align=center> '.($stat eq '' ? '&nbsp;' : $stat).
         ' </td>'."\n");
    }
   
  $r->print("</tr>\n");   $r->print("</tr>\n");
     }      }
   

Removed from v.1.68  
changed lines
  Added in v.1.72


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