[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 19 Apr 2004 21:46:50 -0000


matthew		Mon Apr 19 17:46:50 2004 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  &run_search: Actually compute the time remaining before outputing it.
  &set_up_table_structure: Copy the metadata table description before
  modifying it.  The authoritative copy of the table was being prepended 
  with an 'id' column multiple times.  Since columns must be uniquely
  named MySQL barfed on table creation.
  &xml_sgml_view: Use HTML::Entities::encode to encode '<>&' instead of
  filling the perl code with &lt; and &gt;
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.211 loncom/interface/lonsearchcat.pm:1.212
--- loncom/interface/lonsearchcat.pm:1.211	Mon Apr 19 13:44:47 2004
+++ loncom/interface/lonsearchcat.pm	Mon Apr 19 17:46:50 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.211 2004/04/19 17:44:47 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.212 2004/04/19 21:46:50 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -74,6 +74,7 @@
 use Apache::lonhtmlcommon;
 use Apache::lonlocal;
 use LONCAPA::lonmetadata();
+use HTML::Entities();
 
 ######################################################################
 ######################################################################
@@ -1061,7 +1062,7 @@
 	    $fillflag++;
 	}
     }
-    unless ($fillflag) {
+    if (! $fillflag) {
 	&output_blank_field_error($r,$closebutton,
                                   'phase=disp_adv',$hidden_fields);
 	return ;
@@ -1717,12 +1718,13 @@
 sub set_up_table_structure {
     my ($datatypes,$fullindicies) = 
         &LONCAPA::lonmetadata::describe_metadata_storage();
-    unshift(@$datatypes,{name => 'id', 
+    # Copy the table description before modifying it...
+    @Datatypes = @{$datatypes};
+    unshift(@Datatypes,{name => 'id',  
         type => 'MEDIUMINT',
         restrictions => 'UNSIGNED NOT NULL',
         primary_key  => 'yes',
         auto_inc     => 'yes' });
-    @Datatypes = @{$datatypes};
     @Fullindicies = @{$fullindicies};
     return;
 }
@@ -1926,6 +1928,7 @@
     &update_status($r,'contacting '.$Servers_to_contact[0]);
     while (($time_remaining > 0) &&
            ((@Servers_to_contact) || keys(%Server_status))) {
+        $time_remaining = $max_time - (time - $starttime) ;
         &update_seconds($r,$time_remaining);
         # Send out a search request if it needs to be done.
         if (@Servers_to_contact) {
@@ -2201,6 +2204,7 @@
         }
         my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'},
                                        $Fields{'id'},$checkbox_num++);
+
         # Render the result into html
         $output.= &$viewfunction($prefix,%Fields);
         # Print them out as they come in.
@@ -2716,34 +2720,38 @@
 ######################################################################
 sub xml_sgml_view {
     my ($prefix,%values) = @_;
+    my $xml = <<END;
+<LonCapaResource>
+<url>$values{'url'}</url>
+<title>$values{'title'}</title>
+<author>$values{'author'}</author>
+<subject>$values{'subject'}</subject>
+<keywords>$values{'keywords'}</keywords>
+<notes>$values{'notes'}</notes>
+<mimeInfo>
+<mime>$values{'mime'}</mime>
+<mimetag>$values{'mimetag'}</mimetag>
+</mimeInfo>
+<languageInfo>
+<language>$values{'language'}</language>
+<languagetag>$values{'languagetag'}</languagetag>
+</languageInfo>
+<creationdate>$values{'creationdate'}</creationdate>
+<lastrevisiondate>$values{'lastrevisiondate'}</lastrevisiondate>
+<owner>$values{'owner'}</owner>
+<copyrightInfo>
+<copyright>$values{'copyright'}</copyright>
+<copyrighttag>$values{'copyrighttag'}</copyrighttag>
+</copyrightInfo>
+<repositoryLocation>$values{'hostname'}</repositoryLocation>
+<shortabstract>$values{'shortabstract'}</shortabstract>
+</LonCapaResource>
+END
+    $xml = &HTML::Entities::encode($xml,'<>&');
     my $result=<<END;
 $prefix
 <pre>
-&lt;LonCapaResource&gt;
-&lt;url&gt;$values{'url'}&lt;/url&gt;
-&lt;title&gt;$values{'title'}&lt;/title&gt;
-&lt;author&gt;$values{'author'}&lt;/author&gt;
-&lt;subject&gt;$values{'subject'}&lt;/subject&gt;
-&lt;keywords&gt;$values{'keywords'}&lt;/keywords&gt;
-&lt;notes&gt;$values{'notes'}&lt;/notes&gt;
-&lt;mimeInfo&gt;
-&lt;mime&gt;$values{'mime'}&lt;/mime&gt;
-&lt;mimetag&gt;$values{'mimetag'}&lt;/mimetag&gt;
-&lt;/mimeInfo&gt;
-&lt;languageInfo&gt;
-&lt;language&gt;$values{'language'}&lt;/language&gt;
-&lt;languagetag&gt;$values{'languagetag'}&lt;/languagetag&gt;
-&lt;/languageInfo&gt;
-&lt;creationdate&gt;$values{'creationdate'}&lt;/creationdate&gt;
-&lt;lastrevisiondate&gt;$values{'lastrevisiondate'}&lt;/lastrevisiondate&gt;
-&lt;owner&gt;$values{'owner'}&lt;/owner&gt;
-&lt;copyrightInfo&gt;
-&lt;copyright&gt;$values{'copyright'}&lt;/copyright&gt;
-&lt;copyrighttag&gt;$values{'copyrighttag'}&lt;/copyrighttag&gt;
-&lt;/copyrightInfo&gt;
-&lt;repositoryLocation&gt;$values{'hostname'}&lt;/repositoryLocation&gt;
-&lt;shortabstract&gt;$values{'shortabstract'}&lt;/shortabstract&gt;
-&lt;/LonCapaResource&gt;
+$xml
 </pre>
 $values{'extrashow'}
 <hr align='left' width='200' noshade />