6 // Returns true if can display the book in item with a given prefix (typically the item identifier)
7 public static function canDisplay($item, $prefix, $checkOldScandata = false)
10 // A "book" is an image stack and scandata.
11 // 1. Old items may have scandata.xml or scandata.zip and itemid_{imageformat}.{zip,tar}
12 // 2. Newer items may have multiple {arbitraryname}_scandata.xml and {arbitraryname}_{imageformat}.{zip,tar}
14 $foundScandata = false;
15 $foundImageStack = false;
17 $targetScandata = $prefix . "_scandata.xml";
19 // $$$ TODO add support for jpg and tar stacks
20 // https://bugs.edge.launchpad.net/gnubook/+bug/323003
21 // https://bugs.edge.launchpad.net/gnubook/+bug/385397
22 $imageFormatRegex = '@' . preg_quote($prefix) . '_(jp2|tif)\.zip$@';
24 $baseLength = strlen($item->metadataGrabber->mainDir . '/');
25 foreach ($item->getFiles() as $location => $fileInfo) {
26 $filename = substr($location, $baseLength);
28 if ($checkOldScandata) {
29 if ($filename == 'scandata.xml' || $filename == 'scandata.zip') {
30 $foundScandata = $filename;
34 if ($filename == $targetScandata) {
35 $foundScandata = $filename;
38 if (preg_match($imageFormatRegex, $filename)) {
39 $foundImageStack = $filename;
43 if ($foundScandata && $foundImageStack) {
50 public static function draw($server, $mainDir, $identifier, $title,
51 $coverleaf=null, $titlestart='Internet Archive')
53 // Set title to default if not set
55 $title = 'Bookreader';
60 // manually update with Launchpad version number at each checkin so that browsers
61 // do not use old cached version
62 // see https://bugs.launchpad.net/gnubook/+bug/330748
66 echo "No identifier specified!";
70 $metaURL = GnuBook::jsMetadataURL($server, $identifier, $mainDir);
72 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
75 <title><? echo $title; ?></title>
77 <meta http-equiv="refresh" content="2; URL=/bookreader/browserunsupported.php?id=<? echo($id); ?>">
79 <link rel="stylesheet" type="text/css" href="/bookreader/GnuBook.css?v=<? echo($version); ?>">
80 <script src="http://www.archive.org/includes/jquery-1.2.6.min.js" type="text/javascript"></script>
81 <script type="text/javascript" src="/bookreader/GnuBook.js?v=<? echo($version); ?>"></script>
82 <script type="text/javascript" src="/bookreader/jquery.easing.1.3.js"></script>
84 <body style="background-color: #FFFFFF;">
86 <div id="GnuBook" style="left:10px; right:200px; top:10px; bottom:2em;">x</div>
88 <script type="text/javascript">
89 // Set some config variables -- $$$ NB: Config object format has not been finalized
93 <script type="text/javascript" src="<? echo($metaURL); ?>"></script>
95 <div id="GnuBookSearch" style="width:190px; right:0px; top:10px; bottom:2em;">
96 <form action='javascript:' onsubmit="gb.search($('#GnuBookSearchBox').val());">
97 <p style="display: inline">
98 <input id="GnuBookSearchBox" type="text" size="20" value="search..." onfocus="if('search...'==this.value)this.value='';" /><input type="submit" value="go" />
101 <div id="GnuBookSearchResults">
108 <div class="GBlogotype">
109 <a href="http://archive.org/" class="GBblack">Internet Archive</a>
111 <div class="GBnavlinks">
112 <!-- <a class="GBblack" href="http://openlibrary.org/dev/docs/bookreader">About the Bookreader</a> | -->
113 <a class="GBblack" href="https://bugs.launchpad.net/bookserver/+filebug-advanced">Report Errors</a> |
114 <a class="GBblack" href="http://www.archive.org/details/texts">Texts Collection</a> |
115 <a class="GBblack" href="http://www.archive.org/about/contact.php">Contact Us</a>
119 <script type="text/javascript">
120 // $$$ hack to workaround sizing bug when starting in two-up mode
121 $(document).ready(function() {
122 $(window).trigger('resize');
129 public static function jsMetadataURL($server, $identifier, $mainDir)
131 $serverBaseURL = $server;
133 // Check if we're on a dev vhost and point to JSIA in the user's public_html on the datanode
134 if (preg_match("/^www-(\w+)/", $_SERVER["SERVER_NAME"], $match)) {
135 // $$$ the remapping isn't totally automatic yet and requires user to
136 // ln -s ~/petabox/www/datanode/GnuBook ~/public_html/GnuBook
137 // so we enable it only for known hosts
138 $devhosts = array('mang', 'testflip');
139 if (in_array($match[1], $devhosts)) {
140 $serverBaseURL = $serverBaseURL . ":81/~" . $match[1];
144 $url = "http://{$serverBaseURL}/GnuBook/GnuBookJSIA.php?id={$identifier}&itemPath={$mainDir}&server={$serverBaseURL}";