ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilDclDetailedViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
28 protected int $tableview_id;
31 protected ?ilDclBaseRecordModel $record = null;
32
33 public function __construct(int $tableview_id)
34 {
35 global $DIC;
36
37 $this->tableview_id = $tableview_id;
38 $this->http = $DIC->http();
39 $this->refinery = $DIC->refinery();
40 $this->locator = $DIC['ilLocator'];
41
42 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
43 $this->setStyleId($DIC->contentStyle()->domain()->styleForRefId($ref_id)->getEffectiveStyleId());
44
45 if (!ilPageObject::_exists('dclf', $tableview_id, '-', true)) {
46 $viewdef = new ilDclDetailedViewDefinition();
47 $viewdef->setId($tableview_id);
48 $viewdef->setParentId(ilObject2::_lookupObjectId($ref_id));
49 $viewdef->create();
50 } elseif (!ilPageObject::_lookupActive($tableview_id, 'dclf')) {
52 $page->setActive(true);
53 foreach ($page->getAllPCIds() as $id) {
54 $page->getContentObjectForPcId($id)->disable();
55 }
56 $page->update();
57 }
58
60
61 // content style (using system defaults)
62 $this->tpl->setCurrentBlock("SyntaxStyle");
63 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
64 $this->tpl->parseCurrentBlock();
65
66 $this->tpl->setCurrentBlock("ContentStyle");
67 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
68 $this->tpl->parseCurrentBlock();
69 }
70
71 public function setRecord(ilDclBaseRecordModel $record): void
72 {
73 $this->record = $record;
74 }
75
79 public function executeCommand(): string
80 {
81 $this->ctrl->setParameter($this, "dclv", $this->getPageObject()->getId());
82 $title = $this->lng->txt("dcl_view_viewdefinition");
83 $this->setPresentationTitle($title);
84 $this->locator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
85 return parent::executeCommand();
86 }
87
88 public function showPage(): string
89 {
90 $this->tpl->addCss(ilObjStyleSheet::getContentStylePath($this->getStyleId()));
91 $replacements = [];
92 foreach ($this->getPageObject()->getAvailablePlaceholders() as $field) {
93 $replacements['[[' . $field->getId() . ']]'] = '[[' . $field->getTitle() . ']]';
94 }
95 if ($this->getOutputMode() === ilPageObjectGUI::EDIT) {
96 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_placeholder_info'));
97 $this->obj->setXMLContent(strtr($this->obj->getXMLContent(), $replacements));
98 $this->obj->update();
99 }
100 if ($this->getOutputMode() === ilPageObjectGUI::PREVIEW) {
101 return strtr(parent::showPage(), $replacements);
102 }
103
104 return parent::showPage();
105 }
106
107 public function finishEditing(): void
108 {
109 $replacements = [];
110 foreach ($this->getPageObject()->getAvailablePlaceholders() as $field) {
111 $replacements['[[' . $field->getTitle() . ']]'] = '[[' . $field->getId() . ']]';
112 }
113 $this->obj->setXMLContent(strtr($this->obj->getXMLContent(), $replacements));
114 $this->obj->update();
115 parent::finishEditing();
116 }
117
118 public function postOutputProcessing(string $a_output): string
119 {
120 $replacements = [];
121 foreach ($this->getPageObject()->getAvailablePlaceholders() as $field) {
122 if ($this->record !== null) {
123 $replacements['[[' . $field->getId() . ']]'] = $this->record->getRecordFieldSingleHTML($field->getId());
124 }
125 }
126
127 return strtr($a_output, $replacements);
128 }
129}
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
@ilCtrl_Calls ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI,...
postOutputProcessing(string $a_output)
Finalizing output processing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static _lookupObjectId(int $ref_id)
Class ilPageObjectGUI.
setStyleId(int $a_styleid)
setPresentationTitle(string $a_title="")
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26