]> _ Git - cubeextranet.git/commitdiff
wip #4464 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 14 May 2021 19:03:45 +0000 (19:03 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 14 May 2021 19:03:45 +0000 (19:03 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.theme.php
inc/ws/Metier/class.ws.book.php
inc/ws/Metier/class.ws.theme.php
inc/ws/Util/class.ws.ws3api.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 36b32541bafc6f9eef73c9612b6f1418ce904b6f..48a1fe7ce9bfd6d620762e63ff334fcf9c318754 100644 (file)
@@ -490,6 +490,7 @@ 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'])) {
index c6c2199bc9079143f15df08e1ade114b1a2e059f..39057021905bb735fcd6f543963200354f44bf3f 100644 (file)
@@ -1217,7 +1217,11 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
         }
 
         self::logReferer($book_id);
-        $html = file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html');
+        $htmlFile = WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html';
+        $html = '';
+        if (file_exists($htmlFile)) {
+            $html = file_get_contents($htmlFile);
+        }
         foreach ($replace as $from => $to) {
             $html = str_replace($from, $to, $html);
         }
index 4769e5ce6962f7219908428ad8539fd2481731c4..c54492abf36e237c4fa84095052d2aea6c275ab8 100644 (file)
 <?php\r
 \r
-class wsDAOTheme extends commonDAO {\r
-\r
-       protected function singleton($r) {\r
-               $theme = new wsTheme();\r
-               $theme->theme_id = $r->theme_id;\r
-               $theme->nom = $r->nom;\r
-               $theme->date = $r->date;\r
-               $theme->proprietaire = $r->proprietaire;\r
-               if ($r->exists('nbBooks')) {\r
-                       $theme->nbBooks = $r->nbBooks;\r
-               }\r
-               if ($r->exists('proprietaire_nom')) {\r
-                       $theme->proprietaire_nom = $r->proprietaire_nom;\r
-               }\r
-               $theme->signature = $r->signature;\r
-               $theme->icones = $r->icones;\r
-               $p = unserialize($r->parametres);\r
-               if (!$p) {\r
-                       $p = new wsThemeParametres($theme);\r
-               } else {\r
-                       $p->setParent($theme);\r
-               }\r
-               $theme->parametres = $p;\r
-\r
-               return $theme;\r
-       }\r
-\r
-       public function selectById($theme_id, $table = 'themes_vue') {\r
-               $r = $this->con->select('SELECT * FROM ' . $table . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
-               return $this->singleton($r);\r
-       }\r
-\r
-       public function getThemeOfBook($book_id, $basic = false) {\r
-               if ($basic) {\r
-                       $table = 'themes';\r
-               } else {\r
-                       $table = 'themes_vue';\r
-               }\r
-               $r = $this->con->select('SELECT * FROM ' . $table . ' WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1');\r
-               return $this->singleton($r);\r
-       }\r
-\r
-       public function getAllThemes($user, $order = '', $demos = null) {\r
-               if (wsDroits::admin(false)) {\r
-                       $sql = 'SELECT * FROM themes_vue';\r
-               } else {\r
-                       $or = '';\r
-                       if (wsDroits::revendeur() && !is_null($demos)) {\r
-                               $or = ' OR theme_id IN(' . implode(',', $demos) . ')';\r
-                       }\r
-                       $sql = 'SELECT * FROM themes_vue WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')';\r
-               }\r
-               $r = $this->con->select($sql . ' ' . $order);\r
-               return $this->factory($r);\r
-       }\r
-\r
-       public function sauve($data) {\r
-               $parent = $this->selectById($data['theme_id']);\r
-               $c = $this->con->openCursor('themes');\r
-               $c->date = TIME;\r
-               $p = new wsThemeParametres($parent);\r
-               foreach ($data as $k => $v) {\r
-                       if (!isset($p->$k)) {\r
-                               continue;\r
-                       }\r
-                       $p->$k = $v;\r
-               }\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
-       }\r
-\r
-       protected function getNextId() {\r
-               $r = $this->con->select('SELECT MAX(theme_id) AS theme_id FROM themes');\r
-               if ($r->theme_id < 1000) {\r
-                       return 1000;\r
-               }\r
-               return $r->theme_id + 1;\r
-       }\r
-\r
-       public function delete($theme_id, $onlyFiles = false) {\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
-               }\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
-\r
-       public function rename($theme_id, $newname) {\r
-               $c = $this->con->openCursor('themes');\r
-               $c->nom = $newname;\r
-               $c->update('WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
-       }\r
-\r
-       public function duplicate($theme_id, $proprietaire) {\r
-               if (is_null($theme_id) || $theme_id == '') {\r
-                       return;\r
-               }\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->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($c->theme_id, true);\r
-               // Copie des fichiers\r
-               $from = WS_THEMES . '/' . $theme_id;\r
-               $to = WS_THEMES . '/' . $c->theme_id;\r
-               $dr = opendir($from);\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
-               if (file_exists($from . '.jpg')) {\r
-                       copy($from . '.jpg', $to . '.jpg');\r
-               }\r
-\r
-               return $this->selectById($c->theme_id);\r
-       }\r
-\r
-}\r
-\r
-?>
\ No newline at end of file
+class wsDAOTheme extends commonDAO\r
+{\r
+\r
+    protected function singleton($r)\r
+    {\r
+        $theme = new wsTheme();\r
+        $theme->theme_id = $r->theme_id;\r
+        $theme->nom = $r->nom;\r
+        $theme->date = $r->date;\r
+        $theme->proprietaire = $r->proprietaire;\r
+        if ($r->exists('nbBooks')) {\r
+            $theme->nbBooks = $r->nbBooks;\r
+        }\r
+        if ($r->exists('proprietaire_nom')) {\r
+            $theme->proprietaire_nom = $r->proprietaire_nom;\r
+        }\r
+        $theme->signature = $r->signature;\r
+        $theme->icones = $r->icones;\r
+        $p = unserialize($r->parametres);\r
+        if (!$p) {\r
+            $p = new wsThemeParametres($theme);\r
+        } else {\r
+            $p->setParent($theme);\r
+        }\r
+        $theme->parametres = $p;\r
+\r
+        return $theme;\r
+    }\r
+\r
+    public function selectById($theme_id, $table = 'themes_vue')\r
+    {\r
+        $r = $this->con->select('SELECT * FROM ' . $table . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
+        return $this->singleton($r);\r
+    }\r
+\r
+    public function getThemeOfBook($book_id, $basic = false)\r
+    {\r
+        if ($basic) {\r
+            $table = 'themes';\r
+        } else {\r
+            $table = 'themes_vue';\r
+        }\r
+        $r = $this->con->select('SELECT * FROM ' . $table . ' WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1');\r
+        return $this->singleton($r);\r
+    }\r
+\r
+    public function getAllThemes($user, $order = '', $demos = null)\r
+    {\r
+        if (wsDroits::admin(false)) {\r
+            $sql = 'SELECT * FROM themes_vue';\r
+        } else {\r
+            $or = '';\r
+            if (wsDroits::revendeur() && !is_null($demos)) {\r
+                $or = ' OR theme_id IN(' . implode(',', $demos) . ')';\r
+            }\r
+            $sql = 'SELECT * FROM themes_vue WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')';\r
+        }\r
+        $r = $this->con->select($sql . ' ' . $order);\r
+        return $this->factory($r);\r
+    }\r
+\r
+    public function sauve($data)\r
+    {\r
+        $parent = $this->selectById($data['theme_id']);\r
+        $c = $this->con->openCursor('themes');\r
+        $c->date = TIME;\r
+        $p = new wsThemeParametres($parent);\r
+        foreach ($data as $k => $v) {\r
+            if (!isset($p->$k)) {\r
+                continue;\r
+            }\r
+            $p->$k = $v;\r
+        }\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
+    }\r
+\r
+    protected function getNextId()\r
+    {\r
+        $r = $this->con->select('SELECT MAX(theme_id) AS theme_id FROM themes');\r
+        if ($r->theme_id < 1000) {\r
+            return 1000;\r
+        }\r
+        return $r->theme_id + 1;\r
+    }\r
+\r
+    public function delete($theme_id, $onlyFiles = false)\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
+\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);\r
+        $theme->nom = $newname;\r
+        $api = new ws3API();\r
+        $api->updateTheme($theme);\r
+    }\r
+\r
+    public function duplicate($theme_id, $proprietaire)\r
+    {\r
+        if (is_null($theme_id) || $theme_id == '') {\r
+            return;\r
+        }\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->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($c->theme_id, true);\r
+        // Copie des fichiers\r
+        $from = WS_THEMES . '/' . $theme_id;\r
+        $to = WS_THEMES . '/' . $c->theme_id;\r
+        $dr = opendir($from);\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
+        if (file_exists($from . '.jpg')) {\r
+            copy($from . '.jpg', $to . '.jpg');\r
+        }\r
+\r
+\r
+        $theme=$this->selectById($c->theme_id);\r
+        try {\r
+            $api = new ws3API();\r
+            $api->createTheme($theme);\r
+        }catch (Exception $e){\r
+            print_r($e);\r
+            exit;\r
+        }\r
+\r
+        return $theme;\r
+    }\r
+\r
+}
\ No newline at end of file
index 5049d22ee6909659f8324ef891f1c4233f825d3c..68e9bf4f5f4136daad1fa70d22eac9545bdc8bba 100644 (file)
@@ -112,7 +112,7 @@ class wsBook extends cubeMetier
 \r
     public function getAssetDirId()\r
     {\r
-        return !$this->parametres->assetsDir ? $this->book_id : trim($this->parametres->assetsDir);\r
+        return !isset($this->parametres->assetsDir) || !$this->parametres->assetsDir ? $this->book_id : trim($this->parametres->assetsDir);\r
     }\r
 \r
     public static function getAssetDirOfBook($book_id, $sub = '')\r
index b926cb9167f6fd2aa7c5569cdfb537e0cbe4fd3a..93953e307e2ce61c89ae32daf5d6aaecfe13e5e5 100644 (file)
@@ -24,6 +24,4 @@ class wsTheme extends cubeMetier {
        protected $parametres;\r
        protected $proprietaire_nom;\r
        protected $nbBooks = 0;\r
-}\r
-\r
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 2ddaedd9fcfbc165fa1acadecd9afef5c51cde56..b5033a10e7f63a2d04053cbbc9c8c259fb7cb773 100644 (file)
@@ -6,7 +6,7 @@ class ws3API extends Zend_Rest_Client
     public function __construct($uri = null)\r
     {\r
         if (null === $uri) {\r
-            $uri = 'https://toolbox.fluidbook.com/api/';\r
+            $uri = 'https://toolbox.fluidbook.com/';\r
         }\r
         parent::__construct($uri);\r
 \r
@@ -19,13 +19,19 @@ class ws3API extends Zend_Rest_Client
     public function createTheme($theme)\r
     {\r
         global $core;\r
-        $this->restPost('fluidbook-theme', ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]);\r
+        return $this->restPost('/api/fluidbook-theme', ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]);\r
     }\r
 \r
     public function updateTheme($theme)\r
     {\r
         global $core;\r
-        $this->restPut('fluidbook-theme/' . $theme->theme_id, ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]);\r
+        return $this->restPut('/api/fluidbook-theme/' . $theme->theme_id, ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]);\r
+    }\r
+\r
+    public function deleteTheme($themeId)\r
+    {\r
+        global $core;\r
+        return $this->restDelete('/api/fluidbook-theme/' . $themeId, ['api_token' => $core->user->api_token]);\r
     }\r
 \r
     /**\r
index 3304ff036658e493e94fba4b96136b748c2945c4..2094144e9e72029207f2ded01b555c7c0d4c00e3 100644 (file)
@@ -44,6 +44,9 @@ class wsHTML5Link
     public $borderColor = '#ffffff';
     public $maxWidth = 0;
     public $wdir;
+    public $gamifyCoins = 0;
+    public $tooltipColor = null;
+    public $tooltipBackgroundColor = null;
     protected $role = 'button';
 
     protected $_init;