metadataGrabber->mainDir . '/'); foreach ($item->getFiles() as $location => $fileInfo) { $filename = substr($location, $baseLength); if ($checkOldScandata) { if ($filename == 'scandata.xml' || $filename == 'scandata.zip') { $foundScandata = $filename; } } if ($filename == $targetScandata) { $foundScandata = $filename; } if (preg_match($imageFormatRegex, $filename)) { $foundImageStack = $filename; } } if ($foundScandata && $foundImageStack) { return true; } return false; } // Finds the prefix to use for the book given the part of the URL trailing after /stream/ public static function findPrefix($urlPortion) { if (!preg_match('#[^/&?]+#', $urlPortion, $matches)) { return false; } $prefix = $matches[0]; // identifier // $$$ Currently swallows the rest of the URL. // If we want to support e.g. /stream/itemid/subdir/prefix/page/23 will need to adjust. if (preg_match('#[^/&?]+/([^&?]+)#', $urlPortion, $matches)) { $prefix = $matches[1]; // sub prefix } return $prefix; } // $$$ would be cleaner to use different templates instead of the uiMode param // // @param subprefix Optional prefix to display a book inside an item (e.g. if does not match identifier) public static function draw($server, $mainDir, $identifier, $subPrefix, $title, $coverLeaf=null, $titleStart='Internet Archive', $uiMode='full') { // Set title to default if not set if (!$title) { $title = 'Bookreader'; } $id = $identifier; // manually update with Launchpad version number at each checkin so that browsers // do not use old cached version // see https://bugs.launchpad.net/gnubook/+bug/330748 $version = "r24"; if ("" == $id) { echo "No identifier specified!"; die(-1); } $metaURL = BookReader::jsMetadataURL($server, $identifier, $mainDir, $subPrefix); ?> <? echo $title; ?>
Internet Archive BookReader
Internet Archive Bookreader

Search results
Internet Archive
$identifier, 'itemPath' => $mainDir, 'server' => $server ); if ($subPrefix) { $params['subPrefix'] = $subPrefix; } $keys = array_keys($params); $lastParam = end($keys); $url = "http://{$serverBaseURL}/BookReader/BookReaderJSIA.php?"; foreach($params as $param=>$value) { $url .= $param . '=' . $value; if ($param != $lastParam) { $url .= '&'; } } 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 } } ?>