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 7/** 8 * Metadata block 9 * 10 * @author Jörg Lützenkirchen <luetzenkirchen@leifos.com> 11 * @version $Id$ 12 * 13 * @ilCtrl_IsCalledBy ilObjectMetaDataBlockGUI: ilColumnGUI 14 * 15 * @ingroup ServicesObject 16 */ 17class ilObjectMetaDataBlockGUI extends ilBlockGUI 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 27 /** 28 * Constructor 29 */ 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 parent::__construct(); 37 38 $this->record = $a_record; 39 $this->callback = $a_decorator_callback; 40 41 $this->setTitle($this->record->getTitle()); 42 $this->setBlockId("advmd_" . $this->record->getRecordId()); 43 $this->setEnableNumInfo(false); 44 $this->allow_moving = false; 45 } 46 47 /** 48 * @inheritdoc 49 */ 50 public function getBlockType() : string 51 { 52 return self::$block_type; 53 } 54 55 /** 56 * @inheritdoc 57 */ 58 protected function isRepositoryObject() : bool 59 { 60 return false; 61 } 62 63 /** 64 * Get Screen Mode for current command. 65 */ 66 public static function getScreenMode() 67 { 68 return IL_SCREEN_SIDE; 69 } 70 71 public function setValues(ilAdvancedMDValues $a_values) 72 { 73 $this->values = $a_values; 74 } 75 76 /** 77 * execute command 78 */ 79 public function executeCommand() 80 { 81 $ilCtrl = $this->ctrl; 82 83 $next_class = $ilCtrl->getNextClass(); 84 $cmd = $ilCtrl->getCmd("getHTML"); 85 86 switch ($next_class) { 87 default: 88 return $this->$cmd(); 89 } 90 } 91 92 /** 93 * Fill data section 94 */ 95 public function fillDataSection() 96 { 97 $this->setDataSection($this->getLegacyContent()); 98 } 99 100 // 101 // New rendering 102 // 103 104 protected $new_rendering = true; 105 106 107 /** 108 * @inheritdoc 109 */ 110 protected function getLegacyContent() : string 111 { 112 $btpl = new ilTemplate("tpl.advmd_block.html", true, true, "Services/Object"); 113 114 // see ilAdvancedMDRecordGUI::parseInfoPage() 115 116 $old_dt = ilDatePresentation::useRelativeDates(); 117 ilDatePresentation::setUseRelativeDates(false); 118 119 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php'); 120 include_once('Services/ADT/classes/class.ilADTFactory.php'); 121 122 // this correctly binds group and definitions 123 $this->values->read(); 124 125 $defs = $this->values->getDefinitions(); 126 foreach ($this->values->getADTGroup()->getElements() as $element_id => $element) { 127 $btpl->setCurrentBlock("item"); 128 $btpl->setVariable("CAPTION", $defs[$element_id]->getTitle()); 129 if ($element->isNull()) { 130 $value = "-"; 131 } else { 132 $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element); 133 134 if ($element instanceof ilADTLocation) { 135 $value->setSize("100%", "200px"); 136 } 137 138 if (in_array($element->getType(), array("MultiEnum", "Enum", "Text"))) { 139 $value->setDecoratorCallBack($this->callback); 140 } 141 142 $value = $value->getHTML(); 143 } 144 $btpl->setVariable("VALUE", $value); 145 $btpl->parseCurrentBlock(); 146 } 147 148 $html = $btpl->get(); 149 150 ilDatePresentation::setUseRelativeDates($old_dt); 151 152 return $html; 153 } 154} 155