/**
  * Insert resources
  *
  * @param
  * @return
  */
 static function insertResourcesIntoPageContent($a_content)
 {
     global $objDefinition, $tree, $lng;
     $ref_id = (int) $_GET["ref_id"];
     $obj_id = (int) ilObject::_lookupObjId($ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     // determine type -> group
     $type_to_grp = array();
     $type_grps = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
     foreach ($type_grps as $grp => $def) {
         foreach ($def["objs"] as $t) {
             $type_to_grp[$t] = $grp;
         }
     }
     $childs = $tree->getChilds($ref_id);
     $childs_by_type = array();
     $item_groups = array();
     foreach ($childs as $child) {
         $childs_by_type[$type_to_grp[$child["type"]]][] = $child;
         if ($child["type"] == "itgr") {
             $item_groups[(int) $child["ref_id"]] = $child["title"];
         }
     }
     // handle "by type" lists
     foreach ($type_grps as $type => $v) {
         if (is_int(strpos($a_content, "[list-" . $type . "]"))) {
             // render block
             $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
             $cnt = 0;
             if (is_array($childs_by_type[$type]) && count($childs_by_type[$type]) > 0) {
                 foreach ($childs_by_type[$type] as $child) {
                     $tpl->setCurrentBlock("row");
                     $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($child["obj_id"], "small")));
                     $tpl->setVariable("TITLE", $child["title"]);
                     $tpl->parseCurrentBlock();
                     $cnt++;
                 }
                 $tpl->setVariable("HEADER", $lng->txt("objs_" . $type));
                 $a_content = str_replace("[list-" . $type . "]", $tpl->get(), $a_content);
             } else {
                 $tpl->setCurrentBlock("row");
                 $tpl->setVariable("TITLE", $lng->txt("no_items"));
                 $tpl->parseCurrentBlock();
                 $tpl->setVariable("HEADER", $lng->txt("objs_" . $type));
                 $a_content = str_replace("[list-" . $type . "]", $tpl->get(), $a_content);
             }
         }
     }
     // handle item groups
     while (eregi("\\[(item-group-([0-9]*))\\]", $a_content, $found)) {
         $itgr_ref_id = (int) $found[2];
         // check whether this item group is child -> insert editing html
         if (isset($item_groups[$itgr_ref_id])) {
             include_once "./Modules/ItemGroup/classes/class.ilItemGroupItems.php";
             $itgr_items = new ilItemGroupItems($itgr_ref_id);
             $items = $itgr_items->getValidItems();
             // render block
             $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
             foreach ($items as $it_ref_id) {
                 $it_obj_id = ilObject::_lookupObjId($it_ref_id);
                 $it_title = ilObject::_lookupTitle($it_obj_id);
                 $tpl->setCurrentBlock("row");
                 $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($it_obj_id, "small")));
                 $tpl->setVariable("TITLE", $it_title);
                 $tpl->parseCurrentBlock();
             }
             $tpl->setVariable("HEADER", $item_groups[$itgr_ref_id]);
             $html = $tpl->get();
         } else {
             $html = "<i>" . $lng->txt("cont_element_refers_removed_itgr") . "</i>";
         }
         $a_content = eregi_replace("\\[" . $found[1] . "\\]", $html, $a_content);
     }
     return $a_content;
 }
 /**
  * Get materials of item group
  * 
  * @param int $a_item_group_id (object id)
  * @return array 
  */
 public static function getItemsByItemGroup($a_item_group_ref_id)
 {
     include_once 'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
     $ig_items = new ilItemGroupItems($a_item_group_ref_id);
     $items = $ig_items->getValidItems();
     return self::processListItems($items);
 }