use Fluidbook\Tools\Links\Link;
use Nette\Utils\Image;
-trait Links
-{
+trait Links {
/**
* @throws \SodiumException
*/
- public function compileLinks()
- {
+ public function compileLinks() {
/** @var Link[] $links */
$links = $this->getLinks();
// Custom landing page content
-// if ($this->book->parametres->tabsHTML5 != '' && file_exists($this->wdir . '/' . $this->book->parametres->tabsHTML5)) {
-// $ext = CubeIT_Files::getExtension($this->book->parametres->tabsHTML5);
-// if ($ext === 'zip') {
-// $links[] = [
-// 'page' => 'background',
-// 'top' => 0,
-// 'left' => 0,
-// 'width' => 100,
-// 'height' => 100,
-// 'type' => 6,
-// 'to' => $this->book->parametres->tabsHTML5,
-// 'alternative' => $this->book->parametres->tabsHTML5,
-// 'image' => '',
-// 'inline' => 1,
-// 'interactive' => 1,
-// 'class' => 'tabslink',
-// 'uid' => 'tabs',
-// ];
-// } else if ($ext === 'svg') {
-// $this->vdir->copy($this->wdir . '/' . $this->book->parametres->tabsHTML5, 'data/tabs.svg');
-// $this->config->svgTabs = true;
-// $pagesLists = ['tabsPages', 'tabsSections'];
-// foreach ($pagesLists as $pagesList) {
-// $e = explode(',', $this->book->parametres->$pagesList);
-// $list = [];
-// foreach ($e as $k => $v) {
-// $v = trim($v);
-// if ($v === '') {
-// continue;
-// }
-// if ($v !== '-') {
-// if ($this->book->parametres->tabsPagesNumbers === 'virtual') {
-// $v = $this->virtualToPhysical($v);
-// }
-// }
-// $list[] = $v;
-// }
-// $this->config->$pagesList = $list;
-// }
-// }
-// }
+ // if ($this->book->parametres->tabsHTML5 != '' && file_exists($this->wdir . '/' . $this->book->parametres->tabsHTML5)) {
+ // $ext = CubeIT_Files::getExtension($this->book->parametres->tabsHTML5);
+ // if ($ext === 'zip') {
+ // $links[] = [
+ // 'page' => 'background',
+ // 'top' => 0,
+ // 'left' => 0,
+ // 'width' => 100,
+ // 'height' => 100,
+ // 'type' => 6,
+ // 'to' => $this->book->parametres->tabsHTML5,
+ // 'alternative' => $this->book->parametres->tabsHTML5,
+ // 'image' => '',
+ // 'inline' => 1,
+ // 'interactive' => 1,
+ // 'class' => 'tabslink',
+ // 'uid' => 'tabs',
+ // ];
+ // } else if ($ext === 'svg') {
+ // $this->vdir->copy($this->wdir . '/' . $this->book->parametres->tabsHTML5, 'data/tabs.svg');
+ // $this->config->svgTabs = true;
+ // $pagesLists = ['tabsPages', 'tabsSections'];
+ // foreach ($pagesLists as $pagesList) {
+ // $e = explode(',', $this->book->parametres->$pagesList);
+ // $list = [];
+ // foreach ($e as $k => $v) {
+ // $v = trim($v);
+ // if ($v === '') {
+ // continue;
+ // }
+ // if ($v !== '-') {
+ // if ($this->book->parametres->tabsPagesNumbers === 'virtual') {
+ // $v = $this->virtualToPhysical($v);
+ // }
+ // }
+ // $list[] = $v;
+ // }
+ // $this->config->$pagesList = $list;
+ // }
+ // }
+ // }
$pagesOfCustomLinks = [];
$hiddenLinks = [];
$$v[$lta->page][$lta->blendmode] = [];
}
- array_push($$v[$lta->page][$lta->blendmode],$lta);
+ array_push($$v[$lta->page][$lta->blendmode], $lta);
$i++;
}
// Make old "aftersearch" link compatible with new "extra" menu option by extracting link URL
return $css;
}
- public function getLinks()
- {
+ public function getLinks() {
return [];
}
- protected function getLinksFromPDF()
- {
+ protected function getLinksFromPDF() {
$booleans = ['video_loop', 'video_auto_start', 'video_controls', 'video_sound_on'];
$numbers = ['left', 'top', 'width', 'height'];
return $links;
}
- protected static function makeUID()
- {
+ protected static function makeUID() {
return substr(md5(uniqid('fblink_', true)), 2, 8) . '00';
}
- protected function _htmlLinkList($list)
- {
+ protected function _htmlLinkList($list) {
if (!count($list)) {
return [];
}
}
- protected function _sortLinksByDepth($a, $b)
- {
+ protected function _sortLinksByDepth($a, $b) {
$c = $a->getDepth() - $b->getDepth();
if ($c === 0) {
$c = $b->getSurface() - $a->getSurface();
return $c;
}
- public function _sortLinks($a, $b)
- {
+ public function _sortLinks($a, $b) {
$priorities = array(26 => -1, 35 => 1);
return $pb - $pa;
}
- protected static function base36($val)
- {
+ protected static function base36($val) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$base = strlen($chars);
$str = '';
/**
* @return number
*/
- public function getLinkScale()
- {
+ public function getLinkScale() {
return (float)$this->config->cssScale;
}
/**
* @throws \Exception
*/
- public function copyLinkDir($source, $dest)
- {
+ public function copyLinkDir($source, $dest) {
$this->vdir->copyDirectory($source, $dest);
}
- public function simpleCopyLinkFile($source, $dest, $addVdir = true)
- {
+ public function simpleCopyLinkFile($source, $dest, $addVdir = true) {
if ($addVdir) {
$dest = $dest;
}
$this->vdir->copy($source, $dest);
}
- protected function _fixSVG($source)
- {
+ protected function _fixSVG($source) {
$fixed = str_replace('.svg', '.f.svg', $source);
if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) {
return $fixed;
return $fixed;
}
- public function getVideosFormats()
- {
+ public function getVideosFormats() {
return ['mp4', 'jpg'];
}
- public function copyLinkFile($source, $dest, $video = false)
- {
+ public function copyLinkFile($source, $dest, $video = false) {
$types = $this->getVideosFormats();
if ($video) {
$e = explode('.', $source);
/**
* @throws Exception
*/
- public function unzipFile($file, $moveAssets = false, $baseDir = null)
- {
+ public function unzipFile($file, $moveAssets = false, $baseDir = null) {
$fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', Files::getFilename($file)) : $baseDir;
$dir = $this->wdir . $fdir;
}
- Zip::extract($file, $dir);
+ $fmtime = filemtime($file);
+ if (!file_exists($dir) || filemtime($dir) !== $fmtime) {
+ Zip::extract($file, $dir);
+ touch($dir, $fmtime);
+ }
if ($moveAssets) {
`mv $dir/Assets/* $dir`;
case 16:
return new FileLink($id, $init, $compiler);
case 17:
-
$init['inline'] = self::normalizeInlineIntegration($init['inline']);
if ($init['inline'] === 'inline') {
return new AudioLink($id, $init, $compiler);
case 29:
return new FacebookLikeLink($id, $init, $compiler);
case 30:
- return new SlideshowLink($id, $init, $compiler);
+ if (stristr($init['to'], '.zip')) {
+ return new SlideshowLink($id, $init, $compiler);
+ }else{
+ return new HTMLMultimediaPopupImage($id, $init, $compiler);
+ }
case 31:
$init['inline'] = self::normalizeInlineIntegration($init['inline']);
if ($init['inline'] === 'inline') {
$this->compiler->copyLinkDir($dir, $dest);
}
- public function unzipFile($file, $moveAssets = false) {
- return $this->compiler->unzipFile($file, $moveAssets);
+ public function unzipFile($file, $junkPaths = false) {
+ return $this->compiler->unzipFile($file, false, null, $junkPaths);
}
public function getCssScale() {
use Cubist\Util\Graphics\Image;
use Cubist\Util\Xml;
-class SlideshowLink extends NormalLink
-{
+class SlideshowLink extends NormalLink {
protected $path;
protected $path_absolute;
protected $allowed_extensions;
protected $thumbnail_height = 80; // Height in px of thumbnail slider
- public function getURL()
- {
+ public function getURL() {
if (empty($this->to)) {
return '';
}
- $d = $this->unzipFile($this->to, false);
+ $d = $this->unzipFile($this->to, true);
$this->copyExternalDir($d['dir'], $d['fdir']);
$this->path = $d['fdir'];
return '#/slideshow/' . $this->uid;
}
- public function getAdditionnalContent()
- {
+ public function getAdditionnalContent() {
return 'data-slideshow="' . rawurlencode($this->generateSlideshow('popup')) . '" ';
}
-// public function keep() {
-// return true;
-// }
-
- public function getDefaultTooltip()
- {
+ public function getDefaultTooltip() {
return 'view slideshow';
}
- public function generateSlideshow($context)
- {
+ public function generateSlideshow($context) {
$this->compiler->addSlideshowLibrary($context === 'inline');
$this->allowed_extensions = ['jpg', 'png', 'jpeg', 'gif', 'svg'];
// Allow caption font-size to be overridden from XML file
$slides_options['caption_size'] = $slideshowData->_captionsize ?? null;
-
if (isset($slideshowData->image)) {
$images = [];
if (is_array($slideshowData->image)) {
return $res;
}
- protected function _getSlidesFromDirectory($path)
- {
- // Previously this was getting all files recursively but it caused problems
- // when there was a __MACOSX sub directory inside the zip file containing
- // resource forks for the JPGs. There's no need to support nested directories
- // in the zip so we only look at the zip's root directory...
- $files = Files::getDirectoryIterator($path);
+ protected function _getSlidesFromDirectory($path) {
+ $files = Files::getRecursiveDirectoryIterator($path);
$slides = [];
foreach ($files as $file) {
- /** @var SplFileInfo $file */
+ /** @var \SplFileInfo $file */
if (!$file->isFile()) {
continue;
}
+ if (stristr($file->getPathname(), '__MACOSX')) {
+ continue;
+ }
$ext = mb_strtolower($file->getExtension());
if (!in_array($ext, $this->allowed_extensions)) {
continue;
return $slides;
}
- protected function _slides($slides, $options = [])
- {
+ protected function _slides($slides, $options = []) {
$default_options = [
'show_captions' => true,
'caption_size' => null,
$res .= '<ul class="splide__list">';
foreach ($slides as $slide) {
-
- $image_path_relative = str_replace($this->compiler->getWorkingDir() . "/", '', $slide['path']);
+ $s=new \SplFileInfo($slide['path']);
+ $image_path_relative = $this->path.'/'.$s->getFilename();
$image_info = Image::getimagesize($slide['path']);
$image_info_json = ($image_info) ? json_encode(['width' => $image_info[0], 'height' => $image_info[1], 'ratio' => round($image_info[0] / $image_info[1], 4)]) : '';
}
- protected function _orderSlidesByFilename($a, $b)
- {
+ protected function _orderSlidesByFilename($a, $b) {
return strcmp($a['path'], $b['path']);
}
- public function keep()
- {
+ public function keep() {
return true;
}
}