foreach ($words as $w) {
$word = $w->word;
$word = trim($word, "\0");
- if($word==''){
+ if ($word == '') {
continue;
}
unset($w->word);
$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);
+ $this->compileFlex($book_id, $complete, $compilerDir, $finalDir, $filesToCopy, $book, $pages, $flex, $flexLight, $finalDir);
$res .= $flex->compile() . "\n\n-------------------\n\n";
$flexLight->addVariable('datasSize', filesize($compilerDir . '/FluidbookDatas.swf'));
return $res;
}
- public function compileFlex($book_id, $complete, $compilerDir, $finalDir, &$filesToCopy, $book, $pages, $flex, $flexLight) {
+ public function compileFlex($book_id, $complete, $compilerDir, $finalDir, &$filesToCopy, $book, $pages, $flex, $flexLight, $finalDir) {
cubePHP::neverStop();
/* @var $flex cubeFlexCompiler */
$i++;
}
} elseif ($ext == 'xlsx') {
- $flex->addVariable('basketReferences', wsUtil::excelToArray($referencesFile), false, true, "OrderedObject");
+ $references = wsUtil::excelToArray($referencesFile);
+ if ($book->parametres->customLinkClass == 'AtlanticDownloadLink') {
+ $references = wsUtil::atlanticReferences($this->config->basketReferences, $finalDir . '/local/');
+ }
+ $flex->addVariable('basketReferences', $references, false, true, "OrderedObject");
}
}
if (isset($xml)) {
$cacheFile = WS_CACHE . '/xlsx2array/' . sha1($excelFile . '/' . filemtime($excelFile));\r
\r
if (file_exists($cacheFile)) {\r
- $worksheets = json_decode(file_get_contents($cacheFile));\r
+ $worksheets = json_decode(file_get_contents($cacheFile), true);\r
} else {\r
set_time_limit(0);\r
include_once ROOT . '/inc/ZendFramework/PHPExcel/PHPExcel.php';\r
\r
return $worksheets;\r
}\r
+\r
+ public static function atlanticReferences($references, $dir) {\r
+ if (!file_exists($dir)) {\r
+ mkdir($dir, 0777, true);\r
+ }\r
+ foreach ($references as $i => $sheet) {\r
+ foreach ($sheet as $j => $line) {\r
+ foreach ($line as $k => $v) {\r
+ if (preg_match('|^http:\/\/atlantic-international-book-com\.com\/files\/(.*)$|', $v, $matches)) {\r
+ $local = $dir . '/' . $matches[1];\r
+ $ldir = dirname($local);\r
+ if (!file_exists($ldir)) {\r
+ mkdir($ldir, 0777, true);\r
+ }\r
+ $url = str_replace(' ', '%20', $v);\r
+ $cache = WS_CACHE . '/atlantic/' . md5($url);\r
+ if (!file_exists($cache)) {\r
+ copy($url, $cache);\r
+ }\r
+ copy($cache, $dir . '/' . $matches[1]);\r
+ $references[$i][$j][$k] = 'local/' . $matches[1];\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return $references;\r
+ }\r
}
\ No newline at end of file