switch ($this->book->parametres->mobileVersion) {
case 'html5-desktop':
$this->backgroundsPrefix = array('t', 'p');
- $svg = true;
+ $this->svg = true;
break;
case 'html5-images':
$this->backgroundsPrefix = array('t');
- $svg = false;
+ $this->svg = false;
break;
default:
$this->backgroundsPrefix = array('p');
- $svg = true;
+ $this->svg = true;
break;
}
file_put_contents($this->vdir . '/data/search.index.js', $jsindex);
file_put_contents($this->vdir . '/data/search.texts.js', $jstexts);
+ if ($this->book->parametres->highlightResults) {
+ file_put_contents($this->vdir . '/data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r");
+ }
}
public function supportSVG() {
$this->config->retinaResolution = $this->maxRes;
$this->config->pageLabels = $this->pageLabels;
$this->config->pageZoomFactor = $this->z;
+ $this->config->multiply = $this->multiply;
+ $this->config->cssScale = $this->cssScale;
+ $this->config->pdfZoomFactor = $this->pdf2htmlRatio;
if ($this->home) {
$this->config->home = 'http://home';
}
}
protected function writeImages() {
+ global $core;
foreach ($this->getResolutions() as $r) {
mkdir($this->vdir . '/data/background/' . $r, 0777, true);
}
foreach ($this->pages as $page => $infos) {
$docdir = wsDocument::getDir($infos['document_id']);
if ($this->svg) {
- $orig = $docdir . 'html/p' . $infos['document_page'] . '.svg';
- $opt = $docdir . 'html/o' . $infos['document_page'] . '.svg';
-
- $svg = $orig;
- if (file_exists($opt) && filesize($opt) > 0) {
- $svg = $opt;
+ $full = $docdir . 'html/fp' . $infos['document_page'] . '.svg';
+ $orig = $docdir . 'html/tp' . $infos['document_page'] . '.svg';
+ $opt = $docdir . 'html/to' . $infos['document_page'] . '.svg';
+
+ if (!file_exists($full) || filemtime($full) < 1503671520) {
+ if (!isset($doc) || $doc->document_id != $infos['document_id']) {
+ $dao = new wsDAODocument($core->con);
+ $doc = $dao->selectById($infos['document_id']);
+ }
+ $doc->makeSVGFile($infos['document_page']);
}
+ wsDocument::extractTexts($full, $orig);
+ wsTools::optimizeSVG($orig, $opt);
- $this->copy($svg, $this->vdir . '/data/contents/p' . $page . '.svg');
+ $this->copy($opt, $this->vdir . '/data/contents/p' . $page . '.svg');
}
foreach ($this->getResolutions() as $r) {
$lessVariables['book-page-height'] = $h;
$res[] = '.portrait #pages,.portrait .doublePage.page,.page,.doublePage._3d,#shadow>div{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';
- $res[] = '.doublePage,#pages,#links{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';
+ $res[] = '.doublePage,#pages,#links,#searchHighlights{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';
$res[] = '.landscape .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}';
$res[] = '.landscape .doublePage._2d.axis_x.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}';
$res[] = '.portrait .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}';
}
}
- public
- function makeThumbSprites(array $thumbs) {
+ public function makeThumbSprites(array $thumbs) {
$cols = 10;
$rows = 10;
$perSprite = $cols * $rows;
return $res;
}
- protected
- function _makeCover($orig) {
+ protected function _makeCover($orig) {
$size = getimagesize($orig);
$w = $size[0];
$h = $size[1];
unlink($tmp);
}
- protected
- function copy($s, $t) {
+ protected function copy($s, $t) {
if (!file_exists($s)) {
fb($s . ' dont exists');
return false;
return count($res);
}
- protected
- function _writeLess($variables) {
+ protected function _writeLess($variables) {
if ($this->widget) {
$this->lessFiles[] = 'widget';
}
}
}
- protected
- function _cssBackground() {
+ protected function _cssBackground() {
$body = '#background,#splash{';
$body .= 'background-color:#' . $this->theme->parametres->backgroundColor . ';';
switch ($this->theme->parametres->repeat) {
return $body;
}
- public
- static function writeCSSUA($property, $value) {
+ public static function writeCSSUA($property, $value) {
$res = array();
foreach (self::$uaPrefixes as $prefix) {
$res[] = $prefix . $property . ':' . $value;
return implode(';', $res);
}
- protected
- function base62($val) {
+ protected function base62($val) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$base = strlen($chars);
$str = '';
return $str;
}
- public
- function copyLinkDir($source, $dest) {
+ public function copyLinkDir($source, $dest) {
`cp -a $source $this->vdir/$dest`;
}
- public
- function simpleCopyLinkFile($source, $dest, $addVdir = true) {
+ public function simpleCopyLinkFile($source, $dest, $addVdir = true) {
if ($addVdir) {
$dest = $this->vdir . '/' . $dest;
}
$this->copy($source, $dest);
}
- public
- function copyLinkFile($source, $dest, $video = false) {
+ public function copyLinkFile($source, $dest, $video = false) {
if ($video && $this->book->parametres->mobileVideosPath != '') {
}
}
}
- public
- function __destruct() {
+ public function __destruct() {
}
$w = round($this->width * $this->getCssScale());
$h = round($this->height * $this->getCssScale());
+ // Note: width and height for the video is normally measured from the
+ // preview frame for local files or set to 1280 x 720 for web videos.
+ // The $w and $h variables here seem to be null generally...
+
return $this->makeVideoTag($this, $w, $h, $this->compiler);
}
if (!is_null($w) && !is_null($h)) {
$attr['width'] = $w;
$attr['height'] = $h;
- } else if (!is_null($compiler)) {
+ } else if (!is_null($compiler)) {
+ // Get video dimensions from thumbnail if possible (locally uploaded files)
$path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $basename . '.jpg';
$dim = getimagesize($path);
$attr['width'] = $dim[0];