protected $needToRecompileSettings = true;
protected $width;
protected $height;
+ protected $cssWidth;
+ protected $cssHeight;
+ public $cssScale;
+ protected $optimalWidth = 567;
+ protected $optimalHeight = 709;
+ protected $additionalConfig = array();
function __construct($book_id) {
global $core;
$imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg');
$this->pdf2htmlRatio = round($imagesize[0] / $this->layouts[1]['width'], 2);
-
- $this->scale = 4;
- $this->multiply = $this->pdf2htmlRatio * $this->scale;
- $this->numerotation = explode(',', $this->book->numerotation);
$daoDoc = new wsDAODocument($core->con);
$firstDoc = $daoDoc->selectById($this->pages[1]['document_id']);
$this->width = round($size[0], 2);
$this->height = round($size[1], 2);
+
+ $this->cssScale = min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
+
+ $this->cssWidth = $this->width * $this->cssScale;
+ $this->cssHeight = $this->height * $this->cssScale;
+
+ $this->scale = 4;
+ $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssScale;
+ $this->numerotation = explode(',', $this->book->numerotation);
}
public function virtualToPhysical($virtual) {
$linksCSS = $this->writeLinks();
$numCSS = $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS);
$this->writeLangs();
- $this->writeJs();
$this->writeIndex($numCSS);
+ $this->writeJs();
}
protected function writeIndex($numCSS) {
$config->numerotation = explode(',', $this->book->numerotation);
$config->id = $this->book->book_id;
$config->cacheDate = TIME;
- $config->width = $this->width;
- $config->height = $this->height;
+ $config->width = $this->cssWidth;
+ $config->height = $this->cssHeight;
+ $config->optimalWidth = $this->optimalWidth;
+ $config->optimalHeight = $this->optimalHeight;
+ foreach ($this->additionalConfig as $k => $v) {
+ $config->$k = $v;
+ }
return 'var DATAS=' . json_encode($config) . ';' . "\n";
}
$fontforge->setArg(null, '-');
$fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format);
$fontforge->execute();
-
+
fb($fontforge->commande);
}
}
$res = array();
// General theme
- $h = $this->height . 'px';
- $w2 = ($this->width * 2) . 'px';
- $w = $this->width . 'px';
+ $h = $this->cssHeight . 'px';
+ $w2 = ($this->cssWidth * 2) . 'px';
+ $w = $this->cssWidth . 'px';
$wm = ($this->width * $this->multiply) . 'px';
$hm = ($this->height * $this->multiply) . 'px';
+ $offsetLeft = round(($this->optimalWidth - $this->cssWidth) / 2, 2);
+ $offsetTop = round(($this->optimalHeight - $this->cssHeight) / 2, 2);
+ $navTop = ($this->cssHeight - 40 - 100) / 2;
- $navTop = ($this->height - 40 - 100) / 2;
+
+
+ $res[] = '#fluidbook{left:' . $offsetLeft . 'px;top:' . $offsetTop . 'px;}';
$res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';
$res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';
foreach (self::$resolutions as $r) {
- $ratio = round(72 / $r, 2);
- $wr = $this->width / $ratio;
- $hr = $this->height / $ratio;
+ $ratio = round(72 / $r, 2) * $this->cssScale;
+ $wr = $this->cssWidth / $ratio;
+ $hr = $this->cssHeight / $ratio;
$br = '.background.r' . $r . '{';
if ($ratio != 1) {
}
$texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';';
- $texts.=$this->writeCSSUA('transform', 'scale(' . round(1 / $this->multiply, 2) . ')') . ';';
+ $texts.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $this->cssScale, 2) . ')') . ';';
$texts.='width:' . $wm . '; max-width:' . $wm . ';';
$texts.='height:' . $hm . '; max-height:' . $hm . ';';
$texts.='}';
$body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');';
$body.='background-position:';
+ if(file_exists($this->themeRoot . '/' . $this->theme->parametres->backgroundImage)){
+ $dim=getimagesize($this->themeRoot . '/' . $this->theme->parametres->backgroundImage);
+ $this->additionalConfig['backgroundRatio']=$dim[0]/$dim[1];
+ }else{
+ $this->additionalConfig['backgroundRatio']=1;
+ }
switch ($this->theme->parametres->backgroundVAlign) {
case wsTheme::TOP:
public $display_area;
public $infobulle;
public $id;
- public $packager;
+ public $compiler;
- public static function getInstance($id, $init, &$packager) {
+ public static function getInstance($id, $init, &$compiler) {
switch ($init['type']) {
case 1:
case 2:
- return new webLink($id, $init, $packager);
+ return new webLink($id, $init, $compiler);
case 3:
- return new mailLink($id, $init, $packager);
+ return new mailLink($id, $init, $compiler);
case 5:
- return new internalLink($id, $init, $packager);
+ return new internalLink($id, $init, $compiler);
case 4:
if ($init['inline']) {
- return new videoLink($id, $init, $packager);
+ return new videoLink($id, $init, $compiler);
} else {
- return new videoPopupLink($id, $init, $packager);
+ return new videoPopupLink($id, $init, $compiler);
}
case 6:
- return new multimediaLink($id, $init, $packager);
+ return new multimediaLink($id, $init, $compiler);
case 7:
case 8:
case 9:
return null;
case 10:
if ($init['inline']) {
- return new webVideoLink($id, $init, $packager);
+ return new webVideoLink($id, $init, $compiler);
} else {
- return new webVideoPopupLink($id, $init, $packager);
+ return new webVideoPopupLink($id, $init, $compiler);
}
case 11:
- return new actionLink($id, $init, $packager);
+ return new actionLink($id, $init, $compiler);
case 12:
- return new basketLink($id, $init, $packager);
+ return new basketLink($id, $init, $compiler);
case 13:
return null;
case 14:
- return new colorLink($id, $init, $packager);
+ return new colorLink($id, $init, $compiler);
case 15:
- return new imageLink($id, $init, $packager);
+ return new imageLink($id, $init, $compiler);
case 16:
- return new fileLink($id, $init, $packager);
+ return new fileLink($id, $init, $compiler);
default:
return null;
}
}
- public function __construct($id, $init, &$packager) {
+ public function __construct($id, $init, &$compiler) {
foreach ($init as $k => $v) {
$this->$k = $v;
}
$this->id = $id;
- $this->packager = $packager;
+ $this->compiler = $compiler;
}
public function getHTMLContainer() {
}
public function copyExternalFile($file, $video=false) {
- $this->packager->copyLinkFile($file, 'data/links/', $video);
+ $this->compiler->copyLinkFile($file, 'data/links/', $video);
}
public function getCSSContainer() {
$css = '#link' . $this->id . '{';
- $css.='left:' . $this->left . 'px;top:' . $this->top . 'px;';
- $css.='width:' . $this->width . 'px;height:' . $this->height . 'px;';
+ $css.='left:' . $this->left * $this->compiler->cssScale . 'px;top:' . $this->top * $this->compiler->cssScale . 'px;';
+ $css.='width:' . $this->width * $this->compiler->cssScale . 'px;height:' . $this->height * $this->compiler->cssScale . 'px;';
$css.=$this->getCSS();
$css.='}';
return $css;
if ($this->numerotation == 'physical') {
return $this->to;
} else {
- return $this->packager->virtualToPhysical($this->to);
+ return $this->compiler->virtualToPhysical($this->to);
}
}
$e = explode('.', $file);
$ext = array_pop($e);
$basename = implode('.', $e);
- $w = round($this->width);
- $h = round($this->height);
+ $w = round($this->width*$this->compiler->cssScale);
+ $h = round($this->height*$this->compiler->cssScale);
$res = '<video width="' . $w . '" height="' . $h . '"';
if ($this->video_auto_start) {
}
public function getEmbed() {
- return '<iframe width="' . $this->width . '" height="' . $this->height . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
+ return '<iframe width="' . $this->width*$this->compiler->cssScale . '" height="' . $this->height*$this->compiler->cssScale . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
}
public function getEmbedURL() {
class multimediaLink extends wsHTML5Link {
public function getHTMLContent() {
- return cubeMedia::flashObject(wsHTML5Link::getUniversalLocation($this->to), $this->width, $this->height, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
+ return cubeMedia::flashObject(wsHTML5Link::getUniversalLocation($this->to), $this->width*$this->compiler->cssScale, $this->height*$this->compiler->cssScale, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
}
}