diff options
| author | Horus3 | 2014-02-24 16:42:14 +0100 |
|---|---|---|
| committer | Horus3 | 2014-02-24 16:42:14 +0100 |
| commit | 06f945f27840b53e57795dadbc38e76f7e11ab1c (patch) | |
| tree | 689d5c7f4ffa15460c7e90f47c6a7dd59ce4e8bd /zend/demos/Zend/Gdata/BooksBrowser | |
| download | random-06f945f27840b53e57795dadbc38e76f7e11ab1c.tar.gz | |
init
Diffstat (limited to 'zend/demos/Zend/Gdata/BooksBrowser')
| -rwxr-xr-x | zend/demos/Zend/Gdata/BooksBrowser/books_browser.css | 136 | ||||
| -rwxr-xr-x | zend/demos/Zend/Gdata/BooksBrowser/index.php | 155 | ||||
| -rw-r--r-- | zend/demos/Zend/Gdata/BooksBrowser/interface.html | 81 |
3 files changed, 372 insertions, 0 deletions
diff --git a/zend/demos/Zend/Gdata/BooksBrowser/books_browser.css b/zend/demos/Zend/Gdata/BooksBrowser/books_browser.css new file mode 100755 index 0000000..6ad2bbe --- /dev/null +++ b/zend/demos/Zend/Gdata/BooksBrowser/books_browser.css @@ -0,0 +1,136 @@ +body { + background-color: white; + color: black; + font-family: Arial, sans-serif; + font-size: small; + margin: 8px; + margin-top: 3px; +} + +.thumbnail img { + border-color:black; + border-width:1; + border-style:solid; +} + +table { + border-collapse: collapse; +} + +th, td { + padding: 0; + vertical-align: top; + text-align: left; + font-size: small; +} + +a:link { + color: #0000cc; +} + +a:active { + color: #cc0000; +} + +a:visited { + color: #551a8b; +} + +h1 { + font-size: x-large; + margin-top: 0px; + margin-bottom: 5px; +} + +h2 { + font-size: large; +} + +form { + display: inline; + margin: 0; + padding: 0; +} + +.volumeList td { + padding-bottom: 5px; + padding-right: 5px; +} + +#titleBar { + border: 1px solid silver; + background-color: #e5ecf9; + font-size: large; + font-weight: bold; + margin: 0; + padding: 0; + padding-top: 5px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin-top: 5px; + margin-bottom: 15px; +} + +#titleText { + float: left; +} + +#mainSearchBox { + background-color: #e5ecf9; + border: 1px solid silver; + width: 300; + padding-top: 5px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; +} + +#searchResults { + width: 100%; +} + +.volumeList td +{ + border-top: 1px solid #aaaaaa; + padding: 6px; +} + +.thumbnail +{ + height: 80px; + padding: 3px; +} + +.previewbutton +{ + border: 0px; + margin: 6px 0px 6px 0px; +} + +#resultcell +{ + padding-right: 20px; +} + +#previewcell +{ + border-left: 1px dotted #aaa; + padding-left: 20px; + display: none; + padding-right: 20px; +} + +#viewport { + height: 500px; + width: 100%; + border: 1px solid #aaa; + +} + +/* Google Preview: Boilerplate styling */ +#viewport { font-size: 16px; line-height: 1; } +#viewport img, #viewport table, #viewport div, #viewport td +{ border: 0; padding: 0; margin: 0; background: none } +#viewport td { vertical-align: middle } + diff --git a/zend/demos/Zend/Gdata/BooksBrowser/index.php b/zend/demos/Zend/Gdata/BooksBrowser/index.php new file mode 100755 index 0000000..8d5e9ad --- /dev/null +++ b/zend/demos/Zend/Gdata/BooksBrowser/index.php @@ -0,0 +1,155 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Demos + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ + +/** + * @see Zend_Loader + */ +require_once 'Zend/Loader.php'; + +/** + * @see Zend_Gdata_Books + */ +Zend_Loader::loadClass('Zend_Gdata_Books'); + +/** + * Return a comma separated string representing the elements of an array + * + * @param Array $elements The array of elements + * @return string Comma separated string + */ +function printArray($elements) { + $result = ''; + foreach ($elements as $element) { + if (!empty($result)) $result = $result.', '; + $result = $result.$element; + } + return $result; +} + + +/** + * Echo the list of videos in the specified feed. + * + * @param Zend_Gdata_Books_BookFeed $feed The video feed + * @return void + */ +function echoBookList($feed) +{ + print <<<HTML + <table><tr><td id="resultcell"> + <div id="searchResults"> + <table class="volumeList"><tbody width="100%"> +HTML; + $flipflop = false; + foreach ($feed as $entry) { + $title = printArray($entry->getTitles()); + $volumeId = $entry->getVolumeId(); + if ($thumbnailLink = $entry->getThumbnailLink()) { + $thumbnail = $thumbnailLink->href; + } else { + $thumbnail = null; + } + $preview = $entry->getPreviewLink()->href; + $embeddability = $entry->getEmbeddability()->getValue(); + $creators = printArray($entry->getCreators()); + if (!empty($creators)) $creators = "by " . $creators; + if ($embeddability == + "http://schemas.google.com/books/2008#embeddable") { + $preview_link = '<a href="javascript:load_viewport(\''. + $preview.'\',\'viewport\');">'. + '<img class="previewbutton" src="http://code.google.com/' . + 'apis/books/images/gbs_preview_button1.png" />' . + '</a><br>'; + } else { + $preview_link = ''; + } + $thumbnail_img = (!$thumbnail) ? '' : '<a href="'.$preview. + '"><img src="'.$thumbnail.'"/></a>'; + + print <<<HTML + <tr> + <td><div class="thumbnail"> + $thumbnail_img + </div></td> + <td width="100%"> + <a href="${preview}">$title</a><br> + $creators<br> + $preview_link + </td></tr> +HTML; + } + print <<<HTML + </table></div></td> + <td width=50% id="previewcell"><div id="viewport"></div> + </td></tr></table><br></body></html> +HTML; +} + +/* + * The main controller logic of the Books volume browser demonstration app. + */ +$queryType = isset($_GET['queryType']) ? $_GET['queryType'] : null; + +include 'interface.html'; + +if ($queryType === null) { + /* display the entire interface */ +} else { + $books = new Zend_Gdata_Books(); + $query = $books->newVolumeQuery(); + + /* display a list of volumes */ + if (isset($_GET['searchTerm'])) { + $searchTerm = $_GET['searchTerm']; + $query->setQuery($searchTerm); + } + if (isset($_GET['startIndex'])) { + $startIndex = $_GET['startIndex']; + $query->setStartIndex($startIndex); + } + if (isset($_GET['maxResults'])) { + $maxResults = $_GET['maxResults']; + $query->setMaxResults($maxResults); + } + if (isset($_GET['minViewability'])) { + $minViewability = $_GET['minViewability']; + $query->setMinViewability($minViewability); + } + + /* check for one of the restricted feeds, or list from 'all' videos */ + switch ($queryType) { + case 'full_view': + case 'partial_view': + $query->setMinViewability($queryType); + echo 'Requesting feed: ' . ($query->getQueryUrl()) . '<br><br>'; + $feed = $books->getVolumeFeed($query); + break; + case 'all': + echo 'Requesting feed: ' . ($query->getQueryUrl()) . '<br><br>'; + $feed = $books->getVolumeFeed($query); + break; + default: + echo 'ERROR - unknown queryType - "' . $queryType . '"'; + break; + } + echoBookList($feed); +} + diff --git a/zend/demos/Zend/Gdata/BooksBrowser/interface.html b/zend/demos/Zend/Gdata/BooksBrowser/interface.html new file mode 100644 index 0000000..55530c9 --- /dev/null +++ b/zend/demos/Zend/Gdata/BooksBrowser/interface.html @@ -0,0 +1,81 @@ +<!--- +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Demos + * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * + */ +--> +<html> +<head> + <title>Books Data API Browser in PHP</title> + <link href="books_browser.css" type="text/css" rel="stylesheet"/> + <script type="text/javascript" src="http://www.google.com/jsapi"> + </script> + <script type="text/javascript"> + function load_viewport(identifier, viewport_div_id) { + var viewport_div = document.getElementById(viewport_div_id); + var rightpane_div = viewport_div.parentNode; + rightpane_div.style.display = 'table-cell'; + viewport_div.innerHTML = 'Loading...'; + + var viewer = new google.books.DefaultViewer(viewport_div); + viewer.load(identifier, handle_not_found); + } + + function on_load() { + } + + function handle_not_found() { + var viewport_div = document.getElementById(viewport_div_id); + viewport_div.parentNode.style.display = 'none'; + } + + google.load('books', '0'); + google.setOnLoadCallback(on_load); + </script> + +</head> +<body> + <script> + </script> +<div id="titleBar"> + <div id="titleText"><h1>Books Data API Browser in PHP</h1></div> + <br /> +</div> +<br clear="all" /> +<div id="mainSearchBox"> + <h2>Search Books:</h2> + <form id="mainSearchForm" action="index.php"> + <select name="queryType"> + <option value="all" selected="true">All Books</option> + <option value="partial_view">Limited preview and full view</option> + <option value="full_view">Full view books only</option> + </select> + <input name="maxResults" type="hidden" value="6"> + <input name="searchTerm" type="text" value=""> + <input type="submit" value="Search"> + <a href="http://www.google.com"><img + src="http://books.google.com/googlebooks/images/poweredby.png" + border="0" width="62" height="30" align="absbottom" + style="position:relative; top: 6px; padding-left: 10px"></a> + </form> +</div> +<br> +<br clear="all" /> + + |
