/**
  * insert item title
  *
  * @access	private
  * @param	object		$a_tpl		template object
  * @param	string		$a_title	item title
  */
 public function insertTitle()
 {
     if ($this->restrict_to_goto) {
         $this->default_command = array("frame" => "", "link" => $this->buildGotoLink());
     }
     // begin-patch lok
     if (!$this->default_command || !$this->getCommandsStatus() && !$this->restrict_to_goto || $this->title_link_disabled) {
         $this->tpl->setCurrentBlock("item_title");
         $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
         $this->tpl->parseCurrentBlock();
     } else {
         $this->default_command['link'] = $this->modifyTitleLink($this->default_command['link']);
         $this->default_command["link"] = $this->modifySAHSlaunch($this->default_command["link"], $this->default_command["frame"]);
         if ($this->default_command["frame"] != "") {
             $this->tpl->setCurrentBlock("title_linked_frame");
             $this->tpl->setVariable("TARGET_TITLE_LINKED", $this->default_command["frame"]);
             $this->tpl->parseCurrentBlock();
         }
         // workaround for repository frameset
         #var_dump("<pre>",$this->default_command['link'],"</pre>");
         $this->default_command["link"] = $this->appendRepositoryFrameParameter($this->default_command["link"]);
         #var_dump("<pre>",$this->default_command['link'],"</pre>");
         // the default command is linked with the title
         $this->tpl->setCurrentBlock("item_title_linked");
         $this->tpl->setVariable("TXT_TITLE_LINKED", $this->getTitle());
         $this->tpl->setVariable("HREF_TITLE_LINKED", $this->default_command["link"]);
         // has preview?
         include_once "./Services/Preview/classes/class.ilPreview.php";
         if (ilPreview::hasPreview($this->obj_id, $this->type)) {
             include_once "./Services/Preview/classes/class.ilPreviewGUI.php";
             // get context for access checks later on
             $access_handler = null;
             $context;
             switch ($this->context) {
                 case self::CONTEXT_WORKSPACE:
                 case self::CONTEXT_WORKSPACE_SHARING:
                     $context = ilPreviewGUI::CONTEXT_WORKSPACE;
                     include_once "./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
                     $access_handler = new ilWorkspaceAccessHandler();
                     break;
                 default:
                     global $ilAccess;
                     $context = ilPreviewGUI::CONTEXT_REPOSITORY;
                     $access_handler = $ilAccess;
                     break;
             }
             $preview = new ilPreviewGUI($this->ref_id, $context, $this->obj_id, $access_handler);
             $preview_status = ilPreview::lookupRenderStatus($this->obj_id);
             $preview_status_class = "";
             $preview_text_topic = "preview_show";
             if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
                 $preview_status_class = "ilPreviewStatusNone";
                 $preview_text_topic = "preview_none";
             }
             $this->tpl->setCurrentBlock("item_title_linked");
             $this->tpl->setVariable("PREVIEW_STATUS_CLASS", $preview_status_class);
             $this->tpl->setVariable("SRC_PREVIEW_ICON", ilUtil::getImagePath("preview.png", "Services/Preview"));
             $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt($preview_text_topic));
             $this->tpl->setVariable("SCRIPT_PREVIEW_CLICK", $preview->getJSCall($this->getUniqueItemId(true)));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->parseCurrentBlock();
     }
     if ($this->bold_title == true) {
         $this->tpl->touchBlock('bold_title_start');
         $this->tpl->touchBlock('bold_title_end');
     }
 }
 /**
  * function parses stored value in database to a html output for eg. the record list gui.
  *
  * @param                             $value
  * @param ilDataCollectionRecordField $record_field
  *
  * @return mixed
  */
 public function parseHTML($value, ilDataCollectionRecordField $record_field, $link = true)
 {
     global $ilAccess, $ilCtrl, $lng;
     switch ($this->id) {
         case self::INPUTFORMAT_DATETIME:
             $html = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATETIME));
             break;
         case self::INPUTFORMAT_FILE:
             if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
                 $html = "";
                 break;
             }
             $file_obj = new ilObjFile($value, false);
             $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "record_id", $record_field->getRecord()->getId());
             $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "field_id", $record_field->getField()->getId());
             $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>';
             if (ilPreview::hasPreview($file_obj->getId())) {
                 ilPreview::createPreview($file_obj);
                 // Create preview if not already existing
                 $preview = new ilPreviewGUI((int) $_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $ilAccess);
                 $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
                 $preview_status_class = "";
                 $preview_text_topic = "preview_show";
                 if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
                     $preview_status_class = "ilPreviewStatusNone";
                     $preview_text_topic = "preview_none";
                 }
                 $wrapper_html_id = 'record_field_' . $record_field->getId();
                 $script_preview_click = $preview->getJSCall($wrapper_html_id);
                 $preview_title = $lng->txt($preview_text_topic);
                 $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
                 $html = '<div id="' . $wrapper_html_id . '">' . $html;
                 $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="' . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon . '" height="16" width="16"></a></span></div>';
             }
             break;
         case self::INPUTFORMAT_MOB:
             $mob = new ilObjMediaObject($value, false);
             $med = $mob->getMediaItem('Standard');
             if (!$med->location) {
                 $html = "";
                 break;
             }
             $arr_properties = $record_field->getField()->getProperties();
             $is_linked_field = $arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_MOB];
             $has_view = ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId());
             if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) {
                 // Image
                 $dir = ilObjMediaObject::_getDirectory($mob->getId());
                 $width = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
                 $height = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
                 $html = ilUtil::img($dir . "/" . $med->location, '', $width, $height);
                 if ($is_linked_field and $has_view and $link) {
                     $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
                     $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $html . '</a>';
                 }
             } else {
                 // Video/Audio
                 $mpl = new ilMediaPlayerGUI($med->getId(), '');
                 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
                 $mpl->setMimeType($med->getFormat());
                 $mpl->setDisplayWidth((int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH] . 'px');
                 $mpl->setDisplayHeight((int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT] . 'px');
                 $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
                 $html = $mpl->getPreviewHtml();
                 if ($is_linked_field and $has_view) {
                     global $lng;
                     $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
                     $html = $html . '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $lng->txt('details') . '</a>';
                 }
             }
             break;
         case self::INPUTFORMAT_BOOLEAN:
             switch ($value) {
                 case 0:
                     $im = ilUtil::getImagePath('icon_not_ok.svg');
                     break;
                 case 1:
                     $im = ilUtil::getImagePath('icon_ok.svg');
                     break;
             }
             $html = "<img src='" . $im . "'>";
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_TEXT:
             //Property URL
             $arr_properties = $record_field->getField()->getProperties();
             if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
                 $link = $value;
                 if (preg_match("/^[a-z0-9!#\$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i", $value)) {
                     $value = "mailto:" . $value;
                 } elseif (!preg_match('~(^(news|(ht|f)tp(s?)\\://){1}\\S+)~i', $value)) {
                     return $link;
                 }
                 $link = $this->shortenLink($link);
                 $html = "<a target='_blank' href='" . $value . "'>" . $link . "</a>";
             } elseif ($arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_TEXT] and $link and ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId())) {
                 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
                 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $value . '</a>';
             } else {
                 $html = $value;
             }
             break;
         default:
             $html = $value;
             break;
     }
     return $html;
 }