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