');
}
# Check discussions if requested
@@ -519,72 +532,77 @@ sub course_search {
my $totaldiscussions = 0;
$r->print('
'.&mt('Discussion postings').': ');
my $navmap = Apache::lonnavmaps::navmap->new();
- my @allres=$navmap->retrieveResources();
- my %discussiontime = &Apache::lonnet::dump('discussiontimes',
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
- foreach my $resource (@allres) {
- my $result = '';
- my $applies = 0;
- my $symb = $resource->symb();
- my $ressymb = $symb;
- if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) {
- $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
- unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) {
- $ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#;
+ if (defined($navmap)) {
+ my @allres=$navmap->retrieveResources();
+ my %discussiontime = &Apache::lonnet::dump('discussiontimes',
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ foreach my $resource (@allres) {
+ my $result = '';
+ my $applies = 0;
+ my $symb = $resource->symb();
+ my $ressymb = $symb;
+ if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) {
+ $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
+ unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) {
+ $ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#;
+ }
}
- }
- if (defined($discussiontime{$ressymb})) {
- my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
- if ($contrib{'version'}) {
- for (my $id=1;$id<=$contrib{'version'};$id++) {
- unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) {
- if ($contrib{$id.':subject'}) {
- $result .= $contrib{$id.':subject'};
- }
- if ($contrib{$id.':message'}) {
- $result .= $contrib{$id.':message'};
- }
- if ($contrib{$id,':attachmenturl'}) {
- if ($contrib{$id,':attachmenturl'} =~ m-/([^/]+)$-) {
- $result .= $1;
+ if (defined($discussiontime{$ressymb})) {
+ my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ if ($contrib{'version'}) {
+ for (my $id=1;$id<=$contrib{'version'};$id++) {
+ unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) {
+ if ($contrib{$id.':subject'}) {
+ $result .= $contrib{$id.':subject'};
+ }
+ if ($contrib{$id.':message'}) {
+ $result .= $contrib{$id.':message'};
+ }
+ if ($contrib{$id,':attachmenturl'}) {
+ if ($contrib{$id,':attachmenturl'} =~ m-/([^/]+)$-) {
+ $result .= $1;
+ }
}
+ $applies = &checkwords($result,$applies,@allwords);
}
- $applies = &checkwords($result,$applies,@allwords);
}
}
}
- }
# Does this discussion apply?
- if ($applies) {
- my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb);
- my $disctype = &mt('resource');
- if ($url =~ m#/bulletinboard$#) {
- if ($url =~m#^adm/wrapper/adm/.*/bulletinboard$#) {
- $url =~s#^adm/wrapper##;
+ if ($applies) {
+ my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb);
+ my $disctype = &mt('resource');
+ if ($url =~ m#/bulletinboard$#) {
+ if ($url =~m#^adm/wrapper/adm/.*/bulletinboard$#) {
+ $url =~s#^adm/wrapper##;
+ }
+ $disctype = &mt('discussion board');
+ } else {
+ $url = '/res/'.$url;
}
- $disctype = &mt('bulletin board');
- } else {
- $url = '/res/'.$url;
- }
- if ($url =~ /\?/) {
- $url .= '&symb=';
+ if ($url =~ /\?/) {
+ $url .= '&symb=';
+ } else {
+ $url .= '?symb=';
+ }
+ $url .= &escape($resource->symb());
+ my $title = $resource->compTitle();
+ $r->print(' '.
+ ($title?$title:$url).' - '.
+ $disctype.' ');
+ $totaldiscussions++;
} else {
- $url .= '?symb=';
+ $r->print(' .');
}
- $url .= &escape($resource->symb());
- my $title = $resource->compTitle();
- $r->print(' '.
- ($title?$title:$url).' - '.$disctype.' ');
- $totaldiscussions++;
- } else {
- $r->print(' .');
}
- }
- unless ($totaldiscussions) {
- $r->print('
'.&mt('No matches found in postings').'.
');
+ unless ($totaldiscussions) {
+ $r->print('
'.&mt('No matches found in postings.').'
');
+ }
+ } else {
+ $r->print('
'.&mt('An error occurred retrieving information about resources in the course.').' '.&mt('It is recommended that you [_1]re-initialize the course[_2] and then try your search again.','','').'
');
}
}
@@ -685,7 +703,7 @@ sub print_basic_search_form {
my $bread_crumb =
&Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
$env{'form.catalogmode'} ne 'import');
- my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;
+ my $scrout = &Apache::loncommon::start_page('Content Library').$bread_crumb;
# Search form for resource space
if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
$scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
@@ -699,7 +717,7 @@ sub print_basic_search_form {
'note' => 'Enter terms or phrases, then press "Search" below',
'use' => 'use related words',
'full' =>'fulltext search (time consuming)',
- 'disc' => 'search discussion postings (resources and bulletin boards)',
+ 'disc' => 'search discussion postings (resources and discussion boards)',
);
$scrout.=(<
@@ -711,7 +729,6 @@ $hidden_fields
'.'';
return $scrout;
}
@@ -834,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
-';
+
$scrout .= &Apache::loncommon::end_page();
$r->print($scrout);
return;
@@ -1154,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;
}
@@ -2149,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;
}
##
@@ -2233,18 +2283,19 @@ sub print_sort_form {
}
my $js =<
+//
END
- my $start_page = &Apache::loncommon::start_page('Results',$js,
- {'no_title' => 1});
+ my $start_page = &Apache::loncommon::start_page('Results',$js);
my $breadcrumbs=
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
$env{'form.catalogmode'} ne 'import');
@@ -2383,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();
}
@@ -2419,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;
@@ -2450,10 +2518,10 @@ sub revise_button {
$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;
+ '&cleargroupsort=1'.
+ '&phase='.$revise_phase;
my $result = qq{ };
+ qq{ onclick="parent.location='$newloc';" /> };
return $result;
}
@@ -2482,8 +2550,7 @@ sub run_search {
#
# Print run_search header
#
- my $start_page = &Apache::loncommon::start_page('Search Status',undef,
- {'no_title' => 1});
+ my $start_page = &Apache::loncommon::start_page('Search Status',undef);
my $breadcrumbs =
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
$env{'form.catalogmode'} ne 'import');
@@ -2675,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
@@ -2685,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;
}
@@ -2712,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 .= ''
+ .''
+ .' '
+ .''
+ .' '
+ .''
+ .'
';
}
######################################################################
@@ -2745,7 +2812,9 @@ sub display_results {
##
my $viewfunction = $Views{$env{'form.viewselect'}};
if (!defined($viewfunction)) {
- $r->print("Internal Error - Bad view selected.\n");
+ $r->print('
'
+ .&mt('Internal Error - Bad view selected.')
+ .'
'."\n");
$r->rflush();
return;
}
@@ -2762,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;
@@ -2776,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);
@@ -2881,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
- ('
'.
mt('Results [_1] to [_2] out of [_3]',
$min,$max,$total_results).
- "\n");
+ "
\n");
}
##
## Get results from MySQL table
@@ -2941,13 +3019,14 @@ sub display_results {
if ($area eq 'portfolio') {
$tabletype = 'portfolio_search';
}
+ $r->print(&Apache::loncommon::start_data_table());
foreach my $row (@Results) {
if ($connection->aborted()) {
&cleanup();
return;
}
my %Fields = %{&parse_row($tabletype,@$row)};
- my $output="
\n";
+ my $output;
if (! defined($Fields{'title'}) || $Fields{'title'} eq '') {
$Fields{'title'} = 'Untitled';
}
@@ -2956,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()
+ .'
'
+ .$output
+ .'
'
+ .&Apache::loncommon::end_data_table_row()
+ );
$r->rflush();
}
+ $r->print(&Apache::loncommon::end_data_table());
if (@Results < 1) {
- $r->print(&mt("There were no results matching your query"));
+ $r->print('
'
+ .&mt('There were no results matching your query.')
+ .'
$end_page
ENDPAGE
@@ -3795,23 +3882,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 = '
$end_page
ENDPAGE
@@ -3842,16 +3938,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(<
$hidden_fields
+onclick='this.form.submit();' />
$closebutton
+
-