]> _ Git - cubeextranet.git/commitdiff
wip #1704 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 29 Sep 2017 15:10:32 +0000 (15:10 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 29 Sep 2017 15:10:32 +0000 (15:10 +0000)
inc/ws/DAO/class.ws.dao.book.php

index 734d3191e8416bcb55bcaa1d9abf02687cdb0695..93eb9b5226490438267cba8cfede9f4a15c733fb 100644 (file)
@@ -1136,12 +1136,7 @@ class wsDAOBook extends commonDAO {
                $compilerDir = WS_BOOKS . '/datasCompiler/' . $book_id . '/';
                $finalDir = WS_BOOKS . '/final/' . $book_id . '/';
 
-               $rm = new cubeCommandLine('rm');
-               $rm->setArg('r');
-               $rm->setArg('f');
-               $rm->setArg(null, $finalDir);
-               $rm->execute();
-               mkdir($finalDir, 0777, true);
+               $vdir = new CubeIT_Files_VirtualDirectory($finalDir);
 
                $debug = false;
 
@@ -1149,7 +1144,7 @@ class wsDAOBook extends commonDAO {
                $flexLight = new cubeFlexCompiler('FluidbookDatasLight', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10, 30, 800, 600, $debug);
 
                $filesToCopy = array();
-               $this->compileFlex($book_id, $complete, $compilerDir, $finalDir, $filesToCopy, $book, $pages, $flex, $flexLight, $finalDir);
+               $this->compileFlex($book_id, $complete, $compilerDir, $vdir, $filesToCopy, $book, $pages, $flex, $flexLight, $finalDir);
 
                $res .= $flex->compile() . "\n\n-------------------\n\n";
                $flexLight->addVariable('datasSize', filesize($compilerDir . '/FluidbookDatas.swf'));
@@ -1160,30 +1155,15 @@ class wsDAOBook extends commonDAO {
 
                // Copy of files
                // Check if dest dir exists
-               if (!file_exists($finalDir . 'data')) {
-                       mkdir($finalDir . 'data', 0777, true);
-               }
 
                foreach ($filesToCopy as $local => $source) {
-                       $localPath = $finalDir . $local;
-                       if (!file_exists($localPath) || filemtime($localPath) != filemtime($source) || filesize($localPath) != filesize($source) || filemtime($localPath) < $book->composition_update) {
-                               if (is_dir($source)) {
-                                       continue;
-                               }
-                               $this->copy($source, $localPath);
-                       }
+                       $localPath = $local;
+                       $vdir->copy($source, $localPath);
                }
 
                $workingDir = WS_BOOKS . '/working/' . $book_id . '/';
-               if (file_exists($workingDir . 'media')) {
-                       $cp = new cubeCommandLine('cp');
-                       $cp->setPath(CONVERTER_PATH);
-                       $cp->setArg('r');
-                       $cp->setArg('p');
-                       $cp->setArg(null, $workingDir . 'media');
-                       $cp->setArg(null, $finalDir . 'data');
-                       $cp->execute();
-               }
+               $vdir->copyDirectory($workingDir . 'media', 'data');
+               $vdir->sync(true);
 
                return $res;
        }
@@ -1236,7 +1216,9 @@ class wsDAOBook extends commonDAO {
                return $res;
        }
 
-       public function compileFlex($book_id, $complete, $compilerDir, $finalDir, &$filesToCopy, $book, $pages, $flex, $flexLight, $finalDir) {
+       public function compileFlex($book_id, $complete, $compilerDir, $vdir, &$filesToCopy, $book, $pages, $flex, $flexLight) {
+               /* @var $vdir CubeIT_Files_VirtualDirectory */
+
                cubePHP::neverStop();
                /* @var $flex cubeFlexCompiler */
 
@@ -1547,7 +1529,7 @@ class wsDAOBook extends commonDAO {
                                } elseif ($ext == 'xlsx') {
                                        $references = wsUtil::excelToArray($referencesFile);
                                        if ($book->parametres->customLinkClass == 'AtlanticDownloadLink') {
-                                               $references = wsUtil::atlanticReferences($this->config->basketReferences, $finalDir . '/local/');
+                                               $references = wsUtil::atlanticReferences($references, 'local/', null, array($vdir, 'copy'));
                                        }
                                        $flex->addVariable('basketReferences', $references, false, true, "OrderedObject");
                                }