From c25a4e6975fcba93a9e7dc3b19276798f41d63d8 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 19 Jan 2011 17:18:14 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.flash.php | 2 +- inc/ws/Controlleur/class.ws.url.php | 6 ++ inc/ws/DAO/class.ws.dao.book.php | 21 ++++++- inc/ws/DAO/class.ws.dao.document.php | 80 ++++++++++++++++++++++++++- 4 files changed, 106 insertions(+), 3 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 59c29fe38..bd1c2f143 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -61,7 +61,7 @@ class wsFlash extends cubeFlashGateway { $data['localInfos'] = $li; $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality'], $this->args['objects']); $document = $dao->sauve($data); - $document->copyOriginal($infos['tmp_name']); + $document->copyOriginalFromUpload($infos['tmp_name']); $this->xml->addChild('document_id', $document->document_id); $_SESSION['conversionSession'][$document->document_id] = 'all'; $_SESSION['conversionSessionReload'] = false; diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index e48adb7c2..a2ee69deb 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -398,6 +398,12 @@ html{height:100%}' . "\n"; fb('updateDocument', $document_id); self::updateDocument($document_id); } + + if (count($toUpdate) > 0) { + $dao->setChaptersFromOldFluidbook($book_id); + $daoDoc = new wsDAODocument($core->con); + $daoDoc->setLinksFromOldFluidbook($book_id); + } } protected static function updateDocument($document_id) diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 0c62103fb..80450b3bd 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -317,6 +317,25 @@ class wsDAOBook extends commonDAO { $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } + public function setChaptersFromOldFluidbook($book_id) + { + $xml = simplexml_load_file('http://ws.fluidbook.com/books/' . $book_id . '/links.xml'); + $res = array(); + $chapters = $xml->xpath('//chapters'); + foreach($chapters as $ch) { + $c = array(); + $c['label'] = (string)$ch->txt; + $c['page'] = (string)$ch->page; + $c['level'] = intval((string)$ch->level); + $res[] = $c; + } + + $c = $this->con->openCursor('books'); + $c->chapters = json_encode($res); + $c->changedate = TIME; + $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + } + public function setExtras($book_id, $extras) { if ($extras != '') { @@ -563,7 +582,7 @@ class wsDAOBook extends commonDAO { $flexLight->addVariable('size_p_' . $i, filesize($swffile), false, true, 'Number'); } else { $flex->addBitmap(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i); - $flex->addVariable('size_p_' . $i, filesize($swffile), false, true, 'Number'); + $flexLight->addVariable('size_p_' . $i, filesize($swffile), false, true, 'Number'); } } diff --git a/inc/ws/DAO/class.ws.dao.document.php b/inc/ws/DAO/class.ws.dao.document.php index e6aafe095..3793f6275 100644 --- a/inc/ws/DAO/class.ws.dao.document.php +++ b/inc/ws/DAO/class.ws.dao.document.php @@ -1,6 +1,6 @@ con); + $pages = $daoBook->getPagesOfBook($book_id); + $book = $daoBook->selectById($book_id); + $width = $book->parametres->width; + + $xml = simplexml_load_file('http://ws.fluidbook.com/books/' . $book_id . '/data/links.xml'); + $links = $xml->xpath('//oneLink'); + + /*res.type = type; + res.page = page; + if (page == 0 && rect.x=pageWidth && page!=totalPages){ + res.left = rect.x-pageWidth; + res.page++; + }else { + res.left = rect.x; + } + res.top = rect.y; + res.width = rect.width; + res.height = rect.height; + res.to = to; + res.target = target; + res.video_loop = video_loop; + res.video_auto_start = video_auto_start; + res.video_controls = video_controls; + res.video_sound_on = video_sound_on; + res.infobulle = infobulle; + res.numerotation = numerotation;*/ + + $res = array(); + $lpages = array(); + foreach($links as $l) { + $link = array(); + $link['page'] = (string)$l['page']; + $link['numerotation'] = false; + $link['left'] = intval((string)$l['startX']); + $link['width'] = intval((string)$l['endX']) - $link['left']; + if ($link['left'] > $width) { + $link['page']++; + $link['left'] -= $width; + } + $page = $link['page']; + $link['top'] = intval((string)$l['startY']); + $link['height'] = intval((string)$l['endY']) - $link['top']; + $link['infobulle'] = ''; + $link['target'] = '_blank'; + $link['to'] = (string)$l['linkTo']; + $link['type'] = intval((string)$l['linkType']); + $link['video_loop'] = ((string)$l['loopFlag'] == '1'); + $link['video_auto_start'] = true; + $link['video_controls'] = ((string)$l['playerActive'] == '1'); + $link['video_sound_on'] = ((string)$l['soundOn'] == '1'); + + if (!isset($lpages[$page])) { + $lpages[$page] = array(); + } + $lpages[$page][] = $link; + } + + $c = $this->con->openCursor('document_links'); + $c->update = TIME; + foreach($pages as $page => $infos) { + $c->document_id = $infos['document_id']; + $c->document_page = $infos['document_page']; + if (isset($lpages[$page])) { + $c->links = json_encode($lpages[$page]); + } else { + $c->links = json_encode(array()); + } + $c->rulers = json_encode(array()); + $c->insert(); + } + } + public function getLinksAndRulers($book_id, &$links, &$rulers) { $daoBook = new wsDAOBook($this->con); -- 2.39.5