]> _ Git - cubeextranet.git/commitdiff
wip #2124 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 13 Jul 2018 16:21:48 +0000 (16:21 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 13 Jul 2018 16:21:48 +0000 (16:21 +0000)
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/DAO/class.ws.dao.document.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 51f8fe779f67b9530a1cc8896a99a5baff9e97df..a8262dfb63afc5d9c0155c675f9746a4db3dabcc 100644 (file)
@@ -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);
                }
        }
 
index 121a7b341c498f569353372e3a00f0be916b33e8..187689ceaf175d6a63dfaec0b26ab40b8178a267 100644 (file)
@@ -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);
index e7c238b96fa73a5ba4bd05b17ab9c854dc64d94f..ab0bb732108072f7718c615e29702013dc8eb513 100644 (file)
@@ -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;
index 6856063ebd3c87d9413d38b3477d0a7de0bec6fc..1f2b96824c18ac224e9540c5739ceb0a72d7d474 100644 (file)
@@ -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;
        }
 
index 6b6025604c5741c4a430c44ca27652786d4d1cfb..ab4c179aa93bba064d97d2038b94d0ea4dbd9351 100644 (file)
@@ -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) {