/** * TABLE NewsForContext: Get table HTML. * */ public function getNewsForContextTable() { global $lng; $news_item = new ilNewsItem(); $news_item->setContextObjId($this->getContextObjId()); $news_item->setContextObjType($this->getContextObjType()); $news_item->setContextSubObjId($this->getContextSubObjId()); $news_item->setContextSubObjType($this->getContextSubObjType()); $perm_ref_id = 0; if (in_array($this->getContextObjType(), array("cat", "grp", "crs", "root"))) { $data = $news_item->getNewsForRefId($_GET["ref_id"], false, false, 0, true, false, true, true); } else { $perm_ref_id = $_GET["ref_id"]; if ($this->getContextSubObjId() > 0) { $data = $news_item->queryNewsForContext(false, 0, "", true, true); } else { $data = $news_item->queryNewsForContext(); } } include_once "Services/News/classes/class.ilNewsForContextTableGUI.php"; $table_gui = new ilNewsForContextTableGUI($this, "getNewsForContextTable", $perm_ref_id); $table_gui->setTitle($lng->txt("news_table_news_for_context")); $table_gui->setRowTemplate("tpl.table_row_news_for_context.html", "Services/News"); $table_gui->setData($data); $table_gui->setDefaultOrderField("creation_date"); $table_gui->setDefaultOrderDirection("desc"); $table_gui->addMultiCommand("confirmDeletionNewsItems", $lng->txt("delete")); $table_gui->setTitle($lng->txt("news"), "icon_news.png", $lng->txt("news")); $table_gui->setSelectAllCheckbox("news_id"); return $table_gui->getHTML(); }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "news": $mob_id = null; if ($a_rec["MobId"] > 0) { $mob_id = $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]); } $c = (int) $a_rec["ContextObjId"] . ":" . $a_rec["ContextObjType"] . ":" . (int) $a_rec["ContextSubObjId"] . ":" . $a_rec["ContextSubObjType"]; $context = $a_mapping->getMapping("Services/News", "news_context", $c); $context = explode(":", $context); //var_dump($c); //var_dump($a_mapping->mappings["Services/News"]["news_context"]); include_once "./Services/News/classes/class.ilNewsItem.php"; $newObj = new ilNewsItem(); $newObj->setTitle($a_rec["Title"]); $newObj->setContent($a_rec["Content"]); $newObj->setPriority($a_rec["Priority"]); $newObj->setContextObjId($context[0]); $newObj->setContextObjType($context[1]); $newObj->setContextSubObjId($context[2]); $newObj->setContextSubObjType($context[3]); $newObj->setContentType($a_rec["ContentType"]); $newObj->setVisibility($a_rec["Visibility"]); $newObj->setContentLong($a_rec["ContentLong"]); $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]); $newObj->setMobId($mob_id); $newObj->setPlaytime($a_rec["Playtime"]); $newObj->create(); $a_mapping->addMapping("Services/News", "news", $a_rec["Id"], $newObj->getId()); break; } }