From: vincent@cubedesigners.com Date: Wed, 13 Jul 2011 21:09:02 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=6564b3f746b8ed4cdedd2677e63f11e83f0a3c7a;p=cubeextranet.git --- diff --git a/inc/ws/Util/packager/_common.php b/inc/ws/Util/packager/_common.php index caa932b13..e9c59a1ae 100644 --- a/inc/ws/Util/packager/_common.php +++ b/inc/ws/Util/packager/_common.php @@ -1,10 +1,11 @@ \ 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 index 000000000..7ba0c2a7f --- /dev/null +++ b/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php @@ -0,0 +1,255 @@ +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 '
' . $this->getHTMLContent() . '
'; + } + + 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 ''; + } + + 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 = ''; + return $res; + } + +} + +class webVideoLink extends videoLink { + + public function getHTMLContent() { + return $this->getEmbed(); + } + + public function getEmbed() { + return ''; + } + + 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'; + } + +} + +?> diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.php index 3defc0aa6..3c5f8a2af 100644 --- a/inc/ws/Util/packager/html5/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/html5/class.ws.packager.html5.php @@ -76,8 +76,10 @@ class wsPackagerHTML5 extends wsPackager { $daoDoc = new wsDAODocument($core->con); $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers); - foreach ($links as $link) { - fb($link); + $i = 0; + foreach ($links as $linkData) { + $link = wsPackagerHTML5Link::getInstance($this->base62($i), $linkData, $this); + $i++; } } @@ -111,7 +113,7 @@ class wsPackagerHTML5 extends wsPackager { 'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI); foreach ($icons as $icon => $color) { - wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/',4, $w, $h); + wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h); $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}'; } return $res; @@ -538,6 +540,17 @@ class wsPackagerHTML5 extends wsPackager { return $str; } + public function copyLinkFile($source, $dest) { + $s = WS_BOOKS . '/workink/' . $this->book_id . '/' . $source; + if (file_exists($s)) { + $d = $this->vdir . '/' . $dest . '/' . $source; + if (!file_exists(dirname($d))) { + mkdir(dirname($d), 0777, true); + } + copy($s, $d); + } + } + public static function escapeHTML($in) { $in = htmlentities($in, ENT_NOQUOTES, "UTF-8"); $in = str_replace(' ', '', $in);