/**
  * Get data of first active link resource
  *
  * @return array link data array
  */
 function __readLink()
 {
     include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
     include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
     if (ilParameterAppender::_isEnabled()) {
         return $this->link_data = ilParameterAppender::_append($tmp =& ilLinkResourceItems::_getFirstLink($this->obj_id));
     }
     return $this->link_data = ilLinkResourceItems::_getFirstLink($this->obj_id);
 }
 /**
  * @see ilTable2GUI::fillRow()
  */
 protected function fillRow($a_set)
 {
     global $ilCtrl, $lng;
     if (!stristr($a_set['target'], '|')) {
         $this->tpl->setCurrentBlock('external');
         $this->tpl->setVariable('VAL_ID', $a_set['id']);
         $this->tpl->setVariable('VAL_TARGET', $a_set['target']);
         $this->tpl->parseCurrentBlock();
     } else {
         $ilCtrl->setParameterByClass('ilinternallinkgui', 'postvar', 'tar_' . $a_set['id']);
         $trigger_link = array(get_class($this->parent_obj), 'ilinternallinkgui');
         $trigger_link = $ilCtrl->getLinkTargetByClass($trigger_link, '', false, true, false);
         $ilCtrl->setParameterByClass('ilinternallinkgui', 'postvar', '');
         $this->tpl->setCurrentBlock('internal');
         $this->tpl->setVariable('VAL_ID', $a_set['id']);
         $this->tpl->setVariable('VAL_TRIGGER_INTERNAL', $trigger_link);
         $this->tpl->setVariable('TXT_TRIGGER_INTERNAL', $this->lng->txt('edit'));
         // info about current link
         if ($a_set['target']) {
             $parts = explode('|', $a_set['target']);
             $this->tpl->setVariable('VAL_INTERNAL_TYPE', $parts[0]);
             $this->tpl->setVariable('VAL_INTERNAL_ID', $parts[1]);
             $parts = ilLinkInputGUI::getTranslatedValue($a_set['target']);
             $this->tpl->setVariable('TXT_TRIGGER_INFO', $parts['type'] . ' "' . $parts['name'] . '"');
         }
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable('TXT_LAST_CHECK', $this->lng->txt('webr_last_check_table'));
     $this->tpl->setVariable('LAST_CHECK', $a_set['last_check'] ? ilDatePresentation::formatDate(new ilDateTime($a_set['last_check'], IL_CAL_UNIX)) : $this->lng->txt('no_date'));
     // Valid
     $this->tpl->setVariable('VAL_VALID', ilUtil::formCheckbox($a_set['valid'], 'links[' . $a_set['id'] . '][vali]', 1));
     // Active
     $this->tpl->setVariable('VAL_ACTIVE', ilUtil::formCheckbox($a_set['active'], 'links[' . $a_set['id'] . '][act]', 1));
     // Valid
     $this->tpl->setVariable('VAL_CHECK', ilUtil::formCheckbox($a_set['disable_check'], 'links[' . $a_set['id'] . '][che]', 1));
     // Dynamic parameters
     foreach ($a_set['params'] as $param_id => $param) {
         $this->tpl->setCurrentBlock('dyn_del_row');
         $this->tpl->setVariable('TXT_DYN_DEL', $this->lng->txt('delete'));
         $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'param_id', $param_id);
         $this->tpl->setVariable('DYN_DEL_LINK', $ilCtrl->getLinkTarget($this->getParentObject(), 'deleteParameter'));
         $this->tpl->setVariable('VAL_DYN', ilParameterAppender::parameterToInfo($param['name'], $param['value']));
         $this->tpl->parseCurrentBlock();
     }
     if ($a_set['params']) {
         $this->tpl->setCurrentBlock('dyn_del_rows');
         $this->tpl->setVariable('TXT_EXISTING', $this->lng->txt('links_existing_params'));
         $this->tpl->parseCurrentBlock();
     }
     if (ilParameterAppender::_isEnabled()) {
         $this->tpl->setCurrentBlock('dyn_add');
         $this->tpl->setVariable('TXT_DYN_ADD', $this->lng->txt('links_add_param'));
         $this->tpl->setVariable('TXT_DYN_NAME', $this->lng->txt('links_name'));
         $this->tpl->setVariable('TXT_DYN_VALUE', $this->lng->txt('links_value'));
         $this->tpl->setVariable('VAL_DYN_NAME', $a_set['name']);
         $this->tpl->setVariable('DYN_ID', $a_set['id']);
         $this->tpl->setVariable('SEL_DYN_VAL', ilUtil::formSelect($a_set['value'] ? $a_set['value'] : 0, 'links[' . $a_set['id'] . '][val]', ilParameterAppender::_getOptionSelect(), false, true));
         $this->tpl->parseCurrentBlock();
     }
     if (in_array($a_set['id'], $this->getInvalidLinks())) {
         $this->tpl->setVariable('CSS_ROW', 'warn');
     }
     // Check
     $this->tpl->setVariable('VAL_ID', $a_set['id']);
     $this->tpl->setVariable('VAL_CHECKBOX', ilUtil::formCheckbox(false, 'link_ids[]', $a_set['id']));
     // Column title
     $this->tpl->setVariable('TXT_TITLE', $this->lng->txt('title'));
     $this->tpl->setVariable('VAL_TITLE', ilUtil::prepareFormOutput($a_set['title']));
     $this->tpl->setVariable('TXT_DESC', $this->lng->txt('description'));
     $this->tpl->setVariable('VAL_DESC', ilUtil::prepareFormOutput($a_set['description']));
     // Column Target
     $this->tpl->setVariable('TXT_TARGET', $this->lng->txt('target'));
 }
 function callLink()
 {
     if ($_REQUEST["link_id"]) {
         $obj_id = $this->object->getId();
         include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
         $items = new ilLinkResourceItems($obj_id);
         $item = $items->getItem($_REQUEST["link_id"]);
         if ($item["target"]) {
             // handle internal links
             if (stristr($item["target"], "|")) {
                 $parts = explode("|", $item["target"]);
                 if ($parts[0] == "page") {
                     $parts[0] = "pg";
                 }
                 include_once "./Services/Link/classes/class.ilLink.php";
                 $item["target"] = ilLink::_getStaticLink($parts[1], $parts[0]);
                 if ($parts[0] == "term") {
                     $parts[0] = "git";
                     $item["target"] = ilLink::_getStaticLink(0, $parts[0], true, "&target=git_" . $parts[1]);
                 }
             }
             include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
             if (ilParameterAppender::_isEnabled()) {
                 $item = ilParameterAppender::_append($item);
             }
             //var_dump($item); exit;
             $this->redirectToLink($this->ref_id, $obj_id, $item["target"]);
         }
     }
 }
 function callLink()
 {
     if ($_REQUEST["link_id"]) {
         $obj_id = $this->object->getId();
         include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
         $items = new ilLinkResourceItems($obj_id);
         $item = $items->getItem($_REQUEST["link_id"]);
         if ($item["target"]) {
             $item["target"] = $this->handleSubItemLinks($item["target"]);
             include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
             if (ilParameterAppender::_isEnabled()) {
                 $item = ilParameterAppender::_append($item);
             }
             $this->redirectToLink($this->ref_id, $obj_id, $item["target"]);
         }
     }
 }