From 175f97774911e0ba560b7eab5dc1dfaec4577a56 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 13 Jul 2018 16:21:48 +0000 Subject: [PATCH] wip #2124 @2 --- inc/ws/Controlleur/class.ws.maintenance.php | 30 ++++++++++--------- inc/ws/Controlleur/class.ws.url.php | 1 + inc/ws/DAO/class.ws.dao.book.php | 8 ++--- inc/ws/DAO/class.ws.dao.document.php | 8 +++-- .../html5/master/class.ws.html5.compiler.php | 2 +- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 51f8fe779..a8262dfb6 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -265,20 +265,24 @@ class wsMaintenance } } - public static function copyLinks($args) + public static function copyLinks($args, $eraseTo = false) { - $from=$args[0]; - $to=$args[1]; + $from = $args[0]; + $to = $args[1]; global $core; $dao = new wsDAODocument($core->con); $dao->getLinksAndRulers($from, $fromlinks, $fromrulers); - $dao->getLinksAndRulers($to, $tolinks, $torulers); + if (!$eraseTo) { + $dao->getLinksAndRulers($to, $tolinks, $torulers); - - $tolinks = array_merge($tolinks, $fromlinks); - $torulers = array_merge($torulers, $fromrulers); + $tolinks = array_merge($tolinks, $fromlinks); + $torulers = array_merge($torulers, $fromrulers); + } else { + $tolinks = $fromlinks; + $torulers = $fromrulers; + } $wt = WS_BOOKS . '/working/' . $to; $wf = WS_BOOKS . '/working/' . $from; @@ -804,6 +808,9 @@ class wsMaintenance $c->document_page = $infos['document_page']; $c->insert(); } + + $daoBook = new wsDAOBook($core->con); + $daoBook->saveCompositionVersion($to); } protected static function _duplicateLines($table, $key, $currentKey, $newKey) @@ -1160,15 +1167,10 @@ class wsMaintenance $dao = new wsDAOBook($core->con); for ($i = 0; $i < $times; $i++) { - $newbook = $dao->duplicate($book_id, $core->user->utilisateur_id, null, false, true); + $newbook = $dao->duplicate($book_id, $core->user->utilisateur_id, null, true, true); $new_id = $newbook->book_id; self::copyComposition([$book_id, $new_id]); - self::copyLinks([$book_id,$new_id]); - - $from_assets = WS_FILES . '/books/working/' . $book_id . '/'; - $to_assets = WS_FILES . '/books/working/' . $new_id . '/'; - - `cp -r $from_assets $to_assets`; + self::copyLinks([$book_id, $new_id], true); } } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 121a7b341..187689cea 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -910,6 +910,7 @@ html{height:100%}' . "\n"; $args = cubePage::getArgs($args); $book_id = $args[0]; + $dao = new wsDAODocument($core->con); $updates = $dao->getLinksVersions($book_id); krsort($updates); diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index e7c238b96..ab0bb7321 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -280,7 +280,6 @@ class wsDAOBook extends commonDAO $this->saveCompositionVersion($book_id); - return $this->selectById($book_id); } @@ -314,6 +313,7 @@ class wsDAOBook extends commonDAO public function supprime($book_id) { + $this->con->execute('DELETE FROM book_pages_versions WHERE book_id=\'' . $this->con->escape($book_id) . '\''); $this->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\''); return $this->con->execute('DELETE FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -383,9 +383,9 @@ class wsDAOBook extends commonDAO return $res; } - public function getPagesOfBook($book_id, $conversion = true) + public function getPagesOfBook($book_id, $conversion = true, $force = false) { - if (!isset(self::$pagesOfBookCache[$book_id])) { + if ($force || !isset(self::$pagesOfBookCache[$book_id])) { $pages = array(); $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'; @@ -689,7 +689,7 @@ class wsDAOBook extends commonDAO { $time = is_null($time) ? TIME : $time; - $pages = $this->getPagesOfBook($book_id); + $pages = $this->getPagesOfBook($book_id, true, true); $c = $this->con->openCursor('book_pages_versions'); $c->update = $time; diff --git a/inc/ws/DAO/class.ws.dao.document.php b/inc/ws/DAO/class.ws.dao.document.php index 6856063eb..1f2b96824 100644 --- a/inc/ws/DAO/class.ws.dao.document.php +++ b/inc/ws/DAO/class.ws.dao.document.php @@ -302,6 +302,7 @@ class wsDAODocument extends commonDAO { } public function getLinksVersions($book_id) { + $r = $this->con->select('SELECT * FROM special_links_versions WHERE book_id=\'' . $this->con->escape($book_id) . '\''); $specials = array(); while ($r->fetch()) { @@ -310,7 +311,6 @@ class wsDAODocument extends commonDAO { $specials[$r->update] = array('links' => count($ll), 'rulers' => count($lr)); } - // Get composition versions $r = $this->con->select('SELECT * FROM book_pages_versions WHERE book_id=\'' . $this->con->escape($book_id) . '\''); $docs = array(); @@ -322,7 +322,10 @@ class wsDAODocument extends commonDAO { } $res = array(); - $r = $this->con->select('SELECT l.*,u.prenom,u.nom FROM document_links_versions l LEFT JOIN utilisateurs u ON l.user=u.utilisateur_id WHERE document_id IN(' . implode(',', $docs) . ')'); + $sql='SELECT l.*,u.prenom,u.nom FROM document_links_versions l LEFT JOIN utilisateurs u ON l.user=u.utilisateur_id WHERE document_id IN(' . implode(',', $docs) . ')'; + $r = $this->con->select($sql); + + while ($r->fetch()) { if (!isset($res[$r->update])) { if (isset($specials[$r->update])) { @@ -349,6 +352,7 @@ class wsDAODocument extends commonDAO { } $res[$r->update]['user'] = $user; } + return $res; } diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 6b6025604..ab4c179aa 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -1851,7 +1851,7 @@ class wsHTML5Compiler $res = array('width' => 0, 'height' => 0); if (file_exists($d . '/index.html')) { $doc = new DOMDocument(); - $doc->loadHTMLFile($d . '/index.html'); + @$doc->loadHTMLFile($d . '/index.html'); $xpath = new DOMXPath($doc); $c = $xpath->query("//canvas"); foreach ($c as $canvas) { -- 2.39.5