Information Technology

Example of localFileRetrieval.php

In this example, we recheck a Digitool database and update the records for what we find.  We also update the aMapApp3 database.  In this case, the image database is a bit odd.

//  localFileRetrieval.php
//            Created:   12/3/09
//            Modified:     12/3/09
// This file contains the code to find images from a locally defined
// database, in this case digitools.  This would have to be
// rewritten for another database.  It is called from
// get_location_images.php

  // First get the latest data for the record.  The image_id is the document number, not the
  // pid although the code implies this at points.  That's old code when we through the pid
  // was what we needed.  Since we're rechecking the image, we can't really use any of the data
  // in the database.

  $query_url = "".$responses[$i]['image_id']."&base=gen01&format=dc";
  // Submit the query, get the results, and load into xml structured document.
  $result = file_get_contents($query_url);
  $dom = new DOMDocument;
  // There should only be one record, but what the heck. 
 foreach ($dom->getElementsByTagName('record') as $element) {
                    // Get basic fields
   $responses[$i]['thumbnail_url'] =$element->getElementsByTagName('thumbnail_url')->item(0)->textContent;
   $responses[$i]['title'] = $element->getElementsByTagName('title')->item(0)->textContent;
   $responses[$i]['creator'] = $element->getElementsByTagName('creator')->item(0)->textContent;
   $responses[$i]['cdates'] = $element->getElementsByTagName('creator')->item(1)->textContent;
   $responses[$i]['date'] = $element->getElementsByTagName('date')->item(0)->textContent;
   $responses[$i]['media'] = $element->getElementsByTagName('format')->item(0)->textContent;
   $responses[$i]['size'] = $element->getElementsByTagName('format')->item(1)->textContent;

  // Now get the url.  This is a pain since we can't actually get the full path from the meta data.
  // We get some of the path and search for the rest.
  // the filename is a simple numeric code.
  $pid = $element->getElementsByTagName('pid')->item(0)->textContent;
  // deposit date.  This makes up three parts of the path.
  $ddate =  $element->getElementsByTagName('creationDate')->item(0)->textContent;      
  $responses[$i]['url'] = "".$pid."&creationDate=".$ddate;
        //+++++ update the database+++++++++++++++
  $query = "UPDATE ".PREFIX."entries SET
      WHERE id='".$responses[$i]['id']."'";