$response = array();
- if (! $subPrefix) {
- $subPrefix = $id;
+ if (! $bookId) {
+ $bookId = $id;
}
- $subItemPath = $itemPath . '/' . $subPrefix;
+ $subItemPath = $itemPath . '/' . $bookId;
if ("" == $id) {
$this->BRFatal("No identifier specified!");
$this->BRfatal("File metadata not found!");
}
- $imageStackInfo = $this->findImageStack($subPrefix, $filesData);
+ $imageStackInfo = $this->findImageStack($bookId, $filesData);
if ($imageStackInfo['imageFormat'] == 'unknown') {
$this->BRfatal('Couldn\'t find image stack');
}
// Internet Archive specific
$response['itemId'] = $id; // XXX renamed
- $response['bookId'] = $subPrefix; // XXX renamed
+ $response['bookId'] = $bookId; // XXX renamed
$response['zip'] = $imageStackFile;
$response['server'] = $server;
$response['imageFormat'] = $imageFormat;
}
}
+ function leafForIndex($index, $leafNums) {
+ return $leafNums[$index]; // $$$ todo change to instance variables
+ }
+
function imageURL($leafNum, $metadata, $scale, $rotate) {
// "Under the hood", non-public, dynamically changing (achtung!) image URLs currently look like:
// http://{server}/BookReader/BookReaderImages.php?zip={zipPath}&file={filePath}&scale={scale}&rotate={rotate}
return $url;
}
+ // Return the URL for the requested /download/$path, or null
+ public static function getURL($path, $item) {
+ // $path should look like {itemId}/{operator}/{filename}
+ // Other operators may be added
+
+ $parts = preg_split('#/#', $path, 3);
+ if (count($parts) != 3) {
+ return null;
+ }
+ $identifier = $parts[0];
+ $operator = $parts[1];
+ $filename = $parts[2];
+
+ $serverBaseURL = BookReader::serverBaseURL($item->getServer());
+
+ switch ($operator) {
+ case 'page':
+ // Find bookId and which page was requested
+ $pathParts = pathinfo($filename);
+
+ // Look for preview request
+ if (preg_match('/^(.*)_(cover|title|preview)$/', $pathParts['filename'], $matches) === 0) {
+ return null;
+ }
+ $bookId = $matches[1];
+ $page = $matches[2];
+ $query = array(
+ 'id' => $identifier,
+ 'bookId' => $bookId,
+ 'itemPath' => $item->getMainDir(),
+ 'server' => $serverBaseURL,
+ 'page' => $page,
+ );
+ return 'http://' . $serverBaseURL . '/BookReader/BookReaderPreview.php?' . http_build_query($query, '', '&');
+
+ default:
+ return null;
+ }
+
+ return null; // was not handled
+ }
+
}
- ?>
+
+?>
\ No newline at end of file