Specify file path instead of just index so that images for multi-items are found...
authorMichael Ang <mang@archive.org>
Fri, 25 Sep 2009 20:26:13 +0000 (20:26 +0000)
committerMichael Ang <mang@archive.org>
Fri, 25 Sep 2009 20:26:13 +0000 (20:26 +0000)
GnuBook/GnuBook.js
GnuBookIA/datanode/GnuBookJSIA.php
GnuBookIA/www/print.php

index df4f20a..8ac16f9 100644 (file)
@@ -2465,11 +2465,11 @@ GnuBook.prototype.getPrintURI = function() {
     }
     
     var options = 'id=' + this.bookId + '&server=' + this.server + '&zip=' + this.zip
-        + '&format=' + this.imageFormat + '&index=' + this.leafMap[indexToPrint]
+        + '&format=' + this.imageFormat + '&file=' + this._getPageFile(indexToPrint)
         + '&width=' + this.getPageWidth(indexToPrint) + '&height=' + this.getPageHeight(indexToPrint);
    
     if (this.constMode2up == this.mode) {
-        options += '&index2=' + this.leafMap[this.twoPage.currentIndexR] + '&width2=' + this.getPageWidth(this.twoPage.currentIndexR);
+        options += '&file2=' + this._getPageFile(this.twoPage.currentIndexR) + '&width2=' + this.getPageWidth(this.twoPage.currentIndexR);
         options += '&height2=' + this.getPageHeight(this.twoPage.currentIndexR);
         options += '&title=' + escape(this.shortTitle(30) + ' - Pages ' + this.getPageNum(this.twoPage.currentIndexL) + ', ' + this.getPageNum(this.twoPage.currentIndexR));
     } else {
index 49881a3..34a9611 100755 (executable)
@@ -150,13 +150,8 @@ gb.getPageURI = function(index, reduce, rotate) {
         _rotate = rotate;
     }
     
-    var leafStr = '0000';
-    var imgStr = this.leafMap[index].toString();
-    var re = new RegExp("0{"+imgStr.length+"}$");
-    
-    var insideZipPrefix = this.subPrefix.match('[^/]+$');
-    var file = insideZipPrefix + '_' + this.imageFormat + '/' + insideZipPrefix + '_' + leafStr.replace(re, imgStr) + '.' + this.imageFormat;
-    
+    var file = this._getPageFile(index);
+        
     // $$$ add more image stack formats here
     if (1==this.mode) {
         var url = 'http://'+this.server+'/GnuBook/GnuBookImages.php?zip='+this.zip+'&file='+file+'&scale='+_reduce+'&rotate='+_rotate;
@@ -188,6 +183,17 @@ gb.getPageURI = function(index, reduce, rotate) {
     return url;
 }
 
+gb._getPageFile = function(index) {
+    var leafStr = '0000';
+    var imgStr = this.leafMap[index].toString();
+    var re = new RegExp("0{"+imgStr.length+"}$");
+    
+    var insideZipPrefix = this.subPrefix.match('[^/]+$');
+    var file = insideZipPrefix + '_' + this.imageFormat + '/' + insideZipPrefix + '_' + leafStr.replace(re, imgStr) + '.' + this.imageFormat;
+    
+    return file;
+}
+
 gb.getPageSide = function(index) {
     //assume the book starts with a cover (right-hand leaf)
     //we should really get handside from scandata.xml
@@ -195,7 +201,7 @@ gb.getPageSide = function(index) {
     <? // Use special function if we should infer the page sides based off the title page index
     if (preg_match('/goog$/', $id) && ('' != $titleLeaf)) {
     ?>
-    // assume page side based on title page
+    // assume page side based on title pagex
     var titleIndex = gb.leafNumToIndex(gb.titleLeaf);
     // assume title page is RHS
     var delta = titleIndex - index;
index 33c785f..c3cf1b4 100644 (file)
@@ -24,7 +24,7 @@ us from calling print() on an iframe that comes from a cluster datanode.
 $id     = $_REQUEST['id'];
 $server = $_REQUEST['server'];
 $zip    = $_REQUEST['zip'];
-$index  = $_REQUEST['index'];
+$file  = $_REQUEST['file'];
 $format = $_REQUEST['format'];
 //$imgAspect = $_REQUEST['aspect'];
 $width = floatval($_REQUEST['width']);
@@ -38,7 +38,7 @@ $paperAspect = 8.5/11;
 $allowRotate = true;
 
 // Returns (url, attrs)
-function imageURL($paperAspect, $index, $format, $width, $height, $allowRotate) {
+function imageURL($paperAspect, $file, $format, $width, $height, $allowRotate) {
     global $server, $id, $zip;
     
     $rotate = "0";
@@ -59,8 +59,6 @@ function imageURL($paperAspect, $index, $format, $width, $height, $allowRotate)
         // taller than paper, fit height
         $htmlAttrs = "height='95%'";
     }
-
-    $file = sprintf("%s_%s/%s_%04d.%s", $id, $format, $id, $index, $format);
     
     $queryParams = array(
         'id' => $id, // global
@@ -92,17 +90,17 @@ echo "<title>" . htmlspecialchars($title) . "</title><body onload='conditionalPr
 echo   "<p class='noprint' style='text-align: right'>";
 echo     "<button class='GBicon rollover print' title='Print' onclick='print(); return false;'></button> <a href='#' onclick='print(); return false;'>Print</a></p>";
 echo   "<p style='text-align:center;'>";
-echo     imageURL($paperAspect, $index, $format, $width, $height, $allowRotate);
+echo     imageURL($paperAspect, $file, $format, $width, $height, $allowRotate);
 echo   "</p>";
 
-if (isset($_REQUEST['index2'])) {    
-    $index2 = $_REQUEST['index2'];
+if (isset($_REQUEST['file2'])) {    
+    $file2 = $_REQUEST['file2'];
     $width2 = floatval($_REQUEST['width2']);
     $height2 = floatval($_REQUEST['height2']);
     
     
     echo "<p style='text-align: center;'>";
-    echo imageURL($paperAspect, $index2, $format, $width2, $height2, $allowRotate);
+    echo imageURL($paperAspect, $file2, $format, $width2, $height2, $allowRotate);
     echo "</p>";
 }
 echo  "</body></html>";