From f0aea5bb1f0adf2da39548e257b02511f7b365b6 Mon Sep 17 00:00:00 2001 From: mjansenDatabay Date: Fri, 6 Dec 2019 18:35:26 +0100 Subject: [PATCH] Content Page: Workaround for https://mantis.ilias.de/view.php?id=26594#c64176 --- .../classes/class.ilContentPagePageGUI.php | 106 ++++++++++-------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/Modules/ContentPage/classes/class.ilContentPagePageGUI.php b/Modules/ContentPage/classes/class.ilContentPagePageGUI.php index 238bf64859bb..07742a7e8a9f 100644 --- a/Modules/ContentPage/classes/class.ilContentPagePageGUI.php +++ b/Modules/ContentPage/classes/class.ilContentPagePageGUI.php @@ -7,64 +7,72 @@ * @ilCtrl_Calls ilContentPagePageGUI: ilPublicUserProfileGUI, ilNoteGUI * @ilCtrl_Calls ilContentPagePageGUI: ilPropertyFormGUI, ilInternalLinkGUI */ -class ilContentPagePageGUI extends \ilPageObjectGUI implements \ilContentPageObjectConstants +class ilContentPagePageGUI extends ilPageObjectGUI implements ilContentPageObjectConstants { - /** @var bool */ - protected $isEmbeddedMode = false; + /** @var bool */ + protected $isEmbeddedMode = false; - /** - * ilContentPagePageGUI constructor. - * @param int $a_id - * @param int $a_old_nr - * @param bool $isEmbeddedMode - */ - public function __construct($a_id = 0, $a_old_nr = 0, $isEmbeddedMode = false) - { - parent::__construct(self::OBJ_TYPE, $a_id, $a_old_nr); - $this->setTemplateTargetVar('ADM_CONTENT'); - $this->setTemplateOutput(false); - $this->isEmbeddedMode = $isEmbeddedMode; - } + /** + * ilContentPagePageGUI constructor. + * @param int $a_id + * @param int $a_old_nr + * @param bool $isEmbeddedMode + */ + public function __construct($a_id = 0, $a_old_nr = 0, $isEmbeddedMode = false) + { + parent::__construct(self::OBJ_TYPE, $a_id, $a_old_nr); + $this->setTemplateTargetVar('ADM_CONTENT'); + $this->setTemplateOutput(false); + $this->isEmbeddedMode = $isEmbeddedMode; + } - /** - * @inheritdoc - */ - public function getProfileBackUrl() - { - if ($this->isEmbeddedMode) { - return ''; - } + /** + * @inheritdoc + */ + public function getProfileBackUrl() + { + if ($this->isEmbeddedMode) { + return ''; + } - return parent::getProfileBackUrl(); - } + return parent::getProfileBackUrl(); + } - /** - * @inheritdoc - */ - public function setDefaultLinkXml() - { - parent::setDefaultLinkXml(); + /** + * @inheritdoc + */ + public function setDefaultLinkXml() + { + parent::setDefaultLinkXml(); - if ($this->isEmbeddedMode) { - $linkXml = $this->getLinkXML(); + if ($this->isEmbeddedMode) { + $linkXml = $this->getLinkXML(); - $domDoc = new \DOMDocument(); - $domDoc->loadXML(''. $linkXml); + try { + $domDoc = new DOMDocument(); + $domDoc->loadXML('' . $linkXml); - $xpath = new \DOMXPath($domDoc); - $links = $xpath->query('//IntLinkInfos/IntLinkInfo'); + $xpath = new DOMXPath($domDoc); + $links = $xpath->query('//IntLinkInfos/IntLinkInfo'); - if ($links->length > 0) { - foreach ($links as $link) { - /** @var $link \DOMNode */ - $link->attributes->getNamedItem('LinkTarget')->nodeValue = '_blank'; - } - } + if ($links->length > 0) { + foreach ($links as $link) { + /** @var $link DOMNode */ + $link->attributes->getNamedItem('LinkTarget')->nodeValue = '_blank'; + } + } - $linkXmlWithBlankTargets = $domDoc->saveXML(); + $linkXmlWithBlankTargets = $domDoc->saveXML(); - $this->setLinkXML(str_replace('', '', $linkXmlWithBlankTargets)); - return; - } - } + $this->setLinkXML(str_replace('', '', $linkXmlWithBlankTargets)); + } catch (Throwable $e) { + $this->log->error(sprintf( + 'Could not manipulate page editor link XML: %s / Error Message: %s', + $linkXml, + $e->getMessage() + )); + } + return; + } + } } \ No newline at end of file