--- loncom/interface/lonsearchcat.pm 2004/04/19 17:44:47 1.211 +++ loncom/interface/lonsearchcat.pm 2004/04/21 15:48:34 1.213 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.211 2004/04/19 17:44:47 matthew Exp $ +# $Id: lonsearchcat.pm,v 1.213 2004/04/21 15:48:34 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -74,6 +74,7 @@ use Apache::lonmeta; use Apache::lonhtmlcommon; use Apache::lonlocal; use LONCAPA::lonmetadata(); +use HTML::Entities(); ###################################################################### ###################################################################### @@ -149,7 +150,8 @@ sub handler { ## Initialize global variables ## my $domain = $r->dir_config('lonDefDomain'); - $diropendb= "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db"; + $diropendb= "/home/httpd/perl/tmp/". + "$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db"; # # set the name of the persistent database # $ENV{'form.persistent_db_id'} can only have digits in it. @@ -534,64 +536,75 @@ sub print_basic_search_form { undef,undef,! $ENV{'form.launch'}); my $scrout = &search_html_header().$bodytag; if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) { - my $Statement=&searchhelp(); - $scrout.=(< - -$hidden_fields -

-$Statement. -

-

- -'. + ''. + ''.$/; + # +# $scrout .= ''.$/; + $scrout .= ''.$/; + $scrout .= '
-ENDDOCUMENT - $scrout.=' '. + # Define interface components + my $userelatedwords= + &mt('[_1] use related words', + &Apache::lonhtmlcommon::checkbox + ('related',$ENV{'form.related'})); + my $onlysearchdomain= + &mt('[_1] only search domain [_2]', + &Apache::lonhtmlcommon::checkbox + ('domains',$ENV{'form.domains'}), + $r->dir_config('lonDefDomain')); + my $adv_search_link = + ''.&mt('Advanced Search').''; + # + $scrout.='
'. + ''. + $hidden_fields; + # + $scrout .= '
'.$/; + if ($ENV{'request.course.id'}) { + $scrout .= '

'.&mt('LON-CAPA Catalog Search').'

'; + } else { + # No need to tell them they are searching + $scrout.= ('
'x2); + } + $scrout.=''. + ' - - -
'. &Apache::lonhtmlcommon::textbox('basicexp', - $ENV{'form.basicexp'},40). - ' '; - my $relatedcheckbox = - &Apache::lonhtmlcommon::checkbox('related', - $ENV{'form.related'}); - my $domain = $r->dir_config('lonDefDomain'); - my $domaincheckbox = - &Apache::lonhtmlcommon::checkbox('domains', - $ENV{'form.domains'}); - my $srch=&mt('Search'); - my $header=&mt('Advanced Search'); - my $userelatedwords=&mt('use related words'); - my $onlysearchdomain=&mt('only search domain'); - my $view=&viewoptions(); - $scrout.=<$header
$relatedcheckbox $userelatedwords$domaincheckbox $onlysearchdomain $domain
-

-$view -

  -$closebutton -END - $scrout.=< - -ENDDOCUMENT + $ENV{'form.basicexp'},50).'
'. + ''.&searchhelp().''.'

'. + ''.(' 'x3).$adv_search_link.''.'
'. + ''.(' 'x1).$userelatedwords.''.'
'. + ''.(' 'x1).$onlysearchdomain.''.'
'. + '
'. +# ''. +# $userelatedwords.(' 'x3). +# $onlysearchdomain.(' 'x2).$adv_search_link. +# ''. +# '
'. + ''. + ''. + (' 'x2).$closebutton.(' 'x2).&viewoptions(). + ''. + '
'.$/.''.''; } if ($ENV{'request.course.id'}) { - my %lt=&Apache::lonlocal::texthash( - 'srch' => 'Search', + my %lt=&Apache::lonlocal::texthash('srch' => 'Search', 'header' => 'Course Search', 'note' => 'Enter terms or phrases, then press "Search" below', 'use' => 'use related words', 'full' =>'fulltext search (time consuming)' ); $scrout.=(< +


$lt{'header'}

-
$hidden_fields

@@ -617,6 +630,8 @@ ENDCOURSESEARCH

 

+
+ ENDENDCOURSE } $scrout.=(< 'id', + # Copy the table description before modifying it... + @Datatypes = @{$datatypes}; + unshift(@Datatypes,{name => 'id', type => 'MEDIUMINT', restrictions => 'UNSIGNED NOT NULL', primary_key => 'yes', auto_inc => 'yes' }); - @Datatypes = @{$datatypes}; @Fullindicies = @{$fullindicies}; return; } @@ -1926,6 +1942,7 @@ END &update_status($r,'contacting '.$Servers_to_contact[0]); while (($time_remaining > 0) && ((@Servers_to_contact) || keys(%Server_status))) { + $time_remaining = $max_time - (time - $starttime) ; &update_seconds($r,$time_remaining); # Send out a search request if it needs to be done. if (@Servers_to_contact) { @@ -2201,6 +2218,7 @@ sub display_results { } my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'}, $Fields{'id'},$checkbox_num++); + # Render the result into html $output.= &$viewfunction($prefix,%Fields); # Print them out as they come in. @@ -2716,34 +2734,38 @@ END ###################################################################### sub xml_sgml_view { my ($prefix,%values) = @_; + my $xml = < +$values{'url'} +$values{'title'} +$values{'author'} +$values{'subject'} +$values{'keywords'} +$values{'notes'} + +$values{'mime'} +$values{'mimetag'} + + +$values{'language'} +$values{'languagetag'} + +$values{'creationdate'} +$values{'lastrevisiondate'} +$values{'owner'} + +$values{'copyright'} +$values{'copyrighttag'} + +$values{'hostname'} +$values{'shortabstract'} + +END + $xml = &HTML::Entities::encode($xml,'<>&'); my $result=< -<LonCapaResource> -<url>$values{'url'}</url> -<title>$values{'title'}</title> -<author>$values{'author'}</author> -<subject>$values{'subject'}</subject> -<keywords>$values{'keywords'}</keywords> -<notes>$values{'notes'}</notes> -<mimeInfo> -<mime>$values{'mime'}</mime> -<mimetag>$values{'mimetag'}</mimetag> -</mimeInfo> -<languageInfo> -<language>$values{'language'}</language> -<languagetag>$values{'languagetag'}</languagetag> -</languageInfo> -<creationdate>$values{'creationdate'}</creationdate> -<lastrevisiondate>$values{'lastrevisiondate'}</lastrevisiondate> -<owner>$values{'owner'}</owner> -<copyrightInfo> -<copyright>$values{'copyright'}</copyright> -<copyrighttag>$values{'copyrighttag'}</copyrighttag> -</copyrightInfo> -<repositoryLocation>$values{'hostname'}</repositoryLocation> -<shortabstract>$values{'shortabstract'}</shortabstract> -</LonCapaResource> +$xml $values{'extrashow'}