]> _ Git - fluidbook_tools.git/commitdiff
wip #7868 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 20 Jan 2026 17:23:28 +0000 (18:23 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 20 Jan 2026 17:23:28 +0000 (18:23 +0100)
src/Compiler/Compiler.php
src/Compiler/CompilerInterface.php
src/Compiler/DummyCompiler.php
src/Links/CustomLink.php
src/Links/FileLink.php
src/Links/HTMLMultimediaPopupImage.php
src/Links/Link.php
src/Links/WebLink.php

index edc887be6886e2758f1a871c528a32cced01b2a8..e02bba0d19e72c7ea04df4ba237b5b8aba162b72 100644 (file)
@@ -423,4 +423,9 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface {
     {
         // TODO: Implement getLinkAlternativeText() method.
     }
+
+    public function shortenURL($url)
+    {
+       return $url;
+    }
 }
index 60059d16c758dcf45091d1d2a1988a162323e636..ef129ff3244bbde83b5091984d7efdfa61b500a5 100644 (file)
@@ -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);
 }
index b43e73c22096e8673d628d7c2a4fa7840e984ac8..41d5f5c412cd807ab5b605a454e30b417d11b3c4 100644 (file)
@@ -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;
+    }
 }
index 3c770b7a92a0501989fc7dd3f2c247aee38a203f..186b6494401130ca3c37e7e3c108df7f8a229e54 100644 (file)
@@ -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()
index 9d595f516f8746a7f71263f7714ca895003b6e7e..d69111ca6dc1e89cdc367c65134e696ac6e3323a 100644 (file)
@@ -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()
index aef24e0517bfba33ee07fa7c10b5b2be5f5ac417..4afe11afa1ff427812292efc70e9e35ed8b1b0af 100644 (file)
@@ -40,15 +40,20 @@ class HTMLMultimediaPopupImage extends NormalLink
 
         $alt = $this->getAlternativeText();
         if ($alt) {
+            if (preg_match('/<h2>(.*)<\/h2>/U', $alt, $matches)) {
+                $altTitle = Text::html2text($matches[1]);
+            } else {
+                $altTitle = "";
+            }
             $adbid = 'adb_' . rand(1000, 100000);
             $altmarkup = '<div class="visually-hidden" aria-live="polite" id="' . $adbid . '">' . $alt . '</div>';
-            $alttxt = Text::html2text($alt);
         }
 
         $markup = '<div class="multimediaContainer" data-click-to-close="' . $this->clickToClose . '">';
         $markup .= '<img ' . $imgSizeAttrs . ' src="' . Link::getUniversalLocation($this->to) . '" class="multimedia" ';
         if ($alt) {
-            $markup .= ' alt="' . $alttxt . '" aria-described-by="' . $adbid . '"';
+            $markup .= ' alt="' . $altTitle . '"';
+            $markup .= ' aria-described-by="' . $adbid . '"';
         } else {
             $markup .= ' aria-hidden="true"';
         }
index fbc683de3993f28ce2b46fba9a8123514f8dd009..9b143480ab1c27c284866165f23113a7bcacd67d 100644 (file)
@@ -1223,4 +1223,9 @@ class Link
     {
         return $this->alt ?: $this->compiler->getLinkAlternativeText($this);
     }
+
+    public function shortenURL($url)
+    {
+        return $this->compiler->shortenURL($url);
+    }
 }
index 44ad9311a05bef78fe08e3132932d7b9db23f1d7..24e3db7689e1d3184df50907e5c13fda712f4b2a 100644 (file)
@@ -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()