ILIAS  release_8 Revision v8.24
class.ilContentPagePageGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected bool $isEmbeddedMode = false;
29 protected string $language = '-';
30
31 public function __construct(int $a_id = 0, int $a_old_nr = 0, bool $isEmbeddedMode = false, string $language = '')
32 {
33 parent::__construct(self::OBJ_TYPE, $a_id, $a_old_nr, false, $language);
34 $this->setTemplateTargetVar('ADM_CONTENT');
35 $this->setTemplateOutput(false);
36 $this->isEmbeddedMode = $isEmbeddedMode;
37 }
38
39 public function getProfileBackUrl(): string
40 {
41 if ($this->isEmbeddedMode) {
42 return '';
43 }
44
45 return parent::getProfileBackUrl();
46 }
47
48 public function setDefaultLinkXml(): void
49 {
50 parent::setDefaultLinkXml();
51
52 if ($this->isEmbeddedMode) {
53 $linkXml = $this->getLinkXML();
54
55 try {
56 $linkXml = str_replace('<LinkTargets></LinkTargets>', '', $linkXml);
57
58 $domDoc = new DOMDocument();
59 $domDoc->loadXML('<?xml version="1.0" encoding="UTF-8"?>' . $linkXml);
60
61 $xpath = new DOMXPath($domDoc);
62 $links = $xpath->query('//IntLinkInfos/IntLinkInfo');
63
64 if ($links->length > 0) {
65 foreach ($links as $link) {
67 $link->attributes->getNamedItem('LinkTarget')->nodeValue = '_blank';
68 }
69 }
70
71 $linkXmlWithBlankTargets = $domDoc->saveXML();
72
73 $this->setLinkXml(str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $linkXmlWithBlankTargets));
74 } catch (Throwable $e) {
75 $this->log->error(sprintf(
76 'Could not manipulate page editor link XML: %s / Error Message: %s',
77 $linkXml,
78 $e->getMessage()
79 ));
80 }
81 }
82 }
83
84 public function finishEditing(): void
85 {
86 $this->ctrl->redirectByClass(ilObjContentPageGUI::class, 'view');
87 }
88
89 public function getAdditionalPageActions(): array
90 {
91 $this->ctrl->setParameterByClass(ilObjContentPageGUI::class, 'page_editor_style', '1');
92
93 $tabs = [
94 $this->ui->factory()->link()->standard(
95 $this->lng->txt('obj_sty'),
96 $this->ctrl->getLinkTargetByClass([
97 ilRepositoryGUI::class,
98 ilObjContentPageGUI::class
99 ], self::UI_CMD_STYLES_EDIT)
100 )
101 ];
102
103 $this->ctrl->setParameterByClass(ilObjContentPageGUI::class, 'page_editor_style', null);
104
105 return $tabs;
106 }
107}
@ilCtrl_Calls ilContentPagePageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI @ilCtrl_Calls ...
__construct(int $a_id=0, int $a_old_nr=0, bool $isEmbeddedMode=false, string $language='')
getAdditionalPageActions()
Get additional page actions.
Class ilPageObjectGUI.
setTemplateOutput(bool $a_output=true)
setTemplateTargetVar(string $a_variable)
Interface ilContentPageObjectConstants.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc