Diff for /loncom/interface/lonsearchcat.pm between versions 1.196 and 1.201

version 1.196, 2003/12/22 22:40:37 version 1.201, 2004/01/02 16:34:03
Line 70  use Text::Query; Line 70  use Text::Query;
 use GDBM_File;  use GDBM_File;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonmysql();  use Apache::lonmysql();
   use Apache::lonmeta;
   use Apache::lonhtmlcommon;
 use Apache::lonlocal;  use Apache::lonlocal;
   
 ######################################################################  ######################################################################
Line 83  my %groupsearch_db;  # Database hash use Line 85  my %groupsearch_db;  # Database hash use
                      # groupsearch RAT interface.                       # groupsearch RAT interface.
 my %persistent_db;   # gdbm hash which holds data which is supposed to  my %persistent_db;   # gdbm hash which holds data which is supposed to
                      # persist across calls to lonsearchcat.pm                       # persist across calls to lonsearchcat.pm
 ## %Views:  
 ## Hash which associates an output view description with the function  
 ## that produces it.  
 #             View Description/Name      Function Pointer  
 my %Views = ("Detailed Citation View" => \&detailed_citation_view,  
              "Summary View"           => \&summary_view,  
              "Fielded Format"         => \&fielded_format_view,  
              "XML/SGML"               => \&xml_sgml_view,  
              "Compact View"           => \&compact_view);  
   
   # The different view modes and associated functions
   
   my %Views = ("detailed" => \&detailed_citation_view,
        "summary"  => \&summary_view,
        "fielded"  => \&fielded_format_view,
        "xml"      => \&xml_sgml_view,
        "compact"  => \&compact_view);
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     &set_defaults();  #    &set_defaults();
     #      #
     # set form defaults      # set form defaults
     #      #
Line 293  END Line 293  END
         }          }
         # Set up table          # Set up table
         if (! defined(&create_results_table())) {          if (! defined(&create_results_table())) {
       my $errorstring=&Apache::lonmysql::get_error();
             $r->print(<<END);              $r->print(<<END);
 <html><head><title>Search Error</title></head>  <html><head><title>Search Error</title></head>
 $bodytag  $bodytag
 Unable to create table in which to store search results.    Unable to create table in which to store search results.  
 The search has been aborted.  The search has been aborted.
   <br />$errorstring
 </body>  </body>
 </html>  </html>
 END  END
Line 364  sub course_search { Line 366  sub course_search {
     if ($ENV{'form.crsrelated'}) {      if ($ENV{'form.crsrelated'}) {
         ($search_string,@New_Words) = &related_version($ENV{'form.courseexp'});          ($search_string,@New_Words) = &related_version($ENV{'form.courseexp'});
         if (@New_Words) {          if (@New_Words) {
             $pretty_search_string .= " with related words: <b>@New_Words</b>.";              $pretty_search_string .= ' '.&mt("with related words").": <b>@New_Words</b>.";
         } else {          } else {
             $pretty_search_string .= " with no related words.";              $pretty_search_string .= ' '.&mt('with no related words').".";
         }          }
     }      }
     my $fulltext=$ENV{'form.crsfulltext'};      my $fulltext=$ENV{'form.crsfulltext'};
Line 483  $bodytag Line 485  $bodytag
 ENDDOCUMENT  ENDDOCUMENT
 if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {  if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {
     my $CatalogSearch=&mt('Catalog Search');      my $CatalogSearch=&mt('Catalog Search');
     my $Statement=&mt('Enter terms or phrases separated by AND, OR, or NOT then press SEARCH below');      my $Statement=&searchhelp();
     $scrout.=(<<ENDDOCUMENT);      $scrout.=(<<ENDDOCUMENT);
 <h1>$CatalogSearch</h1>  <h1>$CatalogSearch</h1>
 <form name="loncapa_search" method="post" action="/adm/searchcat">  <form name="loncapa_search" method="post" action="/adm/searchcat">
Line 496  $Statement. Line 498  $Statement.
 <table>  <table>
 <tr><td>  <tr><td>
 ENDDOCUMENT  ENDDOCUMENT
     $scrout.='&nbsp;'.&simpletextfield('basicexp',$ENV{'form.basicexp'},40).      $scrout.='&nbsp;'.&Apache::lonhtmlcommon::textbox('basicexp',
                                               $ENV{'form.basicexp'},40).
         '&nbsp;';          '&nbsp;';
     my $relatedcheckbox = &simplecheckbox('related','related',$ENV{'form.related'});      my $relatedcheckbox = &Apache::lonhtmlcommon::checkbox('related',
    $ENV{'form.related'});
     my $domain = $r->dir_config('lonDefDomain');      my $domain = $r->dir_config('lonDefDomain');
     my $domaincheckbox = &simplecheckbox('domains',$domain);      my $domaincheckbox = &Apache::lonhtmlcommon::checkbox('domains',
    $ENV{'form.domains'});
     my $srch=&mt('Search');      my $srch=&mt('Search');
     my $header=&mt('Advanced Search');      my $header=&mt('Advanced Search');
     my $userelatedwords=&mt('use related words');      my $userelatedwords=&mt('use related words');
     my $onlysearchdomain=&mt('only search domain');      my $onlysearchdomain=&mt('only search domain');
       my $view=&viewoptions();
     $scrout.=<<END;      $scrout.=<<END;
 </td><td><a  </td><td><a
 href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}"  href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}"
Line 513  href="/adm/searchcat?phase=disp_adv&cata Line 519  href="/adm/searchcat?phase=disp_adv&cata
     <td>$domaincheckbox $onlysearchdomain <b>$domain</b></td></tr>      <td>$domaincheckbox $onlysearchdomain <b>$domain</b></td></tr>
 </table>  </table>
 </p>  </p>
   $view
 <p>  <p>
 &nbsp;<input type="submit" name="basicsubmit" value='$srch' />&nbsp;  &nbsp;<input type="submit" name="basicsubmit" value='$srch' />&nbsp;
 $closebutton  $closebutton
 END  END
     $scrout.=&selectbox('View','viewselect',  
  $ENV{'form.viewselect'},  
  undef,undef,undef,  
  sort(keys(%Views)));  
     $scrout.=&selectbox('Per Page','show',  
  $ENV{'form.show'},  
  undef,undef,undef,  
  (10,20,50,100));  
     $scrout.=<<ENDDOCUMENT;      $scrout.=<<ENDDOCUMENT;
 </p>  </p>
 </form>  </form>
Line 535  ENDDOCUMENT Line 534  ENDDOCUMENT
    'srch' => 'Search',     'srch' => 'Search',
                                            'header' => 'Course Search',                                             'header' => 'Course Search',
  'note' => 'Enter terms or phrases, then press "Search" below',   'note' => 'Enter terms or phrases, then press "Search" below',
    'use' => 'use related words',
    'full' =>'fulltext search (time consuming)'
    );     );
         $scrout.=(<<ENDCOURSESEARCH);          $scrout.=(<<ENDCOURSESEARCH);
 <hr />  <hr />
Line 550  $lt{'note'}. Line 551  $lt{'note'}.
 <tr><td>  <tr><td>
 ENDCOURSESEARCH  ENDCOURSESEARCH
         $scrout.='&nbsp;'.          $scrout.='&nbsp;'.
             &simpletextfield('courseexp',$ENV{'form.courseexp'},40);              &Apache::lonhtmlcommon::textbox('courseexp',
                                     $ENV{'form.courseexp'},40);
         my $crscheckbox =           my $crscheckbox = 
             &simplecheckbox('crsfulltext',$ENV{'form.crsfulltext'});              &Apache::lonhtmlcommon::checkbox('crsfulltext',
                                      $ENV{'form.crsfulltext'});
         my $relcheckbox =           my $relcheckbox = 
             &simplecheckbox('crsrelated',$ENV{'form.crsrelated'});              &Apache::lonhtmlcommon::checkbox('crsrelated',
      $ENV{'form.crsrelated'});
         $scrout.=(<<ENDENDCOURSE);          $scrout.=(<<ENDENDCOURSE);
 </td></tr>  </td></tr>
 <tr><td>$relcheckbox use related words</td><td></td></tr>  <tr><td>$relcheckbox $lt{'use'}</td><td></td></tr>
 <tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr>  <tr><td>$crscheckbox $lt{'full'}</td><td></td></tr>
 </table><p>  </table><p>
 &nbsp;<input type="submit" name="coursesubmit" value='$lt{'srch'}' />  &nbsp;<input type="submit" name="coursesubmit" value='$lt{'srch'}' />
 </p>  </p>
Line 587  Returns a scalar which holds html for th Line 591  Returns a scalar which holds html for th
   
 sub print_advanced_search_form{  sub print_advanced_search_form{
     my ($r,$closebutton,$hidden_fields) = @_;      my ($r,$closebutton,$hidden_fields) = @_;
       my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
          'reset' => 'Reset',
          'help' => 'Help');
     my $advanced_buttons = <<"END";      my $advanced_buttons = <<"END";
 <p>  <p>
 <input type="submit" name="advancedsubmit" value='SEARCH' />  <input type="submit" name="advancedsubmit" value='$lt{"srch"}' />
 <input type="reset" name="reset" value='RESET' />  <input type="reset" name="reset" value='$lt{"reset"}' />
 $closebutton  $closebutton
 <input type="button" value="HELP" onClick="openhelp()" />  <input type="button" value="$lt{'help'}" onClick="openhelp()" />
 </p>  </p>
 END  END
     if (!defined($ENV{'form.viewselect'})) {  
         $ENV{'form.viewselect'} ="Detailed Citation View";  
     }  
     my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search');      my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search');
       my $searchhelp=&searchhelp();
     my $scrout=<<"ENDHEADER";      my $scrout=<<"ENDHEADER";
 <html>  <html>
 <head>  <head>
Line 612  END Line 617  END
 </script>  </script>
 </head>  </head>
 $bodytag  $bodytag
 Enter terms or phrases separated by search operators   $searchhelp
 such as AND, OR, or NOT.<br />  <form method="post" action="/adm/searchcat" name="advsearch">
 <form method="post" action="/adm/searchcat">  
 $advanced_buttons  $advanced_buttons
 $hidden_fields  $hidden_fields
 <input type="hidden" name="phase" value="adv_search" />  <input type="hidden" name="phase" value="adv_search" />
 <table>  
 <tr><td><font color="#800000" face="helvetica"><b>VIEW:</b></font></td>  
 <td>  
 ENDHEADER  ENDHEADER
     $scrout.=&selectbox(undef,'viewselect',      $scrout.=&viewoptions();
  $ENV{'form.viewselect'},      my %fields=&Apache::lonmeta::fieldnames();
  undef,undef,undef,  
  sort(keys(%Views)));      $scrout.='<table>';
     $scrout.='&nbsp;';      $scrout.="<tr><th>".&mt('Field').'</th><th>'.&mt('Value').'</th><th>'
     $scrout.=&selectbox(undef,'show',   .&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";
  $ENV{'form.show'},      foreach ('title','author','keywords','notes','abstract','standards',
  undef,undef,undef,       'lowestgradelevel','highestgradelevel','mime') {
  (10,20,50,100));   $scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($fields{$_}).'</td><td>'.
     $scrout.='&nbsp;'.      &Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch',
         '<font color="#800000" face="helvetica">'.&mt('Per Page').'</font>';    1,'</td><td>',$ENV{'form.'.$_.'_related'}).
     $scrout.="</td><td>".&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";      '</td></tr>';
     $scrout.=&searchphrasefield_with_related('title',   'title'   ,      }
                                              $ENV{'form.title'});      my %dates=&Apache::lonlocal::texthash('creationdatestart'     => 'Creation Date After',
     $scrout.=&searchphrasefield('author',  'author'  ,$ENV{'form.author'});      'creationdateend'       => 'Creation Date Before',
     $scrout.=&searchphrasefield_with_related('subject', 'subject' ,    'lastrevisiondatestart' => 'Last Revision Date After',
                                              $ENV{'form.subject'});    'lastrevisiondateend'   => 'Last Revision Date Before');
     $scrout.=&searchphrasefield_with_related('keywords','keywords',      foreach (sort keys %dates) {
                                              $ENV{'form.keywords'});   $scrout.='<tr><td>'.&titlefield($dates{$_}).'</td><td>'. 
     $scrout.=&searchphrasefield('URL',     'url'     ,$ENV{'form.url'});      &Apache::lonhtmlcommon::date_setter('advsearch',$_,0,'',1).
     $scrout.=&searchphrasefield_with_related('notes',   'notes'   ,      '</td><td>&nbsp;</td></td></tr>';
                                              $ENV{'form.notes'});      }
     $scrout.=&searchphrasefield_with_related('abstract','abstract',      
                                              $ENV{'form.abstract'});  
   
     # Hack - an empty table row.      # Hack - an empty table row.
     $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";      $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
     $scrout.=&searchphrasefield('file<br />extension','extension',  #    $scrout.=&searchphrasefield('file<br />extension','extension',
                         $ENV{'form.extension'});  #                        $ENV{'form.extension'});
     $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";  #    $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
     $scrout.=&searchphrasefield('publisher<br />owner','owner',  #    $scrout.=&searchphrasefield('publisher<br />owner','owner',
  $ENV{'form.owner'});   # $ENV{'form.owner'});
     $scrout.="</table>\n";      $scrout.="</table>\n";
     $ENV{'form.category'}='any' if (! defined($ENV{'form.category'}));  #    $scrout.=&Apache::lonmeta::selectbox('File Category','category',
     $scrout.=&selectbox('File Category','category',  # $ENV{'form.category'},
  $ENV{'form.category'},  # 'any','Any category',
  'any','Any category',  # undef,
  undef,  # (&Apache::loncommon::filecategories()));
  (&Apache::loncommon::filecategories()));  
     $ENV{'form.language'}='any' unless length($ENV{'form.language'});  
     #----------------------------------------------------------------      #----------------------------------------------------------------
     # Allow restriction to multiple domains.      # Allow restriction to multiple domains.
     #   I make the crazy assumption that there will never be a domain 'any'.      #   I make the crazy assumption that there will never be a domain 'any'.
     #      #
     $ENV{'form.domains'} = 'any' if (! exists($ENV{'form.domains'}));  
     my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}}       my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}} 
                            :  ($ENV{'form.domains'}) );                             :  ($ENV{'form.domains'}) );
     my %domain_hash = ();      my %domain_hash = ();
Line 676  ENDHEADER Line 675  ENDHEADER
     # adjust the size of the select box      # adjust the size of the select box
     my $size = 4;      my $size = 4;
     $size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size);      $size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size);
     $scrout.="\n".'<font color="#800000" face="helvetica"><b>'.      $scrout.="\n".&titlefield(&mt('Domain to be searched')).
         'DOMAINS TO BE SEARCHED</b></font><br />'.  
             '<select name="domains" size="'.$size.'" multiple>'."\n".              '<select name="domains" size="'.$size.'" multiple>'."\n".
                 '<option name="any" value="any" '.                  '<option name="any" value="any" '.
                     ($domain_hash{'any'}? 'selected ' :'').                      ($domain_hash{'any'}? 'selected ' :'').
Line 687  ENDHEADER Line 685  ENDHEADER
             ($domain_hash{$dom} ? 'selected ' :'').">$dom</option>\n";              ($domain_hash{$dom} ? 'selected ' :'').">$dom</option>\n";
     }      }
     $scrout.="</select>\n";      $scrout.="</select>\n";
     #----------------------------------------------------------------  
     $scrout.=&selectbox('Limit by language','language',  
  $ENV{'form.language'},'any','Any Language',  
  \&Apache::loncommon::languagedescription,  
  (&Apache::loncommon::languageids),  
  );  
 # ------------------------------------------------ Compute date selection boxes  
     $scrout.=<<CREATIONDATESTART;  
 <p>  
 <font color="#800000" face="helvetica"><b>LIMIT BY CREATION DATE RANGE:</b>  
 </font>  
 <br />  
 between:  
 CREATIONDATESTART  
     $scrout.=&dateboxes('creationdatestart',1,1,1976,  
  $ENV{'form.creationdatestart_month'},  
  $ENV{'form.creationdatestart_day'},  
  $ENV{'form.creationdatestart_year'},  
  );  
     $scrout.="and:\n";  
     $scrout.=&dateboxes('creationdateend',12,31,2051,  
  $ENV{'form.creationdateend_month'},  
  $ENV{'form.creationdateend_day'},  
  $ENV{'form.creationdateend_year'},  
  );  
     $scrout.="</p>";  
     $scrout.=<<LASTREVISIONDATESTART;  
 <p>  
 <font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE:  
 </b></font>  
 <br />between:  
 LASTREVISIONDATESTART  
     $scrout.=&dateboxes('lastrevisiondatestart',1,1,1976,  
  $ENV{'form.lastrevisiondatestart_month'},  
  $ENV{'form.lastrevisiondatestart_day'},  
  $ENV{'form.lastrevisiondatestart_year'},  
  );  
     $scrout.=<<LASTREVISIONDATEEND;  
 and:  
 LASTREVISIONDATEEND  
     $scrout.=&dateboxes('lastrevisiondateend',12,31,2051,  
  $ENV{'form.lastrevisiondateend_month'},  
  $ENV{'form.lastrevisiondateend_day'},  
  $ENV{'form.lastrevisiondateend_year'},  
  );  
     $scrout.='</p>';  
     $ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'});  
     $scrout.=&selectbox('Limit by copyright/distribution','copyright',  
  $ENV{'form.copyright'},  
  'any','Any copyright/distribution',  
  \&Apache::loncommon::copyrightdescription,  
  (&Apache::loncommon::copyrightids),  
  );  
 # ------------------------------------------- Compute customized metadata field  # ------------------------------------------- Compute customized metadata field
 #    $scrout.=<<CUSTOMMETADATA;  #    $scrout.=<<CUSTOMMETADATA;
 #<p>  #<p>
Line 769  ENDDOCUMENT Line 715  ENDDOCUMENT
     $r->print($scrout);      $r->print($scrout);
     return;      return;
 }  }
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item &titlefield
   
   Inputs: title text
   
   Outputs: titletext with font wrapper
   
   =cut
   
   ######################################################################
   ######################################################################
   
   sub titlefield {
       my $title=shift;
       return '<font face="arial" color="#800000">'.$title.'</font>';
   }
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item viewoptiontext
   
   Inputs: codename for view option
   
   Outputs: displayed text
   
   =cut
   
   ######################################################################
   ######################################################################
   
   sub viewoptiontext {
       my $code=shift;
       my %desc=&Apache::lonlocal::texthash('detailed' => "Detailed Citation View",
    'xml' => 'XML/SGML',
    'compact' => 'Compact View',
    'fielded' => 'Fielded Format',
    'summary' => 'Summary View');
       return $desc{$code};
   }
   ######################################################################
   
   =pod 
   
   =item viewoptions
   
   Inputs: none
   
   Outputs: text for box with view options
   
   =cut
   
   ######################################################################
   ######################################################################
   
   sub viewoptions {
       my $scrout="\n\n".'<table bgcolor="#FFFFBB"><tr><th>'.&mt('View Options').'</th><th>'.
    &mt('Records per Page').'</th></tr><tr><td>';
       unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; }
       $scrout.=&Apache::lonmeta::selectbox('viewselect',
    $ENV{'form.viewselect'},
    \&viewoptiontext,
    sort(keys(%Views)));
       $scrout.='</td><td>';
       $scrout.=&Apache::lonmeta::selectbox('show',
    $ENV{'form.show'},
    undef,
    (10,20,50,100,1000,10000));
       $scrout.="</td></tr></table>\n\n";
       return $scrout;
   }
   
   ######################################################################
   
   =pod 
   
   =item searchhelp
   
   Inputs: none
   
   Outputs: return little blurb on how to enter searches
   
   =cut
   
   ######################################################################
   ######################################################################
   
   sub searchhelp {
       return &mt('Enter terms or phrases separated by AND, OR, or NOT');
   }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 931  sub make_form_data_persistent { Line 972  sub make_form_data_persistent {
 }  }
   
 ######################################################################  ######################################################################
 #                HTML form building functions                        #    
 ######################################################################  
   
 =pod   
   
 =item HTML form building functions  
   
 =over 4  
   
 =cut  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &simpletextfield()   
   
 Inputs: $name,$value,$size  
   
 Returns a text input field with the given name, value, and size.    
 If size is not specified, a value of 20 is used.  
   
 =cut  
   
 ###############################################  
 ###############################################  
   
 sub simpletextfield {  
     my ($name,$value,$size)=@_;  
     $size = 20 if (! defined($size));  
     return '<input type="text" name="'.$name.  
         '" size="'.$size.'" value="'.$value.'" />';  
 }  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &simplecheckbox()  
   
 Inputs: $name,$value,$checked  
   
 Returns a simple check box with the given $name.  
 If $value eq 'on' the box is checked.  
   
 =cut  
   
 ###############################################  
 ###############################################  
   
 sub simplecheckbox{  
     my ($name,$value,$checked)=@_;  
     $checked="checked" if ($value eq $checked || $value eq 'on');  
     return '<input type="checkbox" name="'.$name.'" value="'.$value.'" '.  
         $checked.' />';  
 }  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &fieldtitle()  
   
 Input: $title  
   
 Returns a scalar with html which will display $title as a search  
 field heading.  
   
 =cut  
   
 ###############################################  
 ###############################################  
   
 sub fieldtitle {  
     my $title = uc(&mt(shift()));  
     return '<font color="#800000" face="helvetica"><b>'.$title.  
         ':&nbsp;</b></font>';  
 }  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &searchphrasefield()  
   
 Inputs: $title,$name,$value  
   
 Returns html for a title line and an input field for entering search terms.  
 The entry field (which is where the $name and $value are used) is a 50 column   
 simpletextfield.  The html returned is for a row in a three column table.  
   
 =cut  
   
 ###############################################  
 ###############################################  
       
 sub searchphrasefield {  
     my ($title,$name,$value)=@_;  
     return '<tr><td>'.&fieldtitle($title).'</td><td>'.  
         &simpletextfield($name,$value,50)."</td><td>&nbsp;</td></tr>\n";  
 }  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &searchphrasefield_with_related()  
   
 Inputs: $title,$name,$value  
   
 Returns html for a title line and an input field for entering search terms  
 and a check box for 'related words'.  The entry field (which is where the   
 $name and $value are used) is a 50 column simpletextfield.  The name of  
 the related words checkbox is "$name_related".  
   
 =cut  
   
 ###############################################  
 ###############################################  
       
 sub searchphrasefield_with_related {  
     my ($title,$name,$value)=@_;  
     return '<tr><td>'.&fieldtitle($title).'</td><td>'.  
         &simpletextfield($name,$value,50).'</td><td align="center">&nbsp;'.  
             &simplecheckbox($name.'_related',$ENV{'form.'.$name.'_related'}).  
                 "&nbsp;</td></tr>\n";  
 }  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &dateboxes()  
   
 Returns html selection form elements for the specification of   
 the day, month, and year.  
   
 =cut  
   
 ###############################################  
 ###############################################  
   
 sub dateboxes {  
     my ($name,$defaultmonth,$defaultday,$defaultyear,  
  $currentmonth,$currentday,$currentyear)=@_;  
     ($defaultmonth,$defaultday,$defaultyear)=('','','');  
     #  
     # Day  
     my $day=<<END;  
 <select name="${name}_day">  
 <option value='$defaultday'> </option>  
 END  
     for (my $i = 1; $i<=31; $i++) {  
  $day.="<option value=\"$i\">$i</option>\n";  
     }  
     $day.="</select>\n";  
     $day=~s/(\"$currentday\")/$1 SELECTED/ if length($currentday);  
     #  
     # Month  
     my $month=<<END;  
 <select name="${name}_month">  
 <option value='$defaultmonth'> </option>  
 END  
     my $i = 1;  
     foreach (qw/January February March April May June   
      July August September October November December /){  
  $month .="<option value=\"$i\">".&mt($_)."</option>\n";  
  $i++;  
     }  
     $month.="</select>\n";  
     $month=~s/(\"$currentmonth\")/$1 SELECTED/ if length($currentmonth);  
     #  
     # Year (obviously)  
     my $year=<<END;  
 <select name="${name}_year">  
 <option value='$defaultyear'> </option>  
 END  
     my $maxyear = 2051;   
     for (my $i = 1976; $i<=$maxyear; $i++) {  
  $year.="<option value=\"$i\">$i</option>\n";  
     }  
     $year.="</select>\n";  
     $year=~s/(\"$currentyear\")/$1 SELECTED/ if length($currentyear);  
     return "$month$day$year";  
 }  
   
 ###############################################  
 ###############################################  
   
 =pod  
   
 =item &selectbox()  
   
 Returns a scalar containing an html <select> form.    
   
 Inputs:   
   
 =over 4  
   
 =item $title   
   
 Printed above the select box, in uppercase.  If undefined, only a select  
 box will be returned, with no additional html.  
   
 =item $name   
   
 The name element of the <select> tag.  
   
 =item $default   
   
 The default value of the form.  Can be $anyvalue, or in @idlist.  
   
 =item $anyvalue   
   
 The <option value="..."> used to indicate a default of   
 none of the values.  Can be undef.  
   
 =item $anytag   
   
 The text associate with $anyvalue above.  
   
 =item $functionref   
   
 Each element in @idlist will be passed as a parameter   
 to the function referenced here.  The return value of the function should  
 be a scalar description of the items.  If this value is undefined the   
 description of each item in @idlist will be the item name.  
   
 =item @idlist   
   
 The items to be selected from.  One of these or $anyvalue will be the   
 value returned by the form element, $ENV{form.$name}.  
   
 =back  
   
 =cut  
   
 ###############################################  
   
 sub selectbox {  
     my ($title,$name,$default,$anyvalue,$anytag,$functionref,@idlist)=@_;  
     if (! defined($functionref)) { $functionref = sub { $_[0]}; }  
     my $selout='';  
     $title=&mt($title);  
     if (defined($title)) {  
         my $uctitle=uc($title);  
         $selout="\n".'<p><font color="#800000" face="helvetica">'.  
             '<b>'.$uctitle.': </b></font>';  
     }  
     $selout .= '<select name="'.$name.'">';  
     unshift @idlist,$anyvalue if (defined($anyvalue));  
     foreach (@idlist) {  
         $selout.='<option value="'.$_.'"';  
         if ($_ eq $default and !/^any$/) {  
     $selout.=' selected >'.&mt(&{$functionref}($_)).'</option>';  
  }  
  elsif ($_ eq $default and /^$anyvalue$/) {  
     $selout.=' selected >'.&mt($anytag).'</option>';  
  }  
         else {$selout.='>'.&mt(&{$functionref}($_)).'</option>';}  
     }  
     return $selout.'</select>'.(defined($title)?'</p>':' ');  
 }  
   
 ######################################################################  
 #                End of HTML form building functions                 #    
 ######################################################################  
   
 =pod  
   
 =back   
   
 =cut  
   
   
 ######################################################################  
 ######################################################################  ######################################################################
   
 =pod   =pod 
Line 1281  sub parse_advanced_search { Line 1040  sub parse_advanced_search {
     my $font = '<font color="#800000" face="helvetica">';      my $font = '<font color="#800000" face="helvetica">';
     # Evaluate logical expression AND/OR/NOT phrase fields.      # Evaluate logical expression AND/OR/NOT phrase fields.
     foreach my $field ('title','author','subject','notes','abstract','url',      foreach my $field ('title','author','subject','notes','abstract','url',
        'keywords','version','owner') {         'keywords','version','owner','standards') {
  if ($ENV{'form.'.$field}) {   if ($ENV{'form.'.$field}) {
             my $searchphrase = $ENV{'form.'.$field};              my $searchphrase = $ENV{'form.'.$field};
             $pretty_search_string .= $font."$field</font> contains <b>".              $pretty_search_string .= $font."$field</font> contains <b>".
Line 1899  my @Datatypes = Line 1658  my @Datatypes =
       { name => 'notes',     type=>'TEXT'},        { name => 'notes',     type=>'TEXT'},
       { name => 'abstract',  type=>'TEXT'},        { name => 'abstract',  type=>'TEXT'},
       { name => 'mime',      type=>'TEXT'},        { name => 'mime',      type=>'TEXT'},
       { name => 'lang',      type=>'TEXT'},        { name => 'language',  type=>'TEXT'},
       { name => 'owner',     type=>'TEXT'},        { name => 'owner',     type=>'TEXT'},
       { name => 'copyright', type=>'TEXT'},        { name => 'copyright', type=>'TEXT'},
       { name => 'hostname',  type=>'TEXT'},        { name => 'dependencies',     type=>'TEXT'},
         { name => 'modifyinguser', type=>'TEXT'},
         { name => 'authorspace', type=>'TEXT'},
         { name => 'lowestgradelevel',  type=>'INT'},
         { name => 'highestgradelevel', type=>'INT'},
         { name => 'standards', type=>'TEXT'},
         { name => 'count',     type=>'INT'},
         { name => 'course', type=>'INT'},
         { name => 'course_list',  type=>'TEXT'},
         { name => 'goto', type=>'INT'},
         { name => 'goto_list',  type=>'TEXT'},
         { name => 'comefrom', type=>'INT'},
         { name => 'comefrom_list',  type=>'TEXT'},
         { name => 'sequsage', type=>'INT'},
         { name => 'sequsage_list',  type=>'TEXT'},
         { name => 'stdno', type=>'INT'},
         { name => 'stdno_list',  type=>'TEXT'},
         { name => 'avetries', type=>'FLOAT'},
         { name => 'avetries_list',  type=>'TEXT'},
         { name => 'difficulty', type=>'FLOAT'},
         { name => 'difficulty_list',  type=>'TEXT'},
         { name => 'clear',  type=>'FLOAT'},
         { name => 'technical',  type=>'FLOAT'},
         { name => 'correct',  type=>'FLOAT'},
         { name => 'helpful',  type=>'FLOAT'},
         { name => 'depth',  type=>'FLOAT'},
         { name => 'hostname', type=> 'TEXT'},
       #--------------------------------------------------        #--------------------------------------------------
       { name => 'creationdate',     type=>'DATETIME'},        { name => 'creationdate',     type=>'DATETIME'},
       { name => 'lastrevisiondate', type=>'DATETIME'},        { name => 'lastrevisiondate', type=>'DATETIME'},
Line 2467  sub parse_row { Line 2252  sub parse_row {
         $Fields{$Datatypes[$i]->{'name'}}=&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{'language'});
     $Fields{'copyrighttag'} =      $Fields{'copyrighttag'} =
         &Apache::loncommon::copyrightdescription($Fields{'copyright'});          &Apache::loncommon::copyrightdescription($Fields{'copyright'});
     $Fields{'mimetag'} =      $Fields{'mimetag'} =
Line 2483  sub parse_row { Line 2268  sub parse_row {
 =item &parse_raw_result()  =item &parse_raw_result()
   
 Takes a line from the file of results and parse it.  Returns a hash   Takes a line from the file of results and parse it.  Returns a hash 
 with keys for the following fields:  with keys according to column labels
 'title', 'author', 'subject', 'url', 'keywords', 'version', 'notes',   
 'abstract', 'mime', 'lang', 'owner', 'copyright', 'creationdate',   
 'lastrevisiondate'.  
   
 In addition, the following tags are set by calling the appropriate   In addition, the following tags are set by calling the appropriate 
 lonnet function: 'language', 'cprtag', 'mimetag'.  lonnet function: 'language', 'copyrighttag', 'mimetag'.
   
 The 'title' field is set to "Untitled" if the title field is blank.  The 'title' field is set to "Untitled" if the title field is blank.
   
Line 2501  The 'title' field is set to "Untitled" i Line 2283  The 'title' field is set to "Untitled" i
 ###########################################################  ###########################################################
 sub parse_raw_result {  sub parse_raw_result {
     my ($result,$hostname) = @_;      my ($result,$hostname) = @_;
     # Check for a comma - if it is there then we do not need to unescape the  # conclude from self to others regarding fields
     # string.  There seems to be some kind of problem with some items in      my %Fields=&Apache::lonmeta::metadata_col_to_hash(
     # the database - the entire string gets sent out unescaped...?   map {
     unless ($result =~ /,/) {   &Apache::lonnet::unescape($_);
         $result = &Apache::lonnet::unescape($result);   } (split(/\,/,$result))
     }        );
     my @fields=map {  
         &Apache::lonnet::unescape($_);  
     } (split(/\,/,$result));  
     my ($title,$author,$subject,$url,$keywords,$version,  
         $notes,$abstract,$mime,$lang,  
         $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;  
     my %Fields =   
         ( title     => &Apache::lonnet::unescape($title),  
           author    => &Apache::lonnet::unescape($author),  
           subject   => &Apache::lonnet::unescape($subject),  
           url       => &Apache::lonnet::unescape($url),  
           keywords  => &Apache::lonnet::unescape($keywords),  
           version   => &Apache::lonnet::unescape($version),  
           notes     => &Apache::lonnet::unescape($notes),  
           abstract  => &Apache::lonnet::unescape($abstract),  
           mime      => &Apache::lonnet::unescape($mime),  
           lang      => &Apache::lonnet::unescape($lang),  
           owner     => &Apache::lonnet::unescape($owner),  
           copyright => &Apache::lonnet::unescape($copyright),  
           creationdate     => &Apache::lonnet::unescape($creationdate),  
           lastrevisiondate => &Apache::lonnet::unescape($lastrevisiondate)  
         );  
     $Fields{'language'} =   
         &Apache::loncommon::languagedescription($Fields{'lang'});  
     $Fields{'copyrighttag'} =  
         &Apache::loncommon::copyrightdescription($Fields{'copyright'});  
     $Fields{'mimetag'} =  
         &Apache::loncommon::filedescription($Fields{'mime'});  
     if ($Fields{'author'}=~/^(\s*|error)$/) {  
         $Fields{'author'}="Unknown Author";  
     }  
     # Put spaces in the keyword list, if needed.  
     $Fields{'keywords'}=~ s/,([A-z])/, $1/g;   
     if ($Fields{'title'}=~ /^\s*$/ ) {   
         $Fields{'title'}='Untitled';   
     }  
     unless ($ENV{'user.adv'}) {  
         # What is this anyway?  
         $Fields{'keywords'} = '- not displayed -';  
         $Fields{'notes'}    = '- not displayed -';  
         $Fields{'abstract'} = '- not displayed -';  
         $Fields{'subject'}  = '- not displayed -';  
     }  
     if (length($Fields{'abstract'})>200) {  
         $Fields{'abstract'} =   
             substr($Fields{'abstract'},0,200).'...';  
     }  
     if (length($Fields{'keywords'})>200) {  
         $Fields{'keywords'} =  
             substr($Fields{'keywords'},0,200).'...';  
     }  
     return %Fields;      return %Fields;
 }  }
   
Line 2836  sub detailed_citation_view { Line 2567  sub detailed_citation_view {
 <b>Notes:         </b> $values{'notes'}<br />  <b>Notes:         </b> $values{'notes'}<br />
 <b>MIME Type:     </b> $values{'mimetag'}<br />  <b>MIME Type:     </b> $values{'mimetag'}<br />
 <b>Language:      </b> $values{'language'}<br />  <b>Language:      </b> $values{'language'}<br />
 <b>Copyright/Distribution:</b> $values{'cprtag'}<br />  <b>Copyright/Distribution:</b> $values{'copyrighttag'}<br />
 </p>  </p>
 $values{'extrashow'}  $values{'extrashow'}
 <p>  <p>
Line 2965  $prefix Line 2696  $prefix
 &lt;mimetag&gt;$values{'mimetag'}&lt;/mimetag&gt;  &lt;mimetag&gt;$values{'mimetag'}&lt;/mimetag&gt;
 &lt;/mimeInfo&gt;  &lt;/mimeInfo&gt;
 &lt;languageInfo&gt;  &lt;languageInfo&gt;
 &lt;language&gt;$values{'lang'}&lt;/language&gt;  &lt;language&gt;$values{'language'}&lt;/language&gt;
 &lt;languagetag&gt;$values{'language'}&lt;/languagetag&gt;  &lt;languagetag&gt;$values{'languagetag'}&lt;/languagetag&gt;
 &lt;/languageInfo&gt;  &lt;/languageInfo&gt;
 &lt;creationdate&gt;$values{'creationdate'}&lt;/creationdate&gt;  &lt;creationdate&gt;$values{'creationdate'}&lt;/creationdate&gt;
 &lt;lastrevisiondate&gt;$values{'lastrevisiondate'}&lt;/lastrevisiondate&gt;  &lt;lastrevisiondate&gt;$values{'lastrevisiondate'}&lt;/lastrevisiondate&gt;

Removed from v.1.196  
changed lines
  Added in v.1.201


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