From d2f570d50940df797cdef4c108ee142ce61c112d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 16 Feb 2023 15:17:47 +0100 Subject: [PATCH] wip #5740 @0.5 --- app/Jobs/FluidbookCompiler.php | 68 ++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 3b8511705..5af7cf593 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -39,6 +39,7 @@ use Fluidbook\Tools\Links\AnchorLink; use Fluidbook\Tools\Links\ContentLink; use Fluidbook\Tools\SVG\SVGTools; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Log; use SimpleXMLElement; use SplFileInfo; @@ -2438,33 +2439,37 @@ height="0" width="0" style="display:none;visibility:hidden"> } foreach ($linksToAdd as $lta) { - /** @var $lta Link */ - // Keep this line because some properties of the link (like blend mode) are parsed with this function - $c = $lta->getHTMLContainer(); - $css[] = $lta->getCSSContainer(); - if (!isset($pages[$lta->page])) { - $pages[$lta->page] = ['normal' => []]; - $cpages[$lta->page] = ['normal' => []]; - $ctpages[$lta->page] = ['normal' => []]; - } + try { + /** @var $lta Link */ + // Keep this line because some properties of the link (like blend mode) are parsed with this function + $c = $lta->getHTMLContainer(); + $css[] = $lta->getCSSContainer(); + if (!isset($pages[$lta->page])) { + $pages[$lta->page] = ['normal' => []]; + $cpages[$lta->page] = ['normal' => []]; + $ctpages[$lta->page] = ['normal' => []]; + } - $d = $lta->getDepth(); - if ($d < 30) { - $v = 'ctpages'; - } else if ($d < 50) { - $v = 'cpages'; - } else { - $v = 'pages'; - } + $d = $lta->getDepth(); + if ($d < 30) { + $v = 'ctpages'; + } else if ($d < 50) { + $v = 'cpages'; + } else { + $v = 'pages'; + } - $lta->setInitialOrder($i); - if (!isset($$v[$lta->page][$lta->blendmode])) { - $$v[$lta->page][$lta->blendmode] = []; - } + $lta->setInitialOrder($i); + if (!isset($$v[$lta->page][$lta->blendmode])) { + $$v[$lta->page][$lta->blendmode] = []; + } - array_push($$v[$lta->page][$lta->blendmode], $lta); - $i++; + array_push($$v[$lta->page][$lta->blendmode], $lta); + $i++; + } catch (\Exception $e) { + $this->triggerLinkError($e, $lta); + } } // Make old "aftersearch" link compatible with new "extra" menu option by extracting link URL if ($link->page == 'aftersearch') { @@ -2513,6 +2518,23 @@ height="0" width="0" style="display:none;visibility:hidden"> return $css; } + /** + * @param $e \Exception + * @param $link Link + * @return void + * @throws \Exception + */ + protected function triggerLinkError($e, $link) + { + Log::error($e); + + $c=explode('\\',get_class($link)); + $type=array_pop($c); + $type=str_replace('Link','',$type); + + throw new \Exception('Error on the '.$type.' link to ' . $link->to . ' on page ' . $link->page . ' with message : ' . $e->getMessage()); + } + protected function _htmlLinkList($list) { if (!count($list)) { -- 2.39.5