--- loncom/interface/lonsearchcat.pm 2009/07/31 10:58:57 1.312 +++ loncom/interface/lonsearchcat.pm 2009/10/22 13:48:55 1.317 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.312 2009/07/31 10:58:57 bisitz Exp $ +# $Id: lonsearchcat.pm,v 1.317 2009/10/22 13:48:55 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -266,25 +266,25 @@ sub handler { ## Configure dynamic components of interface ## if ($env{'form.catalogmode'} eq 'interactive') { - $closebutton=" +onclick='javascript:select_group()' /> END } else { $closebutton = ''; @@ -798,7 +798,7 @@ sub setup_basic_search { $scrout .= ''; } # - $scrout .= '
'.$/; + $scrout .= '
'.$/; # if ($env{'request.course.id'}) { $scrout .= '

'.$lt{$area}.'

'; # } else { @@ -810,23 +810,27 @@ sub setup_basic_search { &Apache::lonhtmlcommon::textbox('basicexp', $env{'form.basicexp'},50). '
'. - ''.&searchhelp().''.''. - ''. + ''.&searchhelp().''.''. + ''. ''.(' 'x3).$adv_search_link.''.'
'. ''.(' 'x1).$userelatedwords.''.'
'. ''.(' 'x1).$onlysearchdomain.''.'
'. ''.(' 'x1).$inclext.''.'
'. - '
'. - ''.$/; + ''. + ''. + ''.$/; + # + $scrout .= '

' + .&viewoptions() + .'

' + .'

' + .'' + .' ' + .$closebutton + .'

'; # - $scrout .= ''. - ''. - ''. - (' 'x2).$closebutton.(' 'x2). &viewoptions(). - ''. - ''.$/; - $scrout .= ''.$/.'
'.''; + $scrout .= ''.''; return $scrout; } @@ -852,15 +856,18 @@ sub print_advanced_search_form{ 'reset' => 'Reset', 'help' => 'Help'); my $advanced_buttons=<<"END"; +

$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 -
-

-$advanced_buttons -ENDHEADER - $scrout.=(' 'x2).&viewoptions().'

'.$hidden_fields. - ''; + $scrout .= $bread_crumb; + + $scrout .= '' + .$hidden_fields + .''; + + $scrout .= '
'."\n" + .''.&mt('Display Options').''."\n" + .&viewoptions() + .'
'; + + $scrout .= $advanced_buttons; + + $scrout .= &Apache::lonhtmlcommon::start_pick_box(); + my %fields=&Apache::lonmeta::fieldnames(); - # - $scrout .= '

'.&mt("Standard $srchtype Metadata").'

'; - $scrout .= "\n"; - $scrout .= '\n"; + + # Standard Metadata + $scrout .= &Apache::lonhtmlcommon::row_headline() + .'

'.&mt("Standard $srchtype Metadata").'

' + .&searchhelp() + .&Apache::lonhtmlcommon::row_closure(); my %related_word_search = ('title' => 1, 'author' => 0, @@ -897,110 +913,111 @@ ENDHEADER 'abstract' => 1, 'standards'=> 1, 'mime' => 1, - 'subject' => 1, + 'subject' => 1, ); # foreach my $field ('title','author','subject','owner','authorspace', - 'modifyinguser','keywords','notes','abstract', - 'standards','mime') { - $scrout.=''.$/; + $scrout .= &Apache::lonhtmlcommon::row_closure(); } foreach my $field ('lowestgradelevel','highestgradelevel') { - $scrout.=''. - ''. - ''.$/; + 0) + .&Apache::lonhtmlcommon::row_closure(); } - $scrout.=''.$/; - $scrout.=''.$/; - # + + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield(&mt('MIME Type Category'))) + .&Apache::loncommon::filecategoryselect('category', + $env{'form.category'}) + .&Apache::lonhtmlcommon::row_closure(); + + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield(&mt('Domains'))) + .&Apache::loncommon::domain_select('domains', + $env{'form.domains'},1) + .&Apache::lonhtmlcommon::row_closure(); + # Misc metadata if ($env{'form.area'} ne 'portfolio') { - $scrout.=''.$/; + ) + .&Apache::lonhtmlcommon::row_closure(); } - $scrout.=''; - $scrout .= "
 '. - (' 'x2).&searchhelp()."
'.&titlefield($fields{$field}).''. - &Apache::lonmeta::prettyinput($field, + 'modifyinguser','keywords','notes','abstract', + 'standards','mime') { + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield($fields{$field})) + .&Apache::lonmeta::prettyinput($field, $env{'form.'.$field}, $field, 'advsearch', - $related_word_search{$field}, - '', + $related_word_search{$field}, + '', $env{'form.'.$field.'_related'}, 50); if ($related_word_search{$field}) { $scrout .= &mt('related words'); } else { - $scrout .= ' '; + $scrout .= ''; } - $scrout .= '
'.&titlefield($fields{$field}).''. - &Apache::lonmeta::prettyinput($field, + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield($fields{$field})) + .&Apache::lonmeta::prettyinput($field, $env{'form.'.$field}, $field, 'advsearch', - 0). - '
'. - &titlefield(&mt('MIME Type Category')).''. - &Apache::loncommon::filecategoryselect('category', - $env{'form.category'}). - '
'. - &titlefield(&mt('Domains')).''. - &Apache::loncommon::domain_select('domains', - $env{'form.domains'},1). - '
'; - $scrout .= '
'. - &titlefield(&mt('Copyright/Distribution')). - ''. - &Apache::lonmeta::selectbox('copyright', + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield(&mt('Copyright/Distribution'))) + .&Apache::lonmeta::selectbox('copyright', $env{'form.copyright'}, \&Apache::loncommon::copyrightdescription, ( undef, &Apache::loncommon::copyrightids) - ).'
'. - &titlefield(&mt('Language')).''. - &Apache::lonmeta::selectbox('language', + + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield(&mt('Language'))) + .&Apache::lonmeta::selectbox('language', $env{'form.language'}, \&Apache::loncommon::languagedescription, ('any',&Apache::loncommon::languageids) - ).'
\n"; - + ) + .&Apache::lonhtmlcommon::row_closure(); + # Portfolio Metadata if ($env{'form.area'} eq 'portfolio') { # Added fields my $curnumadd = $env{'form.numaddedfields'}; if ($curnumadd eq '') { $curnumadd = 1; } - $scrout .= '

'.&mt('Custom Metadata fields').'

'; - $scrout .= "\n"; - $scrout .= ''.''; + $scrout .= &Apache::lonhtmlcommon::row_headline() + .'

'.&mt('Custom Metadata fields').'

' + .&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title('') + .&mt('Field Name').' | '.&mt('Field Value(s)') + .&Apache::lonhtmlcommon::row_closure(); for (my $j=0; $j<$curnumadd; $j++) { my $num = $j+1; - $scrout .= ''. - ''; - } - $scrout .= '
 '. - &mt('Field Name').''. - &mt('Field Value(s)').'
'.&mt('Custom metadata [_1]: ',$num). - ''. - '
'. - '
'; - } else { + $scrout .= &Apache::lonhtmlcommon::row_title(&mt('Custom metadata [_1]',$num)) + .'' + .' ' + .'' + .&Apache::lonhtmlcommon::row_closure(); + } + $scrout .= &Apache::lonhtmlcommon::row_title('') + .'' + .'' + .&Apache::lonhtmlcommon::row_closure(); +} else { # # Dynamic metadata - $scrout .= '

'.&mt('Problem Statistics').'

'; - $scrout .= "\n"; - $scrout .= ''.''."\n"; + $scrout .= &Apache::lonhtmlcommon::row_headline() + .'

'.&mt('Problem Statistics').'

' + .&Apache::lonhtmlcommon::row_closure(); + $scrout .= &Apache::lonhtmlcommon::row_title('') + .&mt('Minimum').' | '.&mt('Maximum') + .&Apache::lonhtmlcommon::row_closure(); foreach my $statistic ({ name=>'count', description=>'Network-wide number of accesses (hits)',}, @@ -1013,20 +1030,21 @@ ENDHEADER description=>'Degree of difficulty',}, { name => 'disc', description=>'Degree of discrimination'}) { - $scrout .= ''.$/; - } - $scrout .= "
 '. - &mt('Minimum').''. - &mt('Maximum').'
'. - &titlefield(&mt($statistic->{'description'})). - ''. - ''. - '
\n"; - $scrout .= '

'.&mt('Evaluation Data').'

'; - $scrout .= "\n"; - $scrout .= ''.''."\n"; + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield(&mt($statistic->{'description'}))) + .'' + .' ' + .'' + .&Apache::lonhtmlcommon::row_closure(); + } + + $scrout .= &Apache::lonhtmlcommon::row_headline() + .'

'.&mt('Evaluation Data').'

' + .&Apache::lonhtmlcommon::row_closure(); + $scrout .= &Apache::lonhtmlcommon::row_title('') + .&mt('Minimum').' | '.&mt('Maximum') + .&Apache::lonhtmlcommon::row_closure(); foreach my $evaluation ( { name => 'clear', description => 'Material presented in clear way'}, @@ -1038,22 +1056,24 @@ ENDHEADER description => 'Material appears to be correct'}, { name => 'technical', description => 'Resource is technically correct'}){ - $scrout .= ''.$/; + $scrout .= &Apache::lonhtmlcommon::row_title(&titlefield(&mt($evaluation->{'description'}))) + .'' + .' ' + .'' + .&Apache::lonhtmlcommon::row_closure(); } - $scrout .= "
 '. - &mt('Minimum').''. - &mt('Maximum').'
'. - &titlefield(&mt($evaluation->{'description'})). - ''. - ''. - ''. - '
\n"; } # # Creation/Modification date limits - $scrout .= '

'.&mt('Creation and Modification dates').'

'; - $scrout .= "\n\n"; - $scrout .= "\n"; + $scrout .= &Apache::lonhtmlcommon::row_headline() + .'

'.&mt('Creation and Modification dates').'

' + .&Apache::lonhtmlcommon::row_closure(); + $scrout .= &Apache::lonhtmlcommon::row_title('') + .&mt('Month[_1]Day[_2]Year',' 'x14,' 'x6) + .&Apache::lonhtmlcommon::row_closure(); + my $cafter = &Apache::lonhtmlcommon::date_setter('advsearch', # formname 'creationdate1', # fieldname @@ -1072,10 +1092,13 @@ ENDHEADER '', # state 1, # no_hh_mm_ss ); - $scrout .= '' - .'' - .'' - .''; + $scrout .= &Apache::lonhtmlcommon::row_title(&mt('Created between')) + .$cafter + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::row_title(&mt('and')) + .$cbefore + .&Apache::lonhtmlcommon::row_closure(); + my $lafter = &Apache::lonhtmlcommon::date_setter('advsearch', 'revisiondate1', @@ -1094,15 +1117,18 @@ ENDHEADER '', # state 1, # no_hh_mm_ss ); - $scrout .= '' - .'' - .'' - .''; - $scrout.="
 ".&mt('Month[_1]Day[_2]Year',' 'x14,' 'x6)."
'.&mt('Created between').''.$cafter.'
'.&mt('and').''.$cbefore.'
'.&mt('Last modified between').''.$lafter.'
'.&mt('and').''.$lbefore.'
\n"; - $scrout.=< -ENDDOCUMENT + $scrout .= &Apache::lonhtmlcommon::row_title(&mt('Last modified between')) + .$lafter + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::row_title(&mt('and')) + .$lbefore + .&Apache::lonhtmlcommon::row_closure(1); # Last row of total pick_box + + $scrout .= &Apache::lonhtmlcommon::end_pick_box(); + + $scrout .= $advanced_buttons + .''; + $scrout .= &Apache::loncommon::end_page(); $r->print($scrout); return; @@ -1172,21 +1198,23 @@ Outputs: text for box with view options ###################################################################### ###################################################################### sub viewoptions { - my $scrout = ''; + my $scrout; 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; } @@ -2167,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; } ## @@ -2251,6 +2283,7 @@ sub print_sort_form { } my $js =< +// END @@ -2400,16 +2434,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(); } @@ -2436,9 +2482,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; @@ -2470,7 +2521,7 @@ sub revise_button { '&cleargroupsort=1'. '&phase='.$revise_phase; my $result = qq{ }; + qq{ onclick="parent.location='$newloc';" /> }; return $result; } @@ -2691,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 @@ -2701,11 +2752,11 @@ END # loaded from /adm/searchcat $r->print(&Apache::loncommon::end_page()); # if ($env{'form.catalogmode'} ne 'import') { - $r->print(""); + $r->print(< +window.location='/adm/searchcat?phase=sort&persistent_db_id=$env{'form.persistent_db_id'}'; + +SCRIPT # } return; } @@ -2728,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 .= '' + .'' + .' ' + .'' + .' ' + .'' + .'

'; } ###################################################################### @@ -2905,29 +2956,32 @@ 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 - ('
'. - ''.$sortform.''. - ''. - &prev_next_buttons($min,$env{'form.show'},$total_results). - ''. - &viewoptions().'
' - ); + ## Display links for 'prev' and 'next' pages (if necessary) and Display Options + $r->print('
'."\n" + .''.&mt('Display Options').''."\n" + .$sortform + .' ' + .&viewoptions() + .'
' + .&prev_next_buttons($min,$env{'form.show'},$total_results) + ); + if ($total_results == 0) { $r->print(''. - '

'.&mt('There are currently no results').'.

'. + '

'.&mt('There are currently no results.').'

'. "". &Apache::loncommon::end_page()); return; @@ -2995,15 +3049,13 @@ sub display_results { .&mt('There were no results matching your query.') .'

'); } else { - $r->print - ('
'. - &prev_next_buttons($min,$env{'form.show'},$total_results, + $r->print( + &prev_next_buttons($min,$env{'form.show'},$total_results, "table=".$env{'form.table'}. "&phase=results". "&persistent_db_id=". $env{'form.persistent_db_id'}) - ."
\n" - ); + ); } $r->print("".&Apache::loncommon::end_page()); $r->rflush(); @@ -3033,7 +3085,7 @@ sub catalogmode_output { if ($env{'form.catalogmode'} eq 'interactive') { $output.=< +onclick="javascript:select_data('$title','$url')" /> END } @@ -3043,7 +3095,7 @@ END $output.=< +onclick="javascript:queue($checkbox_num,$fnum)" /> END } @@ -3212,6 +3264,7 @@ sub search_results_header { if (! exists($env{'form.mode'}) || $env{'form.mode'} ne 'edit') { $js.=< +// SCRIPT } elsif ($env{'form.mode'} eq 'edit') { @@ -3251,6 +3305,7 @@ END $js.=< +// SCRIPT } @@ -3272,6 +3328,7 @@ SCRIPT my $inhibit_menu = "&".&Apache::loncommon::inhibit_menu_check(); $js.=< SCRIPT @@ -3324,8 +3382,10 @@ sub print_frames_interface { my $results_link = &results_link(); my $js = < +// JS @@ -3824,21 +3884,30 @@ 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 $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.'


'; + } else { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'', + text=>$heading,}); + $start_page .= &Apache::lonhtmlcommon::breadcrumbs(); + } + $r->print(< $hidden_fields $closebutton -
+

$heading

$errormsg

-$revise  +$revise

$end_page ENDPAGE @@ -3875,7 +3944,7 @@ $start_page
$hidden_fields +onclick='this.form.submit();' /> $closebutton