]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 14 Jul 2011 10:29:23 +0000 (10:29 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 14 Jul 2011 10:29:23 +0000 (10:29 +0000)
inc/ws/Util/packager/html5/class.ws.packager.html5.links.php
inc/ws/Util/packager/html5/class.ws.packager.html5.php

index 7ba0c2a7fc13ecb46e74d54b94d584633e7c2e3b..71013df069dfcbe40b6bef7613bb353d7545c956 100644 (file)
@@ -26,15 +26,15 @@ class wsPackagerHTML5Link {
        public $packager;
 
        public static function getInstance($id, $init, &$packager) {
-               switch ($init->link) {
+               switch ($init['type']) {
                        case 1:
                        case 2:
                                return new webLink($id, $init, $packager);
                        case 3:
                                return new mailLink($id, $init, $packager);
-                       case 4:
-                               return new internalLink($id, $init, $packager);
                        case 5:
+                               return new internalLink($id, $init, $packager);
+                       case 4:
                                return new videoLink($id, $init, $packager);
                        case 6:
                        case 7:
@@ -61,15 +61,15 @@ class wsPackagerHTML5Link {
        }
 
        public function __construct($id, $init, &$packager) {
-               $this->id = $id;
-               $this->packager = $packager;
                foreach ($init as $k => $v) {
                        $this->$k = $v;
                }
+               $this->id = $id;
+               $this->packager = $packager;
        }
 
        public function getHTMLContainer() {
-               return '<div class="l" id="l' . $this->id . '">' . $this->getHTMLContent() . '</div>';
+               return '<div class="link" id="link' . $this->id . '">' . $this->getHTMLContent() . '</div>';
        }
 
        public function getHTMLContent() {
@@ -77,7 +77,20 @@ class wsPackagerHTML5Link {
        }
 
        public function copyExternalFile($file) {
-               $packager->copyLinkFile($file, 'data/links/');
+               $this->packager->copyLinkFile($file, 'data/links/');
+       }
+
+       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.=$this->getCSS();
+               $css.='}';
+               return $css;
+       }
+
+       public function getCSS() {
+               return 'border:1px dotter #ff0000;';
        }
 
        public static function getUniversalLocation($loc) {
@@ -107,18 +120,6 @@ class normalLink extends wsPackagerHTML5Link {
                return '_self';
        }
 
-       public function getCSSContainer() {
-               $css = '#l' . $this->id . '{';
-               $css.='left:' . $this->left . 'px;top:' . $this->top . 'px;';
-               $css.='width:' . $this->width . 'px;height:' . $this->height . 'px;';
-               $css.=$this->getCSS();
-               $css.='}';
-       }
-
-       public function getCSS() {
-               
-       }
-
 }
 
 class contentLink extends wsPackagerHTML5Link {
@@ -159,6 +160,10 @@ class internalLink extends normalLink {
                return '#/pages/' . $this->getPage();
        }
 
+       public function getPage() {
+               return $this->to;
+       }
+
 }
 
 class videoLink extends wsPackagerHTML5Link {
@@ -178,7 +183,7 @@ class videoLink extends wsPackagerHTML5Link {
                $ext = array_pop($e);
                $basename = implode('.', $e);
 
-               $videos = array('mp4' => 'video/mp4; codecs=\'avc1.42E01E, mp4a.40.2\'', 'ogv' => 'video/ogg; codecs="theora, vorbis');
+               $types = array('mp4' => 'video/mp4; codecs=\'avc1.42E01E, mp4a.40.2\'', 'ogv' => 'video/ogg; codecs=\'theora, vorbis\'');
                foreach ($types as $ext => $type) {
                        $res.='<source src="' . wsPackagerHTML5Link::getUniversalLocation($basename . '.' . $ext) . '" type="' . $type . '" />';
                        $this->copyExternalFile($basename . '.' . $ext);
index 3c5f8a2af1e33eda736d8db5c2c7e77ce0d7c9cd..996c509c420450d25ce8cce44391052780d9fd0c 100644 (file)
@@ -59,14 +59,15 @@ class wsPackagerHTML5 extends wsPackager {
                mkdir($this->vdir . '/data/contents', 0777, true);\r
                mkdir($this->vdir . '/data/background', 0777, true);\r
                mkdir($this->vdir . '/data/style', 0777, true);\r
+               mkdir($this->vdir . '/data/links/pages', 0777, true);\r
 \r
                foreach ($this->div as $n => $page) {\r
                        file_put_contents($this->vdir . '/data/contents/p' . $n . '.html', $this->writePage($page));\r
                }\r
                $this->writeFonts();\r
                $this->writeImages();\r
-               $this->writeLinks();\r
-               $this->writeCSS($this->vdir . '/data/style/style_%d.css');\r
+               $linksCSS = $this->writeLinks();\r
+               $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS);\r
 \r
                file_put_contents($this->vdir . '/data/datas.js', $this->writeConfig());\r
        }\r
@@ -77,10 +78,25 @@ class wsPackagerHTML5 extends wsPackager {
                $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);\r
 \r
                $i = 0;\r
+               $pages = array();\r
+               $css = array();\r
                foreach ($links as $linkData) {\r
                        $link = wsPackagerHTML5Link::getInstance($this->base62($i), $linkData, $this);\r
+                       if (is_null($link)) {\r
+                               continue;\r
+                       }\r
+                       if (!isset($pages[$link->page])) {\r
+                               $pages[$link->page] = '';\r
+                       }\r
+                       $pages[$link->page] .= $link->getHTMLContainer();\r
+                       $css[] = $link->getCSSContainer();\r
                        $i++;\r
                }\r
+\r
+               foreach ($pages as $n => $c) {\r
+                       file_put_contents($this->vdir . '/data/links/pages/p' . $n . '.html', $c);\r
+               }\r
+               return $css;\r
        }\r
 \r
        protected function writeConfig() {\r
@@ -212,7 +228,7 @@ class wsPackagerHTML5 extends wsPackager {
                return self::escapeHTML($span['text']);\r
        }\r
 \r
-       protected function writeCSS($file) {\r
+       protected function writeCSS($file, $links) {\r
                $res = array();\r
 \r
                // General theme\r
@@ -224,7 +240,7 @@ class wsPackagerHTML5 extends wsPackager {
 \r
 \r
                $navTop = ($this->book->parametres->height - 40 - 100) / 2;\r
-               $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';\r
+               $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';\r
                $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';\r
                foreach (self::$resolutions as $r) {\r
                        $ratio = 72 / $r;\r
@@ -339,6 +355,9 @@ class wsPackagerHTML5 extends wsPackager {
                        $res[] = '#shadow{' . $this->writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}';\r
                }\r
 \r
+               // Links Styles\r
+               $res = array_merge($res, $links);\r
+\r
                // Pages styles\r
                foreach ($this->cssColor as $color => $index) {\r
                        $res[] = '.c' . $index . '{color:#' . $color . '}';\r