ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjectMetaDataBlockGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("Services/Block/classes/class.ilBlockGUI.php");
6
18{
19 public static $block_type = "advmd";
20
21 protected $record; // [ilAdvancedMDRecord]
22 protected $values; // [ilAdvancedMDValues]
23 protected $callback; // [string]
24
25 protected static $records = array(); // [array]
26
30 public function __construct(ilAdvancedMDRecord $a_record, $a_decorator_callback = null)
31 {
32 global $DIC;
33
34 $this->ctrl = $DIC->ctrl();
35 $this->lng = $DIC->language();
36
37
39
40 $this->record = $a_record;
41 $this->callback = $a_decorator_callback;
42
43 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
44 $this->setTitle($translations->getTitleForLanguage($this->lng->getLangKey()));
45 $this->setBlockId("advmd_" . $this->record->getRecordId());
46 $this->setEnableNumInfo(false);
47 $this->allow_moving = false;
48 }
49
53 public function getBlockType() : string
54 {
55 return self::$block_type;
56 }
57
61 protected function isRepositoryObject() : bool
62 {
63 return false;
64 }
65
69 public static function getScreenMode()
70 {
71 return IL_SCREEN_SIDE;
72 }
73
74 public function setValues(ilAdvancedMDValues $a_values)
75 {
76 $this->values = $a_values;
77 }
78
82 public function executeCommand()
83 {
84 $ilCtrl = $this->ctrl;
85
86 $next_class = $ilCtrl->getNextClass();
87 $cmd = $ilCtrl->getCmd("getHTML");
88
89 switch ($next_class) {
90 default:
91 return $this->$cmd();
92 }
93 }
94
98 public function fillDataSection()
99 {
100 $this->setDataSection($this->getLegacyContent());
101 }
102
103 //
104 // New rendering
105 //
106
107 protected $new_rendering = true;
108
109
113 protected function getLegacyContent() : string
114 {
115 $btpl = new ilTemplate("tpl.advmd_block.html", true, true, "Services/Object");
116
117 // see ilAdvancedMDRecordGUI::parseInfoPage()
118
121
122 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
123 include_once('Services/ADT/classes/class.ilADTFactory.php');
124
125 // this correctly binds group and definitions
126 $this->values->read();
127
128 $defs = $this->values->getDefinitions();
129 foreach ($this->values->getADTGroup()->getElements() as $element_id => $element) {
130 $field_translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($defs[$element_id]->getRecordId());
131
132 $btpl->setCurrentBlock("item");
133 $btpl->setVariable("CAPTION", $field_translations->getTitleForLanguage($element_id, $this->lng->getLangKey()));
134 if ($element->isNull()) {
135 $value = "-";
136 } else {
137 $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element);
138
139 if ($element instanceof ilADTLocation) {
140 $value->setSize("100%", "200px");
141 }
142
143 if (in_array($element->getType(), array("MultiEnum", "Enum", "Text"))) {
144 $value->setDecoratorCallBack($this->callback);
145 }
146
147 $value = $value->getHTML();
148 }
149 $btpl->setVariable("VALUE", $value);
150 $btpl->parseCurrentBlock();
151 }
152
153 $html = $btpl->get();
154
156
157 return $html;
158 }
159}
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
static getInstance()
Get singleton.
This class represents a block method of a block.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
setTitle($a_title)
Set Title.
setBlockId($a_block_id=0)
Set Block Id.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
getLegacyContent()
Get legacy content.string
__construct(ilAdvancedMDRecord $a_record, $a_decorator_callback=null)
Constructor.
setValues(ilAdvancedMDValues $a_values)
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
static getScreenMode()
Get Screen Mode for current command.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc