Add ppi (pixels per inch) to BookReader metadata API
[bookreader.git] / BookReaderIA / datanode / BookReaderMeta.inc.php
index 179c7cb..89c4a69 100644 (file)
@@ -36,6 +36,7 @@ class BookReaderMeta {
         'contributor' => 'contributor',
         'collection' => 'collection',
         'page-progression' => 'pageProgression',
+        'ppi' => 'ppi',
     );
     
     var $metaDefaults = array(
@@ -263,9 +264,7 @@ class BookReaderMeta {
     
     // Returns { 'imageFormat' => , 'archiveFormat' => '} given a sub-item prefix and loaded xml data
     function findImageStack($subPrefix, $filesData) {
-    
-        static $cbPrefix = NULL;
-    
+        
         // The order of the image formats determines which will be returned first
         $imageFormats = array('JP2' => 'jp2', 'TIFF' => 'tif', 'JPEG' => 'jpg');
         $imageFormatOrder = array_values($imageFormats);
@@ -304,17 +303,13 @@ class BookReaderMeta {
             }
         }
 
-        /*
-        print("<pre>");
-        print("found subPrefix $subPrefix\n");
-        print_r($imageStacks);
-        */
+        // print("<pre>");
+        // print("found subPrefix $subPrefix\n");
+        // print_r($imageStacks);
+        // die(0);
         
         function subPrefixSort($imageStackA, $imageStackB) {
-            if ($imageStackA['subPrefix'] == $imageStackB['subPrefix']) {
-                return 0;
-            }
-            return ($imageStackA['subPrefix'] < $imageStackB['subPrefix']) ? -1 : 1;
+            return strcmp($imageStackA['subPrefix'], $imageStackB['subPrefix']);
         }
         if (! $subPrefix) {
             usort($imageStacks, 'subPrefixSort');
@@ -403,7 +398,7 @@ class BookReaderMeta {
     
     function imageFilePath($leafNum, $subPrefix, $format) {
         $pathParts = pathinfo($subPrefix);
-        $almostIdentifier = $pathParts['filename'];
+        $almostIdentifier = $pathParts['basename'];
         return sprintf("%s_%s/%s_%04d.%s", $almostIdentifier, $format, $almostIdentifier, intval($leafNum), $format);
     }
     
@@ -424,10 +419,11 @@ class BookReaderMeta {
         
         // Check if we're on a dev vhost and point to JSIA in the user's public_html on the datanode
         // $$$ TODO consolidate this logic
-        if (strpos($_SERVER["REQUEST_URI"], "/~mang") === 0) { // Serving out of home dir
-            $server .= ':80/~mang';
-        } else if (strpos($_SERVER["REQUEST_URI"], "/~testflip") === 0) { // Serving out of home dir
-            $server .= ':80/~testflip';
+        $devHosts = array('testflip', 'rkumar', 'mang');
+        foreach ($devHosts as $host) {
+            if (strpos($_SERVER["REQUEST_URI"], '/~' . $host) === 0) { // Serving out of home dir
+                $server .= ':80/' . $host;
+            }
         }
         
         $this->emitResponse( $this->buildMetadata($id, $itemPath, $subPrefix, $server) );