--- loncom/interface/lonsearchcat.pm 2006/09/27 19:32:11 1.277 +++ loncom/interface/lonsearchcat.pm 2008/07/15 16:18:41 1.296 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.277 2006/09/27 19:32:11 raeburn Exp $ +# $Id: lonsearchcat.pm,v 1.296 2008/07/15 16:18:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -78,7 +78,6 @@ use HTML::Entities(); use Parse::RecDescent; use Apache::lonnavmaps; use Apache::lonindexer(); -use lib '/home/httpd/lib/perl/'; use LONCAPA; ###################################################################### @@ -139,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 @@ -191,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", @@ -259,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'}, @@ -380,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); @@ -389,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); @@ -522,7 +527,7 @@ sub course_search { my $applies = 0; my $symb = $resource->symb(); my $ressymb = $symb; - if ($symb =~ m#(___adm/\w+/\w+)/(\d+)/bulletinboard$#) { + if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) { $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) { $ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#; @@ -751,19 +756,19 @@ sub setup_basic_search { ''; $onlysearchdomain = ''; - if ($area eq 'res') { - $inclext= ''; - } $adv_search_link = ''.&mt('Advanced Search').''; # $scrout.='
-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; } @@ -2405,13 +2443,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; } @@ -2475,14 +2514,15 @@ END @Servers_to_contact = ($serverlist); } } else { - @Servers_to_contact = sort(keys(%Apache::lonnet::libserv)); + my %all_library_servers = &Apache::lonnet::all_library(); + @Servers_to_contact = sort(keys(%all_library_servers)); } my %Server_status; # # 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; @@ -2598,8 +2638,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)); @@ -2720,7 +2758,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; @@ -2957,8 +2995,8 @@ sub catalogmode_output { $title=~ s/\'/\\\'/g; if ($env{'form.catalogmode'} eq 'interactive') { $output.=<\n";
$result .= ''.$values{'author'}.','.
@@ -3404,11 +3443,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'},
@@ -3416,15 +3452,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'}});
@@ -3480,19 +3508,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'}
@@ -3525,16 +3547,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'}) &&
@@ -3543,12 +3559,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;
+}
######################################################################
######################################################################
@@ -3572,7 +3606,7 @@ sub fielded_format_view {
$prefix