$tmp = cubeFiles::tempdir();
mkdir($tmp, 0777, true);
-
-
-
- $upload=$_FILES['file']['tmp_name'];
+
+
+
+ $upload = $_FILES['file']['tmp_name'];
$icotool = new cubeCommandLine('icotool');
$icotool->setArg('c');
$icotool->setArg('o', $tmp . '/favicon.ico');
- $sizes = array(256, 128, 114, 72, 64, 57, 32, 16);
+ $sizes = array(128, 114, 72, 64, 57, 32, 16);
$apple = array(114, 72, 57);
$icotool->execute();
- rename($tmp . '/ico-16.png', $tmp.'/favicon.png');
+ rename($tmp . '/ico-16.png', $tmp . '/favicon.png');
foreach ($sizes as $s) {
if ($s == 16 || in_array($s, $apple)) {
unlink($tmp . '/ico-' . $s . '.png');
}
- $tmpfile = cubeFiles::tempnam().'.zip';
+ $tmpfile = cubeFiles::tempnam() . '.zip';
$zip = new cubeCommandLine('zip');
$zip->cd($tmp);
$zip->setArg('X');
$zip->setArg(null, '.');
$zip->execute();
-
- fb($zip->commande);
- fb($zip->output);
-
+
cubeHTTP::downloadFile($tmpfile, 'favicon.zip');
}
protected $optimalHeight = 709;
protected $additionalConfig = array();
protected $fontScale = 1;
+ protected $cache = array();
function __construct($book_id) {
global $core;
-
+
cubePHP::set_memory('4G');
if (trim($book_id) == '') {
}
public function compile() {
-
-
foreach ($this->layouts as $page => $layout) {
$lines = $this->sortPage($layout);
$document_id = $this->pages[$page]['document_id'];
}
$style = array();
foreach ($sheets as $sheet) {
- $style[] = '<link type="text/css" rel="stylesheet" href="' . $sheet . '?junk=' . TIME . '" />';
+ $style[] = '<link type="text/css" rel="stylesheet" href="' . $sheet . '" />';
}
$style = implode("\n\t\t", $style);
}
$fontforge->setArg(null, '-');
$fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format);
+
$fontforge->execute();
}
}
}
$this->fontDocs[$font][$document_id] = true;
- $idx= $this->getIndex($font, $this->cssFont, array('oblique' => $oblique));
-
+ $idx = $this->getIndex($font, $this->cssFont, array('oblique' => $oblique));
+
return $idx;
}
return $this->getIndex($w, $this->cssWidths);
}
- protected function getIndex($value, &$tab, $params=array()) {
+ protected function getIndex($value, &$tab, $params = array()) {
$value = (string) $value;
if (isset($tab[$value])) {
return $tab[$value];
return $tab[$value];
}
- protected function normalizeFloatValue($value, $round=3) {
+ protected function normalizeFloatValue($value, $round = 3) {
$value = str_replace(',', '.', $value);
$value = (float) $value;
$value = round($value, $round);
return $str;
}
- public function copyLinkFile($source, $dest, $video=false) {
+ public function copyLinkFile($source, $dest, $video = false) {
$origDir = WS_BOOKS . '/working/' . $this->book_id . '/';
$types = array('mp4', 'ogv', 'webm', 'jpg');
if ($video) {
//$in = htmlentities($in, ENT_NOQUOTES, "UTF-8");
$in = str_replace(' ', '', $in);
-
+
return $in;
}
}
- public static function colorToCSS($color, $forceAlpha=null) {
+ public static function colorToCSS($color, $forceAlpha = null) {
if (!is_null($forceAlpha)) {
$a = $forceAlpha * 255;
\r
protected $origHTML;\r
\r
- public function __construct($book_id, $vdir=null, $whole=true) {\r
+ public function __construct($book_id, $vdir = null, $whole = true) {\r
parent::__construct($book_id, $vdir, $whole);\r
$this->version = 'html';\r
}\r
$rm->setArg(null, $dest . '/' . $f);\r
}\r
$rm->execute();\r
+\r
+ $this->writeHTML5Cache($dest);\r
+ }\r
+\r
+ public function writeHTML5Cache($dest) {\r
+ $ignore = array('data/l10n/([a-z-]{2,5}).json');\r
+\r
+ $dest = realpath($dest);\r
+ $lines = array();\r
+ $lines[] = 'CACHE MANIFEST';\r
+ $lines[] = '#';\r
+ $lines[] = '';\r
+ $lines[] = 'CACHE:';\r
+ $dir = array('images', 'data', 'style');\r
+ foreach ($dir as $d) {\r
+ $directory = $dest . '/' . $d;\r
+\r
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);\r
+ foreach ($iterator as $path) {\r
+ if (!$path->isFile()) {\r
+ continue;\r
+ }\r
+ $p = str_replace($dest . '/', '', $path);\r
+ foreach ($ignore as $i) {\r
+ if (preg_match('|' . $i . '|i', $p, $matches)) {\r
+ continue 2;\r
+ }\r
+ }\r
+ $lines[] = $p;\r
+ }\r
+ }\r
+ file_put_contents($dest . '/cache.appcache', implode("\n", $lines));\r
}\r
\r
public function makePackage($zip) {\r
protected $size;
- public function __construct($book_id, $vdir=null, $whole=true) {
+ public function __construct($book_id, $vdir = null, $whole = true) {
global $core;
parent::__construct($book_id, $vdir, $whole);
$link['to'] = $this->__virtualToPhysical($link['to']);
}
+ if ($this->_copyWorkingFile($link['to']) && !in_array($link->type, array(4, 6))) {
+ $link['to'] = 'data/' . $link['to'];
+ }
+
$one->addChild('page', $link['page']);
$one->addChild('linkType', $link['type']);
$one->addChild('linkTo', $link['to']);
$one->addChild('endX', $link['left'] + $link['width']);
$one->addChild('startY', $link['top']);
$one->addChild('endY', $link['top'] + $link['height']);
-
- $this->_copyWorkingFile($link['to']);
+ $one->addChild('tooltip', $link['infobulle']);
+ if($link['type']==4){
+ $one->addChild('soundOn',$link['video_sound_on']);
+ $one->addChild('loopFlag',$link['video_loop']);
+ $one->addChild('playerActive',$link['video_auto_start']);
+ }
}
foreach ($this->book->chapters as $c) {
$this->_copyWorkingFile($v);
- $xml->addChild($k, html::escapeHTML($v));
+ if ($k != 'extras') {
+ $xml->addChild($k, html::escapeHTML($v));
+ }
$extras->addChild($k, html::escapeHTML($v));
}
$src = $this->workingDir . '/' . $file;
if (file_exists($src) && is_file($src)) {
- copy($src, $dir . $file);
+ return copy($src, $dir . $file);
}
+ return false;
}
protected function __virtualToPhysical($page, $default = '') {