version 1.167, 2003/03/08 01:43:12
|
version 1.172, 2003/03/17 18:35:51
|
Line 142 my %persistent_db;
|
Line 142 my %persistent_db;
|
my $hidden_fields; |
my $hidden_fields; |
my $bodytag; |
my $bodytag; |
|
|
|
# |
|
# For course search |
|
# |
my %alreadyseen; |
my %alreadyseen; |
my $hashtied; |
my $hashtied; |
my %hash; |
my %hash; |
|
my $totalfound; |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 418 sub course_search {
|
Line 422 sub course_search {
|
} |
} |
my $fulltext=$ENV{'form.crsfulltext'}; |
my $fulltext=$ENV{'form.crsfulltext'}; |
my @allwords=($search_string,@New_Words); |
my @allwords=($search_string,@New_Words); |
|
$totalfound=0; |
$r->print('<html><head><title>LON-CAPA Course Search</title></head>'. |
$r->print('<html><head><title>LON-CAPA Course Search</title></head>'. |
$bodytag.$pretty_search_string); |
$bodytag.$pretty_search_string); |
$r->rflush(); |
$r->rflush(); |
Line 425 sub course_search {
|
Line 430 sub course_search {
|
$hashtied=0; |
$hashtied=0; |
undef %alreadyseen; |
undef %alreadyseen; |
%alreadyseen=(); |
%alreadyseen=(); |
|
my $c=$r->connection; |
&tiehash(); |
&tiehash(); |
foreach (keys %hash) { |
foreach (keys %hash) { |
|
if ($c->aborted()) { last; } |
if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) { |
if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) { |
&checkonthis($r,$hash{$_},0,$hash{'title_'.$1},@allwords,$fulltext); |
&checkonthis($r,$hash{$_},0,$hash{'title_'.$1},$fulltext,@allwords); |
} |
} |
} |
} |
&untiehash(); |
&untiehash(); |
|
unless ($totalfound) { |
|
$r->print('<p>No resources found.</p>'); |
|
} |
# =================================================== Done going through course |
# =================================================== Done going through course |
$r->print('</body></html>'); |
$r->print('</body></html>'); |
} |
} |
Line 456 sub untiehash {
|
Line 466 sub untiehash {
|
# =============================== This pulls up a resource and its dependencies |
# =============================== This pulls up a resource and its dependencies |
|
|
sub checkonthis { |
sub checkonthis { |
my ($r,$url,$level,$title,@allwords,$fulltext)=@_; |
my ($r,$url,$level,$title,$fulltext,@allwords)=@_; |
$alreadyseen{$url}=1; |
$alreadyseen{$url}=1; |
$r->rflush(); |
$r->rflush(); |
my $result=&Apache::lonnet::metadata($url,'title').' '. |
my $result=&Apache::lonnet::metadata($url,'title').' '. |
Line 464 sub checkonthis {
|
Line 474 sub checkonthis {
|
&Apache::lonnet::metadata($url,'abstract').' '. |
&Apache::lonnet::metadata($url,'abstract').' '. |
&Apache::lonnet::metadata($url,'keywords'); |
&Apache::lonnet::metadata($url,'keywords'); |
if (($url) && ($fulltext)) { |
if (($url) && ($fulltext)) { |
$result.=&Apache::lonnet::ssibody($url); |
$result.=&Apache::lonnet::ssi_body($url); |
} |
} |
$result=~s/\s+/ /gs; |
$result=~s/\s+/ /gs; |
my $applies=0; |
my $applies=0; |
Line 482 sub checkonthis {
|
Line 492 sub checkonthis {
|
$r->print(' '); |
$r->print(' '); |
} |
} |
$r->print('<a href="'.$url.'" target="cat">'. |
$r->print('<a href="'.$url.'" target="cat">'. |
($title?$title:$url).'</a>'); |
($title?$title:$url).'</a><br />'); |
$r->rflush(); |
$totalfound++; |
|
} elsif ($fulltext) { |
|
$r->print(' .'); |
} |
} |
|
$r->rflush(); |
# Check also the dependencies of this one |
# Check also the dependencies of this one |
my $dependencies= |
my $dependencies= |
&Apache::lonnet::metadata($url,'dependencies'); |
&Apache::lonnet::metadata($url,'dependencies'); |
foreach (split(/\,/,$dependencies)) { |
foreach (split(/\,/,$dependencies)) { |
if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { |
if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { |
&checkonthis($r,$_,$level+1,'',@allwords,$fulltext); |
&checkonthis($r,$_,$level+1,'',$fulltext,@allwords); |
} |
} |
} |
} |
} |
} |
Line 1885 the following format:
|
Line 1898 the following format:
|
|
|
=cut |
=cut |
|
|
## |
##################################################################### |
## Restrictions: |
##################################################################### |
## columns of type 'text' and 'blob' cannot have defaults. |
|
## columns of type 'enum' cannot be used for FULLTEXT. |
my @Datatypes = |
## |
( { name => 'id', |
my @DataOrder = qw/id title author subject url keywords version notes |
type => 'MEDIUMINT', |
abstract mime lang owner copyright creationdate lastrevisiondate hostname/; |
restrictions => 'UNSIGNED NOT NULL', |
|
primary_key => 'yes', |
my %Datatypes = |
auto_inc => 'yes' }, |
( id =>{ type => 'MEDIUMINT', |
{ name => 'title', type=>'TEXT'}, |
restrictions => 'UNSIGNED NOT NULL', |
{ name => 'author', type=>'TEXT'}, |
primary_key => 'yes', |
{ name => 'subject', type=>'TEXT'}, |
auto_inc => 'yes' |
{ name => 'url', type=>'TEXT', restrictions => 'NOT NULL' }, |
}, |
{ name => 'keywords', type=>'TEXT'}, |
title =>{ type=>'TEXT'}, |
{ name => 'version', type=>'TEXT'}, |
author =>{ type=>'TEXT'}, |
{ name => 'notes', type=>'TEXT'}, |
subject =>{ type=>'TEXT'}, |
{ name => 'abstract', type=>'TEXT'}, |
url =>{ type=>'TEXT', |
{ name => 'mime', type=>'TEXT'}, |
restrictions => 'NOT NULL' }, |
{ name => 'lang', type=>'TEXT'}, |
keywords =>{ type=>'TEXT'}, |
{ name => 'owner', type=>'TEXT'}, |
version =>{ type=>'TEXT'}, |
{ name => 'copyright', type=>'TEXT'}, |
notes =>{ type=>'TEXT'}, |
{ name => 'hostname', type=>'TEXT'}, |
abstract =>{ type=>'TEXT'}, |
|
mime =>{ type=>'TEXT'}, |
|
lang =>{ type=>'TEXT'}, |
|
owner =>{ type=>'TEXT'}, |
|
copyright =>{ type=>'TEXT'}, |
|
hostname =>{ type=>'TEXT'}, |
|
#-------------------------------------------------- |
#-------------------------------------------------- |
creationdate =>{ type=>'DATETIME'}, |
{ name => 'creationdate', type=>'DATETIME'}, |
lastrevisiondate =>{ type=>'DATETIME'}, |
{ name => 'lastrevisiondate', type=>'DATETIME'}, |
#-------------------------------------------------- |
#-------------------------------------------------- |
); |
); |
|
|
Line 1943 Returns: the identifier of the table on
|
Line 1950 Returns: the identifier of the table on
|
###################################################################### |
###################################################################### |
sub create_results_table { |
sub create_results_table { |
my $table = &Apache::lonmysql::create_table |
my $table = &Apache::lonmysql::create_table |
( { columns => \%Datatypes, |
( { columns => \@Datatypes, |
column_order => \@DataOrder, |
FULLTEXT => [{'columns' => \@Fullindicies},], |
fullindex => \@Fullindicies, |
|
} ); |
} ); |
if (defined($table)) { |
if (defined($table)) { |
$ENV{'form.table'} = $table; |
$ENV{'form.table'} = $table; |
Line 2471 sub parse_row {
|
Line 2477 sub parse_row {
|
my @Row = @_; |
my @Row = @_; |
my %Fields; |
my %Fields; |
for (my $i=0;$i<=$#Row;$i++) { |
for (my $i=0;$i<=$#Row;$i++) { |
$Fields{$DataOrder[$i]}=&Apache::lonnet::unescape($Row[$i]); |
$Fields{$Datatypes[$i]->{'name'}}=&Apache::lonnet::unescape($Row[$i]); |
} |
} |
$Fields{'language'} = |
$Fields{'language'} = |
&Apache::loncommon::languagedescription($Fields{'lang'}); |
&Apache::loncommon::languagedescription($Fields{'lang'}); |