--- loncom/interface/lonsearchcat.pm 2008/05/28 22:22:27 1.295 +++ loncom/interface/lonsearchcat.pm 2009/07/31 17:58:16 1.314 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.295 2008/05/28 22:22:27 www Exp $ +# $Id: lonsearchcat.pm,v 1.314 2009/07/31 17:58:16 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -191,9 +191,9 @@ sub handler { &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/searchcat?'. &Apache::loncommon::inhibit_menu_check(). - '&catalogmode='.$env{'form.catalogmode'}. - '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, + '&catalogmode='.$env{'form.catalogmode'}. + '&launch='.$env{'form.launch'}. + '&mode='.$env{'form.mode'}, text=>"$crumb_text", target=>'_top', bug=>'Searching',}); @@ -266,24 +266,25 @@ sub handler { ## Configure dynamic components of interface ## if ($env{'form.catalogmode'} eq 'interactive') { - $closebutton=" + END } else { $closebutton = ''; @@ -313,19 +314,19 @@ END } &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'}, + '&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?'.&Apache::loncommon::inhibit_menu_check(). - '&phase=disp_adv'. + '&phase=disp_adv'. 'catalogmode='.$env{'form.catalogmode'}. - '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, + '&launch='.$env{'form.launch'}. + '&mode='.$env{'form.mode'}, text=>"Course Search", bug=>'Searching',}); } @@ -487,7 +488,20 @@ sub course_search { my $discuss=$env{'form.crsdiscuss'}; my @allwords=($search_string,@New_Words); $totalfound=0; - $r->print(&Apache::loncommon::start_page('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',}); + $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').'.
'); + $r->print(''.&mt('No matches found in resources.').'
'); } # Check discussions if requested @@ -518,72 +532,77 @@ sub course_search { my $totaldiscussions = 0; $r->print(''.&mt('No matches found in postings').'.
'); + unless ($totaldiscussions) { + $r->print(''.&mt('No matches found in postings.').'
'); + } + } else { + $r->print('$lt{'note'}.
-
ENDCOURSESEARCH @@ -731,8 +749,9 @@ ENDCOURSESEARCH | |
- + +
+
@@ -761,14 +780,14 @@ sub setup_basic_search { ''; $adv_search_link = ''.&mt('Advanced Search').''; # $scrout.=''; } # - $scrout .= '' + .&viewoptions() + .'
' + .'' + .'' + .' ' + .$closebutton + .'
'; + # + $scrout .= '$closebutton +
END my $srchtype = 'Catalog'; my $jscript; if ($env{'form.area'} eq 'portfolio') { $srchtype = 'Portfolio'; $jscript = ''; } my $scrout= &Apache::loncommon::start_page("Advanced $srchtype Search", $jscript); - $scrout .= <<"ENDHEADER"; -$bread_crumb -'; + $scrout .= &Apache::loncommon::end_page(); $r->print($scrout); return; @@ -1157,17 +1202,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; } @@ -1393,7 +1441,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. @@ -1638,7 +1686,7 @@ sub parse_advanced_search { # if (@queries) { if ($env{'form.area'} eq 'portfolio') { - $query ="SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa, portfolio_addedfields pf WHERE (pm.url = pa.url AND pf.url = pm.url AND (pa.start < NOW() AND (pa.end IS NULL OR pa.end > NOW())) AND (".join(') AND (',@queries).'))'; + $query ="SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa, portfolio_addedfields pf WHERE (pm.url = pa.url AND pf.url = pm.url AND (pa.start < UTC_TIMESTAMP() AND (pa.end IS NULL OR pa.end > UTC_TIMESTAMP())) AND (".join(') AND (',@queries).'))'; } else { $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')'; } @@ -1701,7 +1749,7 @@ sub parse_basic_search { # # Clean up fields for safety for my $field ('basicexp') { - $env{"form.$field"}=~s/[^\w\s\'\"\!\(\)\-]//g; + $env{"form.$field"}=~s/[^\w\s\'\"\!\(\)\-\*]//g; } foreach ('mode','form','element') { # is this required? Hmmm. @@ -1740,7 +1788,7 @@ sub parse_basic_search { #} my $final_query; if ($env{'form.area'} eq 'portfolio') { - $final_query = 'SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa WHERE (pm.url = pa.url AND (pa.start < NOW() AND (pa.end IS NULL OR pa.end > NOW())) AND '.join(" AND ",@Queries).')'; + $final_query = 'SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa WHERE (pm.url = pa.url AND (pa.start < UTC_TIMESTAMP() AND (pa.end IS NULL OR pa.end > UTC_TIMESTAMP())) AND '.join(" AND ",@Queries).')'; } else { $final_query = 'SELECT * FROM metadata WHERE '.join(" AND ",@Queries); } @@ -2118,7 +2166,7 @@ sub copyright_check { } # Check for custom rights if ($Metadata->{'copyright'} eq 'custom') { - return &Apache::lonnet::customacccess('bre',$Metadata->{'url'}); + return &Apache::lonnet::customaccess('bre',$Metadata->{'url'}); } return 1; } @@ -2147,9 +2195,13 @@ sub ensure_db_and_table { ## Sanity check the table id. ## if (! defined($table) || $table eq '' || $table =~ /\D/ ) { - $r->print("Unable to retrieve search results. ". - "Unable to determine the table results were saved in. ". - &Apache::loncommon::end_page()); + $r->print(&Apache::loncommon::start_page(&mt('Error')) +. 'table: |'.$table.'|
' # SB + .''
+ .&mt('Unable to retrieve search results. '
+ .'Unable to determine the table results were saved in.')
+ .&Apache::loncommon::end_page()
+ );
return undef;
}
##
@@ -2231,18 +2283,19 @@ sub print_sort_form {
}
my $js =<
$pretty_string =~ s:^\s*
::i;
@@ -2500,7 +2567,7 @@ END
pop(@Lines);
}
if (@Lines > 2) {
- $pretty_string = join '
',(@Lines[0..2],'....
');
+ $pretty_string = join '
',(@Lines[0..2],'...
');
}
$r->print(&mt("Search: [_1]",$pretty_string));
$r->rflush();
@@ -2555,18 +2622,22 @@ END
my $server;
my $status;
my $revise = &revise_button();
- $r->print(<
-Status Total Matches Time Remaining
-
-
-
-END
+ $r->print('');
$r->rflush();
&reset_timing();
&update_seconds($r);
@@ -2671,7 +2742,7 @@ END
last if ($connection->aborted());
&update_seconds($r);
}
- &update_status($r,&mt('Search Complete [_1]',$server));
+ &update_status($r,&mt('Search Complete on Server [_1]',$server));
&update_seconds($r);
#
&Apache::lonmysql::disconnect_from_db(); # This is unneccessary
@@ -2681,11 +2752,11 @@ END
# loaded from /adm/searchcat
$r->print(&Apache::loncommon::end_page());
# if ($env{'form.catalogmode'} ne 'import') {
- $r->print("");
+ $r->print(<
+SCRIPT
# }
return;
}
@@ -2708,15 +2779,15 @@ sub prev_next_buttons {
return '' if ($show eq 'all'); # No links if you get them all at once.
#
# Create buttons
- my $buttons = '';
- $buttons .= ' 'x3;
- $buttons .= ''
+ .''
+ .' '
+ .''
+ .' '
+ .''
+ .'
-
-
- $revise
-
' + .&mt('Internal Error - Bad view selected.') + .'
'."\n"); $r->rflush(); return; } @@ -2758,7 +2831,10 @@ sub display_results { if ($env{'form.catalogmode'} eq 'import') { if (! tie(%groupsearch_db,'GDBM_File',$diropendb, &GDBM_WRCREAT(),0640)) { - $r->print('Unable to save import results.'. + $r->print(''. + &mt('Unable to save import results.'). + '
'. + ''. &Apache::loncommon::end_page()); $r->rflush(); return; @@ -2772,7 +2848,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); @@ -2877,37 +2956,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'), 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 $output; if (! defined($Fields{'title'}) || $Fields{'title'} eq '') { $Fields{'title'} = 'Untitled'; } @@ -2952,21 +3035,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"; @@ -3467,17 +3564,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 @@ -3791,7 +3882,7 @@ $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 $start_page = &Apache::loncommon::start_page('Search'); @@ -3803,11 +3894,11 @@ $hidden_fields $closebutton+
$errormsg
$end_page ENDPAGE @@ -3838,16 +3929,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