ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 if ($this->getOutputMode() === ilPageObjectGUI::EDIT) {
92 $legend = $this->getPageObject()->getAvailablePlaceholders();
93 if (sizeof($legend)) {
94 $html = "<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ":<br>";
95 foreach ($legend as $field) {
96 $html .= "[[" . $field->getID() . ']]<i style="opacity: 0.3"> - ' . $field->getTitle() . '</i><br>';
97 }
98 $this->setPrependingHtml($html . "</span>");
99 }
100 }
101
102 return parent::showPage();
103 }
104
105 public function postOutputProcessing(string $a_output): string
106 {
107 foreach ($this->getPageObject()->getAvailablePlaceholders() as $field) {
108 if ($this->record === null) {
109 $replacement = '<b>' . $field->getTitle() . '</b>';
110 } else {
111 $replacement = $this->record->getRecordFieldSingleHTML($field->getId());
112 }
113 $a_output = str_replace('[[' . $field->getId() . ']]', $replacement, $a_output);
114 }
115
116 return $a_output;
117 }
118}
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="")
setPrependingHtml(string $a_prependinghtml)
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