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':
$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);
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 = '<div class="videoContainer"';
- foreach ($attributes as $name => $value) {
- $res .= " data-{$name}='{$value}'";
- }
- $res .= '></div>';
+ $res = '<div class="videoContainer"';
+ foreach ($attributes as $name => $value) {
+ $res .= " data-{$name}='{$value}'";
+ }
+ $res .= '></div>';
- 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;
}
}
}
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)) . '" ';
}
}
-
class audioPopupLink extends normalLink {
public function getURL() {
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() {
} 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);
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)) . '" ';
+ }
}
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() {