--- loncom/interface/lonsearchcat.pm 2009/10/06 10:31:41 1.315 +++ loncom/interface/lonsearchcat.pm 2011/02/15 14:54:51 1.329 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.315 2009/10/06 10:31:41 bisitz Exp $ +# $Id: lonsearchcat.pm,v 1.329 2011/02/15 14:54:51 wenzelju Exp $ # # Copyright Michigan State University Board of Trustees # @@ -78,6 +78,7 @@ use HTML::Entities(); use Parse::RecDescent; use Apache::lonnavmaps; use Apache::lonindexer(); +use Apache::lonwishlist(); use LONCAPA; ###################################################################### @@ -118,8 +119,6 @@ sub handler { # This is set and used in &handler() and is also used in # &output_results(). - my $loaderror=&Apache::lonnet::overloaderror($r); - if ($loaderror) { return $loaderror; } # my $closebutton; # button that closes the search window # This button is different for the RAT compared to @@ -175,18 +174,9 @@ sub handler { if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) { push(@allowed_searches,'res'); } - if (exists($env{'request.course.id'}) && $env{'request.course.id'} ne '') { - 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'; - } + if (@allowed_searches ==2) { + $crumb_text = 'Portfolio and Catalog Search'; } &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/searchcat?'. @@ -303,8 +293,6 @@ END if ($env{'form.phase'} eq 'adv_search' || $env{'form.phase'} eq 'disp_adv') { $env{'form.searchmode'} = 'advanced'; - } elsif ($env{'form.phase'} eq 'course_search') { - $env{'form.searchmode'} = 'course_search'; } # if ($env{'form.searchmode'} eq 'advanced') { @@ -320,16 +308,7 @@ END '&mode='.$env{'form.mode'}, text=>"Advanced $srchtype Search", bug=>'Searching',}); - } elsif ($env{'form.searchmode'} eq 'course search') { - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check(). - '&phase=disp_adv'. - 'catalogmode='.$env{'form.catalogmode'}. - '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, - text=>"Course Search", - bug=>'Searching',}); - } + } ## ## Switch on the phase ## @@ -351,8 +330,6 @@ END &run_search($r,$query,$customquery,$customshow, $libraries,$pretty_string,$env{'form.area'}); } - } elsif ($env{'form.phase'} eq 'course_search') { - &course_search($r); } elsif(($env{'form.phase'} eq 'basic_search') || ($env{'form.phase'} eq 'adv_search')) { # @@ -448,244 +425,6 @@ sub hidden_field { } ###################################################################### -###################################################################### -## -## Course Search -## -###################################################################### -###################################################################### -{ # Scope the course search to avoid global variables -# -# Variables For course search -my %alreadyseen; -my %hash; -my $totalfound; - -sub make_symb { - my ($id)=@_; - my ($mapid,$resid)=split(/\./,$id); - my $map=$hash{'map_id_'.$mapid}; - my $res=$hash{'src_'.$id}; - my $symb=&Apache::lonnet::encode_symb($map,$resid,$res); - return $symb; -} - -sub course_search { - my $r=shift; - my $pretty_search_string = ''.$env{'form.courseexp'}.''; - my $search_string = $env{'form.courseexp'}; - my @New_Words; - undef(%alreadyseen); - if ($env{'form.crsrelated'}) { - ($search_string,@New_Words) = &related_version($env{'form.courseexp'}); - if (@New_Words) { - $pretty_search_string .= ' '.&mt("with related words").": @New_Words."; - } else { - $pretty_search_string .= ' '.&mt('with no related words')."."; - } - } - my $fulltext=$env{'form.crsfulltext'}; - my $discuss=$env{'form.crsdiscuss'}; - my @allwords=($search_string,@New_Words); - $totalfound=0; - - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check(). - '&phase=disp_adv'. - 'catalogmode='.$env{'form.catalogmode'}. - '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, - text=>"Course Search", - bug=>'Searching',}); - $r->print(&Apache::loncommon::start_page('Course Search')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', - $env{'form.catalogmode'} ne 'import')); - - $r->print( - '
'.&mt('No matches found in resources.').'
'); - } - -# Check discussions if requested - if ($discuss) { - my $totaldiscussions = 0; - $r->print(''.&mt('No matches found in postings.').'
'); - } - } else { - $r->print('-$lt{'note'}. -
-
-ENDCOURSESEARCH
- $scrout.=' '.
- &Apache::lonhtmlcommon::textbox('courseexp',
- $env{'form.courseexp'},40);
- my $crscheckbox =
- &Apache::lonhtmlcommon::checkbox('crsfulltext',
- $env{'form.crsfulltext'});
- my $relcheckbox =
- &Apache::lonhtmlcommon::checkbox('crsrelated',
- $env{'form.crsrelated'});
- my $discheckbox =
- &Apache::lonhtmlcommon::checkbox('crsdiscuss',
- $env{'form.crsrelated'});
- $scrout.=(< | |
- -
-\n";
$result .= ''.$values{'author'}.','.
' '.$values{'owner'}.'
';
@@ -3541,7 +3264,7 @@ sub detailed_citation_view {
$result .= ''.&mt($field->{'translate'}).'';
foreach my $item (split(',',$values{$field->{'name'}})){
$item = &Apache::lonnet::clutter($item);
- $result .= &display_url($item,[2,0,1]);
+ $result .= '
'.&display_url($item,1).'
';
}
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
$result.= &mt($field->{'translate'},
@@ -3549,7 +3272,7 @@ sub detailed_citation_view {
$values{$field->{'name'}}))."
\n";
} else {
if ($field->{'special'} eq 'url link') {
- $result .= &display_url($jumpurl,[3,0,1]);
+ $result .= '
'.&display_url($jumpurl,1).'
';
} else {
$result.= &mt($field->{'translate'},
$values{$field->{'name'}});
@@ -3603,11 +3326,18 @@ sub summary_view {
}
my $jumpurl=$values{'url'};
$jumpurl=~s|^/ext/|http://|;
- my $link = &display_url($jumpurl,[2,0,1]);
+ my $link = '
'.&display_url($jumpurl,1).'
';
+ my $titleWL = &mt('Set link to wishlist');
$result.=<
+ target="preview">$values{'title'}
+
+
+
+
$link
$values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}
$values{'copyrighttag'}
@@ -3639,7 +3369,7 @@ sub compact_view {
my $jumpurl=$values{'url'};
$jumpurl=~s|^/ext/|http://|;
- my $link = &display_url($jumpurl,[1,1,1]);
+ my $link = &display_url($jumpurl,1);
my $result =
$prefix.'';
@@ -3653,12 +3383,17 @@ sub compact_view {
$result.=' '.
''.
&HTML::Entities::encode($values{'title'},'<>&"').' '.
+ ''.
+ ''.
+ ''.
$link.' '.$values{'author'}.' ('.$values{'domain'}.')';
return $result;
}
sub display_url {
- my ($url,$crumb_args) = @_;
+ my ($url,$skiplast) = @_;
my $link;
if ($url=~m|^/ext/|) {
$url=~s|^/ext/|http://|;
@@ -3666,10 +3401,12 @@ sub display_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}).' ';
+ $link=&Apache::lonhtmlcommon::crumbs(
+ $url,
+ 'preview',
+ '',
+ (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),
+ $skiplast).' ';
}
return $link;
}
@@ -3692,12 +3429,19 @@ sub fielded_format_view {
my $jumpurl=$values{'url'};
$jumpurl=~s|^/ext/|http://|;
+ my $titleWL = ('Set link to wishlist');
my $result=<