use Fluidbook\Tools\Compiler\CompilerInterface;
use stdClass;
-class Link
-{
+class Link {
protected static string|false $_linksKey;
public $left;
* @param CompilerInterface $compiler
* @return Link
*/
- public static function getInstance($id, $init, &$compiler)
- {
+ public static function getInstance($id, $init, &$compiler) {
$init = ArrayUtil::asArray($init);
$init['scorm'] = self::isScorm($init);
return new TooltipLink($id, $init, $compiler);
}
return new TextPopupLink($id, $init, $compiler);
- case 19:
- break;
case 20:
$compiler->addBookmarkGroup($init);
break;
}
- public function getSurface()
- {
+ public function getSurface() {
return $this->width * $this->height;
}
- public static function normalizeInlineIntegration($inline)
- {
+ public static function normalizeInlineIntegration($inline) {
if ($inline == '1' || $inline === 'true' || $inline === true) {
return 'inline';
} else if (!$inline || $inline === 'false') {
return $inline;
}
- public static function parseExtras($extras, $normalizeKey = false)
- {
+ public static function parseExtras($extras, $normalizeKey = false) {
$extras = trim($extras);
if ($extras === '') {
return [];
return $res;
}
- public static function parseAnimations($animations)
- {
+ public static function parseAnimations($animations) {
$anims = explode('---', $animations);
$res = [];
return $res;
}
- public static function replaceCustomURL($url)
- {
+ public static function replaceCustomURL($url) {
$url = trim($url);
if (strpos($url, 'custom:') === 0) {
$e = explode(':', $url, 2);
return $url;
}
- public static function getMultimediaInstance($id, $init, &$compiler)
- {
+ public static function getMultimediaInstance($id, $init, &$compiler) {
if ($init['alternative'] == '') {
return null;
}
return null;
}
- public static function isScorm($linkData)
- {
+ public static function isScorm($linkData) {
return (isset($linkData['scorm']) && $linkData['scorm']) || (self::_isScormLink($linkData['to']) || (isset($linkData['alternative']) && self::_isScormLink($linkData['alternative'])));
}
- protected static function _isScormLink($url)
- {
+ protected static function _isScormLink($url) {
if (strpos($url, 'http://') >= 0 || strpos($url, 'https://') > 0) {
return false;
}
* @param $init array
* @param $compiler CompilerInterface
*/
- public function __construct($id, $init, &$compiler)
- {
+ public function __construct($id, $init, &$compiler) {
$this->_init = $init;
foreach ($init as $k => $v) {
if ($k == 'extra') {
/**
* @param int $initialOrder
*/
- public function setInitialOrder(int $initialOrder): void
- {
+ public function setInitialOrder(int $initialOrder): void {
$this->initialOrder = $initialOrder;
}
/**
* @return int
*/
- public function getInitialOrder(): int
- {
+ public function getInitialOrder(): int {
return $this->initialOrder;
}
- public function getDepth()
- {
+ public function getDepth() {
if ($this->zindex == -1 || null === $this->zindex || !$this->zindex) {
return $this->defaultZIndex;
}
return $this->zindex;
}
- public function getTooltipAttribute($t = null)
- {
+ public function getTooltipAttribute($t = null) {
if (null === $t) {
$t = $this->getTooltip();
}
}
}
- public function overlapDoublePage()
- {
+ public function overlapDoublePage() {
// $this->page is normally an integer but it can also be a string (eg. background / aftersearch)
- if (!is_int($this->page)) return false;
+ if (!is_int($this->page))
+ return false;
return ($this->page % 2 == 0 && $this->left + $this->width > $this->compiler->getWidth());
}
- public function getRightClone()
- {
+ public function getRightClone() {
$res = clone $this;
$res->page++;
$res->left -= $this->compiler->getWidth();
return $res;
}
- public function init()
- {
+ public function init() {
}
- public function getDefaultTooltip()
- {
+ public function getDefaultTooltip() {
return false;
}
- public function getTooltip()
- {
+ public function getTooltip() {
if ($this->infobulle === null || !$this->infobulle) {
if ($this->getDefaultTooltip() === false) {
return '';
return $this->infobulle;
}
- public function getHTMLContainer()
- {
+ public function getHTMLContainer() {
$addContent = $this->getAdditionnalContent();
return '<div class="' . $this->getHTMLContainerClass() . '" data-blendmode="' . $this->blendmode . '" data-hidden="' . $this->hidden . '" data-scorm="' . $this->scorm . '" data-id="' . $this->uid . '" id="l_' . $this->id . '"' . $addContent . '>' . $this->getHTMLContent() . '</div>';
}
- public function getHTMLContainerClass()
- {
+ public function getHTMLContainerClass() {
$res = trim('link ' . $this->class);
if ((int)$this->page % 2 == 1) {
$res .= ' odd';
return $res;
}
- public function getHTMLContent()
- {
+ public function getHTMLContent() {
return '';
}
- public function getAdditionnalContent()
- {
+ public function getAdditionnalContent() {
$res = '';
if ($this->role !== '') {
$res .= ' role="' . $this->role . '"';
}
- public function getClasses()
- {
+ public function getClasses() {
$res = array();
if (isset($this->image_rollover) && $this->image_rollover != 'none') {
return $res;
}
- public function copyExternalFile($file, $video = false)
- {
+ public function copyExternalFile($file, $video = false) {
$this->compiler->copyLinkFile($file, 'data/links/', $video);
}
- public function copyExternalDir($dir, $dest = 'data/links')
- {
+ public function copyExternalDir($dir, $dest = 'data/links') {
$this->compiler->copyLinkDir($dir, $dest);
}
- public function unzipFile($file, $moveAssets = false)
- {
+ public function unzipFile($file, $moveAssets = false) {
return $this->compiler->unzipFile($file, $moveAssets);
}
- public function getCssScale()
- {
+ public function getCssScale() {
if (is_int($this->page)) {
return $this->compiler->getLinkScale();
} else {
}
}
- public function getCSSZIndex()
- {
+ public function getCSSZIndex() {
$zindex = $this->getAddZIndex() + (($this->getDepth() + 1) * 10000) - min(9999, max(1, round(9999 * (($this->width * $this->height) / $this->compiler->getBookSurface()))));
return 'z-index:' . $zindex . ';';
}
- public function getAddZIndex()
- {
+ public function getAddZIndex() {
return $this->addzindex;
}
- public function moveOnEvenPage()
- {
+ public function moveOnEvenPage() {
return false;
}
- public function getCSSContainer()
- {
+ public function getCSSContainer() {
if ($this->moveOnEvenPage()) {
$this->page--;
$this->left += $this->compiler->getWidth();
return $css;
}
- public function getCSS()
- {
+ public function getCSS() {
return '';
}
- public function keep()
- {
+ public function keep() {
return false;
}
- public static function getUniversalLocation($loc, $css = false)
- {
+ public static function getUniversalLocation($loc, $css = false) {
$datas = parse_url($loc);
if ((isset($datas['scheme']) && !is_null($datas['scheme'])) || strpos($loc, '#') === 0) {
}
}
- public function isOutsidePage()
- {
- if ($this->top > $this->compiler->getSetting('height')) {
+ public function isOutsidePage() {
+ $height = isset($this->compiler->getSetting('pagesDimensions')[$this->page][1]) ?: $this->compiler->getSetting('height');
+
+ if ($this->top > $height) {
return true;
}
if ($this->left > $this->compiler->getSetting('width')) {
}
}
- public function ignore()
- {
+ public function ignore() {
return false;
}
- public function getConfigZIP($d)
- {
+ public function getConfigZIP($d) {
return $this->compiler->getConfigZIP($d);
}
- public function getConfigHTML($d, $html)
- {
+ public function getConfigHTML($d, $html) {
$c = file_get_contents($this->compiler->working_path($html));
$res = array('width' => $this->video_width, 'height' => $this->video_height);
if (stristr($c, '<div id="lottie"></div>')) {
return array_merge($res, $r);
}
- public function getConfigOAM($d)
- {
+ public function getConfigOAM($d) {
$x = simplexml_load_string(file_get_contents($d . '/config.xml'));
$config = (string)$x->oamfile['src'];
$config = str_replace('/Assets', '', $d . '/' . $config);
/**
* @throws \SodiumException
*/
- public static function decryptLink($link)
- {
+ public static function decryptLink($link) {
$array = false;
if (is_array($link)) {
$array = true;
return ArrayUtil::asArray($link);
}
- public static function decryptLinks($links)
- {
+ public static function decryptLinks($links) {
$res = [];
foreach ($links as $key => $link) {
$res[$key] = self::decryptLink($link);
return $res;
}
- public static function _getLinkKey()
- {
+ public static function _getLinkKey() {
if (self::$_linksKey === null) {
self::$_linksKey = base64_decode('o2p2yYGI8yMEHf+Y5/e6NdTINbbXg3NIo8BODgdhPxI=');
}