--- loncom/interface/lonsearchcat.pm 2006/06/29 16:08:43 1.271 +++ loncom/interface/lonsearchcat.pm 2006/09/27 19:32:11 1.277 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.271 2006/06/29 16:08:43 albertel Exp $ +# $Id: lonsearchcat.pm,v 1.277 2006/09/27 19:32:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -139,7 +139,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']); + 'cleargroupsort','titleelement','area']); ## ## 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 @@ -171,25 +171,32 @@ sub handler { '_'.$env{'form.persistent_db_id'}.'_persistent_search.db'; ## &Apache::lonhtmlcommon::clear_breadcrumbs(); + + my @allowed_searches = ('portfolio'); + if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) { + push(@allowed_searches,'res'); + } if (exists($env{'request.course.id'}) && $env{'request.course.id'} ne '') { - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/searchcat?'. - 'catalogmode='.$env{'form.catalogmode'}. - '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, - text=>"Course and Catalog Search", - target=>'_top', - bug=>'Searching',}); - } else { - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/searchcat?'. - 'catalogmode='.$env{'form.catalogmode'}. - '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, - text=>"Catalog Search", + push(@allowed_searches,'course'); + } + my $crumb_text = 'Portfolio Search'; + if (@allowed_searches == 3) { + $crumb_text = 'Course, Portfolio and Catalog Search'; + } elsif (@allowed_searches ==2) { + if (grep(/^res$/,@allowed_searches)) { + $crumb_text = 'Portfolio and Catalog Search'; + } elsif (grep(/^course$/,@allowed_searches)) { + $crumb_text = 'Portfolio and Course Search'; + } + } + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/searchcat?'. + 'catalogmode='.$env{'form.catalogmode'}. + '&launch='.$env{'form.launch'}. + '&mode='.$env{'form.mode'}, + text=>"$crumb_text", target=>'_top', bug=>'Searching',}); - } # if ($env{'form.phase'} !~ m/(basic|adv|course)_search/) { if (! &get_persistent_form_data($persistent_db_file)) { @@ -249,6 +256,9 @@ sub handler { if (exists($env{'form.mode'})) { $hidden_fields .= &hidden_field('mode'); } + if (exists($env{'form.area'})) { + $hidden_fields .= &hidden_field('area'); + } ## ## Configure dynamic components of interface ## @@ -294,12 +304,16 @@ END } # if ($env{'form.searchmode'} eq 'advanced') { + my $srchtype = 'Catalog'; + if ($env{'form.area'} eq 'portfolio') { + $srchtype = 'Portfolio'; + } &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/searchcat?phase=disp_adv&'. 'catalogmode='.$env{'form.catalogmode'}. '&launch='.$env{'form.launch'}. '&mode='.$env{'form.mode'}, - text=>"Advanced Search", + text=>"Advanced $srchtype Search", bug=>'Searching',}); } elsif ($env{'form.searchmode'} eq 'course search') { &Apache::lonhtmlcommon::add_breadcrumb @@ -318,7 +332,8 @@ END } elsif ($env{'form.phase'} eq 'disp_adv') { &print_advanced_search_form($r,$closebutton,$hidden_fields); } elsif ($env{'form.phase'} eq 'results') { - &display_results($r,$importbutton,$closebutton,$diropendb); + &display_results($r,$importbutton,$closebutton,$diropendb, + $env{'form.area'}); } elsif ($env{'form.phase'} =~ /^(sort|run_search)$/) { my ($query,$customquery,$customshow,$libraries,$pretty_string) = &get_persistent_data($persistent_db_file, @@ -328,7 +343,7 @@ END &print_sort_form($r,$pretty_string); } elsif ($env{'form.phase'} eq 'run_search') { &run_search($r,$query,$customquery,$customshow, - $libraries,$pretty_string); + $libraries,$pretty_string,$env{'form.area'}); } } elsif ($env{'form.phase'} eq 'course_search') { &course_search($r); @@ -358,7 +373,7 @@ END $persistent_db_file); # # Set up table - if (! defined(&create_results_table())) { + if (! defined(&create_results_table($env{'form.area'}))) { my $errorstring=&Apache::lonmysql::get_error(); &Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. 'needed table. lonmysql error:'. @@ -665,68 +680,13 @@ sub print_basic_search_form { &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic', $env{'form.catalogmode'} ne 'import'); my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb; +# Search form for resource space if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) { - # Define interface components - my $userelatedwords= ''; - my $onlysearchdomain=''; - my $inclext= ''; - my $adv_search_link = - ''.&mt('Advanced Search').''; - # - $scrout.='
'; + $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton); + $scrout .= '\n"; if (! defined($Fields{'title'}) || $Fields{'title'} eq '') { $Fields{'title'} = 'Untitled'; @@ -2852,10 +2988,10 @@ Parse a row returned from the database. ###################################################################### ###################################################################### sub parse_row { - my @Row = @_; + my ($tabletype,@Row) = @_; my %Fields; if (! scalar(@Datatypes)) { - &set_up_table_structure(); + &set_up_table_structure($tabletype); } for (my $i=0;$i<=$#Row;$i++) { $Fields{$Datatypes[$i]->{'name'}}=&unescape($Row[$i]); @@ -2891,12 +3027,13 @@ The 'title' field is set to "Untitled" i ########################################################### ########################################################### sub parse_raw_result { - my ($result,$hostname) = @_; + my ($result,$hostname,$tabletype) = @_; # conclude from self to others regarding fields my %Fields=&LONCAPA::lonmetadata::metadata_col_to_hash - (map { + ($tabletype, + map { &unescape($_); - } (split(/\,/,$result)) ); + } (split(/\,/,$result)) ); return %Fields; } @@ -3197,11 +3334,11 @@ sub detailed_citation_view { my ($prefix,%values) = @_; my $result; my $jumpurl=$values{'url'}; - $jumpurl=~s/^\/ext\//http\:\/\//; + $jumpurl=~s|^/ext/|http://|; $result .= ''.$prefix. ''.' '. ''.$values{'title'}."\n"; + 'target="preview">'.$values{'title'}."\n"; $result .= "
\n";
$result .= ''.$values{'author'}.','.
' '.$values{'owner'}.'
';
@@ -3268,9 +3405,9 @@ sub detailed_citation_view {
$result .= ''.&mt($field->{'translate'}).'';
foreach my $item (split(',',$values{$field->{'name'}})){
$result .=
- &Apache::lonhtmlcommon::crumbs($item,
- (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
- '/res',
+ &Apache::lonhtmlcommon::crumbs(&Apache::lonnet::clutter($item),
+ 'preview',
+ '',
(($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),2,0,1);
}
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
@@ -3279,11 +3416,15 @@ sub detailed_citation_view {
$values{$field->{'name'}}))."
\n";
} else {
if ($field->{'special'} eq 'url link') {
- $result.=
+ if ($jumpurl=~/^http\:\/\//) {
+ $result.=''.$jumpurl.'';
+ } else {
+ $result .=
&Apache::lonhtmlcommon::crumbs($jumpurl,
- (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
+ 'preview',
'',
(($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),3,0,1);
+ }
} else {
$result.= &mt($field->{'translate'},
$values{$field->{'name'}});
@@ -3339,15 +3480,19 @@ sub summary_view {
$result .= ' '.$tmp.' ';
}
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
- my $link=&Apache::lonhtmlcommon::crumbs($jumpurl,
- (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
+ 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);
-
+ }
$result.=<
$values{'copyrighttag'}
$values{'extrashow'}
@@ -3380,11 +3525,16 @@ sub summary_preview {
sub compact_view {
my ($prefix,%values) = @_;
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
- my $link=&Apache::lonhtmlcommon::crumbs($jumpurl,
- (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
+ 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).' ';
+ }
my $result =
$prefix.'';
if (exists($env{'form.sortfield'}) &&
@@ -3393,7 +3543,7 @@ sub compact_view {
if (! defined($tmp)) { $tmp = 'undefined'; }
$result .= ' '.$tmp.' ';
}
- $result.=' '.
+ $result.=' '.
$values{'title'}.''.(' 'x2).$link.
''.$values{'author'}.' ('.$values{'domain'}.')
';
return $result;
@@ -3416,14 +3566,14 @@ sub fielded_format_view {
my $icon=&Apache::loncommon::icon($values{'url'});
my %Translated = &Apache::lonmeta::fieldnames();
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
+ $jumpurl=~s|^/ext/|http://|;
my $result=<