Skip to content

Commit

Permalink
Content Page: Workaround for https://mantis.ilias.de/view.php?id=2659…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Dec 6, 2019
1 parent 88c1f26 commit f0aea5b
Showing 1 changed file with 57 additions and 49 deletions.
106 changes: 57 additions & 49 deletions Modules/ContentPage/classes/class.ilContentPagePageGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<?xml version="1.0" encoding="UTF-8"?>'. $linkXml);
try {
$domDoc = new DOMDocument();
$domDoc->loadXML('<?xml version="1.0" encoding="UTF-8"?>' . $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('<?xml version="1.0" encoding="UTF-8"?>', '', $linkXmlWithBlankTargets));
return;
}
}
$this->setLinkXML(str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $linkXmlWithBlankTargets));
} catch (Throwable $e) {
$this->log->error(sprintf(
'Could not manipulate page editor link XML: %s / Error Message: %s',
$linkXml,
$e->getMessage()
));
}
return;
}
}
}

0 comments on commit f0aea5b

Please sign in to comment.