Diff for /loncom/interface/lonsearchcat.pm between versions 1.76 and 1.85

version 1.76, 2001/03/22 14:58:58 version 1.85, 2001/03/27 19:32:28
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 487  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',
Line 549  sub advancedsearch { Line 560  sub advancedsearch {
  $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='';   my $reply='';
  unless ($customquery) {   unless ($customquery or $customshow) {
     $reply=&Apache::lonnet::metadata_query($query);      $reply=&Apache::lonnet::metadata_query($query);
  }   }
  else {   else {
     $reply=&Apache::lonnet::metadata_query($query,$customquery);      $reply=&Apache::lonnet::metadata_query($query,
      $customquery,$customshow);
  }   }
  &output_results('Advanced',$r,$envhash,$customquery,$reply);   &output_results('Advanced',$r,$envhash,$customquery,$reply);
     }      }
     else {      else {
  &output_results('Advanced',$r,$envhash,$query);   &output_results('Advanced',$r,$envhash,$query);
     }      }
       $r->print(' '); # just in case.. hrrmm..
     return OK;      return OK;
 }  }
   
Line 665  sub output_results { Line 685  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) {   foreach my $result (@results) {
       if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
    $customdata.=$result;
       }
    }
    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 696  END Line 736  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 747  SCRIPT Line 790  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 839  sub detailed_citation_view { Line 883  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 852  sub detailed_citation_view { Line 896  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 863  sub summary_view { Line 910  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 879  sub fielded_format_view { Line 927  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 896  sub fielded_format_view { Line 944  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 906  sub xml_sgml_view { Line 955  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 935  sub xml_sgml_view { Line 984  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;
 }  }

Removed from v.1.76  
changed lines
  Added in v.1.85


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