]> _ Git - cubeextranet.git/commitdiff
wip #4210 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 21 Jul 2021 12:59:47 +0000 (12:59 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 21 Jul 2021 12:59:47 +0000 (12:59 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/DAO/class.ws.dao.theme.php
inc/ws/Util/class.ws.ws3api.php

index e26d4c4149a52b59816e1e063d84726d92a263a1..a4d5729721d456de5384e42e6dddf4ea75c48385 100644 (file)
@@ -216,8 +216,12 @@ class wsFlash extends cubeFlashGateway
             }
 
             move_uploaded_file($infos['tmp_name'], $dest);
-            $api = new ws3API();
-            $api->uploadThemeField($this->args['theme_id'], $this->args['fieldname'], $dest);
+            try {
+                $api = new ws3API();
+                $api->uploadThemeFile($this->args['theme_id'], $this->args['fieldname'], $dest);
+            }catch (Exception $e){
+
+            }
 
             if (isset($this->args['type']) && $this->args['type'] == 'favicon') {
                 $icotool = new cubeCommandLine('icotool');
@@ -491,8 +495,8 @@ class wsFlash extends cubeFlashGateway
     {
         global $core;
         $dao = new wsDAOTheme($core->con);
-
         $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id);
+
         $this->xml->addChild('theme_id', $theme->theme_id);
         if (isset($this->args['book_id'])) {
             $dao = new wsDAOBook($core->con);
@@ -508,11 +512,6 @@ class wsFlash extends cubeFlashGateway
         $dao->setTheme($this->args['book_id'], $this->args['theme']);
     }
 
-    public function postThemeShot()
-    {
-        file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data']));
-    }
-
     public function getAllIcones()
     {
         global $core;
index 1f4dc36a12779ea9a33fe69a0bad053990fe9f63..9db165417d128d357e9a99830412fa2e8cf961ca 100644 (file)
@@ -1556,6 +1556,12 @@ class wsMaintenance
             }
         }
     }
+
+    public static function test(){
+        global $core;
+        $dao=new wsDAOTheme($core->con);
+        print_r($dao->selectById('3641'));
+    }
 }
 
 
index ae86af0d01a199c1550d5cffc32ebb436d4a7692..d53e76a285aeb8f1a58d9c5d5ad5d9767d700016 100644 (file)
@@ -1198,7 +1198,12 @@ class wsDAOBook extends commonDAO
             return;
         }
 
-        $this->_compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+        $lockId = $book_id;
+        if ($forceTheme) {
+            $lockId .= '-' . wsTheme::hashThemeArray($forceTheme);
+        }
+
+        $this->_compileLock = WS_BOOKS . '/locks/' . $lockId . '.lock';
 
 
         while (file_exists($this->_compileLock) && filemtime($this->_compileLock) > (time() - 900)) {
@@ -1252,14 +1257,14 @@ class wsDAOBook extends commonDAO
         return wsBook::getAssetDirOfBook($book_id, $dir) . $path;
     }
 
-    public function compileHTML5($book_id, $book, $dev = false, $delete = true,$forceTheme=false)
+    public function compileHTML5($book_id, $book, $dev = false, $delete = true, $forceTheme = false)
     {
         $version = $book->parametres->mobileLVersion;
         if ($dev) {
             $version = 'dev';
         }
 
-        $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book,$forceTheme);
+        $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book, $forceTheme);
         $htmlCompiler->compile($delete);
 
         self::$lastHTML5Compiler = $htmlCompiler;
index 3cdcb832de634cd37aa43a463626d4bb8ef6d5c3..87e7f262dbce31f2995dc8170e51dd0cf5cb49d0 100644 (file)
@@ -59,24 +59,28 @@ class wsDAOTheme extends commonDAO
         return $theme;\r
     }\r
 \r
-    protected function _table($table)\r
+    protected function _table($table, $force_table = false)\r
     {\r
+        if ($force_table) {\r
+            return $table;\r
+        }\r
+\r
         global $core;\r
 \r
-        if (false && $core->user->utilisateur_id == 5) {\r
-            if ($table === 'themes_vue') {\r
-                return 'ws3_theme_vue';\r
-            } else if ($table === 'themes') {\r
-                return 'ws3_theme';\r
-            }\r
-        } else {\r
-            return $table;\r
+        //if (is_object($core->user) && $core->user->utilisateur_id == 5) {\r
+        if ($table === 'themes_vue') {\r
+            return 'ws3_theme_vue';\r
+        } else if ($table === 'themes') {\r
+            return 'ws3_theme';\r
         }\r
+        //} else {\r
+        //    return $table;\r
+        //}\r
     }\r
 \r
-    public function selectById($theme_id, $table = 'themes_vue')\r
+    public function selectById($theme_id, $table = 'themes_vue', $force_table = false)\r
     {\r
-        $r = $this->con->select('SELECT * FROM ' . $this->_table($table) . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
+        $r = $this->con->select('SELECT * FROM ' . $this->_table($table, $force_table) . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
         return $this->singleton($r);\r
     }\r
 \r
@@ -128,9 +132,12 @@ class wsDAOTheme extends commonDAO
         if (file_exists(WS_THEMES . '/' . $data['theme_id'] . '.jpg')) {\r
             unlink(WS_THEMES . '/' . $data['theme_id'] . '.jpg');\r
         }\r
+        if (file_exists(WS_FILES . '/themes3/' . $data['theme_id'] . '.jpg')) {\r
+            unlink(WS_FILES . '/themes3/' . $data['theme_id'] . '.jpg');\r
+        }\r
 \r
         $api = new ws3API();\r
-        $api->updateTheme($this->selectById($data['theme_id']));\r
+        $api->updateTheme($this->selectById($data['theme_id'], 'themes_vue', true));\r
     }\r
 \r
     protected function getNextId()\r
@@ -167,7 +174,7 @@ class wsDAOTheme extends commonDAO
         $c->nom = $newname;\r
         $c->update('WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
 \r
-        $theme = $this->selectById($theme_id);\r
+        $theme = $this->selectById($theme_id, 'themes_vue', true);\r
         $theme->nom = $newname;\r
         $api = new ws3API();\r
         $api->updateTheme($theme);\r
@@ -178,10 +185,13 @@ class wsDAOTheme extends commonDAO
         if (is_null($theme_id) || $theme_id == '') {\r
             return;\r
         }\r
+\r
+        $nextID = $this->getNextId();\r
+        echo $nextID;\r
         $theme = $this->selectById($theme_id);\r
         // Copie des donnĂ©es\r
         $c = $this->con->openCursor('themes');\r
-        $c->theme_id = $this->getNextId();\r
+        $c->theme_id = $nextID;\r
         $c->nom = $theme->nom . ' (copy)';\r
         $c->parametres = serialize($theme->parametres);\r
         $c->signature = $theme->signature;\r
@@ -190,30 +200,27 @@ class wsDAOTheme extends commonDAO
         $c->date = TIME;\r
         $c->insert();\r
 \r
-        $this->delete($c->theme_id, true);\r
+        $this->delete($nextID, true);\r
         // Copie des fichiers\r
         $from = WS_THEMES . '/' . $theme_id;\r
-        $to = WS_THEMES . '/' . $c->theme_id;\r
-        $dr = opendir($from);\r
+        $to = WS_THEMES . '/' . $nextID;\r
         if (!file_exists($to)) {\r
             mkdir($to, 0777, true);\r
         } else {\r
             files::deltree($to);\r
             mkdir($to, 0777, true);\r
-        } //.\r
-        while ($file = readdir($dr)) {\r
-            if ($file == '.' || $file == '..') {\r
-                continue;\r
-            }\r
-            copy($from . '/' . $file, $to . '/' . $file);\r
-        }\r
+        } //\r
+        `cp -r $from/* $to`;\r
         if (file_exists($from . '.jpg')) {\r
             copy($from . '.jpg', $to . '.jpg');\r
         }\r
+        $thumb = '/data1/extranet/toolbox/storage/themes/';\r
+        if (file_exists($thumb . $theme_id . '.jpg')) {\r
+            copy($thumb . $theme_id . '.jpg', $thumb . $nextID . '.jpg');\r
+        }\r
 \r
-\r
-        $theme = $this->selectById($c->theme_id);\r
         try {\r
+            $theme = $this->selectById($nextID, 'themes_vue', true);\r
             $api = new ws3API();\r
             $api->createTheme($theme);\r
         } catch (Exception $e) {\r
@@ -221,7 +228,7 @@ class wsDAOTheme extends commonDAO
             exit;\r
         }\r
 \r
-        return $theme;\r
+        return $this->selectById($c->theme_id);\r
     }\r
 \r
 }
\ No newline at end of file
index 47d9cfa8c311ae2f3e3a5ee2fedb611f31c1a6ed..b0f5a204f81a4cd9c692b403fdeecdd5f5327a81 100644 (file)
@@ -9,6 +9,8 @@ class ws3API extends Zend_Rest_Client
             $uri = 'https://toolbox.fluidbook.com/';\r
         }\r
         parent::__construct($uri);\r
+        self::getHttpClient()->setConfig([\r
+            'timeout' => 300]);\r
 \r
     }\r
 \r