X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Finc%2FBookReader.inc;h=56a1fd66c03569b3063cf71a140333ab4677db2c;hb=bc2a1bf0a8e59f009c005cc78f1b22420e689c63;hp=e18ca860eab5e7c31766fdd6076d2f9de66b003d;hpb=a3f88d5908698488bbb9bf13291c89f712fdf43b;p=bookreader.git diff --git a/BookReaderIA/inc/BookReader.inc b/BookReaderIA/inc/BookReader.inc index e18ca86..56a1fd6 100644 --- a/BookReaderIA/inc/BookReader.inc +++ b/BookReaderIA/inc/BookReader.inc @@ -73,7 +73,7 @@ class BookReader { // Set title to default if not set if (!$title) { - $title = 'Bookreader'; + $title = 'BookReader'; } $id = $identifier; @@ -81,7 +81,12 @@ class BookReader // 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 = "r22"; + $version = "r25"; + + if (BookReader::getDevHost($server)) { + // on dev host - add time to force reload + $version .= '_' . time(); + } if ("" == $id) { echo "No identifier specified!"; @@ -94,6 +99,8 @@ class BookReader + + <? echo $title; ?> @@ -163,22 +174,31 @@ class BookReader 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 + } + + // $$$ Ideally we will not rely on user agent, but for the moment we do + public static function paramsFromUserAgent($userAgent) { + $browserParams = array( + 'ipad' => array( 'ui' => 'touch' ), + 'iphone' => array( 'ui' => 'embed', 'mode' => '1up'), + ); + + $browser = BookReader::browserFromUserAgent($userAgent); + if ($browser) { + return $browserParams[$browser]; + } + return array(); + } + + public static function browserFromUserAgent($userAgent) { + $browserPatterns = array( + 'ipad' => '/iPad/', + 'iphone' => '/iPhone/', // Also cover iPod Touch + ); + + foreach ($browserPatterns as $browser => $pattern) { + if (preg_match($pattern, $userAgent)) { + return $browser; + } + } + return null; + } + } - ?> + +?> \ No newline at end of file