Diff for /loncom/interface/lonsearchcat.pm between versions 1.67 and 1.86

version 1.67, 2001/03/22 13:33:07 version 1.86, 2001/03/27 19:57:53
Line 94  sub handler { Line 94  sub handler {
 END  END
   
     $closebutton=<<END if $ENV{'form.catalogmode'} eq 'interactive';      $closebutton=<<END if $ENV{'form.catalogmode'} eq 'interactive';
 <input type="button" name="close" value="CLOSE" onClick="self.close()">  <input type="button" name="close" value='CLOSE' onClick="self.close()">
 END  END
   
 # ------------------------------------------------ First, check out environment  # ------------------------------------------------ First, check out environment
Line 229  LASTREVISIONDATEEND Line 229  LASTREVISIONDATEEND
 # ------------------------------------------- Compute customized metadata field  # ------------------------------------------- Compute customized metadata field
     $scrout.=<<CUSTOMMETADATA;      $scrout.=<<CUSTOMMETADATA;
 <p>  <p>
 <font color="#800000" face="helvetica"><b>LIMIT BY OTHER METADATA FIELDS:</b>  <font color="#800000" face="helvetica"><b>LIMIT BY SPECIAL METADATA FIELDS:</b>
 </font>  </font>
 For author-specific metadata, enter in an expression in the form of   For resource-specific metadata, enter in an expression in the form of 
 <i>key</i>=<i>value</i> separated by operators such as AND or OR.<br>  <i>key</i>=<i>value</i> separated by operators such as AND or OR.<br>
 <b>Example:</b> grandmother=75 OR grandfather=85  <b>Example:</b> grandmother=75 OR grandfather=85
 <br>  <br>
Line 239  CUSTOMMETADATA Line 239  CUSTOMMETADATA
 $scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'});  $scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'});
 $scrout.=' <i>initial users of this system do not need to worry about this option</i>';  $scrout.=' <i>initial users of this system do not need to worry about this option</i>';
   
       $scrout.=<<CUSTOMSHOW;
   <p>
   <font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b>
   </font>
   Enter in a space-separated list of special metadata fields to show
   in a fielded listing for each record result.
   <br>
   CUSTOMSHOW
   $scrout.=&simpletextfield('customshow',$ENV{'form.customshow'});
   $scrout.=' <i>initial users of this system do not need to worry about this option</i>';
   
 # ---------------------------------------------------------------- Print screen  # ---------------------------------------------------------------- Print screen
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);
 <html>  <html>
Line 267  ENDDOCUMENT Line 278  ENDDOCUMENT
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);
 <font color="#800000">Search historic archives</font>  <font color="#800000">Search historic archives</font>
 <br>  <br>
 <input type="submit" name="basicsubmit" value="SEARCH">  <input type="submit" name="basicsubmit" value='SEARCH' />
 <input type="reset" name="reset" value="RESET">  <input type="reset" name="reset" value='RESET' />
 $closebutton  $closebutton
 $basicviewselect  $basicviewselect
 </p>  </p>
Line 276  $basicviewselect Line 287  $basicviewselect
 <h3>Advanced Search</h3>  <h3>Advanced Search</h3>
 $scrout  $scrout
 <p>  <p>
 <input type="submit" name="advancedsubmit" value="SEARCH">  <input type="submit" name="advancedsubmit" value='SEARCH' />
 <input type="reset" name="reset" value="RESET">  <input type="reset" name="reset" value='RESET' />
 $closebutton  $closebutton
 $advancedviewselect  $advancedviewselect
 </p>  </p>
Line 292  ENDDOCUMENT Line 303  ENDDOCUMENT
   
 sub simpletextfield {  sub simpletextfield {
     my ($name,$value)=@_;      my ($name,$value)=@_;
     return '<input type=text name="'.$name.'" size=20 value="'.$value.'">';      return '<input type=text name=\''.$name.
      '\' size=20 value=\''.$value.'\' />';
 }  }
   
 sub simplecheckbox {  sub simplecheckbox {
     my ($name,$value)=@_;      my ($name,$value)=@_;
     my $checked='';      my $checked='';
     $checked="CHECKED" if $value eq 'on';      $checked="CHECKED" if $value eq 'on';
     return '<input type=checkbox name="'.$name.'" '. $checked . '>';      return '<input type=checkbox name=\''.$name.'\' '. $checked . '>';
 }  }
   
 sub searchphrasefield {  sub searchphrasefield {
Line 311  END Line 323  END
     my $uctitle=uc($title);      my $uctitle=uc($title);
     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:</b>".      return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:</b>".
    "</FONT> $instruction<br>".     "</FONT> $instruction<br>".
            '<input type=text name="'.$name.'" size=80 value="'.$value.'">';             '<input type=text name="'.$name.'" size=80 value=\''.$value.'\'>';
 }  }
   
 sub dateboxes {  sub dateboxes {
Line 464  sub selectbox { Line 476  sub selectbox {
     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
  "</b></font><br>".'<select name="'.$name.'">';   "</b></font><br>".'<select name="'.$name.'">';
     map {      map {
         $selout.='<option value="'.$_.'"';          $selout.='<option value=\''.$_.'\'';
         if ($_ eq $value) { $selout.=' selected'; }          if ($_ eq $value) { $selout.=' selected'; }
         $selout.='>'.$options{$_}.'</option>';          $selout.='>'.$options{$_}.'</option>';
     } sort keys %options;      } sort keys %options;
Line 486  sub advancedsearch { Line 498  sub advancedsearch {
    'lastrevisiondatestart_year','lastrevisiondateend_month',     'lastrevisiondatestart_year','lastrevisiondateend_month',
    'lastrevisiondateend_day','lastrevisiondateend_year',     'lastrevisiondateend_day','lastrevisiondateend_year',
    'notes','abstract','mime','language','owner',     'notes','abstract','mime','language','owner',
    'custommetadata') {     'custommetadata','customshow') {
  $ENV{"form.$field"}=~s/[^\w\s\(\)\-\"\']//g;   $ENV{"form.$field"}=~s/[^\w\s\(\)\=\-\"\']//g;
     }      }
     for my $field ('title','author','subject','keywords','url','version',      for my $field ('title','author','subject','keywords','url','version',
    'notes','abstract','mime','language','owner',     'notes','abstract','mime','language','owner',
Line 543  sub advancedsearch { Line 555  sub advancedsearch {
     elsif ($datequery) {      elsif ($datequery) {
  push @queries,$datequery;   push @queries,$datequery;
     }      }
     my $customquery;      my $customquery='';
     if ($ENV{'form.custommetadata'}) {      if ($ENV{'form.custommetadata'}) {
  $customquery=&build_custommetadata_query('custommetadata',   $customquery=&build_custommetadata_query('custommetadata',
       $ENV{'form.custommetadata'});        $ENV{'form.custommetadata'});
     }      }
       my $customshow='';
       if ($ENV{'form.customshow'}) {
    $customshow=$ENV{'form.customshow'};
    $customshow=~s/[^\w\s]//g;
    my @fields=split(/\s+/,$customshow);
    $customshow=join(" ",@fields);
       }
     if (@queries) {      if (@queries) {
  $query=join(" AND ",@queries);   $query=join(" AND ",@queries);
  $query="select * from metadata where $query";   $query="select * from metadata where $query";
  my $reply=&Apache::lonnet::metadata_query($query);   my $reply='';
    unless ($customquery or $customshow) {
       $reply=&Apache::lonnet::metadata_query($query);
    }
    else {
       $reply=&Apache::lonnet::metadata_query($query,
      $customquery,$customshow);
    }
  &output_results('Advanced',$r,$envhash,$customquery,$reply);   &output_results('Advanced',$r,$envhash,$customquery,$reply);
     }      }
     else {      elsif ($customquery) {
  &output_results('Advanced',$r,$envhash,$query);   my $reply='';
    $reply=&Apache::lonnet::metadata_query('',
          $customquery,$customshow);
    &output_results('Advanced',$r,$envhash,$customquery,$reply);
     }      }
       $r->print('system error'); # just in case.. hrrmm..
     return OK;      return OK;
 }  }
   
Line 658  sub output_results { Line 688  sub output_results {
     @results=<$fh>;      @results=<$fh>;
  }   }
   
    my $customshow='';
    my $extrashow='';
    if ($ENV{'form.customshow'}) {
       $customshow=$ENV{'form.customshow'};
       $customshow=~s/[^\w\s]//g;
       my @fields=map {"<font color=\"#008000\">$_:</font>"} 
                      split(/\s+/,$customshow);
       if ($customshow) {
    $extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n";
       }
    }
    my $customdata='';
    foreach my $result (@results) {
       if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
    $customdata.=$result;
       }
    }
  foreach my $result (@results) {   foreach my $result (@results) {
       next if $result=~/^custom\=/;
       chomp $result;
       next unless $result;
     my @fields=map      my @fields=map
                    {&Apache::lonnet::unescape($_)}                     {&Apache::lonnet::unescape($_)}
                    (split(/\,/,$result));                     (split(/\,/,$result));
Line 689  END Line 739  END
   
             if ($viewselect eq 'Detailed Citation View') {              if ($viewselect eq 'Detailed Citation View') {
  $compiledresult.=&detailed_citation_view(@fields,   $compiledresult.=&detailed_citation_view(@fields,
  $hostname,$httphost);   $hostname,$httphost,
    $extrashow);
     }      }
             elsif ($viewselect eq 'Summary View') {              elsif ($viewselect eq 'Summary View') {
  $compiledresult.=&summary_view(@fields,$hostname,$httphost);   $compiledresult.=&summary_view(@fields,$hostname,$httphost,
          $extrashow);
     }      }
             elsif ($viewselect eq 'Fielded Format') {              elsif ($viewselect eq 'Fielded Format') {
  $compiledresult.=&fielded_format_view(@fields,$hostname,   $compiledresult.=&fielded_format_view(@fields,$hostname,
       $httphost);        $httphost,$extrashow);
     }      }
             elsif ($viewselect eq 'XML/SGML') {              elsif ($viewselect eq 'XML/SGML') {
  $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost);   $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,
    $extrashow);
     }      }
   
         }          }
Line 740  SCRIPT Line 793  SCRIPT
 <img align=right src=/adm/lonIcons/lonlogos.gif>  <img align=right src=/adm/lonIcons/lonlogos.gif>
 <h1>Search Catalog</h1>  <h1>Search Catalog</h1>
 <form method="post" action="/adm/searchcat">  <form method="post" action="/adm/searchcat">
   $customdata
 <input type='button' value='Revise search request'  <input type='button' value='Revise search request'
 onClick='this.form.submit();'>  onClick='this.form.submit();'>
 $closebutton  $closebutton
Line 791  sub build_custommetadata_query { Line 845  sub build_custommetadata_query {
   -build => 'Text::Query::BuildAdvancedString');    -build => 'Text::Query::BuildAdvancedString');
     $q->prepare($logic_statement);      $q->prepare($logic_statement);
     my $matchexp=${$q}{'-parse'}{'-build'}{'matchstring'};      my $matchexp=${$q}{'-parse'}{'-build'}{'matchstring'};
       # quick fix to change literal into xml tag-matching
       # will eventually have to write a separate builder module
       my $oldmatchexp=$matchexp;
       $matchexp=~s/(\w+)\\\=(\w+)/\\\<$1\\\>\[\^\\\<\]\*$2\[\^\\\<\]\*\\\<\\\/$1\\\>/g;
     return $matchexp;      return $matchexp;
 }  }
   
Line 828  sub detailed_citation_view { Line 886  sub detailed_citation_view {
     my ($title,$author,$subject,$url,$keywords,$version,      my ($title,$author,$subject,$url,$keywords,$version,
  $notes,$shortabstract,$mime,$lang,   $notes,$shortabstract,$mime,$lang,
  $creationdate,$lastrevisiondate,$owner,$copyright,   $creationdate,$lastrevisiondate,$owner,$copyright,
  $hostname,$httphost)=@_;   $hostname,$httphost,$extrashow)=@_;
     my $result=<<END;      my $result=<<END;
 <i>$owner</i>, last revised $lastrevisiondate  <i>$owner</i>, last revised $lastrevisiondate
 <h3><A HREF="http://$httphost$url" TARGET='search_preview'>$title</A></h3>  <h3><A HREF="http://$httphost$url" TARGET='search_preview'>$title</A></h3>
Line 841  sub detailed_citation_view { Line 899  sub detailed_citation_view {
 <b>MIME Type:</b> $mimetag{$mime}<br>  <b>MIME Type:</b> $mimetag{$mime}<br>
 <b>Language:</b> $language{$lang}<br>  <b>Language:</b> $language{$lang}<br>
 <b>Copyright/Distribution:</b> $cprtag{$copyright}<br>  <b>Copyright/Distribution:</b> $cprtag{$copyright}<br>
   </p>
   $extrashow
   <p>
 $shortabstract  $shortabstract
 </p>  </p>
 END  END
Line 852  sub summary_view { Line 913  sub summary_view {
     my ($title,$author,$subject,$url,$keywords,$version,      my ($title,$author,$subject,$url,$keywords,$version,
  $notes,$shortabstract,$mime,$lang,   $notes,$shortabstract,$mime,$lang,
  $creationdate,$lastrevisiondate,$owner,$copyright,   $creationdate,$lastrevisiondate,$owner,$copyright,
  $hostname,$httphost)=@_;   $hostname,$httphost,$extrashow)=@_;
     my $result=<<END;      my $result=<<END;
 <a href="http://$httphost$url" TARGET='search_preview'>$author</a><br />  <a href="http://$httphost$url" TARGET='search_preview'>$author</a><br />
 $title<br />  $title<br />
 $owner -- $lastrevisiondate<br />  $owner -- $lastrevisiondate<br />
 $cprtag{$copyright}<br />  $cprtag{$copyright}<br />
   $extrashow
 </p>  </p>
 END  END
     return $result;      return $result;
Line 868  sub fielded_format_view { Line 930  sub fielded_format_view {
     my ($title,$author,$subject,$url,$keywords,$version,      my ($title,$author,$subject,$url,$keywords,$version,
  $notes,$shortabstract,$mime,$lang,   $notes,$shortabstract,$mime,$lang,
  $creationdate,$lastrevisiondate,$owner,$copyright,   $creationdate,$lastrevisiondate,$owner,$copyright,
  $hostname,$httphost)=@_;   $hostname,$httphost,$extrashow)=@_;
     my $result=<<END;      my $result=<<END;
 <b>URL: </b> <A HREF="http://$httphost$url" TARGET='search_preview'>$url</A>  <b>URL: </b> <A HREF="http://$httphost$url" TARGET='search_preview'>$url</A>
 <br />  <br />
Line 885  sub fielded_format_view { Line 947  sub fielded_format_view {
 <b>Copyright/Distribution:</b> $cprtag{$copyright}<br />  <b>Copyright/Distribution:</b> $cprtag{$copyright}<br />
 <b>Repository Location:</b> $hostname<br />  <b>Repository Location:</b> $hostname<br />
 <b>Abstract:</b> $shortabstract<br />  <b>Abstract:</b> $shortabstract<br />
   $extrashow
 </p>  </p>
 END  END
     return $result;      return $result;
Line 895  sub xml_sgml_view { Line 958  sub xml_sgml_view {
     my ($title,$author,$subject,$url,$keywords,$version,      my ($title,$author,$subject,$url,$keywords,$version,
  $notes,$shortabstract,$mime,$lang,   $notes,$shortabstract,$mime,$lang,
  $creationdate,$lastrevisiondate,$owner,$copyright,   $creationdate,$lastrevisiondate,$owner,$copyright,
  $hostname,$httphost)=@_;   $hostname,$httphost,$extrashow)=@_;
     my $result=<<END;      my $result=<<END;
 <pre>  <pre>
 &lt;LonCapaResource&gt;  &lt;LonCapaResource&gt;
Line 924  sub xml_sgml_view { Line 987  sub xml_sgml_view {
 &lt;shortabstract&gt;$shortabstract&lt;/shortabstract&gt;  &lt;shortabstract&gt;$shortabstract&lt;/shortabstract&gt;
 &lt;/LonCapaResource&gt;  &lt;/LonCapaResource&gt;
 </pre>  </pre>
   $extrashow
 END  END
     return $result;      return $result;
 }  }
Line 1013  sub make_persistent { Line 1077  sub make_persistent {
  if (/^form\./ && !/submit/) {   if (/^form\./ && !/submit/) {
     my $name=$_;      my $name=$_;
     my $key=$name;      my $key=$name;
     $ENV{$key}=~s/\"/\&quot\;/g;      $ENV{$key}=~s/\'//g; # do not mess with html field syntax
     $name=~s/^form\.//;      $name=~s/^form\.//;
     $persistent.=<<END;      $persistent.=<<END;
 <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>  <input type='hidden' name='$name' value='$ENV{$key}' />
 END  END
         }          }
     } (keys %ENV);      } (keys %ENV);

Removed from v.1.67  
changed lines
  Added in v.1.86


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