Also apply the __toString fix to UserInfo
[cacert-mgr.git] / external / ZendFramework-1.9.5 / demos / Zend / Gdata / BooksBrowser / index.php
1 <?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_Gdata
17 * @subpackage Demos
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 */
21
22 /**
23 * @see Zend_Loader
24 */
25 require_once 'Zend/Loader.php';
26
27 /**
28 * @see Zend_Gdata_Books
29 */
30 Zend_Loader::loadClass('Zend_Gdata_Books');
31
32 /**
33 * Return a comma separated string representing the elements of an array
34 *
35 * @param Array $elements The array of elements
36 * @return string Comma separated string
37 */
38 function printArray($elements) {
39 $result = '';
40 foreach ($elements as $element) {
41 if (!empty($result)) $result = $result.', ';
42 $result = $result.$element;
43 }
44 return $result;
45 }
46
47
48 /**
49 * Echo the list of videos in the specified feed.
50 *
51 * @param Zend_Gdata_Books_BookFeed $feed The video feed
52 * @return void
53 */
54 function echoBookList($feed)
55 {
56 print <<<HTML
57 <table><tr><td id="resultcell">
58 <div id="searchResults">
59 <table class="volumeList"><tbody width="100%">
60 HTML;
61 $flipflop = false;
62 foreach ($feed as $entry) {
63 $title = printArray($entry->getTitles());
64 $volumeId = $entry->getVolumeId();
65 if ($thumbnailLink = $entry->getThumbnailLink()) {
66 $thumbnail = $thumbnailLink->href;
67 } else {
68 $thumbnail = null;
69 }
70 $preview = $entry->getPreviewLink()->href;
71 $embeddability = $entry->getEmbeddability()->getValue();
72 $creators = printArray($entry->getCreators());
73 if (!empty($creators)) $creators = "by " . $creators;
74 if ($embeddability ==
75 "http://schemas.google.com/books/2008#embeddable") {
76 $preview_link = '<a href="javascript:load_viewport(\''.
77 $preview.'\',\'viewport\');">'.
78 '<img class="previewbutton" src="http://code.google.com/' .
79 'apis/books/images/gbs_preview_button1.png" />' .
80 '</a><br>';
81 } else {
82 $preview_link = '';
83 }
84 $thumbnail_img = (!$thumbnail) ? '' : '<a href="'.$preview.
85 '"><img src="'.$thumbnail.'"/></a>';
86
87 print <<<HTML
88 <tr>
89 <td><div class="thumbnail">
90 $thumbnail_img
91 </div></td>
92 <td width="100%">
93 <a href="${preview}">$title</a><br>
94 $creators<br>
95 $preview_link
96 </td></tr>
97 HTML;
98 }
99 print <<<HTML
100 </table></div></td>
101 <td width=50% id="previewcell"><div id="viewport"></div>&nbsp;
102 </td></tr></table><br></body></html>
103 HTML;
104 }
105
106 /*
107 * The main controller logic of the Books volume browser demonstration app.
108 */
109 $queryType = isset($_GET['queryType']) ? $_GET['queryType'] : null;
110
111 include 'interface.html';
112
113 if ($queryType === null) {
114 /* display the entire interface */
115 } else {
116 $books = new Zend_Gdata_Books();
117 $query = $books->newVolumeQuery();
118
119 /* display a list of volumes */
120 if (isset($_GET['searchTerm'])) {
121 $searchTerm = $_GET['searchTerm'];
122 $query->setQuery($searchTerm);
123 }
124 if (isset($_GET['startIndex'])) {
125 $startIndex = $_GET['startIndex'];
126 $query->setStartIndex($startIndex);
127 }
128 if (isset($_GET['maxResults'])) {
129 $maxResults = $_GET['maxResults'];
130 $query->setMaxResults($maxResults);
131 }
132 if (isset($_GET['minViewability'])) {
133 $minViewability = $_GET['minViewability'];
134 $query->setMinViewability($minViewability);
135 }
136
137 /* check for one of the restricted feeds, or list from 'all' videos */
138 switch ($queryType) {
139 case 'full_view':
140 case 'partial_view':
141 $query->setMinViewability($queryType);
142 echo 'Requesting feed: ' . ($query->getQueryUrl()) . '<br><br>';
143 $feed = $books->getVolumeFeed($query);
144 break;
145 case 'all':
146 echo 'Requesting feed: ' . ($query->getQueryUrl()) . '<br><br>';
147 $feed = $books->getVolumeFeed($query);
148 break;
149 default:
150 echo 'ERROR - unknown queryType - "' . $queryType . '"';
151 break;
152 }
153 echoBookList($feed);
154 }
155