From: vincent@cubedesigners.com Date: Wed, 11 Apr 2012 12:01:30 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=957468caa9557f69618a8804023fb3f3f4ea13b9;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index f67005b5e..6e5b5f5fb 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -268,47 +268,41 @@ class wsFlash extends cubeFlashGateway { public function getPagesOfBook() { global $core; + + $this->json = true; + $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); - $pages = $dao->getPagesOfBook($this->args['book_id']); - $p = $this->xml->addChild('pages'); + $pages = $dao->getPagesOfBook($this->args['book_id'], false); + $this->jsonDatas['pages'] = array(); $docs = array(); $defaultNum = array(); foreach ($pages as $page => $info) { $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg'; if (!file_exists($file)) { - $dim = array(0, 0); $info['resolution'] = 150; $info['method'] = 1; $info['objects'] = 1800; $info['quality'] = 85; $info['version'] = 'stable'; - } else { + } elseif (!isset($this->jsonDatas['thumbWidth'])) { $dim = getimagesize($file); + $this->jsonDatas['thumbWidth'] = $dim[0]; + $this->jsonDatas['thumbHeight'] = $dim[1]; } - - - $pa = $p->addChild('page'); - $pa->addAttribute('page', $page); - $pa->addAttribute('document_id', $info['document_id']); - $pa->addAttribute('document_page', $info['document_page']); - $pa->addAttribute('width', $dim[0]); - $pa->addAttribute('height', $dim[1]); - $pa->addAttribute('resolution', $info['resolution']); - $pa->addAttribute('quality', $info['quality']); - $pa->addAttribute('methode', $info['method']); - $pa->addAttribute('objects', $info['objects']); - $pa->addAttribute('version', $info['version']); $docs[] = $info['document_id']; $defaultNum[] = $info['defaultNum']; + + $this->jsonDatas['pages'][] = array($info['document_id'], $info['document_page']); } $docs = array_unique($docs); - $p->addAttribute('documents', implode(',', $docs)); + $this->jsonDatas['documents'] = array_unique($docs); + if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') { - $this->xml->addChild('numerotation', implode(',', $defaultNum)); + $this->jsonDatas['numerotation'] = $defaultNum; } else { - $this->xml->addChild('numerotation', $book->numerotation); + $this->jsonDatas['numerotation'] = explode(',', $book->numerotation); } } @@ -481,16 +475,11 @@ class wsFlash extends cubeFlashGateway { $pages = $dao->getPagesOfBook($this->args['book_id']); $nb_pages = count($pages); - - - - $daoDoc = new wsDAODocument($core->con); $firstDoc = $daoDoc->selectById($pages[1]['document_id']); $size = $firstDoc->generalInfos['size']; $daoDoc->getLinksAndRulers($this->args['book_id'], $links, $rulers); - $this->json = false; $this->json = true; @@ -600,7 +589,7 @@ class wsFlash extends cubeFlashGateway { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); - $pages = $dao->getPagesOfBook($this->args['book_id']); + $pages = $dao->getPagesOfBook($this->args['book_id'], false); $daoDoc = new wsDAODocument($core->con); $nb_pages = count($pages); $this->xml->addChild('pages', $nb_pages); @@ -628,11 +617,6 @@ class wsFlash extends cubeFlashGateway { $res .= __('Taille moyenne des pages') . ' : ' . "\n"; $res .= $average . "\n"; $res .= "\n"; - /* $res .= __('Taille du PDF') . ' : ' . "\n"; - $res .= '7898 Ko' . "\n"; - $res .= "\n"; - $res .= __('Qualité de conversion') . ' : ' . "\n"; - $res .= '150dpi (qualité 85%)' . "\n"; */ $this->xml->addChild('infos', $res); } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index e1f0552c5..697efe73e 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -244,8 +244,10 @@ class wsUrl { $res = '
'; $res .= '
'; return $res; @@ -391,7 +393,7 @@ class wsUrl { $s->setTitle(cubeText::str2URL($lang_name)); - $tab = cubeLang::getTranslationsList(array(PLAYER_SOURCES, WS_COMPILE_ASSETS . '/_html5/js'), array('php', 'as','js'), array(), $lang->traductions); + $tab = cubeLang::getTranslationsList(array(PLAYER_SOURCES, WS_COMPILE_ASSETS . '/_html5/js'), array('php', 'as', 'js'), array(), $lang->traductions); $s->setCellValueByColumnAndRow(0, 1, 'ID', true); $s->setCellValueByColumnAndRow(1, 1, $ref_name, true); @@ -1058,17 +1060,9 @@ html{height:100%}' . "\n"; global $core; cubePHP::neverStop(); $daoBook = new wsDAOBook($core->con); - $book = $daoBook->selectById($book_id); - $pages = $daoBook->getPagesOfBook($book_id); - $toUpdate = array(); - foreach ($pages as $p => $infos) { - if ($infos['version'] < 2) { - $toUpdate[] = $infos['document_id']; - } - } - $toUpdate = array_unique($toUpdate); + $toUpdate = $daoBook->getDocumentsToUpdate($book_id); foreach ($toUpdate as $document_id) { self::updateDocument($document_id); } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 3ba65d778..2bfb062fb 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -246,15 +246,24 @@ class wsDAOBook extends commonDAO { return unserialize($pages); } - public function getPagesOfBook($book_id) { + public function getDocumentsToUpdate($book_id) { + $res = array(); + $r = $this->con->select('SELECT DISTINCT d.document_id FROM book_pages b,documents d WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' AND d.version=1 AND b.document_id=d.document_id'); + while ($r->fetch()) { + $res[] = $r->document_id; + } + return $res; + } + + public function getPagesOfBook($book_id, $conversion = true) { $pages = array(); - $r = $this->con->select('SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page'); + + $sql = 'SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page'; + + $r = $this->con->select($sql); while ($r->fetch()) { $n = explode(',', $r->num); - if ($r->conversion != '') { - $c = unserialize($r->conversion); - $c = $c->pages[$r->document_page]; - } + if (isset($n[$r->document_page - 1])) { $num = $n[$r->document_page - 1]; } else { @@ -267,10 +276,16 @@ class wsDAOBook extends commonDAO { 'nb_pages' => $r->doc_pages ); - $qp = array('resolution', 'method', 'quality', 'objects'); - foreach ($qp as $p) { - if (isset($c) && isset($c->$p)) { - $pages[$r->book_page][$p] = $c->$p; + if ($conversion) { + if ($r->conversion != '') { + $c = unserialize($r->conversion); + $c = $c->pages[$r->document_page]; + } + $qp = array('resolution', 'method', 'quality', 'objects'); + foreach ($qp as $p) { + if (isset($c) && isset($c->$p)) { + $pages[$r->book_page][$p] = $c->$p; + } } } }