From: vincent@cubedesigners.com Date: Fri, 2 Jun 2017 15:59:37 +0000 (+0000) Subject: wip #1388 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8b24deb97fb7d3f0b89f7d9152329d9b7362d605;p=cubeextranet.git wip #1388 @1 --- diff --git a/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php b/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php index a7ac6e215..e0b512a28 100644 --- a/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php @@ -11,7 +11,6 @@ class wsHTML5Compiler { 'js/libs/fix/detect-zoom.js', 'js/libs/cube/fb.js', 'js/libs/cube/util.js', - 'js/libs/fastclick/fastclick.js', 'js/libs/json.js', 'js/libs/flashdetect.js', 'js/libs/screenfull.js', diff --git a/inc/ws/Util/html5/html5video/class.ws.html5.links.php b/inc/ws/Util/html5/html5video/class.ws.html5.links.php index d87aaa6ac..1b1e652a0 100644 --- a/inc/ws/Util/html5/html5video/class.ws.html5.links.php +++ b/inc/ws/Util/html5/html5video/class.ws.html5.links.php @@ -52,11 +52,11 @@ class wsHTML5Link { case 5: return new internalLink($id, $init, $compiler); case 4: - if ($init['inline']) { - return new videoLink($id, $init, $compiler); - } else { - return new videoPopupLink($id, $init, $compiler); - } + if ($init['inline']) { + return new videoLink($id, $init, $compiler); + } else { + return new videoPopupLink($id, $init, $compiler); + } case 7: switch ($compiler->book->parametres->customLinkClass) { case 'WescoLink': @@ -512,13 +512,13 @@ class videoLink extends wsHTML5Link { $compiler->addLess('videojs/videojs', ['videojs/video-js-core.css']); } - public function getClasses() { - return array_merge(['videoLink'], parent::getClasses()); - } + public function getClasses() { + return array_merge(['videoLink'], parent::getClasses()); + } - public function getHTMLContent() { + public function getHTMLContent() { - static::addVideoJS($this->compiler); + static::addVideoJS($this->compiler); $this->copyExternalFile($this->to, true); @@ -530,42 +530,42 @@ class videoLink extends wsHTML5Link { public static function makeVideoTag($linkDatas, $w = null, $h = null, $compiler = null) { - $attributes = static::getVideoAttributes($linkDatas, $w, $h, $compiler); + $attributes = static::getVideoAttributes($linkDatas, $w, $h, $compiler); - $res = '
$value) { - $res .= " data-{$name}='{$value}'"; - } - $res .= '>
'; + $res = '
$value) { + $res .= " data-{$name}='{$value}'"; + } + $res .= '>
'; - return $res; + return $res; } - public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) { - - $file = $data->to; - $e = explode('.', $file); - $ext = array_pop($e); - $basename = implode('.', $e); + public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) { - $attr['name'] = $basename; - $attr['id'] = 'video_' . $data->id; - $attr['autoplay'] = ($data->video_auto_start ? '1' : '0'); - $attr['controls'] = ($data->video_controls ? '1' : '0'); - $attr['loop'] = ($data->video_loop ? '1' : '0'); - $attr['sound'] = ($data->video_sound_on ? '1' : '0'); + $file = $data->to; + $e = explode('.', $file); + $ext = array_pop($e); + $basename = implode('.', $e); - if (!is_null($w) && !is_null($h)) { - $attr['width'] = $w; - $attr['height'] = $h; - } else if (!is_null($compiler)) { - $path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $basename . '.jpg'; - $dim = getimagesize($path); - $attr['width'] = $dim[0]; - $attr['height'] = $dim[1]; - } + $attr['name'] = $basename; + $attr['id'] = 'video_' . $data->id; + $attr['autoplay'] = ($data->video_auto_start ? '1' : '0'); + $attr['controls'] = ($data->video_controls ? '1' : '0'); + $attr['loop'] = ($data->video_loop ? '1' : '0'); + $attr['sound'] = ($data->video_sound_on ? '1' : '0'); + + if (!is_null($w) && !is_null($h)) { + $attr['width'] = $w; + $attr['height'] = $h; + } else if (!is_null($compiler)) { + $path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $basename . '.jpg'; + $dim = getimagesize($path); + $attr['width'] = $dim[0]; + $attr['height'] = $dim[1]; + } - return $attr; + return $attr; } } @@ -583,7 +583,7 @@ class videoPopupLink extends normalLink { } public function getAdditionnalContent() { - $this->video_auto_start = true; // Videos should always autoplay + $this->video_auto_start = true; // Videos should always autoplay return ' data-video="' . rawurlencode(videoLink::makeVideoTag($this, null, null, $this->compiler)) . '" '; } @@ -598,7 +598,6 @@ class videoPopupLink extends normalLink { } - class audioPopupLink extends normalLink { public function getURL() { @@ -627,81 +626,81 @@ class audioPopupLink extends normalLink { class webVideoLink extends videoLink { - public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) { - $attributes = parent::getVideoAttributes($data, $w, $h, $compiler); + public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) { + $attributes = parent::getVideoAttributes($data, $w, $h, $compiler); - // Since the admin interface doesn't offer options for setting controls or sound, we will set some defaults here - $attributes['controls'] = '1'; - $attributes['sound'] = '1'; + // Since the admin interface doesn't offer options for setting controls or sound, we will set some defaults here + $attributes['controls'] = '1'; + $attributes['sound'] = '1'; - $attributes['setup'] = static::getVideoSetup($data, $compiler); + $attributes['setup'] = static::getVideoSetup($data, $compiler); - return $attributes; - } + return $attributes; + } - public static function getVideoSetup($data, $compiler) { - - static::addVideoJS($compiler); // Ensure videoJS core is included first - - switch($data->video_service) { - case 0: // YouTube - $compiler->addJs('js/libs/videojs/Youtube.js'); -// $compiler->addJs('https://rawgit.com/videojs/videojs-youtube/master/dist/Youtube.js'); - $setup = [ - 'techOrder' => ['youtube'], - 'sources' => [ - [ - 'type' => 'video/youtube', - 'src' => 'https://www.youtube.com/watch?v=' . $data->to - ] - ] - ]; - break; - case 1: // Dailymotion - // Todo: add local version of script... - // Note: this plugin doesn't seem to work currently so it is not included - //$compiler->addJs('https://rawgit.com/benjipott/video.js-dailymotion/master/dist-test/videojs-dailymotion.js'); - $setup = [ -// 'techOrder' => ['dailymotion'], -// 'sources' => [ -// [ -// 'src' => 'http://www.dailymotion.com/video/' . $data->to -// ] -// ] - ]; - break; - case 2: // Vimeo - // Todo: add local version of script... - // Note: Vimeo plugin doesn't seem to be working currently - might need updates to work with latest VideoJS module - //$compiler->addJs('https://rawgit.com/videojs/videojs-vimeo/master/dist/videojs-vimeo.min.js'); - $setup = [ -// 'techOrder' => ['vimeo'], -// 'sources' => [ -// [ -// 'type' => 'vimeo/vimeo', -// 'src' => 'https://www.vimeo.com/' . $data->to -// ] -// ] - ]; - break; - default: - $setup = []; - } - - return json_encode($setup, JSON_UNESCAPED_SLASHES); + public static function getVideoSetup($data, $compiler) { - } + static::addVideoJS($compiler); // Ensure videoJS core is included first + + switch ($data->video_service) { + case 0: // YouTube + $compiler->addJs('js/libs/videojs/Youtube.js'); + // $compiler->addJs('https://rawgit.com/videojs/videojs-youtube/master/dist/Youtube.js'); + $setup = [ + 'techOrder' => ['youtube'], + 'sources' => [ + [ + 'type' => 'video/youtube', + 'src' => 'https://www.youtube.com/watch?v=' . $data->to + ] + ] + ]; + break; + case 1: // Dailymotion + // Todo: add local version of script... + // Note: this plugin doesn't seem to work currently so it is not included + //$compiler->addJs('https://rawgit.com/benjipott/video.js-dailymotion/master/dist-test/videojs-dailymotion.js'); + $setup = [ + // 'techOrder' => ['dailymotion'], + // 'sources' => [ + // [ + // 'src' => 'http://www.dailymotion.com/video/' . $data->to + // ] + // ] + ]; + break; + case 2: // Vimeo + // Todo: add local version of script... + // Note: Vimeo plugin doesn't seem to be working currently - might need updates to work with latest VideoJS module + //$compiler->addJs('https://rawgit.com/videojs/videojs-vimeo/master/dist/videojs-vimeo.min.js'); + $setup = [ + // 'techOrder' => ['vimeo'], + // 'sources' => [ + // [ + // 'type' => 'vimeo/vimeo', + // 'src' => 'https://www.vimeo.com/' . $data->to + // ] + // ] + ]; + break; + default: + $setup = []; + } + + return json_encode($setup, JSON_UNESCAPED_SLASHES); + + } - public function getHTMLContent() { + public function getHTMLContent() { - if ($this->video_service !== 0) { - return $this->getEmbed(); - } + if ($this->video_service !== 0) { + return $this->getEmbed(); + } - $w = round($this->width * $this->getCssScale()); - $h = round($this->height * $this->getCssScale()); + $w = round($this->width * $this->getCssScale()); + $h = round($this->height * $this->getCssScale()); - return $this->makeVideoTag($this, $w, $h, $this->compiler); + return $this->makeVideoTag($this, $w, $h, $this->compiler); } public function getEmbed() { @@ -714,7 +713,7 @@ class webVideoLink extends videoLink { } elseif ($this->video_service == 1) { $url = 'https://www.dailymotion.com/embed/video/' . $this->to; } elseif ($this->video_service == 2) { - //Todo: get vimeo embed URL + //Todo: get vimeo embed URL $url = ''; } elseif ($this->video_service == 3) { list($playerId, $videoId) = explode('|', $this->to); @@ -982,27 +981,27 @@ class htmlMultimediaLink extends wsHTML5Link { class webVideoPopupLink extends videoPopupLink { -// public function getURL() { -// if ($this->video_service == 0) { -// $service = 'youtube'; -// } elseif ($this->video_service == 1) { -// $service = 'dailymotion'; -// } elseif ($this->video_service == 2) { -// $service = 'vimeo'; -// } elseif ($this->video_service == 3) { -// $service = 'brightcove'; -// } -// return '#/webvideo/' . $service . '/' . $this->to; -// } - - public function getURL() { - return '#/video/' . $this->to; - } + // public function getURL() { + // if ($this->video_service == 0) { + // $service = 'youtube'; + // } elseif ($this->video_service == 1) { + // $service = 'dailymotion'; + // } elseif ($this->video_service == 2) { + // $service = 'vimeo'; + // } elseif ($this->video_service == 3) { + // $service = 'brightcove'; + // } + // return '#/webvideo/' . $service . '/' . $this->to; + // } - public function getAdditionnalContent() { - $this->video_auto_start = true; // Videos should always autoplay - return ' data-video="' . rawurlencode(webVideoLink::makeVideoTag($this, $this->video_width, $this->video_height, $this->compiler)) . '" '; - } + public function getURL() { + return '#/video/' . $this->to; + } + + public function getAdditionnalContent() { + $this->video_auto_start = true; // Videos should always autoplay + return ' data-video="' . rawurlencode(webVideoLink::makeVideoTag($this, 1280, 720, $this->compiler)) . '" '; + } } @@ -1221,45 +1220,45 @@ class zoomLink extends normalLink { return $res; } - public function generateImage() { - $left = CubeIT_Files::tempnam(); - - $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page); - $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf'; - - $leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath, - $p['document_page'], - array('x' => $this->left, 'y' => $this->top, 'width' => $this->width, 'height' => $this->height), - $left, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/'); - - $bookwidth = $this->compiler->book->parametres->width; - - if (($this->left + $this->width) > $bookwidth) { - $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page + 1); - $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf'; - $diff = ($this->width + $this->left) - $bookwidth; - $right = CubeIT_Files::tempnam(); - $rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath, - $p['document_page'], - array('x' => 0, 'y' => $this->top, 'width' => $diff, 'height' => $this->height), - $right, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/'); - - $both = CubeIT_Files::tempnam() . '.jpg'; - CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal'); - } else { - $both = $leftfile; - } - - $this->compiler->simpleCopyLinkFile($both, 'data/links/zoom_' . $this->id . '.jpg'); - - // Perform tidy up and delete temporary files if they exist - $files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both']; - foreach($files_to_delete as $file) { - if (isset($$file) && file_exists($$file)) { - unlink($$file); - } - } - } + public function generateImage() { + $left = CubeIT_Files::tempnam(); + + $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page); + $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf'; + + $leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath, + $p['document_page'], + array('x' => $this->left, 'y' => $this->top, 'width' => $this->width, 'height' => $this->height), + $left, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/'); + + $bookwidth = $this->compiler->book->parametres->width; + + if (($this->left + $this->width) > $bookwidth) { + $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page + 1); + $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf'; + $diff = ($this->width + $this->left) - $bookwidth; + $right = CubeIT_Files::tempnam(); + $rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath, + $p['document_page'], + array('x' => 0, 'y' => $this->top, 'width' => $diff, 'height' => $this->height), + $right, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/'); + + $both = CubeIT_Files::tempnam() . '.jpg'; + CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal'); + } else { + $both = $leftfile; + } + + $this->compiler->simpleCopyLinkFile($both, 'data/links/zoom_' . $this->id . '.jpg'); + + // Perform tidy up and delete temporary files if they exist + $files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both']; + foreach ($files_to_delete as $file) { + if (isset($$file) && file_exists($$file)) { + unlink($$file); + } + } + } public function getClasses() {