/** * Helper to prepare the viewer (only the javascript differs in view). */ protected function _prepareViewer($item) { $ui = $this->getParam('ui'); $part = $this->getParam('part'); $bookreader = new BookReader($item); $bookreader->setUI($ui); $bookreader->setPart($part); $this->view->bookreader = $bookreader; $this->view->item = $item; // Values have been checked inside BookReader. $this->view->ui = $bookreader->getUI(); $this->view->part = $bookreader->getPart(); }
/** * Checks if it is allowed to save new, empty objects with a auto increment column */ public function testAllowEmptyWithAutoIncrement() { $bookreader = new BookReader(); $bookreader->save(); $this->assertFalse($bookreader->isNew()); }
/** * Testing foreign keys with multiple referrer columns. * @link http://propel.phpdb.org/trac/ticket/606 */ public function testMultiColFk() { $con = Propel::getConnection(BookPeer::DATABASE_NAME); ReaderFavoritePeer::doDeleteAll(); $b1 = new Book(); $b1->setTitle("Book1"); $b1->setISBN("ISBN-1"); $b1->save(); $r1 = new BookReader(); $r1->setName("Me"); $r1->save(); $bo1 = new BookOpinion(); $bo1->setBookId($b1->getId()); $bo1->setReaderId($r1->getId()); $bo1->setRating(9); $bo1->setRecommendToFriend(true); $bo1->save(); $rf1 = new ReaderFavorite(); $rf1->setReaderId($r1->getId()); $rf1->setBookId($b1->getId()); $rf1->save(); $c = new Criteria(ReaderFavoritePeer::DATABASE_NAME); $c->add(ReaderFavoritePeer::BOOK_ID, $b1->getId()); $c->add(ReaderFavoritePeer::READER_ID, $r1->getId()); $results = ReaderFavoritePeer::doSelectJoinBookOpinion($c); $this->assertEquals(1, count($results), "Expected 1 result"); }
/** * @see testDoDeleteCompositePK() */ private function createReaderWithId($id) { $con = Propel::getConnection(BookReaderPeer::DATABASE_NAME); $r = BookReaderPeer::retrieveByPK($id); if (!$r) { $r = new BookReader(); $r->setName('Reader' . $id)->save(); $r1Id = $r->getId(); $sql = "UPDATE " . BookReaderPeer::TABLE_NAME . " SET id = ? WHERE id = ?"; $stmt = $con->prepare($sql); $stmt->bindValue(1, $id); $stmt->bindValue(2, $r1Id); $stmt->execute(); } }
/** * Helper to return image of the current image. * * @param string $type Derivative type of the image. * @return void */ protected function _sendImage($type = null) { $request = $this->getRequest(); $itemId = $request->getParam('id'); $item = get_record_by_id('item', $itemId); if (empty($item)) { throw new Omeka_Controller_Exception_404(); } $index = $request->getParam('image'); // Get the index. if ($index != '000') { $index = preg_replace('`^[0]*`', '', $index); $index--; } else { $index = 0; } $bookreader = new BookReader($item); $part = $request->getParam('part'); $bookreader->setPart($part); if (is_null($type)) { $scale = $request->getParam('scale'); $type = $bookreader->getSizeType($scale); // Set a default, even it's normally useless. $type = $type ?: 'fullsize'; } $imagesFiles = $bookreader->getLeaves(); $file = $imagesFiles[$index]; // No file, so a blank image if (empty($file)) { $filepath = 'images/blank.png'; $image = file_get_contents(physical_path_to($filepath)); $this->getResponse()->clearBody(); $this->getResponse()->setHeader('Content-Type', 'image/jpeg'); $this->getResponse()->setBody($image); } else { $this->_helper->redirector->gotoUrlAndExit($file->getWebPath($type)); } }
public function setTitle(BookReader $bookReader) { $this->title = $bookReader->getTitle(); }
public static function populateOpinionFavorite($con = null) { if ($con === null) { $con = Propel::getConnection(BookPeer::DATABASE_NAME); } $con->beginTransaction(); $book1 = BookPeer::doSelectOne(new Criteria(), $con); $reader1 = new BookReader(); $reader1->save($con); $bo = new BookOpinion(); $bo->setBook($book1); $bo->setBookReader($reader1); $bo->save($con); $rf = new ReaderFavorite(); $rf->setBookOpinion($bo); $rf->save($con); $con->commit(); }
it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. BookReader is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with BookReader. If not, see <http://www.gnu.org/licenses/>. */ require_once '/petabox/setup.inc'; $id = $_REQUEST['id']; $book = $_REQUEST['book']; // support multiple books within an item if ("" == $id) { echo "No identifier specified!"; die(-1); } $locator = new Locator(); $results = $locator->locateUDP($id, 1, false); $server = $results[0][0]; $serverBaseURL = BookReader::serverBaseURL($server); $url = "http://{$serverBaseURL}/BookReader/BookReaderJSIA.php?id=" . urlencode($id) . "&itemPath={$results[0][1]}&server={$server}"; if ($book) { $url .= "&subPrefix=" . urlencode($book); } if ("" != $results[0][0] && "" != $results[0][1]) { header("Location: {$url}"); }
<?php require 'BookMark.php'; require 'BookReader.php'; $bookReader = new BookReader('Martine à la plage', '103'); $bookMark = new BookMark($bookReader); echo $bookReader->getTitle() . $bookReader->getPage(); $bookReader->setPage("104"); $bookMark->setPage($bookReader); echo '<br> Reader : ' . $bookReader->getPage(); $bookReader->setPage("1005"); echo '<br> Reader : ' . $bookReader->getPage(); $bookMark->getPage($bookReader); echo '<br> Reader : ' . $bookReader->getPage();
public function getPage(BookReader $bookReader) { $bookReader->setPage($this->page); }
<?php // For data in a spreadsheet. if (empty($tableUrl)) { echo '<html><head></head><body>'; echo __('This item has no viewable files.'); echo '</body></html>'; return; } $title = metadata($item, array('Dublin Core', 'Title')); $creator = metadata($item, array('Dublin Core', 'Creator')); if ($creator) { $title .= ' - ' . $creator; } $title = BookReader::htmlCharacter($title); $coverFile = $bookreader->getCoverFile(); list($pageIndexes, $pageNumbers, $pageLabels, $imgWidths, $imgHeights) = $bookreader->imagesData(); $server = preg_replace('#^https?://#', '', WEB_ROOT); $serverFullText = $server . '/book-reader/index/fulltext'; $imgDir = WEB_PLUGIN . '/BookReader/views/shared/images/'; try { $favicon = src('favicon.ico'); } catch (Exception $e) { $favicon = ''; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html <?php echo $ui == 'embed' ? 'id="embedded" ' : ''; ?> lang="fr">
/** * 看书 * @return null */ public function read() { $this->bookReader->openBook(); $this->bookReader->turnOnPage(); }
/** * Sort all files of an item by name. * * @param Item $item * @param boolean $mixFileTypes * * @return void */ protected function _sortFiles($item, $mixFileTypes = false) { if ($item->fileCount() < 2) { return; } if ($mixFileTypes) { $list = $item->Files; BookReader_Creator::sortFilesByOriginalName($list, false); } else { $bookreader = new BookReader($item); // Get leaves and remove blank ones. $leaves = array_filter($bookreader->getLeaves()); $non_leaves = array_filter($bookreader->getNonLeaves()); // Manage the case where there is no BookReader data. if (empty($leaves) && empty($non_leaves)) { $list = $item->Files; BookReader_Creator::sortFilesByOriginalName($list, false); } else { // Order them separately. BookReader_Creator::sortFilesByOriginalName($leaves, false); BookReader_Creator::sortFilesByOriginalName($non_leaves, false); // Finally, merge them. $list = array_merge($leaves, $non_leaves); } } // To avoid issues with unique index when updating (order should be // unique for each file of an item), all orders are reset to null before // true process. $db = $this->_db; $bind = array($item->id); $sql = "\n UPDATE `{$db->File}` files\n SET files.order = NULL\n WHERE files.item_id = ?\n "; $db->query($sql, $bind); // To avoid multiple updates, a single query is used. foreach ($list as &$file) { $file = $file->id; } // The array is made unique, because a leaf can be repeated. $list = implode(',', array_unique($list)); $sql = "\n UPDATE `{$db->File}` files\n SET files.order = FIND_IN_SET(files.id, '{$list}')\n WHERE files.id in ({$list})\n "; $db->query($sql); }