use koha rss results to return popup
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 2 Apr 2011 14:43:16 +0000 (14:43 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 2 Apr 2011 14:43:16 +0000 (14:43 +0000)
koha.html
koha.pl

index 7bbc536..c21359e 100644 (file)
--- a/koha.html
+++ b/koha.html
@@ -4,7 +4,7 @@
   <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
   <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
-  <title>World Volcanoes</title>
+  <title>Where are our books comming from?</title>
   <script type="text/javascript">
   //<![CDATA[
 
@@ -37,7 +37,7 @@
       if (x < 0) {
        x += n;
       } 
-      return "tiles/tileserver.pl?Z=" + zoom + "&X=" + x + "&Y=" + tile.y ;
+      return "koha/tiles/" + zoom + "/v_" + x + "_" + tile.y + ".png";
      },
      tileSize: new google.maps.Size(256, 256),
      opacity:1,
    {
     var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;
     var parms = "POINT=" + point.toUrlValue() + "&ZOOM=" + map.getZoom() ;
-    request.open("POST", "volcano.pl", true);
+    request.open("POST", "koha.pl", true);
     request.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;     // Thanks to Darkstar 3D!
     request.onreadystatechange = function() 
     {
diff --git a/koha.pl b/koha.pl
index adce9df..72f7681 100755 (executable)
--- a/koha.pl
+++ b/koha.pl
@@ -7,8 +7,9 @@ use CGI qw/:standard *table/;
 use strict ;
 use DBI ;
 use USNaviguide_Google_Tiles ;
+use XML::FeedPP;
 
-my $dbh        = DBI->connect ( "dbi:Pg:dbname=volcano" , "" , "" , { AutoCommit => 1 } ) ;
+my $dbh        = DBI->connect ( "dbi:Pg:dbname=koha" , "" , "" , { AutoCommit => 1 } ) ;
 my $point      = param('POINT') ;
 my $zoom       = param('ZOOM') ;
 
@@ -30,7 +31,7 @@ my $descript  = '' ;
 my $x          = '' ;
 my $i          = 0 ;
 
-print header('text/xml');
+print qq{Content-type: text/xml\r\n\r\n};
 print qq{<?xml version="1.0" encoding="UTF-8"?>\n} ;
 print qq!<map>\n! ;
 
@@ -64,9 +65,28 @@ if ( $point =~ /(.*),(.*)/ )
   if ( sqrt(($vlatpix -        $latpix)**2  + ($vlngpix - $lngpix)**2) > $maxpix )
   {
    # Click not within maxpix of point...
-   print qq!<info error="No volcano is within range of your click, please try again."/>\n! ;
+   print qq!<info error="No publisher is within range of your click, please try again."/>\n! ;
   } else                                                               # Good point found
   {
+
+       my $hash = eval $descript;
+
+       my $feed = XML::FeedPP->new( "http://koha.ffzg.hr/cgi-bin/koha/opac-search.pl?idx=pl&format=rss2&q=$name" );
+
+       my @links;
+       foreach my $item ( $feed->get_item ) {
+               push @links, sprintf qq|<li><a target="koha" href="%s">%s</a> %s|,
+                       $item->link, $item->title, $item->description
+               ;
+       }
+       $descript = join("\n"
+               , "<b>$name</b>"
+               , " " . @links
+               , "<ol>"
+               , @links
+               , "</ol>"
+       );
+
    print qq!<info error = "" name = "$name" lat="$vlat" lng="$vlng">\n! ;
    print qq! <description><\![CDATA[$descript]]></description>\n! ;
    print qq!</info>\n! ;