From fbe21d1f7040faab9a5e8b85f1d6b5a7e32e3c31 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Sat, 27 Aug 2011 00:37:49 +0000 Subject: [PATCH] --- .../nbproject/private/private.properties | 2 +- inc/ws/Util/html5/class.ws.html5.compiler.php | 59 ++++++++++++++----- inc/ws/Util/html5/class.ws.html5.links.php | 50 ++++++++-------- 3 files changed, 69 insertions(+), 42 deletions(-) diff --git a/fluidbook/tools/fwstk/nbproject/private/private.properties b/fluidbook/tools/fwstk/nbproject/private/private.properties index c85e5f3f2..75eb4042c 100644 --- a/fluidbook/tools/fwstk/nbproject/private/private.properties +++ b/fluidbook/tools/fwstk/nbproject/private/private.properties @@ -4,4 +4,4 @@ do.depend=false do.jar=true javac.debug=true javadoc.preview=true -user.properties.file=C:\\Users\\Vincent\\.netbeans\\7.0\\build.properties +user.properties.file=C:\\Users\\Cube\\.netbeans\\7.0\\build.properties diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 324b56d51..5eac66138 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -51,6 +51,12 @@ class wsHTML5Compiler { 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; @@ -85,10 +91,6 @@ class wsHTML5Compiler { $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']); @@ -96,6 +98,15 @@ class wsHTML5Compiler { $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) { @@ -158,8 +169,8 @@ class wsHTML5Compiler { $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) { @@ -298,8 +309,13 @@ class wsHTML5Compiler { $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"; } @@ -317,7 +333,7 @@ class wsHTML5Compiler { $fontforge->setArg(null, '-'); $fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format); $fontforge->execute(); - + fb($fontforge->commande); } } @@ -431,20 +447,25 @@ class wsHTML5Compiler { $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) { @@ -464,7 +485,7 @@ class wsHTML5Compiler { } $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.='}'; @@ -494,6 +515,12 @@ class wsHTML5Compiler { $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: diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index d2eee02ab..489a66730 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -23,58 +23,58 @@ class wsHTML5Link { 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() { @@ -86,13 +86,13 @@ class wsHTML5Link { } 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; @@ -184,7 +184,7 @@ class internalLink extends normalLink { if ($this->numerotation == 'physical') { return $this->to; } else { - return $this->packager->virtualToPhysical($this->to); + return $this->compiler->virtualToPhysical($this->to); } } @@ -197,8 +197,8 @@ class videoLink extends wsHTML5Link { $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 = '