--- loncom/interface/londocs.pm 2004/09/18 17:06:57 1.146 +++ loncom/interface/londocs.pm 2004/12/10 20:47:33 1.153 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.146 2004/09/18 17:06:57 albertel Exp $ +# $Id: londocs.pm,v 1.153 2004/12/10 20:47:33 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -989,15 +989,17 @@ sub editor { # ---------------------------------------------------------------- End commands # ---------------------------------------------------------------- Print screen my $idx=0; + my $shown=0; $r->print('<table>'); foreach (@Apache::lonratedt::order) { my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); unless ($name) { $name=(split(/\//,$url))[-1]; } - unless ($name) { next; } + unless ($name) { $idx++; next; } $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); $idx++; + $shown++; } - unless ($idx) { + unless ($shown) { $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>'); } $r->print('</table>'); @@ -1150,9 +1152,13 @@ END } elsif ($url=~m|^/ext/|) { $url='/adm/wrapper'.$url; } - unless ($container eq 'page') { + $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); + if ($container eq 'page') { + my $symb=$ENV{'form.pagesymb'}; + + $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); - } + } } my $parameterset=' '; if ($isfolder) { @@ -1161,9 +1167,12 @@ END if ($folderpath) { $folderpath.='&' }; $folderpath.=$folderarg.'&'.$foldername; $url.='folderpath='.&Apache::lonnet::escape($folderpath); - $parameterset=&mt('Randomly Pick: '). + $parameterset='<label>'.&mt('Randomly Pick: '). '<input type="text" size="4" name="randpick_'.$orderidx.'" value="'. - (&Apache::lonratedt::getparameter($orderidx,'parameter_randompick'))[0].'" />'; + (&Apache::lonratedt::getparameter($orderidx, + 'parameter_randompick'))[0]. + '" />'.'</label>'; + } if ($ispage) { my $pagename=&Apache::lonnet::escape($pagetitle); @@ -1171,8 +1180,19 @@ END my $folderpath=$ENV{'form.folderpath'}; if ($folderpath) { $pagepath = $folderpath.'&' }; $pagepath.=$pagearg.'&'.$pagename; - $url.='pagepath='.&Apache::lonnet::escape($pagepath); + my $symb=$ENV{'form.pagesymb'}; + if (!$symb) { + my $path='uploaded/'. + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'. + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'; + $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', + $residx, + $path.$pagearg.'.page'); + } + $url.='pagepath='.&Apache::lonnet::escape($pagepath). + '&pagesymb='.&Apache::lonnet::escape($symb); } + &Apache::lonnet::logthis(" link \n$url"); $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon. '" border="0"></a></td>'. "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>"; @@ -1187,9 +1207,9 @@ END ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); $line.=(<<ENDPARMS); <td bgcolor="#BBBBFF"><font size='-2'> -<input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</td> -<!--<td bgcolor="#BBBBFF"><font size='-2'> -<input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</td>--> +<nobr><label><input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</label></nobr></td> +<td bgcolor="#BBBBFF"><font size='-2'> +<nobr><label><input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</label></nobr></td> <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td> <td bgcolor="#BBBBFF"><font size='-2'> <input type="submit" value="$lt{'sp'}" /> @@ -1205,33 +1225,24 @@ ENDPARMS sub tiehash { my ($mode)=@_; $hashtied=0; - &Apache::lonnet::logthis(" tiehash1 -- $hashtied "); if ($ENV{'request.course.fn'}) { - &Apache::lonnet::logthis(" tiehash2 -- $hashtied "); if ($mode eq 'write') { - &Apache::lonnet::logthis(" tiehash3 -- $hashtied "); if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", &GDBM_WRCREAT(),0640)) { $hashtied=2; - &Apache::lonnet::logthis(" tiehash4 -- $hashtied "); } } else { - &Apache::lonnet::logthis(" tiehash5 -- $hashtied "); if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", &GDBM_READER(),0640)) { $hashtied=1; - &Apache::lonnet::logthis(" tiehash6 -- $hashtied "); } } } - &Apache::lonnet::logthis(" tiehash7 -- $hashtied "); } sub untiehash { - &Apache::lonnet::logthis(" untiehash1 -- $hashtied "); if ($hashtied) { untie %hash; } $hashtied=0; - &Apache::lonnet::logthis(" untiehash2 -- $hashtied "); } # --------------------------------------------------------------- check on this @@ -1587,21 +1598,14 @@ ENDHEADERS sub mark_hash_old { my $retie_hash=0; - &Apache::lonnet::logthis(" markold1 -- $hashtied $retie_hash "); if ($hashtied) { $retie_hash=1; - &Apache::lonnet::logthis(" markold2 -- $hashtied $retie_hash "); &untiehash(); - &Apache::lonnet::logthis(" markold3 -- $hashtied $retie_hash "); } &tiehash('write'); - &Apache::lonnet::logthis(" markold4 -- $hashtied $retie_hash "); $hash{'old'}=1; - &Apache::lonnet::logthis(" markold5 -- $hashtied $retie_hash "); &untiehash(); - &Apache::lonnet::logthis(" markold6 -- $hashtied $retie_hash "); if ($retie_hash) { &tiehash(); } - &Apache::lonnet::logthis(" markold7 -- $hashtied $retie_hash "); } sub is_hash_old { @@ -1618,11 +1622,17 @@ sub is_hash_old { sub changewarning { my ($r,$postexec)=@_; if (!&is_hash_old()) { return; } + my $pathvar='folderpath'; + my $path=&Apache::lonnet::escape($ENV{'form.folderpath'}); + if (defined($ENV{'form.pagepath'})) { + $pathvar='pagepath'; + $path=&Apache::lonnet::escape($ENV{'form.pagepath'}); + } $r->print( '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. '<form method="post" action="/adm/roles" target="loncapaclient">'. -'<input type="hidden" name="orgurl" value="/adm/coursedocs?folderpath='. -&Apache::lonnet::escape($ENV{'form.folderpath'}). +'<input type="hidden" name="orgurl" value="/adm/coursedocs?'. +$pathvar.'='.$path. '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'. &mt('Changes will become active for your current session after'). ' <input type="hidden" name="'. @@ -1681,7 +1691,7 @@ sub handler { my $containertag; my $uploadtag; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['folderpath','pagepath']); + ['folderpath','pagepath','pagesymb']); if ($ENV{'form.folderpath'}) { my (@folderpath)=split('&',$ENV{'form.folderpath'}); $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));