ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectMetaDataBlockGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 public static string $block_type = "advmd";
30 protected static array $records = [];
31
34 protected ?array $callback;
35
43 public function __construct(ilAdvancedMDRecord $record, ?array $decorator_callback = null)
44 {
45 global $DIC;
46
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49
50
52
53 $this->record = $record;
54 $this->callback = $decorator_callback;
55
56 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
57 $this->setTitle($translations->getTitleForLanguage($this->lng->getLangKey()));
58 $this->setBlockId("advmd_" . $this->record->getRecordId());
59 $this->setEnableNumInfo(false);
60 $this->allow_moving = false;
61 }
62
66 public function getBlockType(): string
67 {
68 return self::$block_type;
69 }
70
74 protected function isRepositoryObject(): bool
75 {
76 return false;
77 }
78
82 public static function getScreenMode(): string
83 {
84 return IL_SCREEN_SIDE;
85 }
86
87 public function setValues(ilAdvancedMDValues $a_values): void
88 {
89 $this->values = $a_values;
90 }
91
95 public function executeCommand(): void
96 {
97 $this->ctrl->getNextClass();
98 $cmd = $this->ctrl->getCmd("getHTML");
99 $this->$cmd();
100 }
101
105 protected function getLegacyContent(): string
106 {
107 $btpl = new ilTemplate("tpl.advmd_block.html", true, true, "components/ILIAS/ILIASObject");
108
109 // see ilAdvancedMDRecordGUI::parseInfoPage()
110
113
114 // this correctly binds group and definitions
115 $this->values->read();
116
117 $defs = $this->values->getDefinitions();
118 foreach ($this->values->getADTGroup()->getElements() as $element_id => $element) {
119 $field_translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($defs[$element_id]->getRecordId());
120
121 $btpl->setCurrentBlock("item");
122 $btpl->setVariable("CAPTION", $field_translations->getTitleForLanguage($element_id, $this->lng->getLangKey()));
123 if ($element->isNull()) {
124 $value = "-";
125 } else {
126 $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element);
127
128 if (in_array($element->getType(), ["MultiEnum", "Enum", "Text"])) {
129 $value->setDecoratorCallBack($this->callback);
130 }
131
132 $value = $value->getHTML();
133 }
134 $btpl->setVariable("VALUE", $value);
135 $btpl->parseCurrentBlock();
136 }
137
138 $html = $btpl->get();
139
141
142 return $html;
143 }
144}
const IL_SCREEN_SIDE
This class represents a block method of a block.
setTitle(string $a_title)
setBlockId(string $a_block_id="0")
setEnableNumInfo(bool $a_enablenuminfo)
static setUseRelativeDates(bool $a_status)
set use relative dates
getLegacyContent()
Get legacy content.string
setValues(ilAdvancedMDValues $a_values)
isRepositoryObject()
Returns whether block has a corresponding repository object.
static getScreenMode()
Get Screen Mode for current command.
__construct(ilAdvancedMDRecord $record, ?array $decorator_callback=null)
Takes as an optional second input an array consisting of the object that the method that should be ca...
special template class to simplify handling of ITX/PEAR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26