public function getEmbed()
{
- return '<iframe width="' . $this->width . '" height="' . $this->height . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
+ return '<iframe width="' . $this->width . '" height="' . $this->height . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
}
public function getEmbedURL()
protected $path;
protected $path_absolute;
+ protected $allowed_extensions;
public function getURL()
{
$this->compiler->addLess('slick/slick-bundle');
$this->compiler->addLess('fluidbook.slideshow');
- $extensions = ['jpg', 'png', 'jpeg', 'gif'];
+ $this->allowed_extensions = ['jpg', 'png', 'jpeg', 'gif'];
$slideshowID = 'slideshow_' . $this->uid;
$XML_path = $this->path_absolute . '/slideshow.xml'; // Optional file so it may not exist
+ // Default Slick settings (can be overridden by slideshow.xml)
+ $slick_settings = [
+ 'autoplay' => false,
+ 'fade' => false,
+ ];
+
$this->getURL();
$slides = [];
+
// If the zip file contained a slideshow.xml file, use that for fetching images and their captions
- $thumbnails = true;
if (file_exists($XML_path)) {
$slideshow_XML = simplexml_load_string(file_get_contents($XML_path));
$slideshowData = CubeIT_Util_Xml::toObject($slideshow_XML);
- $images = [];
- if (is_array($slideshowData->image)) {
- $images = $slideshowData->image;
- } else if (is_object($slideshowData->image)) {
- $images = [$slideshowData->image];
+ $thumbnails = isset($slideshowData->_thumbnails) && $slideshowData->_thumbnails !== 'false';
+
+ // Allow "fade" transition to be enabled
+ if (isset($slideshowData->_effect) && $slideshowData->_effect == 'fade') {
+ $slick_settings['fade'] = true;
}
- foreach ($images as $img) {
- $full_path = $this->path_absolute . '/' . $img->_name;
- $slides[] = ['caption' => $img->_caption, 'path' => $full_path];
+ if (isset($slideshowData->_autoplay) && $slideshowData->_autoplay == 'true') {
+ $slick_settings['autoplay'] = true;
}
- $thumbnails = $slideshowData->_thumbnails !== 'false' && $slideshowData->_thumbnails;
- } else {
- // Or by default, just get all the images that were in the zip file...
- $afiles = CubeIT_Files::getRecursiveDirectoryIterator($this->path_absolute);
- foreach ($afiles as $afile) {
- /** @var SplFileInfo $afile */
- if (!$afile->isFile()) {
- continue;
+ if (isset($slideshowData->image)) {
+ $images = [];
+ if (is_array($slideshowData->image)) {
+ $images = $slideshowData->image;
+ } else if (is_object($slideshowData->image)) {
+ $images = [$slideshowData->image];
}
- $ext = mb_strtolower($afile->getExtension());
- if (!in_array($ext, $extensions)) {
- continue;
+ foreach ($images as $img) {
+ $full_path = $this->path_absolute . '/' . $img->_name;
+ $slides[] = ['caption' => $img->_caption, 'path' => $full_path];
}
- $slides[] = ['path' => $afile->getPathname(), 'caption' => null];
- uasort($slides, [$this, '_orderSlidesByFilename']);
}
+
+ // It's possible that images are not defined in the slideshow.xml structure.
+ // In this case, we attempt to read the images from the directory...
+ if (empty($slides)) {
+ $slides = $this->_getSlidesFromDirectory($this->path_absolute);
+ }
+
+
+ } else {
+ // Or by default, just get all the images that were in the zip file...
+ $slides = $this->_getSlidesFromDirectory($this->path_absolute);
+
+ $thumbnails = (count($slides) > 1);
}
$res = '';
$res .= '</div>'; // .fb-slideshow-slide
}
- $res = '<div class="fb-slideshow" id="' . $slideshowID . '" data-open-index="' . $this->extra . '" data-thumbnails="' . ($thumbnails ? '1' : '0') . '">' . $res . '</div>';
+ $res = '<div class="fb-slideshow" id="' . $slideshowID . '" data-open-index="' . $this->extra . '" data-thumbnails="' . ($thumbnails ? '1' : '0') . '" data-slick=\''. json_encode($slick_settings) .'\'>' . $res . '</div>';
$res .= '<script>';
$res .= 'fluidbook.slideshow.initSlideshow("' . $slideshowID . '");';
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 = CubeIT_Files::getDirectoryIterator($path);
+ $slides = [];
+
+ foreach ($files as $file) {
+ /** @var SplFileInfo $file */
+ if (!$file->isFile()) {
+ continue;
+ }
+ $ext = mb_strtolower($file->getExtension());
+ if (!in_array($ext, $this->allowed_extensions)) {
+ continue;
+ }
+ $slides[] = ['path' => $file->getPathname(), 'caption' => null];
+ uasort($slides, [$this, '_orderSlidesByFilename']);
+ }
+
+ return $slides;
+ }
protected function _orderSlidesByFilename($a, $b)
{
public $zindex = 4;
public $rightClone = false;
public $iframeType = "none";
+ public $border = 0;
+ public $borderColor = '#ffffff';
+ public $maxWidth = 0;
+ protected $role = 'button';
protected $_init;
break;
case 37:
return new downloadPortionLink($id, $init, $compiler);
+ case 38:
+ $compiler->addTriggersLink($init['page'], $init['to']);
+ break;
+ case 39:
+ return new layerLink($id, $init, $compiler);
default:
return null;
}
}
+ public static function parseExtras($extras, $normalizeKey = false)
+ {
+ $extras = trim($extras);
+ if ($extras === '') {
+ return [];
+ }
+ $res = [];
+ $lines = CubeIT_Text::splitLines($extras);
+ foreach ($lines as $line) {
+ $e = explode('=', $line);
+ if (count($e) < 2) {
+ continue;
+ }
+ $v = trim($e[1]);
+ // Handle values surronded by quotes
+ if (preg_match('|^\"([^\"]+)\"$|', $v, $matches)) {
+ $v = $matches[1];
+ }
+ $k = trim($e[0]);
+ if ($normalizeKey) {
+ $k = mb_strtolower($k);
+ }
+ $res[$k] = $v;
+ }
+
+ return $res;
+ }
+
+ public static function parseAnimations($animations)
+ {
+ $anims = explode('---', $animations);
+ $res = [];
+
+ foreach ($anims as $animation) {
+ $animation = trim($animation);
+ if (!$animation) {
+ continue;
+ }
+ $extras = self::parseExtras($animation, true);
+ if (count($extras) > 0) {
+ if (!isset($extras['direction'])) {
+ $extras['direction'] = 'right';
+ }
+ if ($extras['direction'] === 'top') {
+ $extras['direction'] = 'up';
+ }
+ if ($extras['direction'] === 'bottom') {
+ $extras['direction'] = 'down';
+ }
+ }
+ $res[] = $extras;
+ }
+ return $res;
+ }
+
public static function replaceCustomURL($url)
{
$url = trim($url);
if ($k == 'extra') {
if (CubeIT_Util_Json::isJson($v)) {
$v = CubeIT_Util_Json::decode($v);
- } else if (stristr($v, '=')) {
+ } else if (strpos($v, '=') !== false && strpos($v, '&') !== false) {
$vv = $v;
$v = [];
parse_str($vv, $v);
$v = CubeIT_Util_Object::asObject($v);
+ } else if (strpos($v, '=') !== false) {
+ $extras = self::parseExtras($v);
+ foreach ($extras as $extrak => $extrav) {
+ $this->$extrak = $extrav;
+ }
+ continue;
}
}
$this->$k = $v;
$this->init();
}
+ public function getTooltipAttribute($t = null)
+ {
+ if (null === $t) {
+ $t = $this->getTooltip();
+ }
+ if ($t !== false) {
+ $escaped = htmlspecialchars($t, ENT_QUOTES);
+ $tooltip = ' data-tooltip="' . $escaped . '"';
+ $tooltip .= ' aria-label="' . $escaped . '"';
+ return $tooltip;
+ } else {
+ return '';
+ }
+ }
+
public function overlapDoublePage()
{
return ($this->page % 2 == 0 && $this->left + $this->width > $this->compiler->width);
public function getAdditionnalContent()
{
- return '';
+ $res = '';
+ if ($this->role !== '') {
+ $res .= ' role="' . $this->role . '"';
+ }
+ if ($this->maxWidth > 0) {
+ $res .= ' data-max-width="' . $this->maxWidth . '"';
+ }
+
+ return $res;
}
$css .= wsHTML5::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)');
$origin = true;
}
- if (isset($this->extra->skewX)) {
- $css .= wsHTML5::writeCSSUA('transform', 'skewX(' . $this->extra->skewX . 'deg)');
+ if (isset($this->skewX)) {
+ $css .= wsHTML5::writeCSSUA('transform', 'skewX(' . $this->skewX . 'deg)');
+ $origin = true;
+ }
+ if (isset($this->skew)) {
+ $css .= wsHTML5::writeCSSUA('transform', 'skew(' . $this->skew . ')');
$origin = true;
}
class normalLink extends wsHTML5Link
{
+ protected $role = 'link';
public function getHTMLContent()
{
if (count($class)) {
$attrs .= ' class="' . implode(' ', $class) . '"';
}
- $t = $this->getTooltip();
- if ($t !== false) {
- $attrs .= ' data-tooltip="' . htmlentities($t, ENT_QUOTES) . '"';
- }
+ $attrs .= $this->getTooltipAttribute();
if (isset($this->extra->blinkdelay)) {
$attrs .= ' data-blinkdelay="' . intval($this->extra->blinkdelay) . '"';
}
return '<a href="' . $this->getURL() . '" data-type="' . $this->type . '" target="' . $this->getTarget() . '"' . $attrs . $this->getAdditionnalContent() . $this->getTrack() . '></a>';
}
+
public function getTrack()
{
return '';
return $alt;
}
+ public function getAdditionnalContent()
+ {
+ return parent::getAdditionnalContent() . ' aria-hidden="true"';
+ }
+
}
class htmlMultimediaPopupLink extends htmlMultimediaPopupImage
public function getAdditionnalContent()
{
$res = parent::getAdditionnalContent();
- $variables = self::parseAnimation($this->image_rollover);
-
- if (!isset($variables['type']) || !$variables['type']) {
- $variables['type'] = 'none';
+ $animations = self::parseAnimations($this->image_rollover);
+ foreach ($animations as $animation) {
+ if (isset($animation['zindex'])) {
+ $this->zindex = $animation['zindex'];
+ }
}
- if (isset($variables['zindex'])) {
- $this->zindex = $variables['zindex'];
+ $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" ';
+ if ($this->_isHiddenFirst($animations)) {
+ $res .= ' data-animation-hide ';
}
- $res .= ' data-animation-type="' . $variables['type'] . '" data-animation="' . htmlspecialchars(json_encode($variables), ENT_QUOTES) . '" ';
-
return $res;
}
- public static function parseAnimation($animation)
+ protected function _isHiddenFirst($animations)
{
- $animation = trim($animation);
- $variables = [];
- if ($animation != '') {
- $lines = CubeIT_Text::splitLines($animation);
- foreach ($lines as $line) {
- $e = explode('=', $line);
- if (count($e) < 2) {
- continue;
- }
- $v = trim($e[1]);
- // Handle values surronded by quotes
- if (preg_match('|^\"([^\"]+)\"$|', $v, $matches)) {
- $v = $matches[1];
- }
- $variables[trim($e[0])] = $v;
- }
- if (!isset($variables['direction'])) {
- $variables['direction'] = 'right';
- }
- if ($variables['direction'] == 'top') {
- $variables['direction'] = 'up';
- }
- if ($variables['direction'] == 'bottom') {
- $variables['direction'] = 'down';
+ $hiddenAnimations = ['reveal', 'fadein', 'translatefrom'];
+ foreach ($animations as $animation) {
+ if (in_array($animation['type'], $hiddenAnimations)) {
+ return true;
}
}
- return $variables;
+ return false;
}
public function getCSSZIndex()
class webLink extends normalLink
{
+ protected $role = 'link';
+
public function getURL()
{
$res = str_replace('"', '\'', wsHTML5Link::getUniversalLocation($this->to));
class mailLink extends normalLink
{
+ protected $role = 'link';
public function getURL()
{
class phoneLink extends mailLink
{
+ protected $role = 'link';
public function getURL()
{
}
}
+ public function getAdditionnalContent()
+ {
+ return parent::getAdditionnalContent() . ' role="button"';
+ }
+
public function getDefaultTooltip()
{
return 'go to page';
public function getHTMLContent()
{
-
-
$this->copyExternalFile($this->to, true);
$w = round($this->width * $this->getCssScale());
}
+class layerLink extends imageLink
+{
+ protected $maxzoom_default = 4;
+
+ public function getCSS()
+ {
+ $attributes = $this->getZoomAttributes();
+ zoomLink::generateImage($attributes, $this->compiler, 'layerlink', 'layer');
+ return 'background-image:url(../links/layer_' . $attributes['id'] . '.jpg);background-size:100% 100%;background-repeat:no-repeat;';
+ }
+
+ public function getZoomAttributes()
+ {
+ return [
+ 'id' => $this->uid,
+ 'page' => $this->page,
+ 'maxzoom' => $this->maxzoom_default,
+ 'width' => round($this->width),
+ 'height' => round($this->height),
+ 'x' => round($this->left),
+ 'y' => round($this->top),
+ ];
+ }
+}
+
class colorLink extends contentLink
{
+ protected $role = '';
+
public function getCSS()
{
return 'background-color:' . wsHTML5::colorToCSS($this->to, 1) . ';';
public function getAdditionnalContent()
{
$res = parent::getAdditionnalContent();
+
return $res;
}
class fileLink extends normalLink
{
+ protected $role = 'link';
public function getURL()
{
{
public function getURL()
{
- zoomLink::generateImage($this->getZoomAttributes(), $this->compiler, 'downloadportion', 'downloadportion');
- return 'data/links/downloadportion_' . $this->id . '.jpg';
+ $attributes = $this->getZoomAttributes();
+ zoomLink::generateImage($attributes, $this->compiler, 'downloadportion', 'downloadportion');
+ return 'data/links/downloadportion_' . $attributes['id'] . '.jpg';
}
public function getZoomAttributes()
'x' => round($this->left),
'y' => round($this->top),
'pdf' => $pdf,
+ 'border' => $this->border,
+ 'borderColor' => $this->borderColor,
];
return $res;
}
class facebookLikeLink extends wsHTML5Link
{
+ protected $role = '';
+
public function getHTMLContent()
{
$this->compiler->addFacebookSDK();
class htmlMultimediaLink extends wsHTML5Link
{
+ protected $role = '';
protected $_config = null;
protected $_content = '';
protected $_url;
$ld = ' data-ld="' . str_replace('index.html', $this->_config['lowDef'], $this->_url) . '" ';
}
- $res = '<iframe' . $ld . 'data-scale="' . $s . '" data-width="' . $iw . '" data-height="' . $ih . '" width="' . $iw . '" height="' . $ih . '" src="' . $this->_url . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel="" style="visibility:hidden;" onload="this.style.visibility=\'visible\';"></iframe>';
+ $res = '<iframe' . $ld . 'data-scale="' . $s . '" data-width="' . $iw . '" data-height="' . $ih . '" width="' . $iw . '" height="' . $ih . '" src="' . $this->_url . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel="" style="visibility:hidden;" tabindex="-1" onload="this.style.visibility=\'visible\';"></iframe>';
}
if ($this->_externalIframe !== false) {
$iw = $this->_config['width'] * $s;
$ih = $this->_config['height'] * $s;
- $res = '<iframe data-scale="' . $s . '" data-width="' . $iw . '" data-height="' . $ih . '" width="' . $iw . '" height="' . $ih . '" src="' . $this->_externalIframe . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel="" style="visibility:hidden;" onload="this.style.visibility=\'visible\';"></iframe>';
+ $res = '<iframe data-scale="' . $s . '" data-width="' . $iw . '" data-height="' . $ih . '" width="' . $iw . '" height="' . $ih . '" src="' . $this->_externalIframe . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel="" style="visibility:hidden;" tabindex="-1" onload="this.style.visibility=\'visible\';"></iframe>';
}
foreach ($this->_config['inject'] as $i) {
class wescoLink extends normalLink
{
+ protected $role = 'link';
+
public static function _getURL($to)
{
return self::_getURLOfType('wesco', $to);
class pierronLink extends normalLink
{
+ protected $role = 'link';
public function getURL()
{
if (count($class)) {
$c = ' class="' . implode(' ', $class) . '"';
}
- $tooltip = '';
- $t = $this->getTooltip();
- if ($t !== false) {
- $tooltip = ' data-tooltip="' . htmlspecialchars($t, ENT_QUOTES) . '"';
- }
+ $tooltip = $this->getTooltipAttribute();
+
return '<a href="#" ' . $tooltip . $c . $this->getAdditionnalContent() . '></a>';
}
class flfLink extends wescoLink
{
+ protected $role = 'link';
public function getURL()
{
class customLink extends wescoLink
{
+ protected $role = 'link';
+
public static function getCustomInstance($id, $init, &$compiler)
{
$e = explode(':', $init['to']);
public function getZoomAttributes()
{
return [
- 'id' => $this->id,
+ 'id' => $this->uid,
'page' => $this->page,
'maxzoom' => empty($this->to) ? $this->maxzoom_default : $this->to,
'group' => implode(',', $this->getGroups()),
'width' => round($this->width),
'height' => round($this->height),
'x' => round($this->left),
- 'y' => round($this->top)
+ 'y' => round($this->top),
+ 'border' => $this->border,
+ 'borderColor' => $this->borderColor,
];
}
// The Poppler::extractArea function accepts a resolution setting and uses that to determine the
// scale factor on the extracted images. It does so by dividing by 72, so we can pass our own scale
// factor by setting the resolution to 72 * $maxzoom
- 'resolution' => 72 * $maxzoom
+ 'resolution' => 150 * $maxzoom
];
// Round all link co-ordinates because there seems to be a problem with the the Workshop link editor
$y = $attributes['y'];
$w = $attributes['width'];
$h = $attributes['height'];
- $bookwidth = round($compiler->book->parametres->width);
+ $bookwidth = round($compiler->width);
//error_log("--- Book Width: $bookwidth ---");
$both = $leftfile;
}
+ if (isset($attributes['border']) && $attributes['border'] > 0) {
+ $tmp = CubeIT_Files::tempnam() . '.jpg';
+ CubeIT_CommandLine_Imagemagick::addBorder($both, $tmp, $attributes['border'], $attributes['borderColor']);
+ $compiler->vdir->addTemp($both);
+ $both = $tmp;
+ }
+
$compiler->simpleCopyLinkFile($both, 'data/links/' . $save . '_' . $attributes['id'] . '.jpg');
// Perform tidy up and delete temporary files if they exist
protected $path;
protected $path_absolute;
+ protected $allowed_extensions;
+ protected $thumbnail_height = 80; // Height in px of thumbnail slider
public function getURL()
{
$this->compiler->addJsLib('splide', 'js/libs/splide/splide.js');
$this->compiler->addLess('fluidbook.slideshow');
- $extensions = ['jpg', 'png', 'jpeg', 'gif'];
+ $this->allowed_extensions = ['jpg', 'png', 'jpeg', 'gif'];
$slideshowID = 'slideshow_' . $this->uid;
$XML_path = $this->path_absolute . '/slideshow.xml'; // Optional file so it may not exist
+ // Default Slick settings (can be overridden by slideshow.xml)
+ $slideshow_settings = [
+ 'autoplay' => false,
+ 'fade' => false,
+ ];
+
$this->getURL();
$slides = [];
if (file_exists($XML_path)) {
$slideshow_XML = simplexml_load_string(file_get_contents($XML_path));
$slideshowData = CubeIT_Util_Xml::toObject($slideshow_XML);
- $images = [];
- if (is_array($slideshowData->image)) {
- $images = $slideshowData->image;
- } else if (is_object($slideshowData->image)) {
- $images = [$slideshowData->image];
+ $thumbnails = isset($slideshowData->_thumbnails) && $slideshowData->_thumbnails !== 'false';
+
+ // Allow "fade" transition to be enabled
+ if (isset($slideshowData->_effect) && $slideshowData->_effect == 'fade') {
+ $slideshow_settings['type'] = 'fade';
+ $slideshow_settings['rewind'] = true; // Loop infinitely
}
- foreach ($images as $img) {
- $full_path = $this->path_absolute . '/' . $img->_name;
- $slides[] = ['caption' => $img->_caption, 'path' => $full_path];
+ if (isset($slideshowData->_autoplay) && $slideshowData->_autoplay == 'true') {
+ $slideshow_settings['autoplay'] = true;
}
- $thumbnails = $slideshowData->_thumbnails !== 'false' && $slideshowData->_thumbnails;
- } else {
- // Or by default, just get all the images that were in the zip file...
- // 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...
- $afiles = CubeIT_Files::getDirectoryIterator($this->path_absolute);
-
- foreach ($afiles as $afile) {
- /** @var SplFileInfo $afile */
- if (!$afile->isFile()) {
- continue;
+ if (isset($slideshowData->image)) {
+ $images = [];
+ if (is_array($slideshowData->image)) {
+ $images = $slideshowData->image;
+ } else if (is_object($slideshowData->image)) {
+ $images = [$slideshowData->image];
}
- $ext = mb_strtolower($afile->getExtension());
- if (!in_array($ext, $extensions)) {
- continue;
+ foreach ($images as $img) {
+ $full_path = $this->path_absolute . '/' . $img->_name;
+ $slides[] = ['caption' => $img->_caption, 'path' => $full_path];
}
- $slides[] = ['path' => $afile->getPathname(), 'caption' => null];
- uasort($slides, [$this, '_orderSlidesByFilename']);
}
+ // It's possible that images are not defined in the slideshow.xml structure.
+ // In this case, we attempt to read the images from the directory...
+ if (empty($slides)) {
+ $slides = $this->_getSlidesFromDirectory($this->path_absolute);
+ }
+
+
+ } else {
+ // Or by default, just get all the images that were in the zip file...
+ $slides = $this->_getSlidesFromDirectory($this->path_absolute);
+
$thumbnails = (count($slides) > 1);
}
// Main slider
- $res = '<div class="fb-slideshow splide" id="' . $slideshowID . '" data-open-index="' . $this->extra . '" data-thumbnails="' . ($thumbnails ? '1' : '0') . '">' . $this->_slides($slides) . '</div>';
+ $res = '<div class="fb-slideshow splide" id="' . $slideshowID . '" data-open-index="' . $this->extra . '" data-thumbnails="' . ($thumbnails ? '1' : '0') . '" data-splide=\''. json_encode($slideshow_settings) .'\'>' . $this->_slides($slides) . '</div>';
// Thumbnails slider
if ($thumbnails) {
- $res .= '<div class="fb-slideshow-thumbnails splide" id="' . $slideshowID . '_thumbnails">' . $this->_slides($slides, false) . '</div>';
+ $res .= '<div class="fb-slideshow-thumbnails splide" id="' . $slideshowID . '_thumbnails">' . $this->_slides($slides, false, $this->thumbnail_height) . '</div>';
}
// $res .= '<script>';
return $res;
}
- protected function _slides($slides, $show_captions = true) {
+ 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 = CubeIT_Files::getDirectoryIterator($path);
+ $slides = [];
+
+ foreach ($files as $file) {
+ /** @var SplFileInfo $file */
+ if (!$file->isFile()) {
+ continue;
+ }
+ $ext = mb_strtolower($file->getExtension());
+ if (!in_array($ext, $this->allowed_extensions)) {
+ continue;
+ }
+ $slides[] = ['path' => $file->getPathname(), 'caption' => null];
+ uasort($slides, [$this, '_orderSlidesByFilename']);
+ }
+
+ return $slides;
+ }
+
+ protected function _slides($slides, $show_captions = true, $max_height = null) {
$res = '<div class="splide__track">';
$res .= '<ul class="splide__list">';
$image_info_json = ($image_info) ? json_encode(['width' => $image_info[0], 'height' => $image_info[1]]) : '';
$image_dimensions = ($image_info) ? $image_info[3] : '';
+ // When displaying thumbnails, they are a fixed size, based on height
+ // We set dimensions here to avoid extra work on the client side
+ if ($max_height && $image_info) {
+ $thumb_width = round($max_height / $image_info[1] * $image_info[0]); // max_height / image_height * image_width
+ $image_dimensions = 'style="width:'. $thumb_width .'px; height:'. $max_height .'px"';
+ }
+
$res .= '<li class="fb-slideshow-slide splide__slide">';
- $res .= '<div class="splide__slide__container">';
+ //$res .= '<div class="splide__slide__container">';
$res .= '<img class="fb-slideshow-slide-image" src="' . $image_path_relative . '" data-meta="'. htmlspecialchars($image_info_json, ENT_QUOTES) .'" '. $image_dimensions .'>';
- $res .= '</div>'; // .splide__slide__container
+ //$res .= '</div>'; // .splide__slide__container
if ($show_captions && null !== $slide['caption']) {
$res .= '<p class="fb-slideshow-slide-caption">' . $slide['caption'] . '</p>';
public function init()
{
parent::init();
- $this->compiler->config->articlesList[$this->to]['page'] = $this->page;
$this->article = $this->compiler->config->articlesList[$this->to];
+ if (!isset($this->compiler->config->articlesList[$this->to]['page'])) {
+ $this->compiler->config->articlesList[$this->to]['page'] = $this->page;
+ }
}
public function getURL()