/**
  * get html 
  * @return
  */
 public function getHTML()
 {
     global $lng;
     $lng->loadLanguageModule('webr');
     foreach ($this->getSubItemIds(true) as $sub_item) {
         if (is_object($this->getHighlighter()) and strlen($this->getHighlighter()->getContent($this->getObjId(), $sub_item))) {
             $this->tpl->setCurrentBlock('sea_fragment');
             $this->tpl->setVariable('TXT_FRAGMENT', $this->getHighlighter()->getContent($this->getObjId(), $sub_item));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('subitem');
         $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('webr'));
         $this->tpl->setVariable('SEPERATOR', ':');
         $link_data = ilLinkResourceItems::lookupItem($this->getObjId(), $sub_item);
         $link_data = ilParameterAppender::_append($link_data);
         // handle internal links (#10620)
         if (stristr($link_data["target"], "|")) {
             $parts = explode("|", $link_data["target"]);
             if ($parts[0] == "page") {
                 $parts[0] = "pg";
             }
             if ($parts[0] == "term") {
                 $parts[0] = "git";
             }
             $link_data["target"] = ilLink::_getStaticLink($parts[1], $parts[0]);
         }
         #$this->getItemListGUI()->setChildId($sub_item);
         $this->tpl->setVariable('LINK', $link_data['target']);
         $this->tpl->setVariable('TARGET', '_blank');
         $this->tpl->setVariable('TITLE', $link_data['title']);
         $this->tpl->parseCurrentBlock();
     }
     $this->showDetailsLink();
     return $this->tpl->get();
 }
 function __getWebResourceLinks()
 {
     global $objDefinition;
     include_once 'Modules/WebResource/classes/class.ilLinkResourceItems.php';
     $link_res_obj = new ilLinkResourceItems($this->getObjId());
     foreach ($check_links = $link_res_obj->getCheckItems($this->getCheckPeriod()) as $item_data) {
         // #10091 - internal
         if (strpos($item_data['target'], '|')) {
             $parts = explode('|', $item_data['target']);
             if (sizeof($parts) == 2 && is_numeric($parts[1]) && $objDefinition->isAllowedInRepository($parts[0])) {
                 $link[] = array('page_id' => $item_data['link_id'], 'obj_id' => $this->getObjId(), 'type' => 'webr', 'complete' => $item_data['target'], 'scheme' => 'internal', 'obj_type' => $parts[0], 'ref_id' => $parts[1]);
                 continue;
             }
         }
         // external
         $url_data = @parse_url($item_data['target']);
         // PUH, HTTP_REQUEST needs a beginning http://
         if (!$url_data['scheme']) {
             $item_data['target'] = 'http://' . $item_data['target'];
         }
         $link[] = array('page_id' => $item_data['link_id'], 'obj_id' => $this->getObjId(), 'type' => 'webr', 'complete' => $item_data['target'], 'scheme' => isset($url_data['scheme']) ? $url_data['scheme'] : 'http', 'host' => isset($url_data['host']) ? $url_data['host'] : $url_data['path']);
     }
     return $link ? $link : array();
 }
 /**
  * Check whether there is only one active link in the web resource.
  * In this case this link is shown in a new browser window
  *
  */
 static function _checkDirectLink($a_obj_id)
 {
     if (isset(self::$single_link[$a_obj_id])) {
         return self::$single_link[$a_obj_id];
     }
     include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
     return self::$single_link[$a_obj_id] = ilLinkResourceItems::_isSingular($a_obj_id);
 }
 /**
  * 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);
 }
 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"]);
         }
     }
 }
 /**
  * Write webresource xml
  * @param ilXmlWriter $writer
  * @return 
  */
 public function toXML(ilXmlWriter $writer)
 {
     $attribs = array("obj_id" => "il_" . IL_INST_ID . "_webr_" . $this->getId());
     $writer->xmlStartTag('WebLinks', $attribs);
     // LOM MetaData
     include_once 'Services/MetaData/classes/class.ilMD2XML.php';
     $md2xml = new ilMD2XML($this->getId(), $this->getId(), 'webr');
     $md2xml->startExport();
     $writer->appendXML($md2xml->getXML());
     // Sorting
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     switch (ilContainerSortingSettings::_lookupSortMode($this->getId())) {
         case ilContainer::SORT_MANUAL:
             $writer->xmlElement('Sorting', array('type' => 'Manual'));
             break;
         case ilContainer::SORT_TITLE:
         default:
             $writer->xmlElement('Sorting', array('type' => 'Title'));
             break;
     }
     // All links
     include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
     $links = new ilLinkResourceItems($this->getId());
     $links->toXML($writer);
     $writer->xmlEndTag('WebLinks');
     return true;
 }
 /**
  * Copy web resource items
  *
  * @access public
  * @param int obj_id of new object
  * 
  */
 public function cloneItems($a_new_id)
 {
     include_once 'Modules/WebResource/classes/class.ilParameterAppender.php';
     $appender = new ilParameterAppender($this->getLinkResourceId());
     foreach ($this->getAllItems() as $item) {
         $new_item = new ilLinkResourceItems($a_new_id);
         $new_item->setTitle($item['title']);
         $new_item->setDescription($item['description']);
         $new_item->setTarget($item['target']);
         $new_item->setActiveStatus($item['active']);
         $new_item->setDisableCheckStatus($item['disable_check']);
         $new_item->setLastCheckDate($item['last_check']);
         $new_item->setValidStatus($item['valid']);
         $new_item->add(true);
         // Add parameters
         foreach (ilParameterAppender::_getParams($item['link_id']) as $param_id => $data) {
             $appender->setName($data['name']);
             $appender->setValue($data['value']);
             $appender->add($new_item->getLinkId());
         }
         unset($new_item);
     }
     return true;
 }
 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"]);
         }
     }
 }