--- /dev/null
+<?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';
+ }
+
+}
+
+?>
$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
'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
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(' ', '', $in);\r