--- loncom/interface/lonsearchcat.pm 2006/06/19 09:40:18 1.270
+++ loncom/interface/lonsearchcat.pm 2014/02/22 18:12:09 1.342
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.270 2006/06/19 09:40:18 www Exp $
+# $Id: lonsearchcat.pm,v 1.342 2014/02/22 18:12:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,8 +52,6 @@ search (on a server basis) is displayed
=head1 Internals
-=over 4
-
=cut
###############################################################################
@@ -78,7 +76,7 @@ use HTML::Entities();
use Parse::RecDescent;
use Apache::lonnavmaps;
use Apache::lonindexer();
-use lib '/home/httpd/lib/perl/';
+use Apache::lonwishlist();
use LONCAPA;
######################################################################
@@ -119,8 +117,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
@@ -139,7 +135,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','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
@@ -154,7 +150,8 @@ sub handler {
## Initialize global variables
##
my $domain = $r->dir_config('lonDefDomain');
- $diropendb= "/home/httpd/perl/tmp/".
+ my $temp_file_dir = LONCAPA::tempdir();
+ $diropendb= $temp_file_dir .
"$env{'user.domain'}_$env{'user.name'}_sel_res.db";
#
# set the name of the persistent database
@@ -165,31 +162,30 @@ sub handler {
$env{'form.persistent_db_id'} = time;
}
- my $persistent_db_file = "/home/httpd/perl/tmp/".
+ my $persistent_db_file = $temp_file_dir .
&escape($domain).
'_'.&escape($env{'user.name'}).
'_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
##
&Apache::lonhtmlcommon::clear_breadcrumbs();
- 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",
+
+ my @allowed_searches = ('portfolio');
+ if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'}) eq 'F') {
+ push(@allowed_searches,'res');
+ }
+ my $crumb_text = 'Portfolio Search';
+ if (@allowed_searches ==2) {
+ $crumb_text = 'Portfolio and Catalog Search';
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/searchcat?'.
+ &Apache::loncommon::inhibit_menu_check().
+ '&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)) {
@@ -198,11 +194,14 @@ sub handler {
'Unable to recover data from '.
$persistent_db_file);
my $msg =
- 'We were unable to retrieve data describing your search. '.
- 'This is a serious error and has been logged. '.
- 'Please alert your LON-CAPA administrator.';
- &Apache::loncommon::simple_error_page($r,'Search Error',
- $msg);
+ &mt('We were unable to retrieve data describing your search.').
+ ' '.&mt('This is a serious error and has been logged.').
+ '
'.
+ &mt('Please alert your LON-CAPA administrator.');
+ &Apache::loncommon::simple_error_page(
+ $r,'Search Error',
+ $msg,
+ {'no_auto_mt_msg' => 1});
return OK;
}
}
@@ -249,28 +248,35 @@ sub handler {
if (exists($env{'form.mode'})) {
$hidden_fields .= &hidden_field('mode');
}
+ 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="
+
END
} else {
$closebutton = '';
@@ -289,27 +295,22 @@ 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') {
+ 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",
- bug=>'Searching',});
- } elsif ($env{'form.searchmode'} eq 'course search') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/searchcat?phase=disp_adv&'.
- 'catalogmode='.$env{'form.catalogmode'}.
- '&launch='.$env{'form.launch'}.
- '&mode='.$env{'form.mode'},
- text=>"Course Search",
+ ({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',});
- }
+ }
##
## Switch on the phase
##
@@ -318,35 +319,34 @@ 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) =
+ my ($query,$customquery,$customshow,$libraries,$pretty_string,$domainsref) =
&get_persistent_data($persistent_db_file,
['query','customquery','customshow',
- 'libraries','pretty_string']);
+ 'libraries','pretty_string','domains']);
if ($env{'form.phase'} eq 'sort') {
&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'},$domainsref);
}
- } elsif ($env{'form.phase'} eq 'course_search') {
- &course_search($r);
} elsif(($env{'form.phase'} eq 'basic_search') ||
($env{'form.phase'} eq 'adv_search')) {
#
# We are running a search, try to parse it
- my ($query,$customquery,$customshow,$libraries) =
- (undef,undef,undef,undef);
+ my ($query,$customquery,$customshow,$libraries,$domains) =
+ (undef,undef,undef,undef,undef);
my $pretty_string;
if ($env{'form.phase'} eq 'basic_search') {
- ($query,$pretty_string,$libraries) =
+ ($query,$pretty_string,$libraries,$domains) =
&parse_basic_search($r,$closebutton,$hidden_fields);
return OK if (! defined($query));
&make_persistent({ basicexp => $env{'form.basicexp'}},
$persistent_db_file);
} else { # Advanced search
- ($query,$customquery,$customshow,$libraries,$pretty_string)
+ ($query,$customquery,$customshow,$libraries,$pretty_string,$domains)
= &parse_advanced_search($r,$closebutton,$hidden_fields);
return OK if (! defined($query));
}
@@ -354,18 +354,19 @@ END
customquery => $customquery,
customshow => $customshow,
libraries => $libraries,
- pretty_string => $pretty_string },
+ pretty_string => $pretty_string,
+ domains => $domains },
$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:'.
$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);
@@ -374,7 +375,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);
@@ -427,229 +428,11 @@ 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;
- $r->print(&Apache::loncommon::start_page('Course Search').
- '
'.&mt('No matches found in resources').'.
'); - } - -# Check discussions if requested - if ($discuss) { - my $totaldiscussions = 0; - $r->print(''.&mt('No matches found in postings').'.
'); - } - } - -# =================================================== Done going through course - $r->print(&Apache::loncommon::end_page()); -} - -# =============================== This pulls up a resource and its dependencies - -sub checkonthis { - my ($r,$id,$url,$level,$title,$fulltext,$symb,@allwords)=@_; - $alreadyseen{$id}=1; - if (&Apache::loncommon::connection_aborted($r)) { return; } - $r->rflush(); - - my $result=$title.' '; - if ($env{'request.role.adv'} || !$hash{'encrypted_'.$id}) { - $result.=&Apache::lonnet::metadata($url,'title').' '. - &Apache::lonnet::metadata($url,'subject').' '. - &Apache::lonnet::metadata($url,'abstract').' '. - &Apache::lonnet::metadata($url,'keywords'); - } - my ($extension)=($url=~/\.(\w+)$/); - if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' && - ($url) && ($fulltext)) { - $result.=&Apache::lonnet::ssi_body($url.'?symb='.&escape($symb)); - } - $result=~s/\s+/ /gs; - my $applies = 0; - $applies = &checkwords($result,$applies,@allwords); -# Does this resource apply? - if ($applies) { - $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.=(< | |
- -
-$closebutton +
END - my $scrout= &Apache::loncommon::start_page('Advanced Catalog Search'); - $scrout .= <<"ENDHEADER"; -$bread_crumb -'; + $scrout .= &Apache::loncommon::end_page(); $r->print($scrout); return; @@ -1074,17 +912,20 @@ sub viewoptions { if (! defined($env{'form.viewselect'})) { $env{'form.viewselect'}='detailed'; } - $scrout.=&Apache::lonmeta::selectbox('viewselect', - $env{'form.viewselect'}, - \&viewoptiontext, - sort(keys(%Views))); - $scrout.= ' '; + $scrout .= '' + .&mt('Type:').' ' + .&Apache::lonmeta::selectbox('viewselect', + $env{'form.viewselect'}, + \&viewoptiontext, + sort(keys(%Views))) + .''; my $countselect = &Apache::lonmeta::selectbox('show', $env{'form.show'}, undef, (10,20,50,100,1000,10000)); - $scrout .= (' 'x2).&mt('[_1] Records per Page',$countselect). - ''.$/; + $scrout .= ' ' + .&mt('Records per Page:').' '.$countselect + .''.$/; return $scrout; } @@ -1175,8 +1016,9 @@ Outputs: array of values. Returns undef This function is the reverse of &make_persistent(); Retrieve persistent data from %persistent_db. Retrieved items will have their -values unescaped. If the item contains commas (before unescaping), the -returned value will be an array pointer. +values unescaped. If the item is 'domains; then the returned +value will be a hash pointer. Otherwise, if the item contains +commas (before unescaping), the returned value will be an array pointer. =cut @@ -1194,13 +1036,25 @@ sub get_persistent_data { push @Values, undef; next; } - my @values = map { - &unescape($_); - } split(',',$persistent_db{$name}); - if (@values <= 1) { - push @Values,$values[0]; + if ($name eq 'domains') { + my %valueshash; + my @items= map { &unescape($_); } split(',',$persistent_db{$name}); + foreach my $item (@items) { + if ($item =~ /=/) { + my ($key,$val) = map { &unescape($_); } split(/=/,$item); + $valueshash{$key} = $val; + } + } + push(@Values,\%valueshash); } else { - push @Values,\@values; + my @values = map { + &unescape($_); + } split(',',$persistent_db{$name}); + if (@values <= 1) { + push @Values,$values[0]; + } else { + push @Values,\@values; + } } } untie (%persistent_db); @@ -1218,7 +1072,9 @@ Inputs: Hash of values to save, filename Store variables away to the %persistent_db. Values will be escaped. Values that are array pointers will have their -elements escaped and concatenated in a comma separated string. +elements escaped and concatenated in a comma separated string. Values +that are hash pointers will have their keys and values escaped and +concatenated in a comma separated string. =cut @@ -1230,8 +1086,17 @@ sub make_persistent { return undef if (! tie(%persistent_db,'GDBM_File', $filename,&GDBM_WRCREAT(),0640)); foreach my $name (keys(%save)) { - my @values = (ref($save{$name}) ? @{$save{$name}} : ($save{$name})); - # We handle array references, but not recursively. + my @values=(); + if (ref($save{$name}) eq 'ARRAY') { + @values = @{$save{$name}}; + } elsif (ref($save{$name}) eq 'HASH') { + foreach my $key (%{$save{$name}}) { + push(@values,&escape($key).'='.&escape($save{$name}{$key})); + } + } else { + @values = $save{$name}; + } + # We handle array and hash references, but not recursively. my $store = join(',', map { &escape($_); } @values ); $persistent_db{$name} = $store; } @@ -1310,7 +1175,7 @@ sub parse_advanced_search { 'lastrevisiondatestart_month','lastrevisiondatestart_day', 'lastrevisiondatestart_year','lastrevisiondateend_month', 'lastrevisiondateend_day','lastrevisiondateend_year') { - $env{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\']//g; + $env{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\'.\*]//g; } foreach ('mode','form','element') { # is this required? Hmmm. @@ -1343,6 +1208,17 @@ sub parse_advanced_search { $fillflag++; } } + if ($env{'form.area'} eq 'portfolio') { + # Added metadata fields + for (my $i=0; $i<$env{'form.numaddedfields'} ; $i++) { + my $field = $env{'form.addedfield_'.$i}; + $field =~ s/^\s*(\S*)\s*$/$1/; + $field =~ s/\W/_/g; + if ($field ne '') { + $fillflag++; + } + } + } if (! $fillflag) { &output_blank_field_error($r,$closebutton, 'phase=disp_adv',$hidden_fields); @@ -1429,29 +1305,56 @@ sub parse_advanced_search { &Apache::loncommon::copyrightdescription($env{'form.copyright'}). "' + .&mt('Unable to retrieve search results. ' + .'Unable to determine the table results were saved in.') + .'
' + . ''.&mt('Internal info:').'
' + .''.$table.'' + .&Apache::loncommon::end_page() + ); return undef; } ## @@ -2019,9 +1968,12 @@ sub ensure_db_and_table { ## my $connection_result = &Apache::lonmysql::connect_to_db(); if (!defined($connection_result)) { - $r->print("Unable to connect to the MySQL database where your results". - " are stored.". - &Apache::loncommon::end_page()); + $r->print( + '
' + .&mt('Unable to connect to the MySQL database where your results are saved.') + .'
' + .&Apache::loncommon::end_page() + ); &Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to". " connect to database."); &Apache::lonnet::logthis(&Apache::lonmysql::get_error()); @@ -2029,13 +1981,20 @@ sub ensure_db_and_table { } my $table_check = &Apache::lonmysql::check_table($table); if (! defined($table_check)) { - $r->print("A MySQL error has occurred.". - &Apache::loncommon::end_page()); + $r->print( + '' + .&mt('A MySQL error has occurred.') + .'
' + .&Apache::loncommon::end_page()); &Apache::lonnet::logthis("lonmysql was unable to determine the status". " of table ".$table); return undef; } elsif (! $table_check) { - $r->print("The table of results could not be found."); + $r->print( + '' + .&mt('The table of results could not be found.') + .'
' + ); &Apache::lonnet::logthis("The user requested a table, ".$table. ", that could not be found."); return undef; @@ -2093,6 +2052,7 @@ sub print_sort_form { } my $js =<-Search:$pretty_query_string -
- -END + $result.='' + .&mt('Total of [quant,_1,match,matches] to your query.',$total_results) + .' '.$revise.'
' + .''.&mt('Search: ').$pretty_query_string + .'
'; $r->print($result.&Apache::loncommon::end_page()); return; } @@ -2173,7 +2130,7 @@ my @Fullindicies; Creates the table of search results by calling lonmysql. Stores the table id in $env{'form.table'} -Inputs: none. +Inputs: search area - either res or portfolio Returns: the identifier of the table on success, undef on error. @@ -2182,8 +2139,9 @@ Returns: the identifier of the table on ###################################################################### ###################################################################### sub set_up_table_structure { + my ($tabletype) = @_; my ($datatypes,$fullindicies) = - &LONCAPA::lonmetadata::describe_metadata_storage(); + &LONCAPA::lonmetadata::describe_metadata_storage($tabletype); # Copy the table description before modifying it... @Datatypes = @{$datatypes}; unshift(@Datatypes,{name => 'id', @@ -2196,7 +2154,12 @@ sub set_up_table_structure { } sub create_results_table { - &set_up_table_structure(); + my ($area) = @_; + if ($area eq 'portfolio') { + &set_up_table_structure('portfolio_search'); + } else { + &set_up_table_structure('metadata'); + } my $table = &Apache::lonmysql::create_table ( { columns => \@Datatypes, FULLTEXT => [{'columns' => \@Fullindicies},], @@ -2240,16 +2203,28 @@ Returns: Nothing. sub update_count_status { my ($r,$text) = @_; $text =~ s/\'/\\\'/g; - $r->print - ("\n"); + $r->print(< +SCRIPT + $r->rflush(); } sub update_status { my ($r,$text) = @_; $text =~ s/\'/\\\'/g; - $r->print - ("\n"); + $r->print(< +SCRIPT + $r->rflush(); } @@ -2276,9 +2251,14 @@ sub update_seconds { my ($r) = @_; my $time = &time_left(); if (($last_time-$time) > 0) { - $r->print("\n"); + $r->print(< +SCRIPT + $r->rflush(); } $last_time = $time; @@ -2302,14 +2282,15 @@ 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{ }; + '&cleargroupsort=1'. + '&phase='.$revise_phase; + my $result = qq{ }; return $result; } @@ -2328,22 +2309,23 @@ results into MySQL. ###################################################################### ###################################################################### sub run_search { - my ($r,$query,$customquery,$customshow,$serverlist,$pretty_string) = @_; - + my ($r,$query,$customquery,$customshow,$serverlist, + $pretty_string,$area,$domainsref) = @_; + my $tabletype = 'metadata'; + if ($area eq 'portfolio') { + $tabletype = 'portfolio_search'; + } my $connection = $r->connection; # # Print run_search header # - my $start_page = &Apache::loncommon::start_page('Search Status',undef, - {'only_body' => 1}); + my $start_page = &Apache::loncommon::start_page('Search Status',undef); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', $env{'form.catalogmode'} ne 'import'); $r->print(<' + .&mt('Internal Error - Bad view selected.') + .'
'."\n"); $r->rflush(); return; } @@ -2606,7 +2626,10 @@ 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(''. + &mt('Unable to save import results.'). + '
'. + ''. &Apache::loncommon::end_page()); $r->rflush(); return; @@ -2620,7 +2643,10 @@ sub display_results { ## Get the number of results my $total_results = &Apache::lonmysql::number_of_rows($table); if (! defined($total_results)) { - $r->print("A MySQL error has occurred.". + $r->print(''. + &mt('A MySQL error has occurred.'). + '
'. + ''. &Apache::loncommon::end_page()); &Apache::lonnet::logthis("lonmysql was unable to determine the number". " of rows in table ".$table); @@ -2651,7 +2677,8 @@ sub display_results { $r->print(&hidden_field('table'). &hidden_field('phase'). &hidden_field('persistent_db_id'). - &hidden_field('start') + &hidden_field('start'). + &hidden_field('area') ); # # Build sorting selector @@ -2672,6 +2699,16 @@ sub display_results { {key =>'lowestgradelevel'}, {key =>'highestgradelevel'}, {key =>'standards',desc=>'Standards'}, + ); + if ($area eq 'portfolio') { + push(@fields, + ( + {key => 'scope'}, + {key => 'keynum'}, + )); + } else { + push(@fields, + ( {key =>'count',desc=>'Number of accesses'}, {key =>'stdno',desc=>'Students Attempting'}, {key =>'avetries',desc=>'Average Number of Tries'}, @@ -2682,7 +2719,8 @@ sub display_results { {key =>'correct',desc=>'Evaluation: Material is Correct'}, {key =>'helpful',desc=>'Evaluation: Material is Helpful'}, {key =>'depth',desc=>'Evaluation: Material has Depth'}, - ); + )); + } my %fieldnames = &Apache::lonmeta::fieldnames(); my @field_order; foreach my $field_data (@fields) { @@ -2699,7 +2737,13 @@ sub display_results { my %sort_fields = map {$_->{'key'},$_->{'desc'}} @fields; $sort_fields{'select_form_order'} = \@field_order; $env{'form.sortorder'} = 'desc' if (! exists($env{'form.sortorder'})); - $env{'form.sortfield'} = 'count' if (! exists($env{'form.sortfield'})); + if (! exists($env{'form.sortfield'})) { + if ($area eq 'portfolio') { + $env{'form.sortfield'} = 'owner'; + } else { + $env{'form.sortfield'} = 'count'; + } + } if (! exists($env{'form.sortorder'})) { if ($env{'form.sortfield'}=~/^(count|stdno|disc|clear|technical|correct|helpful)$/) { $env{'form.sortorder'}='desc'; @@ -2707,37 +2751,40 @@ sub display_results { $env{'form.sortorder'}='asc'; } } - my $sortform = &mt('Sort by [_1] [_2]', - &Apache::loncommon::select_form($env{'form.sortfield'}, + my $sortform = '' + .&mt('Sort by:').' ' + .&Apache::loncommon::select_form($env{'form.sortfield'}, 'sortfield', - %sort_fields), - &Apache::loncommon::select_form($env{'form.sortorder'}, + \%sort_fields) + .' ' + .&Apache::loncommon::select_form($env{'form.sortorder'}, 'sortorder', - (asc =>&mt('Ascending'), + {asc =>&mt('Ascending'), desc=>&mt('Descending') - )) - ); + }) + .''; ## - ## Output links (if necessary) for 'prev' and 'next' pages. - $r->print - (''.
- ' | '. - &prev_next_buttons($min,$env{'form.show'},$total_results). - ' | '. - &viewoptions().' |
'.&mt('There are currently no results.').'
'. "". &Apache::loncommon::end_page()); return; } else { - $r->print('\n"; + my %Fields = %{&parse_row($tabletype,@$row)}; + my $output; if (! defined($Fields{'title'}) || $Fields{'title'} eq '') { $Fields{'title'} = 'Untitled'; } @@ -2778,21 +2830,27 @@ sub display_results { # Render the result into html $output.= &$viewfunction($prefix,%Fields); # Print them out as they come in. - $r->print($output); + $r->print(&Apache::loncommon::start_data_table_row() + .'
' + .&mt('There were no results matching your query.') + .'
'); } else { - $r->print - ('\n"; - $result .= ''.$values{'author'}.','. + $jumpurl=~s|^/ext/|http://|; + $result .= + ''.$prefix. + ''.' '. + ''.$values{'title'}."\n". + &display_tools($values{'title'}, $jumpurl). + "
\n".
+ ''.$values{'author'}.','.
' '.$values{'owner'}.'
';
foreach my $field
(
@@ -3279,11 +3361,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($item,
- (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
- '/res',
- (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),2,0,1);
+ $item = &Apache::lonnet::clutter($item);
+ $result .= '
'.&display_url($item,1).'
';
}
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
$result.= &mt($field->{'translate'},
@@ -3291,11 +3370,7 @@ sub detailed_citation_view {
$values{$field->{'name'}}))."
\n";
} else {
if ($field->{'special'} eq 'url link') {
- $result.=
- &Apache::lonhtmlcommon::crumbs($jumpurl,
- (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
- '',
- (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),3,0,1);
+ $result .= '
'.&display_url($jumpurl,1).'
';
} else {
$result.= &mt($field->{'translate'},
$values{$field->{'name'}});
@@ -3310,17 +3385,14 @@ sub detailed_citation_view {
if (exists($values{'shortabstract'}) && $values{'shortabstract'} ne '') {
$result .= '
'.$values{'shortabstract'}.'
'; } - $result .= ''. - &detailed_citation_view($prefix,%values). + return &detailed_citation_view($prefix,%values). ' | '. - &Apache::lonindexer::showpreview($values{'url'}). - ' |
'. - &summary_view($prefix,%values). + return &summary_view($prefix,%values). ' | '. - &Apache::lonindexer::showpreview($values{'url'}). - ' |
+
$errorstring
$end_page ENDPAGE @@ -3619,23 +3710,32 @@ $parms is extra information to include i ###################################################################### sub output_blank_field_error { my ($r,$closebutton,$parms,$hidden_fields)=@_; - my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.'); + my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.'); my $revise = &mt('Revise Search Request'); - my $heading = &mt('Unactionable Search Queary'); + my $heading = &mt('Unactionable Search Query'); my $start_page = &Apache::loncommon::start_page('Search'); my $end_page = &Apache::loncommon::end_page(); + if ($closebutton) { + $closebutton = ''.$closebutton.'
+
$errormsg
$end_page ENDPAGE @@ -3666,16 +3766,18 @@ sub output_date_error { # make query information persistent to allow for subsequent revision my $start_page = &Apache::loncommon::start_page('Search'); my $end_page = &Apache::loncommon::end_page(); + my $heading = &mt('Error'); $r->print(<+
$message
$end_page @@ -3716,7 +3818,6 @@ sub cleanup { &Apache::lonnet::logthis('Failed cleanup searchcat: groupsearch_db'); } } - &untiehash(); &Apache::lonmysql::disconnect_from_db(); return OK; }