--- loncom/interface/lonsearchcat.pm 2007/03/12 22:05:30 1.283 +++ loncom/interface/lonsearchcat.pm 2008/05/28 21:07:29 1.293 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.283 2007/03/12 22:05:30 banghart Exp $ +# $Id: lonsearchcat.pm,v 1.293 2008/05/28 21:07:29 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -138,7 +138,7 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['catalogmode','launch','acts','mode','form','element','pause', 'phase','persistent_db_id','table','start','show', - 'cleargroupsort','titleelement','area']); + 'cleargroupsort','titleelement','area','inhibitmenu']); ## ## The following is a trick - we wait a few seconds if asked to so ## the daemon running the search can get ahead of the daemon @@ -190,7 +190,8 @@ sub handler { } &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/searchcat?'. - 'catalogmode='.$env{'form.catalogmode'}. + &Apache::loncommon::inhibit_menu_check(). + '&catalogmode='.$env{'form.catalogmode'}. '&launch='.$env{'form.launch'}. '&mode='.$env{'form.mode'}, text=>"$crumb_text", @@ -258,11 +259,14 @@ sub handler { if (exists($env{'form.area'})) { $hidden_fields .= &hidden_field('area'); } + if (exists($env{'form.inhibitmenu'})) { + $hidden_fields .= &hidden_field('inhibitmenu'); + } ## ## Configure dynamic components of interface ## if ($env{'form.catalogmode'} eq 'interactive') { - $closebutton="'/adm/searchcat?phase=disp_adv&'. - 'catalogmode='.$env{'form.catalogmode'}. + ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check(). + '&phase=disp_adv'. + '&catalogmode='.$env{'form.catalogmode'}. '&launch='.$env{'form.launch'}. '&mode='.$env{'form.mode'}, text=>"Advanced $srchtype Search", bug=>'Searching',}); } elsif ($env{'form.searchmode'} eq 'course search') { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/searchcat?phase=disp_adv&'. + ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check(). + '&phase=disp_adv'. 'catalogmode='.$env{'form.catalogmode'}. '&launch='.$env{'form.launch'}. '&mode='.$env{'form.mode'}, @@ -379,7 +385,7 @@ END $errorstring); my $msg = - 'Unable to create table in which to store search results. '. + 'Unable to create table in which to save search results. '. 'The search has been aborted.'; &Apache::loncommon::simple_error_page($r,'Search Error', $msg); @@ -388,7 +394,7 @@ END delete($env{'form.launch'}); if (! &make_form_data_persistent($r,$persistent_db_file)) { my $msg= - 'Unable to properly store search information. '. + 'Unable to properly save search information. '. 'The search has been aborted.'; &Apache::loncommon::simple_error_page($r,'Search Error', $msg); @@ -753,14 +759,10 @@ sub setup_basic_search { $r->dir_config('lonDefDomain')), $r->dir_config('lonDefDomain')). ''; - if ($area eq 'res') { - $inclext= ''; - } $adv_search_link = ''; my %fields=&Apache::lonmeta::fieldnames(); # - $scrout .= '
'. (' 'x2).&searchhelp()." | ';
}
@@ -919,11 +921,6 @@ ENDHEADER
&Apache::loncommon::domain_select('domains',
$env{'form.domains'},1).
' ' - } $scrout .= ' | '.$/;
#
# Misc metadata
@@ -990,7 +987,7 @@ ENDHEADER
description=>'Network-wide number of accesses (hits)',},
{ name=>'stdno',
description=>
- 'Total number of students who have worked on this problem',},
+ 'Statistics calculated for number of students',},
{ name => 'avetries',
description=>'Average number of tries till solved',},
{ name => 'difficulty',
@@ -1037,6 +1034,7 @@ ENDHEADER
# Creation/Modification date limits
$scrout .= '
".&mt('Month[_1]Day[_2]Year',' 'x14,' 'x6)." | |
Created between | '. - '[_1] |
and | '. - '[_2] |
'.&mt('Created between').' | ' + .''.$cafter.' |
'.&mt('and').' | ' + .''.$cbefore.' |
Last modified between | '. - '[_1] |
and | '. - '[_2] |
'.&mt('Last modified between').' | ' + .''.$lafter.' |
'.&mt('and').' | ' + .''.$lbefore.' |
-Search: $pretty_query_string -
- -END + $result.='' + .&mt('There are [_1] matches to your query.',$total_results) + .' '.$revise.'
' + .''.&mt('Search: ').$pretty_query_string + .'
'; $r->print($result.&Apache::loncommon::end_page()); return; } @@ -2444,13 +2439,14 @@ Returns: html string for a 'revise searc ###################################################################### ###################################################################### sub revise_button { + my $revisetext = &mt('Revise search'); my $revise_phase = 'disp_basic'; $revise_phase = 'disp_adv' if ($env{'form.searchmode'} eq 'advanced'); my $newloc = '/adm/searchcat'. '?persistent_db_id='.$env{'form.persistent_db_id'}. '&cleargroupsort=1'. '&phase='.$revise_phase; - my $result = qq{ }; return $result; } @@ -2522,7 +2518,7 @@ END # Check on the mysql table we will use to store results. my $table =$env{'form.table'}; if (! defined($table) || $table eq '' || $table =~ /\D/ ) { - $r->print("Unable to determine table id to store search results in.". + $r->print("Unable to determine table id to save search results in.". "The search has been aborted.". &Apache::loncommon::end_page()); return; @@ -2638,8 +2634,6 @@ END my %Fields = &parse_raw_result($result,$server,$tabletype); $Fields{'hostname'} = $server; # - # Skip if external and we did not want that - next if ((! $env{'form.inclext'}) && ($Fields{'url'}=~/^\/ext\//)); # Skip based on copyright next if (! ©right_check(\%Fields)); @@ -2760,7 +2754,7 @@ sub display_results { if ($env{'form.catalogmode'} eq 'import') { if (! tie(%groupsearch_db,'GDBM_File',$diropendb, &GDBM_WRCREAT(),0640)) { - $r->print('Unable to store import results.'. + $r->print('Unable to save import results.'. &Apache::loncommon::end_page()); $r->rflush(); return; @@ -2997,8 +2991,8 @@ sub catalogmode_output { $title=~ s/\'/\\\'/g; if ($env{'form.catalogmode'} eq 'interactive') { $output.=<\n";
$result .= ''.$values{'author'}.','.
@@ -3444,11 +3439,8 @@ sub detailed_citation_view {
if (exists($field->{'type'}) && $field->{'type'} eq 'list') {
$result .= ''.&mt($field->{'translate'}).'';
foreach my $item (split(',',$values{$field->{'name'}})){
- $result .=
- &Apache::lonhtmlcommon::crumbs(&Apache::lonnet::clutter($item),
- 'preview',
- '',
- (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),2,0,1);
+ $item = &Apache::lonnet::clutter($item);
+ $result .= &display_url($item,[2,0,1]);
}
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
$result.= &mt($field->{'translate'},
@@ -3456,15 +3448,7 @@ sub detailed_citation_view {
$values{$field->{'name'}}))."
\n";
} else {
if ($field->{'special'} eq 'url link') {
- if ($jumpurl=~/^http\:\/\//) {
- $result.=''.$jumpurl.'';
- } else {
- $result .=
- &Apache::lonhtmlcommon::crumbs($jumpurl,
- 'preview',
- '',
- (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),3,0,1);
- }
+ $result .= &display_url($jumpurl,[3,0,1]);
} else {
$result.= &mt($field->{'translate'},
$values{$field->{'name'}});
@@ -3520,19 +3504,13 @@ sub summary_view {
$result .= ' '.$tmp.' ';
}
my $jumpurl=$values{'url'};
- my $link;
- if ($jumpurl=~m|^/ext/|) {
- $jumpurl=~s|^/ext/|http://|;
- $link='
'.$jumpurl.'';
- } else {
- $link=&Apache::lonhtmlcommon::crumbs($jumpurl,
- 'preview',
- '',
- (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),2,0,1);
- }
+ $jumpurl=~s|^/ext/|http://|;
+ my $link = &display_url($jumpurl,[2,0,1]);
+
$result.=<
+$link
$values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}
$values{'copyrighttag'}
$values{'extrashow'}
@@ -3565,16 +3543,10 @@ sub summary_preview {
sub compact_view {
my ($prefix,%values) = @_;
my $jumpurl=$values{'url'};
- my $link;
- if ($jumpurl=~m|^/ext/|) {
- $jumpurl=~s|^/ext/|http://|;
- $link=''.$jumpurl.'';
- } else {
- $link=&Apache::lonhtmlcommon::crumbs($jumpurl,
- 'preview',
- '',
- (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),1,1,1).' ';
- }
+ $jumpurl=~s|^/ext/|http://|;
+
+ my $link = &display_url($jumpurl,[1,1,1]);
+
my $result =
$prefix.'';
if (exists($env{'form.sortfield'}) &&
@@ -3583,12 +3555,30 @@ sub compact_view {
if (! defined($tmp)) { $tmp = 'undefined'; }
$result .= ' '.$tmp.' ';
}
- $result.=' '.
- $values{'title'}.''.(' 'x2).$link.
- ''.$values{'author'}.' ('.$values{'domain'}.')
';
+ $jumpurl = &HTML::Entities::encode($jumpurl,'<>&"');
+ $result.=' '.
+ ''.
+ &HTML::Entities::encode($values{'title'},'<>&"').' '.
+ $link.' '.$values{'author'}.' ('.$values{'domain'}.')
';
return $result;
}
+sub display_url {
+ my ($url,$crumb_args) = @_;
+ my $link;
+ if ($url=~m|^/ext/|) {
+ $url=~s|^/ext/|http://|;
+ $link=''.$url.'';
+ } elsif ($url=~m{^(http://|/uploaded/)}) {
+ $link=''.$url.'';
+ } else {
+ $link=&Apache::lonhtmlcommon::crumbs($url,
+ 'preview',
+ '',
+ (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),@{$crumb_args}).' ';
+ }
+ return $link;
+}
######################################################################
######################################################################
@@ -3612,7 +3602,7 @@ sub fielded_format_view {
$prefix