Diff for /loncom/interface/lonsearchcat.pm between versions 1.116 and 1.125

version 1.116, 2002/03/07 20:12:36 version 1.125, 2002/06/20 19:43:50
Line 31 Line 31
 # 10/12,10/14,10/15,10/16,11/28,11/29,12/10,12/12,12/16 Scott Harrison  # 10/12,10/14,10/15,10/16,11/28,11/29,12/10,12/12,12/16 Scott Harrison
 # YEAR=2002  # YEAR=2002
 # 1/17 Scott Harrison  # 1/17 Scott Harrison
   # 6/17 Matthew Hall
 #  #
 ###  ###############################################################################
   ###############################################################################
   
   =pod 
   
   =head1 NAME
   
   lonsearchcat
   
   =head1 SYNOPSIS
   
   Search interface to LON-CAPAs digital library
   
   =head1 DESCRIPTION
   
   This module enables searching for a distributed browseable catalog.
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   lonsearchcat presents the user with an interface to search the LON-CAPA
   digital library.  lonsearchcat also initiates the execution of a search
   by sending the search parameters to LON-CAPA servers.  The progress of 
   search (on a server basis) is displayed to the user in a seperate window.
   
   =head1 Internals
   
   =over 4
   
   =cut
   
   ###############################################################################
 ###############################################################################  ###############################################################################
   
 ##                                                                           ##  ##                                                                           ##
 ## ORGANIZATION OF THIS PERL MODULE                                          ##  ## ORGANIZATION OF THIS PERL MODULE                                          ##
 ##                                                                           ##  ##                                                                           ##
Line 60  use Apache::loncommon(); Line 92  use Apache::loncommon();
   
 # ---------------------------------------- variables used throughout the module  # ---------------------------------------- variables used throughout the module
   
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item Global variables
   
   =over 4
   
   =item %hostdomains
   
   matches host name to host domain
   
   =item %hostips
   
   matches host name to host ip
   
   =item %hitcount
   
   stores number of hits per host
   
   =item $closebutton
   
   button that closes the search window
   
   =item $importbutton
   
   button to take the selecte results and go to group sorting
   
   =item %hash   
   
   The ubiquitous database hash
   
   =item $diropendb 
   
   The full path to the (temporary) search database file.  This is set and
   used in &handler() and is also used in &output_results().
   
   =back 
   
   =cut
   
   ######################################################################
   ######################################################################
   
 # -- information holders  # -- information holders
 my %hostdomains; # matches host name to host domain  my %hostdomains; # matches host name to host domain
 my %hostips; # matches host name to host ip  my %hostips;     # matches host name to host ip
 my %hitcount; # stores number of hits per host  my %hitcount;    # stores number of hits per host
   
 # -- dynamically rendered interface components  # -- dynamically rendered interface components
 my $closebutton; # button that closes the search window  my $closebutton;  # button that closes the search window
 my $importbutton; # button to take the selected results and go to group sorting  my $importbutton; # button to take the selected results and go to group sorting
   
 # -- miscellaneous variables  # -- miscellaneous variables
 my $scrout; # string that holds portions of the screen output  
 my $yourself; # allows for quickly limiting to oneself  my $yourself; # allows for quickly limiting to oneself
 my %hash;  my %hash;     # database hash
   
 # ------------------------------------------ choices for different output views  # ------------------------------------------ choices for different output views
 # Detailed Citation View ---> sub detailed_citation_view  # Detailed Citation View ---> sub detailed_citation_view
 # Summary View ---> sub summary_view  # Summary View ---> sub summary_view
 # Fielded Format ---> sub fielded_format_view  # Fielded Format ---> sub fielded_format_view
 # XML/SGML ---> sub xml_sgml_view  # XML/SGML ---> sub xml_sgml_view
 my $basicviewselect=<<END;  
 <select name='basicviewselect'>  #------------------------------------------------------------- global variables
 <option value='Detailed Citation View'>Detailed Citation View</option>  my $diropendb = "";
 <option value='Summary View'>Summary View</option>  my $domain = "";
 <option value='Fielded Format'>Fielded Format</option>  
 <option value='XML/SGML'>XML/SGML</option>  
 </select>  
 END  
 my $advancedviewselect=<<END;  
 <select name='advancedviewselect'>  
 <option value='Detailed Citation View'>Detailed Citation View</option>  
 <option value='Summary View'>Summary View</option>  
 <option value='Fielded Format'>Fielded Format</option>  
 <option value='XML/SGML'>XML/SGML</option>  
 </select>  
 END  
   
 # ----------------------------------------------------------------------- BEGIN  # ----------------------------------------------------------------------- BEGIN
   
   =pod
   
   =item BEGIN block
   
   Load %hostdomains and %hostips with data from lonnet.pm.  Only library
   servers are considered.
   
   =cut
   
 BEGIN {  BEGIN {
     {      foreach (keys (%Apache::lonnet::libserv)) {
  my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.          $hostdomains{$_}=$Apache::lonnet::hostdom{$_};
  '/hosts.tab');          $hostips{$_}=$Apache::lonnet::hostip{$_};
  while (<$fh>) {  
     $_=~/(\w+?)\:(\w+?)\:(\w+?)\:(.*)/; chomp;  
     if ($3 eq 'library') {  
  $hostdomains{$1}=$2;  
  $hostips{$1}=$4;  
     }  
  }  
     }      }
 }  }
   
 my $diropendb = "";  ######################################################################
 my $domain = "";  ######################################################################
   
   =pod 
   
   =item &handler() - main handler invoked by httpd child
   
   =item Variables
   
 # ----------------------------- Handling routine called via Apache and mod_perl  =over 4
   
   =item $hidden
   
   holds 'hidden' html forms
   
   =item $scrout
   
   string that holds portions of the screen output
   
   =back 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     untie %hash;      untie %hash;
Line 123  sub handler { Line 211  sub handler {
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
   
     $domain  = $r->dir_config('lonDefDomain');      my $domain  = $r->dir_config('lonDefDomain');
     $diropendb= "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_searchcat.db";      $diropendb= "/home/httpd/perl/tmp/".&Apache::lonnet::escape($domain).
               "\_".&Apache::lonnet::escape($ENV{'user.name'})."_searchcat.db";
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
              ['catalogmode','launch','acts']);               ['catalogmode','launch','acts','mode','form','element',
                 'reqinterface']);
       ##
       ## Clear out old values from database
       ##
     if ($ENV{'form.launch'} eq '1') {      if ($ENV{'form.launch'} eq '1') {
  if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {   if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
     &start_fresh_session();      &start_fresh_session();
     untie %hash;      untie %hash;
  }   } else {
  else {  
     $r->print('<html><head></head><body>Unable to tie hash to db '.      $r->print('<html><head></head><body>Unable to tie hash to db '.
       'file</body></html>');        'file</body></html>');
     return OK;      return OK;
  }   }
     }      }
       ##
 # ----------------------------------- configure dynamic components of interface      ## Produce some output, so people know it is working
     my $hidden='';      ##
       $r->print("\n");
       $r->rflush;
       ##
       ## Configure dynamic components of interface
       ##
       my $hidden;       # Holds 'hidden' html forms
     if ($ENV{'form.catalogmode'} eq 'interactive') {      if ($ENV{'form.catalogmode'} eq 'interactive') {
  $hidden="<input type='hidden' name='catalogmode' value='interactive'>".   $hidden="<input type='hidden' name='catalogmode' value='interactive'>".
     "\n";      "\n";
         $closebutton="<input type='button' name='close' value='CLOSE' ".          $closebutton="<input type='button' name='close' value='CLOSE' ".
     "onClick='self.close()'>"."\n";      "onClick='self.close()'>"."\n";
     }      } elsif ($ENV{'form.catalogmode'} eq 'groupsearch') {
     elsif ($ENV{'form.catalogmode'} eq 'groupsearch') {  
  $hidden=<<END;   $hidden=<<END;
 <input type='hidden' name='catalogmode' value='groupsearch'>  <input type='hidden' name='catalogmode' value='groupsearch'>
 END  END
Line 161  END Line 257  END
 onClick='javascript:select_group()'>  onClick='javascript:select_group()'>
 END  END
     }      }
       $hidden .= <<END;
   <input type='hidden' name='mode'    value='$ENV{'form.mode'}'>
   <input type='hidden' name='form'    value='$ENV{'form.form'}'>
   <input type='hidden' name='element' value='$ENV{'form.element'}'>
   <input type='hidden' name='date' value='2'>
   END
       ##
       ##  What are we doing?
       ##
       if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
           # Perform basic search and give results
    return &basicsearch($r,\%ENV,$hidden);
       } elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') {
           # Perform advanced search and give results
    return &advancedsearch($r,\%ENV,$hidden);
       } elsif ($ENV{'form.reqinterface'} eq 'advanced') {
           # Output the advanced interface
           $r->print(&advanced_search_form($closebutton,$hidden));
           return OK;
       } else { 
           # Output normal search interface
           $r->print(&basic_search_form($closebutton,$hidden));
       }
       return OK;
   } 
   
 # ------------------------------------------------------ Determine current user  ######################################################################
     $yourself=$ENV{'user.name'}.'@'.$ENV{'user.domain'};  ######################################################################
   
 # --- Now, depending on the interface actions, do one of three things here:  =pod 
 # --- 1. a basic search  
 # --- 2. an advanced search  
 # --- 3. output a search interface  
   
 # ----------------------------------- See if a search invocation should be done  =item &basic_search_form() 
     if ($ENV{'form.basicsubmit'} eq 'SEARCH') {  
  untie %hash; return &basicsearch($r,\%ENV);  Returns a scalar which holds html for the basic search form.
     }  
     elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') {  =cut
  untie %hash; return &advancedsearch($r,\%ENV);  
   ######################################################################
   ######################################################################
   
   sub basic_search_form{
       my ($closebutton,$hidden) = @_;
       my $scrout=<<"ENDDOCUMENT";
   <html>
   <head>
   <title>The LearningOnline Network with CAPA</title>
   <script type="text/javascript">
       function openhelp(val) {
    openhelpwin=open('/adm/help/searchcat.html','helpscreen',
        'scrollbars=1,width=600,height=300');
    openhelpwin.focus();
     }      }
   </script>
   </head>
   <body bgcolor="#FFFFFF">
   <img align='right' src='/adm/lonIcons/lonlogos.gif' />
   <h1>Search Catalog</h1>
   <form method="post" action="/adm/searchcat">
   $hidden
   <h3>Basic Search</h3>
   <p>
   Enter terms or phrases separated by AND, OR, or NOT then press SEARCH below.
   </p>
   <p>
   <table>
   <tr><td>
   ENDDOCUMENT
       $scrout.='&nbsp;'.&simpletextfield('basicexp',$ENV{'form.basicexp'},40).
           '&nbsp;';
   #    $scrout.=&simplecheckbox('allversions',$ENV{'form.allversions'});
   #    $scrout.='<font color="#800000">Search historic archives</font>';
       $scrout.=<<ENDDOCUMENT;
   </td><td><a href="/adm/searchcat?reqinterface=advanced">Advanced Search</a></td></tr></table>
   </p>
   <p>
   &nbsp;<input type="submit" name="basicsubmit" value='SEARCH' />&nbsp;
   $closebutton
   <!-- basic view selection -->
   <select name='basicviewselect'>
   <option value='Detailed Citation View' selected="true">
   Detailed Citation View</option>
   <option value='Summary View'>Summary View</option>
   <option value='Fielded Format'>Fielded Format</option>
   <option value='XML/SGML'>XML/SGML</option>
   </select>
   <!-- end of basic view selection -->
   <input type="button" value="HELP" onClick="openhelp()" />
   </p>
   </form>
   </body>
   </html>
   ENDDOCUMENT
       return $scrout;
   }
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item &advanced_search_form() 
   
   Returns a scalar which holds html for the advanced search form.
   
 # ----------------------------- Else, begin building search interface to output  =cut
     $scrout=''; # building a part of screen output  
   ######################################################################
   ######################################################################
   
   sub advanced_search_form{
       my ($closebutton,$hidden) = @_;
       my $scrout=<<"ENDHEADER";
   <html>
   <head>
   <title>The LearningOnline Network with CAPA</title>
   <script type="text/javascript">
       function openhelp(val) {
    openhelpwin=open('/adm/help/searchcat.html','helpscreen',
        'scrollbars=1,width=600,height=300');
    openhelpwin.focus();
       }
   </script>
   </head>
   <body bgcolor="#FFFFFF">
   <img align='right' src='/adm/lonIcons/lonlogos.gif' />
   <h1>Search Catalog</h1>
   <form method="post" action="/adm/searchcat">
   $hidden
   <hr />
   <h3>Advanced Search</h3>
   ENDHEADER
     $scrout.=&searchphrasefield('Limit by title','title',      $scrout.=&searchphrasefield('Limit by title','title',
  $ENV{'form.title'});   $ENV{'form.title'});
   
     $scrout.=&searchphrasefield('Limit by author','author',      $scrout.=&searchphrasefield('Limit by author','author',
  $ENV{'form.author'});   $ENV{'form.author'});
   
     $scrout.=&searchphrasefield('Limit by subject','subject',      $scrout.=&searchphrasefield('Limit by subject','subject',
  $ENV{'form.subject'});   $ENV{'form.subject'});
   
     $scrout.=&searchphrasefield('Limit by keywords','keywords',      $scrout.=&searchphrasefield('Limit by keywords','keywords',
  $ENV{'form.keywords'});   $ENV{'form.keywords'});
   
     $scrout.=&searchphrasefield('Limit by URL','url',      $scrout.=&searchphrasefield('Limit by URL','url',
  $ENV{'form.url'});   $ENV{'form.url'});
   
 #    $scrout.=&searchphrasefield('Limit by version','version',  #    $scrout.=&searchphrasefield('Limit by version','version',
 # $ENV{'form.version'});  # $ENV{'form.version'});
   
     $scrout.=&searchphrasefield('Limit by notes','notes',      $scrout.=&searchphrasefield('Limit by notes','notes',
  $ENV{'form.notes'});   $ENV{'form.notes'});
   
     $scrout.=&searchphrasefield('Limit by abstract','abstract',      $scrout.=&searchphrasefield('Limit by abstract','abstract',
  $ENV{'form.abstract'});   $ENV{'form.abstract'});
   
     $ENV{'form.mime'}='any' unless length($ENV{'form.mime'});      $ENV{'form.mime'}='any' unless length($ENV{'form.mime'});
     $scrout.=&selectbox('Limit by MIME type','mime',      $scrout.=&selectbox('Limit by MIME type','mime',
  $ENV{'form.mime'},   $ENV{'form.mime'},
  'any','Any type',   'any','Any type',
  \&{Apache::loncommon::filedescriptionex},   \&{Apache::loncommon::filedescriptionex},
  (&Apache::loncommon::fileextensions));   (&Apache::loncommon::fileextensions));
   
     $ENV{'form.language'}='any' unless length($ENV{'form.language'});      $ENV{'form.language'}='any' unless length($ENV{'form.language'});
   
     $scrout.=&selectbox('Limit by language','language',      $scrout.=&selectbox('Limit by language','language',
  $ENV{'form.language'},'any','Any Language',   $ENV{'form.language'},'any','Any Language',
  \&{Apache::loncommon::languagedescription},   \&{Apache::loncommon::languagedescription},
  (&Apache::loncommon::languageids),   (&Apache::loncommon::languageids),
  );   );
   
 # ------------------------------------------------ Compute date selection boxes  # ------------------------------------------------ Compute date selection boxes
     $scrout.=<<CREATIONDATESTART;      $scrout.=<<CREATIONDATESTART;
 <p>  <p>
Line 232  CREATIONDATESTART Line 428  CREATIONDATESTART
  $ENV{'form.creationdatestart_day'},   $ENV{'form.creationdatestart_day'},
  $ENV{'form.creationdatestart_year'},   $ENV{'form.creationdatestart_year'},
  );   );
     $scrout.=<<CREATIONDATEEND;      $scrout.="and:\n";
 and:  
 CREATIONDATEEND  
     $scrout.=&dateboxes('creationdateend',12,31,2051,      $scrout.=&dateboxes('creationdateend',12,31,2051,
  $ENV{'form.creationdateend_month'},   $ENV{'form.creationdateend_month'},
  $ENV{'form.creationdateend_day'},   $ENV{'form.creationdateend_day'},
  $ENV{'form.creationdateend_year'},   $ENV{'form.creationdateend_year'},
  );   );
     $scrout.="</p>";      $scrout.="</p>";
   
     $scrout.=<<LASTREVISIONDATESTART;      $scrout.=<<LASTREVISIONDATESTART;
 <p>  <p>
 <font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE:  <font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE:
Line 262  LASTREVISIONDATEEND Line 455  LASTREVISIONDATEEND
  $ENV{'form.lastrevisiondateend_year'},   $ENV{'form.lastrevisiondateend_year'},
  );   );
     $scrout.='</p>';      $scrout.='</p>';
   
     $scrout.=&searchphrasefield('Limit by publisher/owner','owner',      $scrout.=&searchphrasefield('Limit by publisher/owner','owner',
  $ENV{'form.owner'});   $ENV{'form.owner'});
   
     $ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'});      $ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'});
     $scrout.=&selectbox('Limit by copyright/distribution','copyright',      $scrout.=&selectbox('Limit by copyright/distribution','copyright',
  $ENV{'form.copyright'},   $ENV{'form.copyright'},
Line 273  LASTREVISIONDATEEND Line 464  LASTREVISIONDATEEND
  \&{Apache::loncommon::copyrightdescription},   \&{Apache::loncommon::copyrightdescription},
  (&Apache::loncommon::copyrightids),   (&Apache::loncommon::copyrightids),
  );   );
   
 # ------------------------------------------- Compute customized metadata field  # ------------------------------------------- Compute customized metadata field
     $scrout.=<<CUSTOMMETADATA;      $scrout.=<<CUSTOMMETADATA;
 <p>  <p>
Line 284  For resource-specific metadata, enter in Line 474  For resource-specific metadata, enter in
 <b>Example:</b> grandmother=75 OR grandfather=85  <b>Example:</b> grandmother=75 OR grandfather=85
 <br />  <br />
 CUSTOMMETADATA  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.=<<CUSTOMSHOW;      $scrout.=<<CUSTOMSHOW;
 <p>  <p>
 <font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b>  <font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b>
Line 295  Enter in a space-separated list of speci Line 483  Enter in a space-separated list of speci
 in a fielded listing for each record result.  in a fielded listing for each record result.
 <br />  <br />
 CUSTOMSHOW  CUSTOMSHOW
 $scrout.=&simpletextfield('customshow',$ENV{'form.customshow'});      $scrout.=&simpletextfield('customshow',$ENV{'form.customshow'});
 $scrout.=' <i>initial users of this system do not need to worry about this option</i>';      $scrout.=<<ENDDOCUMENT;
   
 # ---------------------------------------------------------------- Print screen  
     $r->print(<<ENDDOCUMENT);  
 <html>  
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 <script type="text/javascript">  
     function openhelp(val) {  
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',  
      'scrollbars=1,width=600,height=300');  
  openhelpwin.focus();  
     }  
 </script>  
 </head>  
 <body bgcolor="#FFFFFF">  
 <img align='right' src='/adm/lonIcons/lonlogos.gif' />  
 <h1>Search Catalog</h1>  
 <form method="post" action="/adm/searchcat">  
 $hidden  
 <hr />  
 <h3>Basic Search</h3>  
 <p>  
 Enter terms or phrases separated by search operators  
 such as AND, OR, or NOT then press SEARCH below.  Terms should be specific  
 to the title, author, subject, notes, or abstract information associated  
 with a resource.  
 <br />  
 ENDDOCUMENT  
     $r->print(&simpletextfield('basicexp',$ENV{'form.basicexp'}));  
     $r->print(' ');  
     $r->print(&simplecheckbox('titleonly',$ENV{'form.titleonly'}));  
     $r->print('<font color="#800000">Title only</font> ');  
 #    $r->print(&simplecheckbox('allversions',$ENV{'form.allversions'}));  
 # <font color="#800000">Search historic archives</font>  
     $r->print(<<ENDDOCUMENT);  
 <br />  
 <input type="submit" name="basicsubmit" value='SEARCH' />  
 <input type="reset" name="reset" value='RESET' />  
 $closebutton  
 $basicviewselect  
 <input type="button" value="HELP" onClick="openhelp()" />  
 </p>  
 <hr />  
 <h3>Advanced Search</h3>  
 $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  <!-- advance view select -->
   <select name='advancedviewselect'>
   <option value='Detailed Citation View' selected="true">
   Detailed Citation View</option>
   <option value='Summary View'>Summary View</option>
   <option value='Fielded Format'>Fielded Format</option>
   <option value='XML/SGML'>XML/SGML</option>
   </select>
   <!-- end of advanced view select -->
 <input type="button" value="HELP" onClick="openhelp()" />  <input type="button" value="HELP" onClick="openhelp()" />
 </p>  </p>
 </form>  </form>
 </body>  </body>
 </html>  </html>
 ENDDOCUMENT  ENDDOCUMENT
     return OK;      return $scrout;
 }   }
   
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item &make_persistent() 
   
   Returns a scalar which holds the current ENV{'form.*'} values in
   a 'hidden' html input tag.  
   
   =cut
   
   ######################################################################
   ######################################################################
   
 # ------------------------------------------------------------- make persistent  
 sub make_persistent {  sub make_persistent {
     my $persistent='';      my $persistent='';
       
     foreach (keys %ENV) {      foreach (keys %ENV) {
  if (/^form\./ && !/submit/) {   if (/^form\./ && !/submit/) {
     my $name=$_;      my $name=$_;
Line 367  sub make_persistent { Line 531  sub make_persistent {
     $ENV{$key}=~s/\'//g; # do not mess with html field syntax      $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
         }          }
     }      }
     return $persistent;      return $persistent;
 }  }
   
 # --------------------------------------------------------- Various form fields  
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item HTML form building functions
   
   =over 4
   
   =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.
   
   =item &simplecheckbox()
   
   Inputs: $name,$value
   
   Returns a simple check box with the given $name.
   If $value eq 'on' the box is checked.
   
   =item &searchphrasefield()
   
   Inputs: $title,$name,$value
   
   Returns html for a title line and an input field for entering search terms.
   the instructions "Enter terms or phrases separated by search operators such 
   as AND, OR, or NOT." are given following the title.  The entry field (which
   is where the $name and $value are used) is an 80 column simpletextfield.
   
   =item &dateboxes()
   
   =item &selectbox()
   
   =back 
   
   =cut
   
   ######################################################################
   ######################################################################
   
 sub simpletextfield {  sub simpletextfield {
     my ($name,$value)=@_;      my ($name,$value,$size)=@_;
     return '<input type=text name=\''.$name.      $size = 20 if (! defined($size));
    '\' size=20 value=\''.$value.'\' />';      return '<input type="text" name="'.$name.
           '" size="'.$size.'" 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 {
     my ($title,$name,$value)=@_;      my ($title,$name,$value)=@_;
     my $instruction=<<END;      my $instruction=<<END;
 Enter terms or phrases separated by search operators such  Enter terms or phrases separated by search operators such as AND, OR, or NOT.
 as AND, OR, or NOT.  
 END  END
     my $uctitle=uc($title);      my $uctitle=uc($title);
     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:</b>".      return "\n".
    "</FONT> $instruction<br />".          '<p><font color="#800000" face="helvetica"><b>'.$uctitle.':</b>'.
            '<input type=text name="'.$name.'" size=80 value=\''.$value.'\'>';          "</FONT> $instruction<br />".&simpletextfield($name,$value,80);
 }  }
   
 sub dateboxes {  sub dateboxes {
     my ($name,$defaultmonth,$defaultday,$defaultyear,      my ($name,$defaultmonth,$defaultday,$defaultyear,
  $currentmonth,$currentday,$currentyear)=@_;   $currentmonth,$currentday,$currentyear)=@_;
     ($defaultmonth,$defaultday,$defaultyear)=('','','');      ($defaultmonth,$defaultday,$defaultyear)=('','','');
     my $month=<<END;      #
 <select name="${name}_month">      # Day
 <option value='$defaultmonth'> </option>  
 <option value="1">January</option>  
 <option value="2">February</option>  
 <option value="3">March</option>  
 <option value="4">April</option>  
 <option value="5">May</option>  
 <option value="6">June</option>  
 <option value="7">July</option>  
 <option value="8">August</option>  
 <option value="9">September</option>  
 <option value="10">October</option>  
 <option value="11">November</option>  
 <option value="12">December</option>  
 </select>  
 END  
     $month=~s/(\"$currentmonth\")/$1 SELECTED/ if length($currentmonth);  
     my $day=<<END;      my $day=<<END;
 <select name="${name}_day">  <select name="${name}_day">
 <option value='$defaultday'> </option>  <option value='$defaultday'> </option>
 <option value="1">1</option>  
 <option value="2">2</option>  
 <option value="3">3</option>  
 <option value="4">4</option>  
 <option value="5">5</option>  
 <option value="6">6</option>  
 <option value="7">7</option>  
 <option value="8">8</option>  
 <option value="9">9</option>  
 <option value="10">10</option>  
 <option value="11">11</option>  
 <option value="12">12</option>  
 <option value="13">13</option>  
 <option value="14">14</option>  
 <option value="15">15</option>  
 <option value="16">16</option>  
 <option value="17">17</option>  
 <option value="18">18</option>  
 <option value="19">19</option>  
 <option value="20">20</option>  
 <option value="21">21</option>  
 <option value="22">22</option>  
 <option value="23">23</option>  
 <option value="24">24</option>  
 <option value="25">25</option>  
 <option value="26">26</option>  
 <option value="27">27</option>  
 <option value="28">28</option>  
 <option value="29">29</option>  
 <option value="30">30</option>  
 <option value="31">31</option>  
 </select>  
 END  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);      $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\">$_</option>\n";
    $i++;
       }
       $month.="</select>\n";
       $month=~s/(\"$currentmonth\")/$1 SELECTED/ if length($currentmonth);
       #
       # Year (obviously)
     my $year=<<END;      my $year=<<END;
 <select name="${name}_year">  <select name="${name}_year">
 <option value='$defaultyear'> </option>  <option value='$defaultyear'> </option>
 <option value="1976">1976</option>  
 <option value="1977">1977</option>  
 <option value="1978">1978</option>  
 <option value="1979">1979</option>  
 <option value="1980">1980</option>  
 <option value="1981">1981</option>  
 <option value="1982">1982</option>  
 <option value="1983">1983</option>  
 <option value="1984">1984</option>  
 <option value="1985">1985</option>  
 <option value="1986">1986</option>  
 <option value="1987">1987</option>  
 <option value="1988">1988</option>  
 <option value="1989">1989</option>  
 <option value="1990">1990</option>  
 <option value="1991">1991</option>  
 <option value="1992">1992</option>  
 <option value="1993">1993</option>  
 <option value="1994">1994</option>  
 <option value="1995">1995</option>  
 <option value="1996">1996</option>  
 <option value="1997">1997</option>  
 <option value="1998">1998</option>  
 <option value="1999">1999</option>  
 <option value="2000">2000</option>  
 <option value="2001">2001</option>  
 <option value="2002">2002</option>  
 <option value="2003">2003</option>  
 <option value="2004">2004</option>  
 <option value="2005">2005</option>  
 <option value="2006">2006</option>  
 <option value="2007">2007</option>  
 <option value="2008">2008</option>  
 <option value="2009">2009</option>  
 <option value="2010">2010</option>  
 <option value="2011">2011</option>  
 <option value="2012">2012</option>  
 <option value="2013">2013</option>  
 <option value="2014">2014</option>  
 <option value="2015">2015</option>  
 <option value="2016">2016</option>  
 <option value="2017">2017</option>  
 <option value="2018">2018</option>  
 <option value="2019">2019</option>  
 <option value="2020">2020</option>  
 <option value="2021">2021</option>  
 <option value="2022">2022</option>  
 <option value="2023">2023</option>  
 <option value="2024">2024</option>  
 <option value="2025">2025</option>  
 <option value="2026">2026</option>  
 <option value="2027">2027</option>  
 <option value="2028">2028</option>  
 <option value="2029">2029</option>  
 <option value="2030">2030</option>  
 <option value="2031">2031</option>  
 <option value="2032">2032</option>  
 <option value="2033">2033</option>  
 <option value="2034">2034</option>  
 <option value="2035">2035</option>  
 <option value="2036">2036</option>  
 <option value="2037">2037</option>  
 <option value="2038">2038</option>  
 <option value="2039">2039</option>  
 <option value="2040">2040</option>  
 <option value="2041">2041</option>  
 <option value="2042">2042</option>  
 <option value="2043">2043</option>  
 <option value="2044">2044</option>  
 <option value="2045">2045</option>  
 <option value="2046">2046</option>  
 <option value="2047">2047</option>  
 <option value="2048">2048</option>  
 <option value="2049">2049</option>  
 <option value="2050">2050</option>  
 <option value="2051">2051</option>  
 </select>  
 END  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);      $year=~s/(\"$currentyear\")/$1 SELECTED/ if length($currentyear);
     return "$month$day$year";      return "$month$day$year";
 }  }
Line 548  END Line 654  END
 sub selectbox {  sub selectbox {
     my ($title,$name,$value,$anyvalue,$anytag,$functionref,@idlist)=@_;      my ($title,$name,$value,$anyvalue,$anytag,$functionref,@idlist)=@_;
     my $uctitle=uc($title);      my $uctitle=uc($title);
     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      my $selout="\n".'<p><font color="#800000" face="helvetica">'.
  "</b></font><br />".'<select name="'.$name.'">';          '<b>'.$uctitle.':</b></font><br /><select name="'.$name.'">';
     foreach ($anyvalue,@idlist) {      foreach ($anyvalue,@idlist) {
         $selout.='<option value=\''.$_.'\'';          $selout.='<option value="'.$_.'"';
         if ($_ eq $value and !/^any$/) {          if ($_ eq $value and !/^any$/) {
     $selout.=' selected>'.&{$functionref}($_).'</option>';      $selout.=' selected >'.&{$functionref}($_).'</option>';
  }   }
  elsif ($_ eq $value and /^$anyvalue$/) {   elsif ($_ eq $value and /^$anyvalue$/) {
     $selout.=' selected>'.$anytag.'</option>';      $selout.=' selected >'.$anytag.'</option>';
  }   }
         else {$selout.='>'.&{$functionref}($_).'</option>';}          else {$selout.='>'.&{$functionref}($_).'</option>';}
     }      }
     return $selout.'</select>';      return $selout.'</select>';
 }  }
   
 sub testf {  ######################################################################
     return @_[0];  ######################################################################
 }  
   =pod 
   
   =item &advancedsearch() 
   
 # ----------------------------------------------- Performing an advanced search  =cut
   
   ######################################################################
   ######################################################################
 sub advancedsearch {  sub advancedsearch {
     my ($r,$envhash)=@_;      my ($r,$envhash,$hidden)=@_;
     my %ENV=%{$envhash};      my %ENV=%{$envhash};
   
     my $fillflag=0;      my $fillflag=0;
     # Clean up fields for safety      # Clean up fields for safety
     for my $field ('title','author','subject','keywords','url','version',      for my $field ('title','author','subject','keywords','url','version',
Line 585  sub advancedsearch { Line 696  sub advancedsearch {
    'custommetadata','customshow') {     'custommetadata','customshow') {
  $ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g;   $ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }      }
       foreach ('mode','form','element') {
    # is this required?  Hmmm.
    next unless (exists($ENV{"form.$_"}));
    $ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
    $ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
       }
     # Check to see if enough information was filled in      # Check to see if enough information was filled in
     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 598  sub advancedsearch { Line 714  sub advancedsearch {
  &output_blank_field_error($r);   &output_blank_field_error($r);
  return OK;   return OK;
     }      }
   
   
     # Turn the form input into a SQL-based query      # Turn the form input into a SQL-based query
     my $query='';      my $query='';
   
     my @queries;      my @queries;
     # 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',
Line 644  sub advancedsearch { Line 757  sub advancedsearch {
     elsif ($datequery) {      elsif ($datequery) {
  push @queries,$datequery;   push @queries,$datequery;
     }      }
   
     # Process form information for custom metadata querying      # Process form information for custom metadata querying
     my $customquery='';      my $customquery='';
     if ($ENV{'form.custommetadata'}) {      if ($ENV{'form.custommetadata'}) {
Line 672  sub advancedsearch { Line 784  sub advancedsearch {
     $reply=&Apache::lonnet::metadata_query($query,      $reply=&Apache::lonnet::metadata_query($query,
    $customquery,$customshow);     $customquery,$customshow);
  }   }
  &output_results('Advanced',$r,$envhash,$customquery,$reply);   &output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden);
     }      }
     elsif ($customquery) {      elsif ($customquery) {
  my $reply; # reply hash reference   my $reply; # reply hash reference
  $reply=&Apache::lonnet::metadata_query('',   $reply=&Apache::lonnet::metadata_query('',
        $customquery,$customshow);         $customquery,$customshow);
  &output_results('Advanced',$r,$envhash,$customquery,$reply);   &output_results('Advanced',$r,$envhash,$customquery,$reply,$hidden);
     }      }
     # should not get to this point      # should not get to this point
     return 'Error.  Should not have gone to this point.';      return 'Error.  Should not have gone to this point.';
 }  }
   
 # --------------------------------------------------- Performing a basic search  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &basicsearch() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub basicsearch {  sub basicsearch {
     my ($r,$envhash)=@_;      my ($r,$envhash,$hidden)=@_;
     my %ENV=%{$envhash};      my %ENV=%{$envhash};
     # Clean up fields for safety      # Clean up fields for safety
     for my $field ('basicexp') {      for my $field ('basicexp') {
  $ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g;   $ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g;
     }      }
       foreach ('mode','form','element') {
    # is this required?  Hmmm.
    next unless (exists($ENV{"form.$_"}));
    $ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
    $ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
       }
   
     # Check to see if enough is filled in      # Check to see if enough is filled in
     unless (&filled($ENV{'form.basicexp'})) {      unless (&filled($ENV{'form.basicexp'})) {
Line 702  sub basicsearch { Line 830  sub basicsearch {
     # Build SQL query string based on form page      # Build SQL query string based on form page
     my $query='';      my $query='';
     my $concatarg=join(',"    ",',      my $concatarg=join(',"    ",',
        ('title', 'author', 'subject', 'notes', 'abstract'));         ('title', 'author', 'subject', 'notes', 'abstract',
                           'keywords'));
     $concatarg='title' if $ENV{'form.titleonly'};      $concatarg='title' if $ENV{'form.titleonly'};
   
     $query=&build_SQL_query('concat('.$concatarg.')',$ENV{'form.'.'basicexp'});      $query=&build_SQL_query('concat('.$concatarg.')',$ENV{'form.'.'basicexp'});
Line 712  sub basicsearch { Line 841  sub basicsearch {
   
     # Output search results      # Output search results
   
     &output_results('Basic',$r,$envhash,$query,$reply);      &output_results('Basic',$r,$envhash,$query,$reply,$hidden);
   
     return OK;      return OK;
 }  }
   
 # ------------------------------------------------------------- build_SQL_query  
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item &build_SQL_query() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub build_SQL_query {  sub build_SQL_query {
     my ($field_name,$logic_statement)=@_;      my ($field_name,$logic_statement)=@_;
     my $q=new Text::Query('abc',      my $q=new Text::Query('abc',
Line 729  sub build_SQL_query { Line 869  sub build_SQL_query {
     return $sql_query;      return $sql_query;
 }  }
   
 # ------------------------------------------------- build custom metadata query  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &build_custommetadata_query() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub build_custommetadata_query {  sub build_custommetadata_query {
     my ($field_name,$logic_statement)=@_;      my ($field_name,$logic_statement)=@_;
       &Apache::lonnet::logthis("Entered build_custommetadata_query:".
                                $field_name.':'.$logic_statement);
     my $q=new Text::Query('abc',      my $q=new Text::Query('abc',
   -parse => 'Text::Query::ParseAdvanced',    -parse => 'Text::Query::ParseAdvanced',
   -build => 'Text::Query::BuildAdvancedString');    -build => 'Text::Query::BuildAdvancedString');
Line 739  sub build_custommetadata_query { Line 891  sub build_custommetadata_query {
     my $matchexp=${$q}{'-parse'}{'-build'}{'matchstring'};      my $matchexp=${$q}{'-parse'}{'-build'}{'matchstring'};
     # quick fix to change literal into xml tag-matching      # quick fix to change literal into xml tag-matching
     # will eventually have to write a separate builder module      # will eventually have to write a separate builder module
     my $oldmatchexp=$matchexp;      # wordone=wordtwo becomes\<wordone\>[^\<] *wordtwo[^\<]*\<\/wordone\>
     $matchexp=~s/(\w+)\\\=([\w\\\+]+)/\\\<$1\\\>\[\^\\\<\]\*$2\[\^\\\<\]\*\\\<\\\/$1\\\>/g;      $matchexp =~ s/(\w+)\\=([\w\\\+]+)?# wordone=wordtwo is changed to 
                    /\\<$1\\>?#           \<wordone\>
                      \[\^\\<\]?#        [^\<]         
                      \*$2\[\^\\<\]?#           *wordtwo[^\<]
                      \*\\<\\\/$1\\>?#                        *\<\/wordone\>
                      /g;
       &Apache::lonnet::logthis("match expression: ".$matchexp);
     return $matchexp;      return $matchexp;
 }  }
   
 # - Recursively parse a reverse notation expression into a SQL query expression  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &recursive_SQL_query_build() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub recursive_SQL_query_build {  sub recursive_SQL_query_build {
     my ($dkey,$pattern)=@_;      my ($dkey,$pattern)=@_;
     my @matches=($pattern=~/(\[[^\]|\[]*\])/g);      my @matches=($pattern=~/(\[[^\]|\[]*\])/g);
Line 778  sub recursive_SQL_query_build { Line 946  sub recursive_SQL_query_build {
     &recursive_SQL_query_build($dkey,$pattern);      &recursive_SQL_query_build($dkey,$pattern);
 }  }
   
 # ------------------------------------------------------------ Build date query  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &build_date_queries() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub build_date_queries {  sub build_date_queries {
     my ($cmonth1,$cday1,$cyear1,$cmonth2,$cday2,$cyear2,      my ($cmonth1,$cday1,$cyear1,$cmonth2,$cday2,$cyear2,
  $lmonth1,$lday1,$lyear1,$lmonth2,$lday2,$lyear2)=@_;   $lmonth1,$lday1,$lyear1,$lmonth2,$lday2,$lyear2)=@_;
Line 827  sub build_date_queries { Line 1005  sub build_date_queries {
     return '';      return '';
 }  }
   
 # ----------------------------- format and output results based on a reply list  ######################################################################
 # There are two windows that this function writes to.  The main search  ######################################################################
 # window ("srch") has a listing of the results.  A secondary window ("popwin")  
 # gives the status of the network search (time elapsed, number of machines  =pod 
 # contacted, etc.)  
   =item &output_results() 
   
   Format and output results based on a reply list.
   There are two windows that this function writes to.  The main search
   window ("srch") has a listing of the results.  A secondary window ("popwin")
   gives the status of the network search (time elapsed, number of machines
   contacted, etc.)
   
   =cut
   
   ######################################################################
   ######################################################################
 sub output_results {  sub output_results {
     my $fnum; # search result counter      my $fnum; # search result counter
     my ($mode,$r,$envhash,$query,$replyref)=@_;      my ($mode,$r,$envhash,$query,$replyref,$hidden)=@_;
     my %ENV=%{$envhash};      my %ENV=%{$envhash};
     my %rhash=%{$replyref};      my %rhash=%{$replyref};
     my $compiledresult='';      my $compiledresult='';
     my $timeremain=300;      my $timeremain=300; # (seconds)
     my $elapsetime=0;      my $elapsetime=0;
     my $resultflag=0;      my $resultflag=0;
     my $tflag=1;      my $tflag=1;
       #
     # make query information persistent to allow for subsequent revision      # make query information persistent to allow for subsequent revision
     my $persistent=&make_persistent();      my $persistent=&make_persistent();
       # spit out the generic header
     # output beginning of search page      $r->print(&search_results_header());
  $r->print(<<BEGINNING);  
 <html>  
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 BEGINNING  
   
     # conditional output of script functions dependent on the mode in  
     # which the search was invoked  
         $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'interactive';  
 <script type="text/javascript">  
     function select_data(title,url) {  
  changeTitle(title);  
  changeURL(url);  
  self.close();  
     }  
     function changeTitle(val) {  
  if (opener.inf.document.forms.resinfo.elements.t) {  
     opener.inf.document.forms.resinfo.elements.t.value=val;  
  }  
     }  
     function changeURL(val) {  
  if (opener.inf.document.forms.resinfo.elements.u) {  
     opener.inf.document.forms.resinfo.elements.u.value=val;  
  }  
     }  
 </script>  
 SCRIPT  
         $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'groupsearch';  
 <script type="text/javascript">  
     function select_data(title,url) {  
 // alert('DEBUG: Should be storing '+title+' and '+url);  
     }  
     function queue(val) {  
  if (eval("document.forms.results.returnvalues["+val+"].checked")) {  
     document.forms.results.acts.value+='1a'+val+'b';  
  }  
  else {  
     document.forms.results.acts.value+='0a'+val+'b';  
  }  
     }  
     function select_group() {  
  window.location="/adm/groupsort?catalogmode=groupsearch&acts="+  
     document.forms.results.acts.value;  
     }  
 </script>  
 SCRIPT  
         $r->print(<<SCRIPT);  
 <script type="text/javascript">  
     function displayinfo(val) {  
  popwin.document.forms.popremain.sdetails.value=val;  
     }  
     function openhelp(val) {  
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',  
      'scrollbars=1,width=400,height=300');  
  openhelpwin.focus();  
     }  
     function abortsearch(val) {  
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',  
      'scrollbars=1,width=400,height=300');  
  openhelpwin.focus();  
     }  
 </script>  
 SCRIPT  
     $r->rflush();      $r->rflush();
   
     # begin showing the cataloged results      # begin showing the cataloged results
     $r->print(<<CATALOGBEGIN);      $r->print(<<CATALOGBEGIN);
 </head>  </head>
Line 921  SCRIPT Line 1047  SCRIPT
 CATALOGBEGIN  CATALOGBEGIN
         $r->print(<<CATALOGCONTROLS);          $r->print(<<CATALOGCONTROLS);
 <form name='results' method="post" action="/adm/searchcat">  <form name='results' method="post" action="/adm/searchcat">
   $hidden
 <input type='hidden' name='acts' value='' />  <input type='hidden' name='acts' value='' />
 <input type='button' value='Revise search request'  <input type='button' value='Revise search request'
 onClick='this.form.submit();' />  onClick='this.form.submit();' />
Line 930  $persistent Line 1057  $persistent
 <hr />  <hr />
 <h3>Search Query</h3>  <h3>Search Query</h3>
 CATALOGCONTROLS  CATALOGCONTROLS
       #
       # Remind them what they searched for
       #
     if ($mode eq 'Basic') {      if ($mode eq 'Basic') {
  $r->print(<<RESULTS);   $r->print('<p><b>Basic search:</b> '.$ENV{'form.basicexp'}.'</p>');
 <p>      } elsif ($mode eq 'Advanced') {
 <b>Basic search:</b> $ENV{'form.basicexp'}   $r->print('<p><b>Advanced search</b> '.$query.'</p>');
 </p>  
 RESULTS  
     }  
     elsif ($mode eq 'Advanced') {  
  $r->print(<<RESULTS);  
 <p>  
 <b>Advanced search</b>  
 $query  
 </p>  
 RESULTS  
     }      }
     $r->print('<h3>Search Results</h3>');      $r->print('<h3>Search Results</h3>');
     $r->rflush();      $r->rflush();
     my $servernum=(keys %rhash)+0;      #
       # make the pop-up window for status
     # define server grid (shows status of multiple machines)      #
     my $hcinit;      $r->print(&make_popwin(%rhash));
     my $grid="'<br />'+";  
     $grid.="\n";  
     my $sn=1;  
     for my $sk (sort keys %rhash) {  
  # '<a href="  
  $grid.="'<a href=\"";  
  # javascript:displayinfo('+  
  $grid.="javascript:opener.displayinfo('+";  
  # "'"+'key  
  $grid.="\"'\"+'";  
  $grid.=$sk;  
  my $hc;  
  if ($rhash{$sk} eq 'con_lost') {  
     $hc="BAD CONNECTION, CONTACT SYSTEM ADMINISTRATOR ";  
  }  
  else {  
     $hc="'+\"'\"+\"+hc['$sk']+\"+\"'\"+'";  
     $hcinit.="hc[\"$sk\"]=\"not yet connected...\";";  
  }  
  $grid.=" hitcount=".$hc;  
  $grid.=" domain=".$hostdomains{$sk};  
  $grid.=" IP=".$hostips{$sk};  
  # '+"'"+'">'+  
  $grid.="'+\"'\"+')\">'+";  
  $grid.="\n";  
  $grid.="'<img border=\"0\" name=\"img".$sn."\"".  
     " src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk."\" /></a>'+\n";  
  $grid.="'<br />'+\n" unless $sn%10;  
         $sn++;  
     }  
     $r->print(<<ENDPOP);  
 <script type="text/javascript">  
     popwin=open('','popwin','scrollbars=1,width=400,height=220');  
     popwin.focus();  
     popwin.document.writeln('<'+'html>');  
     popwin.document.writeln('<'+'head>');  
     popwin.document.writeln('<'+'script>');  
     popwin.document.writeln('hc=new Array();$hcinit');  
     popwin.document.writeln('<'+'/script>');  
     popwin.document.writeln('<'+'/head>'+  
         '<'+'body bgcolor="#FFFFFF">'+  
  '<'+'image name="whirly" align="right" src="/adm/lonIcons/'+  
  'lonanim.gif" '+  
  'alt="animated logo" />'+  
  '<'+'h3>Search Results Progress<'+'/h3>'+  
         '<'+'form name="popremain">'+  
         '<'+'tt>'+  
  '<'+'br clear="all"/><i>PLEASE BE PATIENT</i>'+  
  '<'+'br />SCANNING $servernum SERVERS'+  
  '<'+'br clear="all" />Number of record hits found '+  
  '<'+'input type="text" size="10" name="numhits"'+  
  ' value="0" />'+  
  '<'+'br clear="all" />Time elapsed '+  
  '<'+'input type="text" size="10" name="elapsetime"'+  
  ' value="0" />'+  
  '<'+'br />'+  
  'SERVER GRID (click on any cell for details)'+  
         $grid  
         '<'+'br />'+  
  'Server details '+  
  '<'+'input type="text" size="35" name="sdetails"'+  
  ' value="" />'+  
  '<'+'br />'+  
  ' <'+'input type="button" name="button"'+  
  ' value="abort search and view current results" '+  
  ' onClick="javascript:opener.abortsearch()" />'+  
  ' <'+'input type="button" name="button"'+  
  ' value="help" onClick="javascript:opener.openhelp()" />'+  
  '<'+'/tt>'+  
         '<'+'/form>'+  
         '<'+'/body><'+'/html>');  
     popwin.document.close();  
 </script>  
 ENDPOP  
     $r->rflush();      $r->rflush();
       ##
       ## Prepare for the main loop below
       ##
     my $servercount=0;      my $servercount=0;
     my $hitcountsum=0;      my $hitcountsum=0;
     my $bloop=$servernum;      my $servernum=(keys %rhash);
     my %orkey;      my $serversleft=$servernum;
   BLOOP: while(1) {      ##
       my $sn=0;      ## Run until we run out of time or we run out of servers
       last BLOOP unless $bloop;      ##
       last BLOOP unless $timeremain;      while($serversleft && $timeremain) {
     RLOOP: foreach my $rkey (sort keys %rhash) {        ##
  $sn++;        ## %rhash has servers deleted from it as results come in 
  next RLOOP if $orkey{$rkey};        ## (within the foreach loop below).
         ##
         foreach my $rkey (sort keys %rhash) {
  $servercount++;   $servercount++;
  $tflag=1;   $tflag=1;
  $compiledresult='';   $compiledresult='';
  my $hostname=$rkey;   my $hostname=$rkey;
  my $reply=$rhash{$rkey};   my $reply=$rhash{$rkey};
  my @results;   my @results;
   
  my $replyfile='';  
   
  if ($reply eq 'con_lost') {   if ($reply eq 'con_lost') {
     $r->print('<script type="text/javascript">popwin.document.img'.      &popwin_imgupdate($r,$rkey,"srvbad.gif");
       $sn.'.'.      $serversleft--;
       'src="/adm/lonIcons/srvbad.gif";</script>'.              delete $rhash{$rkey};
       "\n");   } else {
     $r->rflush();              # must do since 'use strict' checks for tainting
     $bloop--;      $reply=~/^([\.\w]+)$/; 
     $orkey{$rkey}=1;      my $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
  }  
  else {  
     $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting  
     $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;  
     $reply=~/(.*?)\_/;      $reply=~/(.*?)\_/;
     {      {
  my $temp=0;   my $temp=0;
       WLOOP: while (1) {        WLOOP: while (1) {
   if (-e $replyfile && $tflag) {    if (-e $replyfile && $tflag) {
       $r->print('<script type="text/javascript">'.        &popwin_imgupdate($r,$rkey,"srvhalf.gif");
  'popwin.document.img'.$sn.'.'.        &popwin_js($r,'popwin.hc["'.$rkey.'"]='.
  'src="/adm/lonIcons/srvhalf.gif";</script>'.   '"still transferring..."'.';');
  "\n");  
       $r->rflush();  
       $r->print('<script type="text/javascript">'.  
  'popwin.hc["'.$rkey.'"]='.  
  '"still transferring..."'.';</script>'.  
  "\n");  
       $r->rflush();  
       $tflag=0;        $tflag=0;
   }    }
   if (-e "$replyfile.end") {    if (-e "$replyfile.end") {
       $bloop--;        $serversleft--;
       $orkey{$rkey}=1;                        delete $rhash{$rkey};
       if (-s $replyfile) {        if (-s $replyfile) {
   $r->print('<script type="text/javascript">'.    &popwin_imgupdate($r,$rkey,"srvgood.gif");
     'popwin.document.img'.$sn.'.'.  
     'src="/adm/lonIcons/srvgood.gif";'.  
     '</script>'."\n");  
   $r->rflush();  
   my $fh=Apache::File->new($replyfile) or     my $fh=Apache::File->new($replyfile) or 
       ($r->print('ERROR: file '.        ($r->print('ERROR: file '.
  $replyfile.' cannot be opened') and   $replyfile.' cannot be opened') and
        return OK);         return OK);
   @results=<$fh> if $fh;    @results=<$fh> if $fh;
   $hitcount{$rkey}=@results+0;    $hitcount{$rkey}=@results+0;
   $r->print('<script type="text/javascript">'.    &popwin_js($r,'popwin.hc["'.$rkey.'"]='.
     'popwin.hc["'.$rkey.'"]='.      $hitcount{$rkey}.';');
     $hitcount{$rkey}.';</script>'.  
     "\n");  
   $r->rflush();  
   $hitcountsum+=$hitcount{$rkey};    $hitcountsum+=$hitcount{$rkey};
   $r->print('<script type="text/javascript">'.    &popwin_js($r,'popwin.document.forms.popremain.'.
     'popwin.document.forms.popremain.'.      'numhits.value='.$hitcountsum.';');
     'numhits.value='.$hitcountsum.  
     ';</script>'.  
     "\n");  
   $r->rflush();  
       }        }
       else {        else {
   $r->print('<script type="text/javascript">'.    &popwin_imgupdate($r,$rkey,"srvempty.gif");
     'popwin.document.img'.$sn.'.'.    &popwin_js($r,'popwin.hc["'.$rkey.'"]=0;');
     'src="/adm/lonIcons/srvempty.gif";'.  
     '</script>'.  
     "\n");  
   $r->rflush();  
   $r->print('<script type="text/javascript">'.  
     'popwin.hc["'.$rkey.'"]=0'.  
     ';</script>'.  
     "\n");  
   $r->rflush();  
       }        }
       last WLOOP;        last WLOOP;
   }    } # end of if ( -e "$replyfile.end")
   if ($temp>1) {  
       sleep 1;  
       $timeremain--;  
       $elapsetime++;  
       last WLOOP;  
   }  
   last WLOOP unless $timeremain;    last WLOOP unless $timeremain;
   sleep 1;    sleep 1;    # wait for daemons to write files?
   $timeremain--;    $timeremain--;
   $elapsetime++;    $elapsetime++;
   $r->print('<script type="text/javascript">'.    last WLOOP if ($temp>1);
     'popwin.document.popremain.elapsetime.'.    &popwin_js($r,"popwin.document.popremain.".
     'value="'.$elapsetime.'";</script>'."\n");         "elapsetime.value=$elapsetime;");
   $r->rflush();  
   $temp++;    $temp++;
       }        }
     }      }
     $r->print('<script type="text/javascript">'.      &popwin_js($r,'popwin.document.whirly.'.
       'popwin.document.whirly.'.         'src="/adm/lonIcons/lonanimend.gif";');
       'src="'.'/adm/lonIcons/lonanimend.gif'.   } # end of if ($reply eq 'con_lost') else statement
       '";</script>'."\n");  
     $r->rflush();  
  }  
  my $customshow='';   my $customshow='';
  my $extrashow='';   my $extrashow='';
  my @customfields;   my @customfields;
Line 1183  ENDPOP Line 1189  ENDPOP
  my ($title,$author,$subject,$url,$keywords,$version,   my ($title,$author,$subject,$url,$keywords,$version,
     $notes,$abstract,$mime,$lang,      $notes,$abstract,$mime,$lang,
     $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;      $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;
                   unless ($title =~ /^\s*$/ ) { $title='<i>Untitled</i>'; }
  unless ($ENV{'user.adv'}) {   unless ($ENV{'user.adv'}) {
     $keywords='<i>- not displayed -</i>';      $keywords='<i>- not displayed -</i>';
     $fields[4]=$keywords;      $fields[4]=$keywords;
Line 1235  END Line 1241  END
     $hash{"pre_${fnum}_link"}=$url;      $hash{"pre_${fnum}_link"}=$url;
     $hash{"pre_${fnum}_title"}=$title;      $hash{"pre_${fnum}_title"}=$title;
     $compiledresult.=<<END;      $compiledresult.=<<END;
 <font size='-1'><input type="checkbox" name="returnvalues" value="SELECT"  <font size='-1'>
   <input type="checkbox" name="returnvalues" value="SELECT"
 onClick="javascript:queue($fnum)" />  onClick="javascript:queue($fnum)" />
 </font>  </font>
 <br />  <br />
Line 1300  RESULTS Line 1307  RESULTS
 RESULTS  RESULTS
 }  }
   
 # ------------------------------------------------------ Detailed Citation View  ######################################################################
   ######################################################################
   
   =pod
   
   =item &search_results_header
   
   =cut
   
   ######################################################################
   ######################################################################
   sub search_results_header {
       my $result = '';
       # output beginning of search page
       $result.=<<BEGINNING;
   <html>
   <head>
   <title>The LearningOnline Network with CAPA</title>
   BEGINNING
       # conditional output of script functions dependent on the mode in
       # which the search was invoked
       if ($ENV{'form.catalogmode'} eq 'interactive'){
    if (! exists($ENV{'form.mode'}) || $ENV{'form.mode'} ne 'edit') {
               $result.=<<SCRIPT;
   <script type="text/javascript">
       function select_data(title,url) {
    changeTitle(title);
    changeURL(url);
    self.close();
       }
       function changeTitle(val) {
    if (opener.inf.document.forms.resinfo.elements.t) {
       opener.inf.document.forms.resinfo.elements.t.value=val;
    }
       }
       function changeURL(val) {
    if (opener.inf.document.forms.resinfo.elements.u) {
       opener.inf.document.forms.resinfo.elements.u.value=val;
    }
       }
   </script>
   SCRIPT
           } elsif ($ENV{'form.mode'} eq 'edit') {
               my $form = $ENV{'form.form'};
               my $element = $ENV{'form.element'};
               $result.=<<SCRIPT;
   <script type="text/javascript">
   function select_data(title,url) {
       changeURL(url);
       self.close();
   }
   function changeTitle(val) {
   }
   function changeURL(val) {
       if (window.opener.document) {
           window.opener.document.forms["$form"].elements["$element"].value=val;
       } else {
    var url = 'forms[\"$form\"].elements[\"$element\"].value';
           alert("Unable to transfer data to "+url);
       }
   }
   </script>
   SCRIPT
           }
       }
       $result.=<<SCRIPT if $ENV{'form.catalogmode'} eq 'groupsearch';
   <script type="text/javascript">
       function select_data(title,url) {
   // alert('DEBUG: Should be storing '+title+' and '+url);
       }
       function queue(val) {
    if (eval("document.forms.results.returnvalues["+val+"].checked")) {
       document.forms.results.acts.value+='1a'+val+'b';
    }
    else {
       document.forms.results.acts.value+='0a'+val+'b';
    }
       }
       function select_group() {
    window.location=
       "/adm/groupsort?mode=$ENV{'form.mode'}&catalogmode=groupsearch&acts="+
       document.forms.results.acts.value;
       }
   </script>
   SCRIPT
       $result.=<<SCRIPT;
   <script type="text/javascript">
       function displayinfo(val) {
    popwin.document.forms.popremain.sdetails.value=val;
       }
       function openhelp(val) {
    openhelpwin=open('/adm/help/searchcat.html','helpscreen',
        'scrollbars=1,width=400,height=300');
    openhelpwin.focus();
       }
       function abortsearch(val) {
    popwin.close();
       }
   </script>
   SCRIPT
       return $result;
   }
   
   ######################################################################
   ######################################################################
   
   =pod
   
   =item &make_popwin()
   
   Returns html with javascript in it to open up the status window.
   
   =cut
   
   ######################################################################
   ######################################################################
   sub make_popwin {
       my %rhash = @_;
       my $servernum=(keys %rhash);
       my $hcinit;
       my $grid="'<br />'+\n";
       # $sn is the server number, used ONLY to make sure we have
       # rows of 10 each.  No longer used to index images.
       my $sn=1;
       foreach my $sk (sort keys %rhash) {
    # '<a href="
    $grid.="'<a href=\"";
    # javascript:displayinfo('+
    $grid.="javascript:opener.displayinfo('+";
    # "'"+'key
    $grid.="\"'\"+'";
    $grid.=$sk;
    my $hc;
    if ($rhash{$sk} eq 'con_lost') {
       $hc="BAD CONNECTION, CONTACT SYSTEM ADMINISTRATOR ";
    }
    else {
       $hc="'+\"'\"+\"+hc['$sk']+\"+\"'\"+'";
       $hcinit.="hc[\"$sk\"]=\"not yet connected...\";";
    }
    $grid.=" hitcount=".$hc;
    $grid.=" domain=".$hostdomains{$sk};
    $grid.=" IP=".$hostips{$sk};
    # '+"'"+'">'+
    $grid.="'+\"'\"+')\">'+";
    $grid.="\n";
    $grid.="'<img border=\"0\" name=\"img_".$hostdomains{$sk}.'_'.$sk."\"".
       " src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk."\" /></a>'+\n";
    $grid.="'<br />'+\n" unless $sn%10;
           $sn++;
       }
       my $result.=<<ENDPOP;
   <script type="text/javascript">
       popwin=open('','popwin','scrollbars=1,width=400,height=220');
       popwin.focus();
       popwin.document.writeln('<'+'html>');
       popwin.document.writeln('<'+'head>');
       popwin.document.writeln('<'+'script>');
       popwin.document.writeln('hc=new Array();$hcinit');
       popwin.document.writeln('<'+'/script>');
       popwin.document.writeln('<'+'/head>'+
           '<'+'body bgcolor="#FFFFFF">'+
    '<'+'image name="whirly" align="right" src="/adm/lonIcons/'+
    'lonanim.gif" '+
    'alt="animated logo" />'+
    '<'+'h3>Search Results Progress<'+'/h3>'+
           '<'+'form name="popremain">'+
           '<'+'tt>'+
    '<'+'br clear="all"/><i>PLEASE BE PATIENT</i>'+
    '<'+'br />SCANNING $servernum SERVERS'+
    '<'+'br clear="all" />Number of record hits found '+
    '<'+'input type="text" size="10" name="numhits"'+
    ' value="0" />'+
    '<'+'br clear="all" />Time elapsed '+
    '<'+'input type="text" size="10" name="elapsetime"'+
    ' value="0" />'+
    '<'+'br />'+
    'SERVER GRID (click on any cell for details)'+
           $grid
           '<'+'br />'+
    'Server details '+
    '<'+'input type="text" size="35" name="sdetails"'+
    ' value="" />'+
    '<'+'br />'+
    ' <'+'input type="button" name="button"'+
    ' value="close this window" '+
    ' onClick="javascript:opener.abortsearch()" />'+
    ' <'+'input type="button" name="button"'+
    ' value="help" onClick="javascript:opener.openhelp()" />'+
    '<'+'/tt>'+
           '<'+'/form>'+
           '<'+'/body><'+'/html>');
       popwin.document.close();
   </script>
   ENDPOP
       return $result;
   }
   
   ######################################################################
   ######################################################################
   
   =pod 
   
   =item Metadata Viewing Functions
   
   Output is a HTML-ified string.
   Input arguments are title, author, subject, url, keywords, version,
   notes, short abstract, mime, language, creation date,
   last revision date, owner, copyright, hostname, httphost, and
   extra custom metadata to show.
   
   =over 4
   
   =item &detailed_citation_view() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub detailed_citation_view {  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,
Line 1339  END Line 1564  END
     return $result;      return $result;
 }  }
   
 # ---------------------------------------------------------------- Summary View  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &summary_view() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub summary_view {  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,
Line 1357  END Line 1592  END
     return $result;      return $result;
 }  }
   
 # -------------------------------------------------------------- Fielded Format  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &fielded_format_view() 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub fielded_format_view {  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,
Line 1388  END Line 1633  END
     return $result;      return $result;
 }  }
   
 # -------------------------------------------------------------------- XML/SGML  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &xml_sgml_view() 
   
   =back 
   
   =cut
   
   ######################################################################
   ######################################################################
 sub xml_sgml_view {  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,
Line 1430  END Line 1687  END
     return $result;      return $result;
 }  }
   
 # ---------------------------------------------------- see if a field is filled  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &filled() see if field is filled.
   
   =cut
   
   ######################################################################
   ######################################################################
 sub filled {  sub filled {
     my ($field)=@_;      my ($field)=@_;
     if ($field=~/\S/ && $field ne 'any') {      if ($field=~/\S/ && $field ne 'any') {
Line 1441  sub filled { Line 1708  sub filled {
     }      }
 }  }
   
 # ---------------- Message to output when there are not enough fields filled in  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &output_blank_field_error()
   
   =cut
   
   ######################################################################
   ######################################################################
 sub output_blank_field_error {  sub output_blank_field_error {
     my ($r)=@_;      my ($r)=@_;
     # make query information persistent to allow for subsequent revision      # make query information persistent to allow for subsequent revision
Line 1475  processed. Line 1752  processed.
 RESULTS  RESULTS
 }  }
   
 # ----------------------------------------------------------- Output date error  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &output_date_error()
   
   Output a full html page with an error message.
   
   =cut
   
   ######################################################################
   ######################################################################
 sub output_date_error {  sub output_date_error {
     my ($r,$message)=@_;      my ($r,$message)=@_;
     # make query information persistent to allow for subsequent revision      # make query information persistent to allow for subsequent revision
     my $persistent=&make_persistent();      my $persistent=&make_persistent();
   
     $r->print(<<BEGINNING);      $r->print(<<RESULTS);
 <html>  <html>
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 BEGINNING  
     $r->print(<<RESULTS);  
 </head>  </head>
 <body bgcolor="#ffffff">  <body bgcolor="#ffffff">
 <img align='right' src='/adm/lonIcons/lonlogos.gif' />  <img align='right' src='/adm/lonIcons/lonlogos.gif' />
Line 1506  $message Line 1793  $message
 RESULTS  RESULTS
 }  }
   
 # --------- settings whenever the user causes the search window to be launched  ######################################################################
   ######################################################################
   
   =pod 
   
   =item &start_fresh_session()
   
   Cleans the global %hash by removing all fields which begin with
   'pre_' or 'store'.
   
   =cut
   
   ######################################################################
   ######################################################################
 sub start_fresh_session {  sub start_fresh_session {
     delete $hash{'mode_catalog'};      delete $hash{'mode_catalog'};
     foreach (keys %hash) {      foreach (keys %hash) {
Line 1519  sub start_fresh_session { Line 1819  sub start_fresh_session {
     }      }
 }  }
   
 1;  ######################################################################
   ######################################################################
   
 __END__  =pod 
   
 =head1 NAME  =item &popwin_js() send javascript to popwin
   
 Apache::lonsearchcat - mod_perl module for handling a searchable catalog  =cut
   
 =head1 SYNOPSIS  ######################################################################
   ######################################################################
   sub popwin_js {
       # Print javascript out to popwin, but make sure we dont generate
       # any javascript errors in doing so.
       my ($r,$text) = @_;
       $r->print(<<"END");
   <script type="text/javascript">
       if (! popwin.closed) {
    $text
       }
   </script>
   END
       $r->rflush();
   }
   
 Invoked by /etc/httpd/conf/srm.conf:  ######################################################################
   ######################################################################
   
  <Location /adm/searchcat>  =pod 
  PerlAccessHandler       Apache::lonacc  
  SetHandler perl-script  
  PerlHandler Apache::lonsearchcat  
  ErrorDocument     403 /adm/login  
  ErrorDocument  500 /adm/errorhandler  
  </Location>  
   
 =head1 INTRODUCTION  =item &popwin_imgupdate()
   
 This module enables searching for a distributed browseable catalog.  Send a given image (and its location) out to the browser.  Takes as 
   input $r, loncapa server id, and an icon URL.
   
 This is part of the LearningOnline Network with CAPA project  =cut
 described at http://www.lon-capa.org.  
   
 =head1 BEGIN SUBROUTINE  ######################################################################
   ######################################################################
   sub popwin_imgupdate {
       my ($r,$server,$icon) = @_;
       &popwin_js($r,'popwin.document.img_'.$hostdomains{$server}.'_'.$server.'.'.
          'src="/adm/lonIcons/'.$icon.'";');
   }    
   
 This routine is only run once after compilation.  1;
   
 =over 4  __END__
   
 =item *  =pod
   
 Initializes %hostdomains and hostips hash table (for hosts.tab).  =back 
   
 =back  =over 4
   
 =head1 HANDLER SUBROUTINE  =head1 HANDLER SUBROUTINE
   
Line 1746  more fields need to be filled in Line 2062  more fields need to be filled in
   
 =item *  =item *
   
 output_date_error(server reference, error message) : outputs  output_date_error(server reference, error message) : 
 an error message specific to bad date format.  
   
 =back  =back
   

Removed from v.1.116  
changed lines
  Added in v.1.125


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