--- loncom/interface/lonindexer.pm 2006/09/21 22:11:12 1.152 +++ loncom/interface/lonindexer.pm 2007/06/27 22:39:48 1.162 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.152 2006/09/21 22:11:12 albertel Exp $ +# $Id: lonindexer.pm,v 1.162 2007/06/27 22:39:48 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,6 +54,7 @@ use Apache::File; use Apache::lonlocal; use Apache::lonsource(); use GDBM_File; +use LONCAPA qw(:match); # ---------------------------------------- variables used throughout the module my %hash; # global user-specific gdbm file @@ -173,7 +174,7 @@ ENDSUBM if ($env{'form.catalogmode'} eq 'interactive') { $extrafield=''. ''; + ' class="LC_icon" />'; $colspan=" colspan='2' "; my $cl=&mt('Close'); $closebutton=<'. ''; + ' class="LC_icon" />'; $colspan=" colspan='2' "; my $cl=&mt('Close'); my $gi=&mt('Import'); @@ -349,6 +350,25 @@ END my $js = <<"ENDHEADER"; ENDHEADER - my ($headerdom)=($uri=~/^\/res\/(\w+)\//); + my ($headerdom)=($uri=~m{^/res/($match_domain)/}); $r->print(&Apache::loncommon::start_page('Browse Resources',$js, {'domain' => $headerdom,})); # - Evaluate actions from previous page (both cumulatively and chronologically) @@ -679,7 +699,7 @@ sub get_list { $uri=~s/\/+/\//g; foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$uri))) { my @ratpart=split(/\:/,$_); - push @list,$ratpart[1]; + push(@list,&LONCAPA::map::qtescape($ratpart[1])); } $hash{'dirlist_files_'.$luri} = join("\n",@list); } else { @@ -688,7 +708,7 @@ sub get_list { $hash{'dirlist_files_'.$luri} = join("\n",@list); $hash{'dirlist_timestamp_files_'.$luri} = time; } - return @list=&match_ext($r,@list); + return @list=&match_ext($r,@list); } sub dynmetaread { @@ -798,7 +818,8 @@ sub display_line { my $i=0; while ($i<=11) { $tabtag=join('',$tabtag," ") - if $hash{'display_attrs_'.$i} == 1; + if ($i != 9 && + $hash{'display_attrs_'.$i} == 1); $i++; } my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom'); @@ -810,7 +831,7 @@ sub display_line { $updir='/'.(split(/\.(page|sequence)\/\//,$startdir))[-1]; $updir=~s/\/+/\//g; - $r->print("$extrafield"); + $r->print("$extrafield"); $r->print("\n"); $r->print ('
'."\n"); $r->print (''."\n"); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0" />'. + $r->print (' name="'.$msg.'" type="image" class="LC_indexer_icon" />'. "\n"); $r->print(&mt("Up")."
$tabtag\n"); return OK; @@ -838,24 +859,24 @@ sub display_line { if ($filecom[1] eq 'domain') { $r->print (''."\n") if ($env{'form.dirPointer'} eq "on"); - $r->print("$extrafield"); + $r->print("$extrafield"); $r->print(""); &begin_form ($r,$filecom[0]); my $anchor = $filecom[0]; - $anchor =~ s/\///g; + $anchor =~ s/\W//g; $r->print (''); $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0" />'. + $r->print (' name="'.$msg.'" type="image" class="LC_indexer_icon" />'. "\n"); my $quotable_filecom = &Apache::loncommon::escape_single($filecom[0]); $r->print ('print (' border="0" />'."\n"); + $r->print (' class="LC_icon" />'."\n"); $r->print (&mt("Domain")." - $listname "); - if ($Apache::lonnet::domaindescription{$listname}) { - $r->print("(".$Apache::lonnet::domaindescription{$listname}. + if (&Apache::lonnet::domain($listname,'description')) { + $r->print("(".&Apache::lonnet::domain($listname,'description'). ")"); } $r->print ("$tabtag\n"); @@ -864,24 +885,26 @@ sub display_line { # display user directory } if ($filecom[1] eq 'user') { - $r->print("$extrafield"); - $r->print("\n"); + # $r->print("$extrafield"); my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; - $anchor =~ s/\///g; + $anchor =~ s/\W//g; + $r->print(""); + $r->print("\n"); + $r->print("\n"); + $r->print("\n"); &begin_form ($r,$curdir); $r->print (''."\n"); + 'whitespace1.gif" class="LC_icon" />'."\n"); $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0" />'. + $r->print (' name="'.$msg.'" type="image" class="LC_indexer_icon" />'. "\n"); my $quotable_curdir = &Apache::loncommon::escape_single($curdir); $r->print (''); + .'\')">'.$msg.''); my $domain=(split(m|/|,$startdir))[2]; my $plainname=&Apache::loncommon::plainname($listname,$domain); $r->print ($listname); @@ -905,15 +928,15 @@ sub display_line { } # Set the icon for the file my $iconname = &Apache::loncommon::icon($listname); - $r->print(""); + $r->print(""); if ($env{'form.catalogmode'} eq 'interactive') { my $quotable_filelink = &Apache::loncommon::escape_single($filelink); $r->print(""); - $r->print("\"\"". + $r->print("\"\"". "\n"); - $r->print(""); + $r->print(""); } elsif ($env{'form.catalogmode'} eq 'import') { $r->print("
\n"); $r->print("print("checked"); } $r->print(" />\n"); - $r->print("
"); + $r->print(""); $hash{"pre_${fnum}_link"}=$filelink; $fnum++; } # Form to open or close sequences if ($filelink=~/\.(page|sequence)$/) { my $curdir = $startdir.$filecom[0].'/'; - my $anchor = $curdir; - $anchor =~ s/\///g; &begin_form($r,$curdir); $indent--; } # General indentation if ($indent > 0 and $indent < 11) { - $r->print("\"\"\n"); + $r->print("\"\"\n"); } elsif ($indent >0) { my $ten = int($indent/10.); my $rem = $indent%10.0; my $count = 0; while ($count < $ten) { - $r->print("\"\"\n"); + $r->print("\"\"\n"); $count++; } $r->print("\"\"\n") if $rem > 0; + ".gif class='LC_icon' />\n") if $rem > 0; } # Sequence open/close icon if ($filelink=~/\.(page|sequence)$/) { my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; - $anchor =~ s/\///g; + $anchor =~ s/\W//g; $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0" />'. + $r->print (' name="'.$msg.'" type="image" class="LC_indexer_icon" />'. "\n"); } # Filetype icons - $r->print("\"\"\n"); + $r->print("\"\"\n"); my $quotable_filelink = &Apache::loncommon::escape_single($filelink); $r->print (" $listname "); $r->print (" (metadata) "); # Close form to open/close sequence if ($filelink=~/\.(page|sequence)$/) { @@ -1069,35 +1090,35 @@ sub display_line { if ($fnptr == $dirptr) { my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; - $anchor =~ s/\///g; - $r->print("$extrafield"); + $anchor =~ s/\W//g; + $r->print("$extrafield"); &begin_form ($r,$curdir); my $indentm1 = $indent-1; if ($indentm1 < 11 and $indentm1 > 0) { $r->print("\"\"\n"); + ".gif class='LC_icon' />\n"); } else { my $ten = int($indentm1/10.); my $rem = $indentm1%10.0; my $count = 0; while ($count < $ten) { $r->print ("\"\"\n"); + ,"whitespace10.gif class='LC_icon' />\n"); $count++; } $r->print ("\"\"\n") if $rem > 0; + ".gif class='LC_icon' />\n") if $rem > 0; } $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0" />'. + $r->print (' name="'.$msg.'" type="image" class="LC_indexer_icon" />'. "\n"); my $quotable_curdir = &Apache::loncommon::escape_single($curdir); $r->print ('' .''.&mt('Open Folder').''. + $iconpath.'folder_'.$diropen.'.gif" class="LC_icon" />'. "\n"); $r->print ("$listname\n"); # Attributes @@ -1199,9 +1220,9 @@ sub showpreview { $output=''.$output.''; } elsif ($embstyle eq 'img') { $output=''.&mt('Preview').''; - } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) { + } elsif ($filelink=~m{^/res/($match_domain)/($match_username)/}) { $output=''.&mt('Preview').''; } return $output; @@ -1223,7 +1244,8 @@ sub dynmetaprint { sub begin_form { my ($r,$uri) = @_; my $anchor = $uri; - $anchor =~ s/\///g; + $anchor =~ s/\W//g; + $uri=&Apache::loncommon::escape_single($uri); $r->print ('