--- loncom/interface/lonindexer.pm 2004/05/11 05:19:30 1.104 +++ loncom/interface/lonindexer.pm 2004/06/12 04:44:31 1.110 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.104 2004/05/11 05:19:30 albertel Exp $ +# $Id: lonindexer.pm,v 1.110 2004/06/12 04:44:31 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,6 +52,7 @@ use Apache::Constants qw(:common); use Apache::lonmeta; use Apache::File; use Apache::lonlocal; +use Apache::lonsource(); use GDBM_File; # ---------------------------------------- variables used throughout the module @@ -127,7 +128,33 @@ sub handler { { if ($ENV{'form.launch'} eq '1') { &start_fresh_session(); - } + } + #Hijack lonindexer to verify a title and be close down. + if ($ENV{'form.launch'} eq '2') { + $r->content_type('text/html'); + my $extra=''; + if (defined($ENV{'form.titleelement'})) { + my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); + &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); + $verify_title=~s/'/\\'/g; + $extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; + } + $r->print(< + + + + +ENDSUBM + return OK; + } + # -------------------- refresh environment with user database values (in %hash) &setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode' ); @@ -207,21 +234,13 @@ END $location .= "mode=".$mode."&"; $location .= "acts="; $catalogmodefunctions=<<"END"; -function select_data(title,url) { - changeTitle(title); +function select_data(url) { changeURL(url); self.close(); } function select_group() { window.location="$location"+document.forms.fileattr.acts.value; } -function changeTitle(val) { - if (opener.inf) { - if (opener.inf.document.forms.resinfo.elements.t) { - opener.inf.document.forms.resinfo.elements.t.value=val; - } - } -} function changeURL(val) { if (opener.inf) { if (opener.inf.document.forms.resinfo.elements.u) { @@ -235,12 +254,10 @@ END $location .= "form=$form&element=$element&mode=edit&acts="; $catalogmodefunctions=<print(&Apache::loncommon::bodytag('B # ---------------------------------- get state of file attributes to be showing if ($ENV{'form.attrs'}) { - for (my $i=0; $i<=9; $i++) { + for (my $i=0; $i<=10; $i++) { delete $hash{'display_attrs_'.$i}; if ($ENV{'form.attr'.$i} == 1) { $attrchk[$i] = 'checked'; @@ -398,7 +415,7 @@ $r->print(&Apache::loncommon::bodytag('B } } } else { - for (my $i=0; $i<=9; $i++) { + for (my $i=0; $i<=10; $i++) { $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; } } @@ -415,6 +432,7 @@ $r->print(&Apache::loncommon::bodytag('B 'au' => 'Author', 'kw' => 'Keywords', 'ln' => 'Language', + 'sa' => 'Source Available', 'sr' => 'Show resource', 'av' => 'All versions', 'ud' => 'Update Display' @@ -430,6 +448,7 @@ $r->print(&Apache::loncommon::bodytag('B $lt{'la'} $lt{'lm'} $lt{'st'} + $lt{'sa'} $lt{'au'} $lt{'kw'} @@ -495,6 +514,8 @@ END $r->print("".&mt("Usage Statistics")."
(". &mt("Courses/Network Hits").")
\n") if ($hash{'display_attrs_8'} == 1); + $r->print("".&mt("Source Available")."\n") + if ($hash{'display_attrs_10'} == 1); $r->print(''); # ----------------- read in what directories have previously been set to "open" @@ -713,7 +734,7 @@ sub display_line { # or absolute paths (for example, from sequences) my $absolute; my $pathprefix; - if ($line=~/^\/res\//) { + if ($line=~m|^/res/| && $startdir ne '') { $absolute=1; $pathprefix=''; } else { @@ -733,12 +754,11 @@ sub display_line { my $tabtag=''; my $i=0; - while ($i<=8) { + while ($i<=11) { $tabtag=join('',$tabtag," ") if $hash{'display_attrs_'.$i} == 1; $i++; } - my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom'); # display uplink arrow @@ -849,25 +869,13 @@ sub display_line { } else { $metafile=0; } - my $title; if ($ENV{'form.catalogmode'} eq 'interactive') { - $title=$listname; - $title = &Apache::lonnet::metadata($filelink,'title') - if ($metafile == 1); - $title=$listname unless $title; - my $titleesc=HTML::Entities::encode($title,'<>&"'); - $titleesc=~s/\'/\\'/; #' (clean up this spare quote) $r->print(""); + $filelink,"')\">"); $r->print("". "\n"); $r->print(""); } elsif ($ENV{'form.catalogmode'} eq 'groupimport') { - $title=$listname; - $title = &Apache::lonnet::metadata($filelink,'title') - if ($metafile == 1); - $title=$listname unless $title; - my $titleesc=&HTML::Entities::encode($title,'<>&"'); $r->print("
\n"); $r->print("\n"); $r->print("
\n"); $r->print(""); $hash{"pre_${fnum}_link"}=$filelink; - $hash{"pre_${fnum}_title"}=$titleesc; $fnum++; } # Form to open or close sequences @@ -959,6 +964,8 @@ sub display_line { $r->print(' '.($keywords eq '' ? ' ' : $keywords). " \n"); } +#' + if ($hash{'display_attrs_6'} == 1) { my $lang = &Apache::lonnet::metadata($filelink,'language'); $lang = &Apache::loncommon::languagedescription($lang); @@ -1001,7 +1008,17 @@ sub display_line { $r->print(' '.($stat eq '' ? ' ' : $stat). ' '."\n"); } - + if ($hash{'display_attrs_10'} == 1) { + my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); + if($source eq 'open') { + my $sourcelink = &Apache::lonsource::make_link($filelink); + $r->print(''."Yes "."\n"); + } else { #A cuddled else. :P + $r->print(''."\n"); + } + } $r->print("\n"); } @@ -1078,6 +1095,9 @@ sub display_line { if ($hash{'display_attrs_8'} == 1) { $r->print(' '); } + if ($hash{'display_attrs_10'} == 1) { + $r->print(' '); + } $r->print(''); }