From ede3774da67259305496a0258729d75af0f87c17 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 20 Jan 2026 18:23:28 +0100 Subject: [PATCH] wip #7868 @1 --- src/Compiler/Compiler.php | 5 ++ src/Compiler/CompilerInterface.php | 4 +- src/Compiler/DummyCompiler.php | 103 +++++++++++++++++-------- src/Links/CustomLink.php | 2 +- src/Links/FileLink.php | 2 +- src/Links/HTMLMultimediaPopupImage.php | 9 ++- src/Links/Link.php | 5 ++ src/Links/WebLink.php | 2 +- 8 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/Compiler/Compiler.php b/src/Compiler/Compiler.php index edc887b..e02bba0 100644 --- a/src/Compiler/Compiler.php +++ b/src/Compiler/Compiler.php @@ -423,4 +423,9 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface { { // TODO: Implement getLinkAlternativeText() method. } + + public function shortenURL($url) + { + return $url; + } } diff --git a/src/Compiler/CompilerInterface.php b/src/Compiler/CompilerInterface.php index 60059d1..ef129ff 100644 --- a/src/Compiler/CompilerInterface.php +++ b/src/Compiler/CompilerInterface.php @@ -79,9 +79,11 @@ interface CompilerInterface public function getExternalMultimediaContents($to); - public function extractPDFArea($file, $page, $rect, $to=null, $options = array(), $cache = null); + public function extractPDFArea($file, $page, $rect, $to = null, $options = array(), $cache = null); public function addMask($layer, $page, $area); public function getLinkAlternativeText($link); + + public function shortenURL($url); } diff --git a/src/Compiler/DummyCompiler.php b/src/Compiler/DummyCompiler.php index b43e73c..41d5f5c 100644 --- a/src/Compiler/DummyCompiler.php +++ b/src/Compiler/DummyCompiler.php @@ -5,82 +5,101 @@ namespace Fluidbook\Tools\Compiler; use Cubist\Util\Data; use Cubist\Util\Files\VirtualDirectory; -class DummyCompiler implements CompilerInterface { +class DummyCompiler implements CompilerInterface +{ /** * @var Data */ protected $_data; - public function addContentLock($page, $unlockConditions = '') { + public function addContentLock($page, $unlockConditions = '') + { // TODO: Implement addContentLock() method. } - public function addTriggersLink($page, $link, $delay = 0) { + public function addTriggersLink($page, $link, $delay = 0) + { // TODO: Implement addTriggersLink() method. } - public function addAudiodescription($link) { + public function addAudiodescription($link) + { // TODO: Implement addAudiodescription() method. } - public function addBookmarkGroup($link) { + public function addBookmarkGroup($link) + { // TODO: Implement addBookmarkGroup() method. } - public function getConfigZIP($d, $file = null, $uid = null, $page = null) { + public function getConfigZIP($d, $file = null, $uid = null, $page = null) + { // TODO: Implement getConfigZIP() method. } - public function getSetting($key, $default = null) { + public function getSetting($key, $default = null) + { return $this->_data->get($key, $default); } - public function setSetting($key, $value) { + public function setSetting($key, $value) + { $this->_data->set($key, $value); } - public function getVirtualDirectory(): VirtualDirectory { + public function getVirtualDirectory(): VirtualDirectory + { // TODO: Implement getVirtualDirectory() method. } - public function getWorkingDir(): string { + public function getWorkingDir(): string + { // TODO: Implement getWorkingDir() method. } - public function setWorkingDir(string $wdir) { + public function setWorkingDir(string $wdir) + { // TODO: Implement setWorkingDir() method. } - public function working_path($path = ''): string { + public function working_path($path = ''): string + { // TODO: Implement working_path() method. } - public function source_path($path = ''): string { + public function source_path($path = ''): string + { // TODO: Implement source_path() method. } - public function page_path($page, $path = ''): string { + public function page_path($page, $path = ''): string + { // TODO: Implement page_path() method. } - public function getWidth($page = 1) { + public function getWidth($page = 1) + { // TODO: Implement getWidth() method. } - public function getHeight($page = 1) { + public function getHeight($page = 1) + { // TODO: Implement getHeight() method. } - public function virtualToPhysical($virtual) { + public function virtualToPhysical($virtual) + { // TODO: Implement virtualToPhysical() method. } - public function getPagePDFSource($page): string { + public function getPagePDFSource($page): string + { // TODO: Implement getPagePDFSource() method. } - public function addJsLib($name, $files) { + public function addJsLib($name, $files) + { // TODO: Implement addJsLib() method. } @@ -88,55 +107,68 @@ class DummyCompiler implements CompilerInterface { /** * @param Data $data */ - public function setData(Data $data): void { + public function setData(Data $data): void + { $this->_data = $data; } - public function getCacheDir(string $path) { + public function getCacheDir(string $path) + { // TODO: Implement getCacheDir() method. } - public function isOnePage(): bool { + public function isOnePage(): bool + { // TODO: Implement isOnePage() method. } - public function simpleCopyLinkFile($source, $dest) { + public function simpleCopyLinkFile($source, $dest) + { // TODO: Implement simpleCopyLinkFile() method. } - public function unzipFile($file, $moveAssets = false, $baseDir = null, $junkPaths = false) { + public function unzipFile($file, $moveAssets = false, $baseDir = null, $junkPaths = false) + { // TODO: Implement unzipFile() method. } - public function addPDFJS($force = false) { + public function addPDFJS($force = false) + { // TODO: Implement addPDFJS() method. } - public function addSEOArticle($page, $title, $intro, $image, $id = null, $url = null, $content = '') { + public function addSEOArticle($page, $title, $intro, $image, $id = null, $url = null, $content = '') + { // TODO: Implement addSEOArticle() method. } - public function getWidthForLinks($page=1) { + public function getWidthForLinks($page = 1) + { // TODO: Implement getWidthForLinks() method. } - public function getHeightForLinks($page=1) { + public function getHeightForLinks($page = 1) + { // TODO: Implement getHeightForLinks() method. } - public function isSinglePage(): bool { + public function isSinglePage(): bool + { return $this->isOnePage(); } - public function isDoublePage(): bool { + public function isDoublePage(): bool + { return !$this->isSinglePage(); } - public function getPageNumber(): int { + public function getPageNumber(): int + { // TODO: Implement getPageNumber() method. } - public function getQuality(): int { + public function getQuality(): int + { // TODO: Implement getQuality() method. } @@ -150,7 +182,7 @@ class DummyCompiler implements CompilerInterface { // TODO: Implement addIssue() method. } - public function addPageBackground($page, $color, $arrowsColor,$image) + public function addPageBackground($page, $color, $arrowsColor, $image) { // TODO: Implement addPageBackgroundColor() method. } @@ -179,4 +211,9 @@ class DummyCompiler implements CompilerInterface { { // TODO: Implement getLinkAlternativeText() method. } + + public function shortenURL($url) + { + return $url; + } } diff --git a/src/Links/CustomLink.php b/src/Links/CustomLink.php index 3c770b7..186b649 100644 --- a/src/Links/CustomLink.php +++ b/src/Links/CustomLink.php @@ -12,7 +12,7 @@ class CustomLink extends NormalLink public function getURL() { - return static::_getURL($this->to); + return $this->shortenURL(static::_getURL($this->to)); } public function getTarget() diff --git a/src/Links/FileLink.php b/src/Links/FileLink.php index 9d595f5..d69111c 100644 --- a/src/Links/FileLink.php +++ b/src/Links/FileLink.php @@ -28,7 +28,7 @@ class FileLink extends NormalLink } return 'pdfjs/web/viewer.html?file=' . rawurlencode('../../' . $res) . $hash; } - return $res; + return $this->shortenURL($res); } public function getTarget() diff --git a/src/Links/HTMLMultimediaPopupImage.php b/src/Links/HTMLMultimediaPopupImage.php index aef24e0..4afe11a 100644 --- a/src/Links/HTMLMultimediaPopupImage.php +++ b/src/Links/HTMLMultimediaPopupImage.php @@ -40,15 +40,20 @@ class HTMLMultimediaPopupImage extends NormalLink $alt = $this->getAlternativeText(); if ($alt) { + if (preg_match('/

(.*)<\/h2>/U', $alt, $matches)) { + $altTitle = Text::html2text($matches[1]); + } else { + $altTitle = ""; + } $adbid = 'adb_' . rand(1000, 100000); $altmarkup = '
' . $alt . '
'; - $alttxt = Text::html2text($alt); } $markup = '
'; $markup .= 'alt ?: $this->compiler->getLinkAlternativeText($this); } + + public function shortenURL($url) + { + return $this->compiler->shortenURL($url); + } } diff --git a/src/Links/WebLink.php b/src/Links/WebLink.php index 44ad931..24e3db7 100644 --- a/src/Links/WebLink.php +++ b/src/Links/WebLink.php @@ -9,7 +9,7 @@ class WebLink extends NormalLink public function getURL() { - return str_replace('"', '\'', Link::getUniversalLocation($this->to)); + return $this->shortenURL(str_replace('"', '\'', Link::getUniversalLocation($this->to))); } public function getTarget() -- 2.39.5