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
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
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
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
$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
\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
\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
{\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
$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
$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
*/\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
\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
$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
}\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
$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