Diff for /loncom/interface/lonsearchcat.pm between versions 1.168 and 1.170

version 1.168, 2003/03/08 03:24:58 version 1.170, 2003/03/10 21:22:36
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},$fulltext,@allwords);             &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 482  sub checkonthis { Line 492  sub checkonthis {
            $r->print('&nbsp;');             $r->print('&nbsp;');
        }         }
        $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');
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,  
             fullindex => \@Fullindicies,              fullindex => \@Fullindicies,
         } );          } );
     if (defined($table)) {      if (defined($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'});

Removed from v.1.168  
changed lines
  Added in v.1.170


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>