]> _ Git - cubeextranet.git/commitdiff
wip #4210 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 22 Jul 2021 15:56:29 +0000 (15:56 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 22 Jul 2021 15:56:29 +0000 (15:56 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/DAO/class.ws.dao.theme.php
inc/ws/Metier/class.ws.theme.parametres.php
inc/ws/Util/class.ws.ws3api.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index a4d5729721d456de5384e42e6dddf4ea75c48385..0f6ed14c233fc068fa491895866cbfa58ba9c738 100644 (file)
@@ -219,7 +219,7 @@ class wsFlash extends cubeFlashGateway
             try {
                 $api = new ws3API();
                 $api->uploadThemeFile($this->args['theme_id'], $this->args['fieldname'], $dest);
-            }catch (Exception $e){
+            } catch (Exception $e) {
 
             }
 
@@ -445,7 +445,7 @@ class wsFlash extends cubeFlashGateway
         $readOnly = array(1);
 
         $dao = new wsDAOTheme($core->con);
-        $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',' . implode(',', $demos) . ') DESC, theme_id DESC', $demos,$this->xml);
+        $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',' . implode(',', $demos) . ') DESC, theme_id DESC', $demos, $this->xml);
         foreach ($themes as $theme) {
             $t = $this->xml->addChild('theme');
             $t->addAttribute('id', $theme->theme_id);
@@ -486,9 +486,9 @@ class wsFlash extends cubeFlashGateway
     public function renameTheme()
     {
         global $core;
-
         $dao = new wsDAOTheme($core->con);
         $dao->rename($this->args['theme_id'], $this->args['text']);
+
     }
 
     public function duplicateTheme()
index 87e7f262dbce31f2995dc8170e51dd0cf5cb49d0..19d2104a019822ec4ac9ecb3f89a042a3ec04fc6 100644 (file)
@@ -129,12 +129,6 @@ class wsDAOTheme extends commonDAO
         }\r
         $c->parametres = serialize($p);\r
         $c->update('WHERE theme_id=\'' . $this->con->escape($data['theme_id']) . '\'');\r
-        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'], 'themes_vue', true));\r
@@ -149,35 +143,20 @@ class wsDAOTheme extends commonDAO
         return $r->theme_id + 1;\r
     }\r
 \r
-    public function delete($theme_id, $onlyFiles = false)\r
+    public function delete($theme_id)\r
     {\r
         if (is_null($theme_id) || $theme_id == '') {\r
             return;\r
         }\r
-        if (!$onlyFiles) {\r
-            $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
-            $api = new ws3API();\r
-            $api->deleteTheme($theme_id);\r
-        }\r
-        $fref = WS_THEMES . '/' . $theme_id;\r
-        if (file_exists($fref)) {\r
-            files::deltree($fref);\r
-        }\r
-        if (file_exists($fref . '.jpg')) {\r
-            unlink($fref . '.jpg');\r
-        }\r
+\r
+        $api = new ws3API();\r
+        $api->deleteTheme($theme_id);\r
     }\r
 \r
     public function rename($theme_id, $newname)\r
     {\r
-        $c = $this->con->openCursor('themes');\r
-        $c->nom = $newname;\r
-        $c->update('WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
-\r
-        $theme = $this->selectById($theme_id, 'themes_vue', true);\r
-        $theme->nom = $newname;\r
         $api = new ws3API();\r
-        $api->updateTheme($theme);\r
+        $api->renameTheme($theme_id, $newname);\r
     }\r
 \r
     public function duplicate($theme_id, $proprietaire)\r
@@ -186,49 +165,11 @@ class wsDAOTheme extends commonDAO
             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 = $nextID;\r
-        $c->nom = $theme->nom . ' (copy)';\r
-        $c->parametres = serialize($theme->parametres);\r
-        $c->signature = $theme->signature;\r
-        $c->icones = $theme->icones;\r
-        $c->proprietaire = $proprietaire;\r
-        $c->date = TIME;\r
-        $c->insert();\r
-\r
-        $this->delete($nextID, true);\r
-        // Copie des fichiers\r
-        $from = WS_THEMES . '/' . $theme_id;\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
-        `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
-        try {\r
-            $theme = $this->selectById($nextID, 'themes_vue', true);\r
-            $api = new ws3API();\r
-            $api->createTheme($theme);\r
-        } catch (Exception $e) {\r
-            print_r($e);\r
-            exit;\r
-        }\r
+        $api = new ws3API();\r
+        $newId = ws3API::getResponseBody($api->cloneTheme($theme_id));\r
 \r
-        return $this->selectById($c->theme_id);\r
+        return $this->selectById($newId);\r
     }\r
 \r
 }
\ No newline at end of file
index 9094171a775d980304d2f6079dc579fd8e28d0dc..2e865d146ab24dd84b205c13984be079a710401b 100644 (file)
@@ -14,7 +14,7 @@ class wsThemeParametres extends wsParametres
             return;\r
         }\r
 \r
-        $themeRoot = 'fluidbook/themes/' . $this->parent->theme_id;\r
+        $themeRoot = 'fluidbook/themes3/' . $this->parent->theme_id;\r
         $uploadThemeURL = SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&amp;' . session_name() . '=' . session_id();\r
 \r
         parent::initFields();\r
index b0f5a204f81a4cd9c692b403fdeecdd5f5327a81..dea2a93fd50573a009de2ee53214f44094e80336 100644 (file)
@@ -24,6 +24,18 @@ class ws3API extends Zend_Rest_Client
         return $this->restPost('/api/fluidbook-theme', ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]);\r
     }\r
 \r
+    public function renameTheme($theme_id, $newname)\r
+    {\r
+        global $core;\r
+        return $this->restPut('/api/fluidbook-theme/' . $theme_id . '/rename', ['api_token' => $core->user->api_token, 'newname' => $newname]);\r
+    }\r
+\r
+    public function cloneTheme($theme_id)\r
+    {\r
+        global $core;\r
+        return $this->restPost('/api/fluidbook-theme/' . $theme_id . '/clone', ['api_token' => $core->user->api_token]);\r
+    }\r
+\r
     public function updateTheme($theme)\r
     {\r
         global $core;\r
@@ -56,4 +68,9 @@ class ws3API extends Zend_Rest_Client
         return $data;\r
     }\r
 \r
+    public static function getResponseBody(Zend_Http_Response $response)\r
+    {\r
+        return $response->getBody();\r
+    }\r
+\r
 }
\ No newline at end of file
index 3846f1851b8bc0f9064048522d35199bda6831fd..132e834ba32bcc508f55954715972d58998670f2 100644 (file)
@@ -306,7 +306,7 @@ class wsHTML5Compiler
         } else {
             $this->theme = $daoTheme->getThemeOfBook($book_id, true);
         }
-        $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/';
+        $this->themeRoot = WS_FILES . '/themes3/' . $this->theme->theme_id . '/';
 
 
         $daoDoc = new wsDAODocument($core->con);