]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 7 Dec 2010 17:07:38 +0000 (17:07 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 7 Dec 2010 17:07:38 +0000 (17:07 +0000)
inc/config.inc.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.document.php

index c541467f7e2d10cd74a5975ede57b49cba10db4d..8f5514d4cea1164dcd3b6df324af06c467d5af37 100644 (file)
@@ -48,7 +48,7 @@ if (in_array($_SERVER['HTTP_HOST'], $ws)) {
        define('MODE', 'ws');\r
        define('GA', 'UA-4339912-5');\r
        define('TITLE', 'Fuidbook Workshop');\r
-       if(DEV){\r
+       if (DEV) {\r
                define('STATIC_SERVER', 'http://devstatic.ws.fluidbook.com' . WEBROOT);\r
        }\r
 } else {\r
@@ -56,9 +56,16 @@ if (in_array($_SERVER['HTTP_HOST'], $ws)) {
        define('GA', 'UA-4339912-4');\r
        define('TITLE', 'Extranet Cubedesigners');\r
 }\r
-\r
-\r
+// Workshop\r
+define('THEMES', WEBROOT . '/themes/');\r
+define('ICONS', WEBROOT . '/icones/');\r
 define('WS_STATS', 'http://stats.fluidbook.com/');\r
+define('WS_FILES', ROOT . '/fluidbook');\r
+define('WS_BOOKS', WS_FILES . '/books');\r
+define('WS_DOCS', WS_FILES . '/docs');\r
+define('WS_ICONS', WS_FILES . '/icones');\r
+define('WS_THEMES', WS_FILES . '/themes');\r
+define('WS_COMPILE_ASSETS', WS_FILES . '/compile');\r
 // define('MINIMIZE_JS', false);\r
 define('WORKER_PREFIX', 'worker.');\r
 \r
@@ -89,9 +96,6 @@ define('MAIL_BCC', 'contact@cubedesigners.com');
 define('ZEND', dirname(__FILE__) . '/Zend');\r
 // Timezone\r
 define('TIMEZONE', 'UTC');\r
-// Workshop\r
-define('THEMES', WEBROOT . '/themes/');\r
-define('ICONS', WEBROOT . '/icones/');\r
 \r
 define('CUBE_SEARCH_LIMIT_CHARS', 3);\r
 \r
index 925a29aea322b8d8d292a3418421258af49b5d78..ad34eec1b0e07477917d4d741d6edad6d7f80dee 100644 (file)
@@ -60,12 +60,12 @@ class wsFlash extends cubeFlashGateway {
                                continue;\r
                        }\r
                        $fname = cubeFiles::tidyName($infos['name']);\r
-                       $dir = '/books/working/' . $this->args['book_id'] . '/' ;\r
-                       if (!file_exists(ROOT . $dir)) {\r
-                               mkdir(ROOT . $dir, 0777, true);\r
+                       $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' ;\r
+                       if (!file_exists($dir)) {\r
+                               mkdir($dir, 0777, true);\r
                        }\r
                        $dest = $dir . $fname;\r
-                       move_uploaded_file($infos['tmp_name'], ROOT . $dest);\r
+                       move_uploaded_file($infos['tmp_name'], $dest);\r
                        $this->xml->addChild('file', $fname);\r
                        return;\r
                }\r
@@ -91,7 +91,7 @@ class wsFlash extends cubeFlashGateway {
                $docs = array();\r
                $defaultNum = array();\r
                foreach($pages as $page => $info) {\r
-                       $file = ROOT . '/docs/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';\r
+                       $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';\r
                        $dim = getimagesize($file);\r
                        $pa = $p->addChild('page');\r
                        $pa->addAttribute('page', $page);\r
@@ -249,7 +249,7 @@ class wsFlash extends cubeFlashGateway {
 \r
        public function postThemeShot()\r
        {\r
-               file_put_contents(ROOT . '/themes/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data']));\r
+               file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data']));\r
        }\r
 \r
        public function getAllIcones()\r
@@ -404,7 +404,7 @@ class wsFlash extends cubeFlashGateway {
 \r
                $total_size = 0;\r
                foreach($pages as $page => $info) {\r
-                       $file = ROOT . '/docs/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf';\r
+                       $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf';\r
                        $total_size += filesize($file);\r
                }\r
                $average_size = $total_size / $nb_pages;\r
@@ -487,7 +487,10 @@ class wsFlash extends cubeFlashGateway {
        {\r
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
-               fb($dao->compile($this->args['book_id'], 3));\r
+               $dao->compile($this->args['book_id'], 3);\r
+\r
+               $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/fluidbook/books/final/' . $this->args['book_id'] . '/';\r
+               $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL);\r
        }\r
 }\r
 \r
index ce37f774a7f280f5b41e53c24e51b71370d2a0b5..190d0e8e05b45a54187c058d76481f7ce947c1ba 100644 (file)
@@ -369,7 +369,7 @@ class wsDAOBook extends extranetDAO {
                $res = array\r
                ();\r
                foreach($pages as $page => $p) {\r
-                       $csv = ROOT . '/docs/' . $p['document_id'] . '/p' . $p['document_page'] . '.csv';\r
+                       $csv = WS_DOCS . '/' . $p['document_id'] . '/p' . $p['document_page'] . '.csv';\r
                        $fp = fopen($csv, 'rb');\r
 \r
                        while (true) {\r
@@ -410,8 +410,8 @@ class wsDAOBook extends extranetDAO {
                $index = array();\r
                $textes = array();\r
                foreach($pages as $book_page => $infos) {\r
-                       $tfile = ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.txt';\r
-                       $ifile = ROOT . '/docs/' . $infos['document_id'] . '/i' . $infos['document_page'] . '.txt';\r
+                       $tfile = WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.txt';\r
+                       $ifile = WS_DOCS . '/' . $infos['document_id'] . '/i' . $infos['document_page'] . '.txt';\r
                        $text = file_get_contents($tfile);\r
                        $ipage = file_get_contents($ifile);\r
 \r
@@ -460,6 +460,11 @@ class wsDAOBook extends extranetDAO {
         */\r
        public function compile3($book_id, $complete)\r
        {\r
+               $filesToCopy = array();\r
+               $finalDir = WS_BOOKS . '/final/' . $book_id . '/';\r
+               $workingDir = WS_BOOKS . '/working/' . $book_id . '/';\r
+               $compilerDir = WS_BOOKS . '/datasCompiler/' . $book_id . '/';\r
+\r
                $res = '';\r
                $book = $this->selectById($book_id);\r
                $pages = $this->getPagesOfBook($book_id);\r
@@ -476,8 +481,8 @@ class wsDAOBook extends extranetDAO {
 \r
                $this->makeTextsIndexes($book_id, $index, $textes);\r
 \r
-               $flex = new cubeFlexCompiler('FluidbookDatas', ROOT . '/books/datasCompiler/' . $book_id, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH);\r
-               $flexLight = new cubeFlexCompiler('FluidbookDatasLight', ROOT . '/books/datasCompiler/' . $book_id, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH);\r
+               $flex = new cubeFlexCompiler('FluidbookDatas', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH);\r
+               $flexLight = new cubeFlexCompiler('FluidbookDatasLight', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH);\r
                $flex->addVariable('links', $book->links);\r
                $flexLight->addVariable('datas', $book->parametres->toStandardObject());\r
                $flexLight->addVariable('id', $book_id, false, true, 'uint');\r
@@ -494,28 +499,33 @@ class wsDAOBook extends extranetDAO {
                $flex->addVariable('index', $index);\r
                $flex->addVariable('textes', $textes);\r
                foreach($pages as $i => $infos) {\r
-                       $swffile = ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.swf';\r
+                       $swffile = WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.swf';\r
                        if ($i == 1) {\r
-                               $flexLight->addBitmap(ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb1');\r
+                               $flexLight->addBitmap(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb1');\r
                                $flexLight->addVariable('size_p_' . $i, filesize($swffile), false, true, 'Number');\r
                        } else {\r
-                               $flex->addBitmap(ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i);\r
+                               $flex->addBitmap(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'thumb' . $i);\r
                                $flex->addVariable('size_p_' . $i, filesize($swffile), false, true, 'Number');\r
                        }\r
                }\r
 \r
                if ($complete) {\r
                        foreach($pages as $i => $infos) {\r
-                               $swffile = ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.swf';\r
+                               $swffile = WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.swf';\r
                                if ($i == 1) {\r
                                        $flexLight->addSWF($swffile, 'page' . $i);\r
                                } else {\r
                                        $flex->addSWF($swffile, 'page' . $i);\r
                                }\r
                        }\r
+               } else {\r
+                       foreach($pages as $i => $infos) {\r
+                               $swffile = WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.swf';\r
+                               $filesToCopy['data/p' . $infos['document_page'] . '.swf'] = $swffile;\r
+                       }\r
                }\r
                // Theme assets\r
-               $themeRoot = ROOT . '/themes/' . $theme->theme_id . '/';\r
+               $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/';\r
                if ($theme->parametres->useBackgroundImage) {\r
                        $flexLight->addBitmap($themeRoot . $theme->parametres->backgroundImage, 'background');\r
                }\r
@@ -527,7 +537,7 @@ class wsDAOBook extends extranetDAO {
                }\r
                $flex->addBitmap($themeRoot . $theme->parametres->logo, 'logo');\r
                // Icons assets\r
-               $iconsRoot = ROOT . '/icones/' . $theme->parametres->iconSet . '/';\r
+               $iconsRoot = WS_ICONS . '/' . $theme->parametres->iconSet . '/';\r
                foreach(wsIcone::$files as $file) {\r
                        $flex->addBitmap($iconsRoot . 'nav-' . $file . '.png', 'nav_' . $file);\r
                }\r
@@ -536,11 +546,35 @@ class wsDAOBook extends extranetDAO {
                $flex->addFont(FONT_PATH . '/DIN Medium_0.ttf', 'GeneralFont', 'Latin');\r
                $flexLight->addFont(FONT_PATH . '/DIN Medium_0.ttf', 'GeneralFontLight', 'Numerals');\r
                $res .= $flex->compile() . "\n\n-------------------\n\n";\r
-               $flexLight->addVariable('datasSize', filesize(ROOT . '/books/datasCompiler/' . $book_id . '/FluidbookDatas.swf'));\r
+               $flexLight->addVariable('datasSize', filesize($compilerDir . '/FluidbookDatas.swf'));\r
                $res .= $flexLight->compile();\r
 \r
-               $filesToCopy['index.swf'] = 'html/index.swf';\r
+               $filesToCopy['FluidbookDatas.swf'] = $compilerDir . '/FluidbookDatas.swf';\r
+               $filesToCopy['FluidbookDatasLight.swf'] = $compilerDir . '/FluidbookDatasLight.swf';\r
+               $filesToCopy['index.swf'] = WS_COMPILE_ASSETS . '/index.swf';\r
                // Copy of files\r
+               // Check if dest dir exists\r
+               if (!file_exists($finalDir . 'data')) {\r
+                       mkdir($finalDir . 'data', 0777, true);\r
+               }\r
+               // Check working dir\r
+               if (file_exists($workingDir)) {\r
+                       $dr = opendir($workingDir);\r
+                       while ($file = readdir($dr)) {\r
+                               if ($file == '.' || $file == '..') {\r
+                                       continue;\r
+                               }\r
+                               $filesToCopy['data/' . $file] = $workingDir . '/' . $file;\r
+                       }\r
+               }\r
+\r
+               foreach($filesToCopy as $local => $source) {\r
+                       $localPath = $finalDir . $local;\r
+                       if (!file_exists($localPath) || filemtime($localPath) < filemtime($source)) {\r
+                               copy($source, $localPath);\r
+                       }\r
+               }\r
+\r
                return $res;\r
        }\r
 }\r
index df23683197cc707460ed0e9ff72579ac9994d024..d83c7f487756a970be4b2948f17f0d7a8768c7ba 100644 (file)
@@ -54,7 +54,7 @@ class wsDocument extends cubeMetier {
 \r
        public function init()\r
        {\r
-               $this->out = ROOT . '/docs/' . $this->document_id . '/';\r
+               $this->out = WS_DOCS. '/' . $this->document_id . '/';\r
                $this->log = $this->out . 'log.txt';\r
                $this->in = $this->out . 'original.pdf';\r
                $this->uncompressed = $this->out . 'uncompressed.pdf';\r