8 include_once
"./Services/Object/classes/class.ilObject.php";
9 include_once (
"./Modules/Wiki/classes/class.ilWikiUtil.php");
30 function ilObjWiki($a_id = 0,$a_call_by_reference =
true)
33 $this->
ilObject($a_id,$a_call_by_reference);
43 $this->online = $a_online;
63 $this->rating = (bool)$a_rating;
83 $this->rating_block = (bool)$a_rating;
93 return $this->rating_block;
103 $this->rating_new_pages = (bool)$a_rating;
113 return $this->rating_new_pages;
123 $this->rating_categories = (bool)$a_rating;
133 return $this->rating_categories;
141 $this->public_notes = $a_val;
159 $this->imp_pages = $a_val;
169 return $this->imp_pages;
189 return $this->startpage;
199 $this->shorttitle = $a_shorttitle;
209 return $this->shorttitle;
219 $this->introduction = $a_introduction;
229 return $this->introduction;
237 return $this->style_id;
245 $this->style_id = $a_style_id;
255 $this->page_toc = $a_val;
265 return $this->page_toc;
275 if ($a_ref_id > 0 && $a_ref_id == OH_REF_ID)
285 function create($a_prevent_start_page_creation =
false)
291 $ilDB->insert(
"il_wiki_data", array(
292 "id" => array(
"integer", $this->
getId()),
293 "is_online" => array(
"integer", (
int) $this->
getOnline()),
296 "rating" => array(
"integer", (
int) $this->
getRating()),
297 "public_notes" => array(
"integer", (
int) $this->
getPublicNotes()),
302 if ($this->
getStartPage() !=
"" && !$a_prevent_start_page_creation)
304 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
306 $start_page->setWikiId($this->
getId());
308 $start_page->create();
313 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
324 function update($a_prevent_start_page_creation =
false)
328 if (!parent::update())
333 $ilDB->update(
"il_wiki_data", array(
334 "is_online" => array(
"integer", $this->
getOnline()),
337 "rating" => array(
"integer", $this->
getRating()),
344 "page_toc" => array(
"integer", $this->
getPageToc())
346 "id" => array(
"integer", $this->
getId())
350 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
352 && !$a_prevent_start_page_creation)
355 $start_page->setWikiId($this->
getId());
357 $start_page->create();
360 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
375 $query =
"SELECT * FROM il_wiki_data WHERE id = ".
376 $ilDB->quote($this->
getId(),
"integer");
377 $set = $ilDB->query(
$query);
378 $rec = $ilDB->fetchAssoc($set);
392 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
409 if (!parent::delete())
415 $query =
"DELETE FROM il_wiki_data".
416 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
417 $ilDB->manipulate(
$query);
420 include_once
"./Services/Notification/classes/class.ilNotification.php";
423 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
436 $res = $ilDB->queryF(
"SELECT id FROM il_wiki_data WHERE short = %s",
437 array(
"text"), array($a_short_title));
438 if ($ilDB->fetchAssoc(
$res))
469 return $roles ? $roles : array();
485 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
525 if ($a_node_id==
$_GET[
"ref_id"])
527 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
528 $parent_type = $parent_obj->getType();
529 if($parent_type == $this->
getType())
531 $a_node_id = (int) $tree->getParentId($a_node_id);
535 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
594 private static function _lookup($a_wiki_id, $a_field)
598 $query =
"SELECT $a_field FROM il_wiki_data WHERE id = ".
599 $ilDB->quote($a_wiki_id,
"integer");
600 $set = $ilDB->query(
$query);
601 $rec = $ilDB->fetchAssoc($set);
602 return $rec[$a_field];
624 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
625 $ilDB->manipulate(
"UPDATE il_wiki_data SET ".
627 " WHERE id = ".$ilDB->quote($a_id,
"integer")
637 include_once
'Services/Search/classes/class.ilQueryParser.php';
640 $query_parser->setCombination(
"or");
641 $query_parser->parse();
643 include_once
'Services/Search/classes/class.ilSearchResult.php';
645 if($query_parser->validate())
648 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
650 $wiki_search->setFilter(array(
'wpg'));
651 $search_result->mergeEntries($wiki_search->performSearch());
654 $entries = $search_result->getEntries();
656 $found_pages = array();
657 foreach($entries as $entry)
659 if ($entry[
"obj_id"] == $a_wiki_id && is_array($entry[
"child"]))
661 foreach($entry[
"child"] as $child)
663 $found_pages[] = $child;
697 $set = $ilDB->query(
"SELECT * FROM il_wiki_imp_pages WHERE ".
698 " wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
" ORDER BY ord ASC "
701 $imp_pages = array();
703 while ($rec = $ilDB->fetchAssoc($set))
720 $set = $ilDB->query(
"SELECT MAX(ord) as m FROM il_wiki_imp_pages WHERE ".
721 " wiki_id = ".$ilDB->quote($a_wiki_id,
"integer")
724 $rec = $ilDB->fetchAssoc($set);
725 return (
int) $rec[
"m"];
745 $ilDB->manipulate(
"INSERT INTO il_wiki_imp_pages ".
746 "(wiki_id, ord, indent, page_id) VALUES (".
747 $ilDB->quote($this->getId(),
"integer").
",".
748 $ilDB->quote($a_nr,
"integer").
",".
749 $ilDB->quote($a_indent,
"integer").
",".
750 $ilDB->quote($a_page_id,
"integer").
765 $set = $ilDB->query(
"SELECT * FROM il_wiki_imp_pages WHERE ".
766 " wiki_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
767 " page_id = ".$ilDB->quote($a_page_id,
"integer")
769 if ($rec = $ilDB->fetchAssoc($set))
785 $ilDB->manipulate(
"DELETE FROM il_wiki_imp_pages WHERE "
786 .
" wiki_id = ".$ilDB->quote($this->getId(),
"integer")
787 .
" AND page_id = ".$ilDB->quote($a_id,
"integer")
805 foreach ($ipages as $k => $v)
807 if (isset($a_ord[$v[
"page_id"]]))
809 $ipages[$k][
"ord"] = (int) $a_ord[$v[
"page_id"]];
811 if (isset($a_indent[$v[
"page_id"]]))
813 $ipages[$k][
"indent"] = (int) $a_indent[$v[
"page_id"]];
821 foreach ($ipages as $k => $v)
823 if ($ipages[$k][
"indent"] == 2 && $c_indent == 0)
825 $ipages[$k][
"indent"] = 1;
828 $c_indent = $ipages[$k][
"indent"];
833 foreach ($ipages as $k => $v)
835 $ilDB->manipulate($q =
"UPDATE il_wiki_imp_pages SET ".
836 " ord = ".$ilDB->quote($ord,
"integer").
",".
837 " indent = ".$ilDB->quote($v[
"indent"],
"integer").
838 " WHERE wiki_id = ".$ilDB->quote($v[
"wiki_id"],
"integer").
839 " AND page_id = ".$ilDB->quote($v[
"page_id"],
"integer")
859 foreach ($ipages as $k => $v)
861 if ($ipages[$k][
"indent"] == 2 && $c_indent == 0)
863 $ipages[$k][
"indent"] = 1;
866 $c_indent = $ipages[$k][
"indent"];
870 foreach ($ipages as $k => $v)
872 $ilDB->manipulate($q =
"UPDATE il_wiki_imp_pages SET ".
873 " ord = ".$ilDB->quote($ord,
"integer").
874 ", indent = ".$ilDB->quote($v[
"indent"],
"integer").
875 " WHERE wiki_id = ".$ilDB->quote($v[
"wiki_id"],
"integer").
876 " AND page_id = ".$ilDB->quote($v[
"page_id"],
"integer")
911 $new_obj->setTitle($this->
getTitle());
925 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
929 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
930 $new_id = $style_obj->ilClone();
931 $new_obj->setStyleSheetId($new_id);
936 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
938 if (count($pages) > 0)
943 $start_page->delete();
946 foreach ($pages as $p)
950 $new_page->setTitle($page->getTitle());
951 $new_page->setWikiId($new_obj->getId());
952 $new_page->setTitle($page->getTitle());
953 $new_page->setBlocked($page->getBlocked());
954 $new_page->setRating($page->getRating());
957 $new_page->setXMLContent($page->copyXMLContent(
true));
958 $new_page->buildDom();
960 $map[$p[
"id"]] = $new_page->getId();
966 $new_obj->addImportantPage($map[$ip[
"page_id"]], $ip[
"ord"], $ip[
"indent"]);
970 include_once(
"./Services/Rating/classes/class.ilRatingCategory.php");
974 $new_rc->setParentId($new_obj->getId());
975 $new_rc->setTitle($rc[
"title"]);
976 $new_rc->setDescription($rc[
"description"]);