--- loncom/interface/lonsearchcat.pm 2006/03/19 22:08:38 1.258
+++ loncom/interface/lonsearchcat.pm 2006/09/26 15:24:18 1.276
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.258 2006/03/19 22:08:38 albertel Exp $
+# $Id: lonsearchcat.pm,v 1.276 2006/09/26 15:24:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -78,6 +78,8 @@ use HTML::Entities();
use Parse::RecDescent;
use Apache::lonnavmaps;
use Apache::lonindexer();
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
######################################################################
######################################################################
@@ -137,7 +139,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']);
##
## 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
@@ -153,7 +155,7 @@ sub handler {
##
my $domain = $r->dir_config('lonDefDomain');
$diropendb= "/home/httpd/perl/tmp/".
- "$env{'user.domain'}_$env{'user.name'}_searchcat.db";
+ "$env{'user.domain'}_$env{'user.name'}_sel_res.db";
#
# set the name of the persistent database
# $env{'form.persistent_db_id'} can only have digits in it.
@@ -164,8 +166,8 @@ sub handler {
}
my $persistent_db_file = "/home/httpd/perl/tmp/".
- &Apache::lonnet::escape($domain).
- '_'.&Apache::lonnet::escape($env{'user.name'}).
+ &escape($domain).
+ '_'.&escape($env{'user.name'}).
'_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
##
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -199,7 +201,9 @@ sub handler {
'We were unable to retrieve data describing your search. '.
'This is a serious error and has been logged. '.
'Please alert your LON-CAPA administrator.';
- return &error_page($r,$msg);
+ &Apache::loncommon::simple_error_page($r,'Search Error',
+ $msg);
+ return OK;
}
}
} else {
@@ -211,7 +215,7 @@ sub handler {
untie %groupsearch_db if (tied(%groupsearch_db));
if (($env{'form.cleargroupsort'} eq '1') ||
(($env{'form.launch'} eq '1') &&
- ($env{'form.catalogmode'} eq 'groupsearch'))) {
+ ($env{'form.catalogmode'} eq 'import'))) {
if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
&start_fresh_session();
untie %groupsearch_db;
@@ -220,7 +224,9 @@ sub handler {
# This is a stupid error to give to the user.
# It really tells them nothing.
my $msg = 'Unable to tie hash to db file.';
- return &error_page($r,$msg);
+ &Apache::loncommon::simple_error_page($r,'Search Error',
+ $msg);
+ return OK;
}
}
##
@@ -243,6 +249,9 @@ sub handler {
if (exists($env{'form.mode'})) {
$hidden_fields .= &hidden_field('mode');
}
+ if (exists($env{'form.area'})) {
+ $hidden_fields .= &hidden_field('area');
+ }
##
## Configure dynamic components of interface
##
@@ -254,7 +263,7 @@ sub handler {
$closebutton .="onClick='self.close()'";
}
$closebutton .=">\n";
- } elsif ($env{'form.catalogmode'} eq 'groupsearch') {
+ } elsif ($env{'form.catalogmode'} eq 'import') {
$closebutton="print(&Apache::loncommon::start_page('Search Error').
- &mt($msg).
- &Apache::loncommon::end_page());
- return OK;
-}
-
#
# The mechanism used to store values away and retrieve them does not
# handle the case of missing environment variables being significant.
@@ -551,7 +557,7 @@ sub course_search {
} else {
$url .= '?symb=';
}
- $url .= &Apache::lonnet::escape($resource->symb());
+ $url .= &escape($resource->symb());
my $title = $resource->compTitle();
$r->print(' '.
($title?$title:$url).' - '.$disctype.' ');
@@ -587,7 +593,7 @@ sub checkonthis {
my ($extension)=($url=~/\.(\w+)$/);
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' &&
($url) && ($fulltext)) {
- $result.=&Apache::lonnet::ssi_body($url.'?symb='.&Apache::lonnet::escape($symb));
+ $result.=&Apache::lonnet::ssi_body($url.'?symb='.&escape($symb));
}
$result=~s/\s+/ /gs;
my $applies = 0;
@@ -603,7 +609,7 @@ sub checkonthis {
$href=&Apache::lonenc::encrypted($href)
.'?symb='.&Apache::lonenc::encrypted($symb);
} else {
- $href.='?symb='.&Apache::lonnet::escape($symb);
+ $href.='?symb='.&escape($symb);
}
$r->print(''.($title?$title:$url).
' ');
@@ -658,76 +664,18 @@ Prints the form for the basic search. S
######################################################################
sub print_basic_search_form {
my ($r,$closebutton,$hidden_fields) = @_;
- my $result = ($env{'form.catalogmode'} ne 'groupsearch');
+ my $result = ($env{'form.catalogmode'} ne 'import');
my $bread_crumb =
- &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic',
- undef,undef,
- $env{'form.catalogmode'} ne 'groupsearch');
+ &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
+ $env{'form.catalogmode'} ne 'import');
my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;
+# Search form for resource space
if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
- # Define interface components
- my $userelatedwords= '';
- my $onlysearchdomain='';
- my $inclext= '';
- my $adv_search_link =
- ''.&mt('Advanced Search').'';
- #
- $scrout.='
';
+ $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
+ $scrout .= ' ';
}
+# Search form for accessible portfolio files
+ $scrout.= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
if ($env{'request.course.id'}) {
my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
'header' => 'Course Search',
@@ -778,6 +726,75 @@ ENDENDCOURSE
$r->print($scrout);
return;
}
+
+sub setup_basic_search {
+ my ($r,$area,$hidden_fields,$closebutton) = @_;
+ # Define interface components
+ my %lt = &Apache::lonlocal::texthash (
+ res => 'LON-CAPA Catalog Search',
+ portfolio => 'Portfolio Search',
+ );
+ my ($userelatedwords,$onlysearchdomain,$inclext,$adv_search_link,$scrout);
+ $userelatedwords = '';
+ $onlysearchdomain = '';
+ if ($area eq 'res') {
+ $inclext= '';
+ }
+ $adv_search_link = ''.&mt('Advanced Search').'';
+ #
+ $scrout.='';
+ return $scrout;
+}
+
######################################################################
######################################################################
@@ -794,10 +811,8 @@ Prints the advanced search form.
sub print_advanced_search_form{
my ($r,$closebutton,$hidden_fields) = @_;
my $bread_crumb =
- &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',
- 'Search_Advanced',
- undef,undef,
- $env{'form.catalogmode'} ne 'groupsearch');
+ &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Advanced',
+ $env{'form.catalogmode'} ne 'import');
my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
'reset' => 'Reset',
'help' => 'Help');
@@ -874,20 +889,26 @@ ENDHEADER
&titlefield(&mt('Domains')).'
'."\n";
- foreach my $statistic
- ({ name=>'count',
- description=>'Network-wide number of accesses (hits)',},
- { name=>'stdno',
- description=>
- 'Total number of students who have worked on this problem',},
- { name => 'avetries',
- description=>'Average number of tries till solved',},
- { name => 'difficulty',
- description=>'Degree of difficulty',},
- { name => 'disc',
- description=>'Degree of discrimination'}) {
- $scrout .= '
'."\n";
+ foreach my $statistic
+ ({ name=>'count',
+ description=>'Network-wide number of accesses (hits)',},
+ { name=>'stdno',
+ description=>
+ 'Total number of students who have worked on this problem',},
+ { name => 'avetries',
+ description=>'Average number of tries till solved',},
+ { name => 'difficulty',
+ description=>'Degree of difficulty',},
+ { name => 'disc',
+ description=>'Degree of discrimination'}) {
+ $scrout .= '