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