/**
  * showRecord
  * a_val = 
  */
 public function renderRecord()
 {
     global $ilTabs, $tpl, $ilCtrl, $lng;
     $rctpl = new ilTemplate("tpl.record_view.html", true, true, "Modules/DataCollection");
     $ilTabs->setTabActive("id_content");
     $view_id = self::_getViewDefinitionId($this->record_obj);
     if (!$view_id) {
         $ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
     }
     // please do not use ilPageObjectGUI directly here, use derived class
     // ilDataCollectionRecordViewViewdefinitionGUI
     //$pageObj = new ilPageObjectGUI("dclf", $view_id);
     // see ilObjDataCollectionGUI->executeCommand about instantiation
     include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinitionGUI.php";
     $pageObj = new ilDataCollectionRecordViewViewdefinitionGUI($this->record_obj->getTableId(), $view_id);
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $pageObj->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
     $html = $pageObj->getHTML();
     $rctpl->addCss("./Services/COPage/css/content.css");
     $rctpl->fillCssFiles();
     $table = ilDataCollectionCache::getTableCache($this->record_obj->getTableId());
     foreach ($table->getFields() as $field) {
         //ILIAS_Ref_Links
         $pattern = '/\\[dcliln field="' . preg_quote($field->getTitle(), "/") . '"\\](.*?)\\[\\/dcliln\\]/';
         if (preg_match($pattern, $html)) {
             $html = preg_replace($pattern, $this->record_obj->getRecordFieldSingleHTML($field->getId(), $this->setOptions("\$1")), $html);
         }
         //DataCollection Ref Links
         $pattern = '/\\[dclrefln field="' . preg_quote($field->getTitle(), "/") . '"\\](.*?)\\[\\/dclrefln\\]/';
         if (preg_match($pattern, $html)) {
             $this->currentField = $field;
             $html = preg_replace_callback($pattern, array($this, "doReplace"), $html);
         }
         $pattern = '/\\[ext tableOf="' . preg_quote($field->getTitle(), "/") . '" field="(.*?)"\\]/';
         if (preg_match($pattern, $html)) {
             $this->currentField = $field;
             $html = preg_replace_callback($pattern, array($this, "doExtReplace"), $html);
         }
         $html = str_ireplace("[" . $field->getTitle() . "]", $this->record_obj->getRecordFieldHTML($field->getId()), $html);
     }
     $rctpl->setVariable("CONTENT", $html);
     //Permanent Link
     include_once "./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php";
     $perma_link = new ilPermanentLinkGUI("dcl", $_GET["ref_id"], "_" . $_GET['record_id']);
     $rctpl->setVariable("PERMA_LINK", $perma_link->getHTML());
     $tpl->setContent($rctpl->get());
 }
 /**
  * @param bool $editComments
  */
 public function renderRecord($editComments = false)
 {
     global $ilTabs, $tpl, $ilCtrl, $lng;
     $rctpl = new ilTemplate("tpl.record_view.html", false, true, "Modules/DataCollection");
     $ilTabs->setTabActive("id_content");
     $view_id = self::_getViewDefinitionId($this->record_obj);
     if (!$view_id) {
         $ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
     }
     // see ilObjDataCollectionGUI->executeCommand about instantiation
     include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinitionGUI.php";
     $pageObj = new ilDataCollectionRecordViewViewdefinitionGUI($this->record_obj->getTableId(), $view_id);
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $pageObj->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
     $html = $pageObj->getHTML();
     $rctpl->addCss("./Services/COPage/css/content.css");
     $rctpl->fillCssFiles();
     $table = ilDataCollectionCache::getTableCache($this->record_obj->getTableId());
     foreach ($table->getRecordFields() as $field) {
         //ILIAS_Ref_Links
         $pattern = '/\\[dcliln field="' . preg_quote($field->getTitle(), "/") . '"\\](.*?)\\[\\/dcliln\\]/';
         if (preg_match($pattern, $html)) {
             $html = preg_replace($pattern, $this->record_obj->getRecordFieldSingleHTML($field->getId(), $this->setOptions("\$1")), $html);
         }
         //DataCollection Ref Links
         $pattern = '/\\[dclrefln field="' . preg_quote($field->getTitle(), "/") . '"\\](.*?)\\[\\/dclrefln\\]/';
         if (preg_match($pattern, $html)) {
             $this->currentField = $field;
             $html = preg_replace_callback($pattern, array($this, "doReplace"), $html);
         }
         $pattern = '/\\[ext tableOf="' . preg_quote($field->getTitle(), "/") . '" field="(.*?)"\\]/';
         if (preg_match($pattern, $html)) {
             $this->currentField = $field;
             $html = preg_replace_callback($pattern, array($this, "doExtReplace"), $html);
         }
         $html = str_ireplace("[" . $field->getTitle() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
     }
     foreach ($table->getStandardFields() as $field) {
         $html = str_ireplace("[" . $field->getId() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
     }
     $rctpl->setVariable("CONTENT", $html);
     //Permanent Link
     $perma_link = new ilPermanentLinkGUI("dcl", $_GET["ref_id"], "_" . $_GET['record_id']);
     $tpl->setVariable('PRMLINK', $perma_link->getHTML());
     // Buttons for previous/next records
     if ($this->is_enabled_paging) {
         $prevNextLinks = $this->renderPrevNextLinks();
         $rctpl->setVariable('PREV_NEXT_RECORD_LINKS', $prevNextLinks);
         $ilCtrl->clearParameters($this);
         // #14083
         $rctpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this));
         $rctpl->setVariable('RECORD', $lng->txt('dcl_record'));
         $rctpl->setVariable('RECORD_FROM_TOTAL', sprintf($lng->txt('dcl_record_from_total'), $this->current_record_position, count($this->record_ids)));
         $rctpl->setVariable('SELECT_OPTIONS', $this->renderSelectOptions());
     }
     // Edit Button
     if ($this->record_obj->hasPermissionToEdit((int) $_GET['ref_id'])) {
         $button = ilLinkButton::getInstance();
         $ilCtrl->setParameterByClass('ildatacollectionrecordeditgui', 'table_id', $this->table->getId());
         $ilCtrl->setParameterByClass('ildatacollectionrecordeditgui', 'redirect', ilDataCollectionRecordEditGUI::REDIRECT_DETAIL);
         $ilCtrl->saveParameterByClass('ildatacollectionrecordeditgui', 'record_id');
         $button->setUrl($ilCtrl->getLinkTargetByClass('ildatacollectionrecordeditgui', 'edit'));
         $button->setCaption($lng->txt('dcl_edit_record'), false);
         $rctpl->setVariable('EDIT_RECORD_BUTTON', $button->render());
     }
     // Comments
     if ($this->table->getPublicCommentsEnabled()) {
         $rctpl->setVariable('COMMENTS', $this->renderComments($editComments));
     }
     $tpl->setContent($rctpl->get());
 }
 public function executeCommand()
 {
     global $ilCtrl, $ilTabs, $ilNavigationHistory, $ilUser, $tpl;
     // Navigation History
     $link = $ilCtrl->getLinkTarget($this, "render");
     if ($this->object != NULL) {
         $ilNavigationHistory->addItem($this->object->getRefId(), $link, "dcl");
     }
     //Direct-Link Resource
     if ($_GET["dcl_gtr"]) {
         $ilCtrl->setCmdClass("ildatacollectionrecordviewgui");
         $_GET['record_id'] = $_GET["dcl_gtr"];
         $ilCtrl->setCmd("renderRecord");
     }
     $next_class = $ilCtrl->getNextClass($this);
     $cmd = $ilCtrl->getCmd();
     if (!$this->getCreationMode() && $next_class != "ilinfoscreengui" && !$this->checkPermissionBool("read")) {
         $tpl->getStandardTemplate();
         $tpl->setContent("Permission Denied.");
         return;
     }
     switch ($next_class) {
         case "ilinfoscreengui":
             $this->prepareOutput();
             $ilTabs->activateTab("id_info");
             $this->infoScreenForward();
             break;
         case "ilcommonactiondispatchergui":
             include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
             $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
             $this->ctrl->forwardCommand($gui);
             break;
         case "ilpermissiongui":
             $this->prepareOutput();
             $ilTabs->activateTab("id_permissions");
             include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
             $perm_gui = new ilPermissionGUI($this);
             $this->ctrl->forwardCommand($perm_gui);
             break;
         case "ilobjectcopygui":
             include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
             $cp = new ilObjectCopyGUI($this);
             $cp->setType("dcl");
             $tpl->getStandardTemplate();
             $this->ctrl->forwardCommand($cp);
             break;
         case "ildatacollectionfieldlistgui":
             $this->prepareOutput();
             $this->addListFieldsTabs("list_fields");
             $ilTabs->setTabActive("id_fields");
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionFieldListGUI.php";
             $fieldlist_gui = new ilDataCollectionFieldListGUI($this, $this->table_id);
             $this->ctrl->forwardCommand($fieldlist_gui);
             break;
         case "ildatacollectiontableeditgui":
             $this->prepareOutput();
             $ilTabs->setTabActive("id_fields");
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionTableEditGUI.php";
             $tableedit_gui = new ilDataCollectionTableEditGUI($this);
             $this->ctrl->forwardCommand($tableedit_gui);
             break;
         case "ildatacollectionfieldeditgui":
             $this->prepareOutput();
             $ilTabs->activateTab("id_fields");
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionFieldEditGUI.php";
             $fieldedit_gui = new ilDataCollectionFieldEditGUI($this, $this->table_id, $_REQUEST["field_id"]);
             $this->ctrl->forwardCommand($fieldedit_gui);
             break;
         case "ildatacollectionrecordlistgui":
             $this->addHeaderAction(false);
             $this->prepareOutput();
             $ilTabs->activateTab("id_records");
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordListGUI.php";
             $recordlist_gui = new ilDataCollectionRecordListGUI($this, $this->table_id);
             $this->ctrl->forwardCommand($recordlist_gui);
             break;
         case "ildatacollectionrecordeditgui":
             $this->prepareOutput();
             $ilTabs->activateTab("id_records");
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordEditGUI.php";
             $recordedit_gui = new ilDataCollectionRecordEditGUI($this);
             $this->ctrl->forwardCommand($recordedit_gui);
             break;
         case "ildatacollectionrecordviewviewdefinitiongui":
             $this->prepareOutput();
             // page editor will set its own tabs
             $ilTabs->clearTargets();
             $ilTabs->setBackTarget($this->lng->txt("back"), $ilCtrl->getLinkTargetByClass("ildatacollectionfieldlistgui", "listFields"));
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinitionGUI.php";
             $recordedit_gui = new ilDataCollectionRecordViewViewdefinitionGUI($this->table_id);
             // needed for editor
             $recordedit_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
             if (!$this->checkPermissionBool("write")) {
                 $recordedit_gui->setEnableEditing(false);
             }
             $ret = $this->ctrl->forwardCommand($recordedit_gui);
             if ($ret != "") {
                 $this->tpl->setContent($ret);
             }
             $ilTabs->removeTab('history');
             $ilTabs->removeTab('clipboard');
             // Fixme
             $ilTabs->removeTab('pg');
             break;
         case "ildatacollectionrecordlistviewdefinitiongui":
             $this->prepareOutput();
             $this->addListFieldsTabs("list_viewdefinition");
             $ilTabs->setTabActive("id_fields");
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordListViewdefinitionGUI.php";
             $recordlist_gui = new ilDataCollectionRecordListViewdefinitionGUI($this, $this->table_id);
             $this->ctrl->forwardCommand($recordlist_gui);
             break;
         case "ilobjfilegui":
             $this->prepareOutput();
             $ilTabs->setTabActive("id_records");
             include_once "./Modules/File/classes/class.ilObjFile.php";
             $file_gui = new ilObjFile($this);
             $this->ctrl->forwardCommand($file_gui);
             break;
         case "ildatacollectionrecordviewgui":
             $this->prepareOutput();
             include_once "./Modules/DataCollection/classes/class.ilDataCollectionRecordViewGUI.php";
             $recordview_gui = new ilDataCollectionRecordViewGUI($this);
             $this->ctrl->forwardCommand($recordview_gui);
             $ilTabs->clearTargets();
             $ilTabs->setBackTarget($this->lng->txt("back"), $ilCtrl->getLinkTargetByClass("ilObjDataCollectionGUI", ""));
             break;
         case "ilratinggui":
             $rgui = new ilRatingGUI();
             $rgui->setObject($_GET['record_id'], "dcl_record", $_GET["field_id"], "dcl_field");
             $rgui->executeCommand();
             $ilCtrl->redirectByClass("ilDataCollectionRecordListGUI", "listRecords");
             break;
         default:
             return parent::executeCommand();
     }
     return true;
 }