]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 13 Jul 2011 21:09:02 +0000 (21:09 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 13 Jul 2011 21:09:02 +0000 (21:09 +0000)
inc/ws/Util/packager/_common.php
inc/ws/Util/packager/html5/class.ws.packager.html5.links.php [new file with mode: 0644]
inc/ws/Util/packager/html5/class.ws.packager.html5.php

index caa932b1314373b25fa1273585ee9f45a063295c..e9c59a1ae9126e18b321ad94dc8424ce649e9a14 100644 (file)
@@ -1,10 +1,11 @@
 <?php\r
+\r
 $__autoload['wsPackager'] = dirname(__FILE__) . '/class.ws.packager.php';\r
 $__autoload['wsPackagerHTML'] = dirname(__FILE__) . '/class.ws.packager.html.php';\r
 $__autoload['wsPackagerHTML5'] = dirname(__FILE__) . '/html5/class.ws.packager.html5.php';\r
+$__autoload['wsPackagerHTML5Link'] = dirname(__FILE__) . '/html5/class.ws.packager.html5.links.php';\r
 $__autoload['wsPackagerWinEXE'] = dirname(__FILE__) . '/class.ws.packager.win.exe.php';\r
 $__autoload['wsPackagerWinCD'] = dirname(__FILE__) . '/class.ws.packager.win.cd.php';\r
 $__autoload['wsPackagerMacEXE'] = dirname(__FILE__) . '/class.ws.packager.mac.exe.php';\r
 $__autoload['wsPackagerWinINST'] = dirname(__FILE__) . '/class.ws.packager.win.inst.php';\r
-\r
 ?>
\ No newline at end of file
diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php
new file mode 100644 (file)
index 0000000..7ba0c2a
--- /dev/null
@@ -0,0 +1,255 @@
+<?php
+
+class wsPackagerHTML5Link {
+
+       public $left;
+       public $top;
+       public $width;
+       public $height;
+       public $page;
+       public $type;
+       public $to;
+       public $numerotation;
+       public $target;
+       public $interactive;
+       public $video_loop;
+       public $video_sound_on;
+       public $video_controls;
+       public $video_auto_start;
+       public $video_height;
+       public $video_width;
+       public $video_service;
+       public $inline;
+       public $display_area;
+       public $infobulle;
+       public $id;
+       public $packager;
+
+       public static function getInstance($id, $init, &$packager) {
+               switch ($init->link) {
+                       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 videoLink($id, $init, $packager);
+                       case 6:
+                       case 7:
+                       case 8:
+                       case 9:
+                               return null;
+                       case 10:
+                               return new webVideoLink($id, $init, $packager);
+                       case 11:
+                               return new actionLink($id, $init, $packager);
+                       case 12:
+                               return new basketLink($id, $init, $packager);
+                       case 13:
+                               return null;
+                       case 14:
+                               return new colorLink($id, $init, $packager);
+                       case 15:
+                               return new imageLink($id, $init, $packager);
+                       case 16:
+                               return new fileLink($id, $init, $packager);
+                       default:
+                               return null;
+               }
+       }
+
+       public function __construct($id, $init, &$packager) {
+               $this->id = $id;
+               $this->packager = $packager;
+               foreach ($init as $k => $v) {
+                       $this->$k = $v;
+               }
+       }
+
+       public function getHTMLContainer() {
+               return '<div class="l" id="l' . $this->id . '">' . $this->getHTMLContent() . '</div>';
+       }
+
+       public function getHTMLContent() {
+               return '';
+       }
+
+       public function copyExternalFile($file) {
+               $packager->copyLinkFile($file, 'data/links/');
+       }
+
+       public static function getUniversalLocation($loc) {
+               $target = null;
+               parse_url($loc);
+
+               if (!is_null($loc['scheme'])) {
+                       return $loc;
+               } else {
+                       return 'data/links/' . $loc;
+               }
+       }
+
+}
+
+class normalLink extends wsPackagerHTML5Link {
+
+       public function getHTMLContent() {
+               return '<a href="' . $this->getURL() . '" target="' . $this->getTarget() . '"></a>';
+       }
+
+       public function getURL() {
+               return '#';
+       }
+
+       public function getTarget() {
+               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 {
+       
+}
+
+class webLink extends normalLink {
+
+       public function getURL() {
+               return wsPackagerHTML5Link::getUniversalLocation($this->to);
+       }
+
+       public function getTarget() {
+               return $this->target;
+       }
+
+       public function getCSS() {
+               
+       }
+
+}
+
+class mailLink extends normalLink {
+
+       public function getURL() {
+               return 'mailto:' . $this->to;
+       }
+
+       public function getTarget() {
+               return '_self';
+       }
+
+}
+
+class internalLink extends normalLink {
+
+       public function getURL() {
+               return '#/pages/' . $this->getPage();
+       }
+
+}
+
+class videoLink extends wsPackagerHTML5Link {
+
+       public function getHTMLContent() {
+               $res = '<video width="' . $this->width . '" height="' . $this->height . '"';
+               if ($this->video_auto_start) {
+                       $res.=' autoplay';
+               }
+               if ($this->video_controls) {
+                       $res.=' controls';
+               }
+               $res.='>';
+
+               $file = $this->to;
+               $e = explode('.', $file);
+               $ext = array_pop($e);
+               $basename = implode('.', $e);
+
+               $videos = 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);
+               }
+               $res.='</video>';
+               return $res;
+       }
+
+}
+
+class webVideoLink extends videoLink {
+
+       public function getHTMLContent() {
+               return $this->getEmbed();
+       }
+
+       public function getEmbed() {
+               return '<iframe width="' . $this->width . '" height="' . $this->height . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
+       }
+
+       public function getEmbedURL() {
+               if ($this->video_service == 0) {
+                       $url = 'http://www.youtube.com/embed/' . $this->to;
+               } else {
+                       $url = 'http://www.dailymotion.com/embed/video/' . $this->to;
+               }
+               return $url;
+       }
+
+}
+
+class actionLink extends internalLink {
+
+       public function getURL() {
+               return '#' . $to;
+       }
+
+}
+
+class basketLink extends wsPackagerHTML5Link {
+       
+}
+
+class colorLink extends contentLink {
+
+       public function getCSS() {
+               return 'background-color:#' . $this->to . ';';
+       }
+
+}
+
+class imageLink extends contentLink {
+
+       public function getCSS() {
+               $this->copyExternalFile($this->to);
+               return 'background-image:url(../' . wsPackagerHTML5Link::getUniversalLocation($this->to) . ');background-size:100% 100%;background-repeat:no-repeat;';
+       }
+
+}
+
+class fileLink extends normalLink {
+
+       public function getURL() {
+               $this->copyExternalFile($this->to);
+               return wsPackagerHTML5Link::getUniversalLocation($this->to);
+       }
+
+       public function getTarget() {
+               return '_blank';
+       }
+
+}
+
+?>
index 3defc0aa69d561df3997f3849266fa082c939c9e..3c5f8a2af1e33eda736d8db5c2c7e77ce0d7c9cd 100644 (file)
@@ -76,8 +76,10 @@ class wsPackagerHTML5 extends wsPackager {
                $daoDoc = new wsDAODocument($core->con);\r
                $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);\r
 \r
-               foreach ($links as $link) {\r
-                       fb($link);\r
+               $i = 0;\r
+               foreach ($links as $linkData) {\r
+                       $link = wsPackagerHTML5Link::getInstance($this->base62($i), $linkData, $this);\r
+                       $i++;\r
                }\r
        }\r
 \r
@@ -111,7 +113,7 @@ class wsPackagerHTML5 extends wsPackager {
                        'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI);\r
 \r
                foreach ($icons as $icon => $color) {\r
-                       wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/',4, $w, $h);\r
+                       wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h);\r
                        $res[] = '#icon-' . $icon . '{width:' . $w . 'px;height:' . $h . 'px;background-image:url(data/images/' . $icon . '.svg), url(data/images/' . $icon . '.png);background-repeat:no-repeat;background-size:' . $w . 'px ' . $h . 'px}';\r
                }\r
                return $res;\r
@@ -538,6 +540,17 @@ class wsPackagerHTML5 extends wsPackager {
                return $str;\r
        }\r
 \r
+       public function copyLinkFile($source, $dest) {\r
+               $s = WS_BOOKS . '/workink/' . $this->book_id . '/' . $source;\r
+               if (file_exists($s)) {\r
+                       $d = $this->vdir . '/' . $dest . '/' . $source;\r
+                       if (!file_exists(dirname($d))) {\r
+                               mkdir(dirname($d), 0777, true);\r
+                       }\r
+                       copy($s, $d);\r
+               }\r
+       }\r
+\r
        public static function escapeHTML($in) {\r
                $in = htmlentities($in, ENT_NOQUOTES, "UTF-8");\r
                $in = str_replace('&thinsp;', '', $in);\r