]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 27 Aug 2011 00:37:49 +0000 (00:37 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 27 Aug 2011 00:37:49 +0000 (00:37 +0000)
fluidbook/tools/fwstk/nbproject/private/private.properties
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/html5/class.ws.html5.links.php

index c85e5f3f2e1a01c3d61bf97f79be5499643ed027..75eb4042cfe9916c9d015a70e633193825e04eb6 100644 (file)
@@ -4,4 +4,4 @@ do.depend=false
 do.jar=true\r
 javac.debug=true\r
 javadoc.preview=true\r
-user.properties.file=C:\\Users\\Vincent\\.netbeans\\7.0\\build.properties\r
+user.properties.file=C:\\Users\\Cube\\.netbeans\\7.0\\build.properties\r
index 324b56d51187438cc50610bfce1c7180b31fc4fe..5eac661385c34e51c139203c868dc965fcf7061a 100644 (file)
@@ -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:
index d2eee02ab2dc0e28a6b5f10664303ca377c4bc22..489a667306223b0a53b7530440ddbe7d88518717 100644 (file)
@@ -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 = '<video width="' . $w . '" height="' . $h . '"';
                if ($this->video_auto_start) {
@@ -245,7 +245,7 @@ class webVideoLink extends videoLink {
        }
 
        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() {
@@ -304,7 +304,7 @@ class fileLink extends normalLink {
 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');
        }
 
 }