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_overall = (bool)$a_rating;
73 return $this->rating_overall;
83 $this->rating = (bool)$a_rating;
103 $this->rating_block = (bool)$a_rating;
113 return $this->rating_block;
123 $this->rating_new_pages = (bool)$a_rating;
133 return $this->rating_new_pages;
143 $this->rating_categories = (bool)$a_rating;
153 return $this->rating_categories;
161 $this->public_notes = $a_val;
179 $this->imp_pages = $a_val;
189 return $this->imp_pages;
209 return $this->startpage;
219 $this->shorttitle = $a_shorttitle;
229 return $this->shorttitle;
239 $this->introduction = $a_introduction;
249 return $this->introduction;
257 return $this->style_id;
265 $this->style_id = $a_style_id;
275 $this->page_toc = $a_val;
285 return $this->page_toc;
295 if ($a_ref_id > 0 && $a_ref_id == OH_REF_ID)
305 function create($a_prevent_start_page_creation =
false)
311 $ilDB->insert(
"il_wiki_data", array(
312 "id" => array(
"integer", $this->
getId()),
313 "is_online" => array(
"integer", (
int) $this->
getOnline()),
316 "rating" => array(
"integer", (
int) $this->
getRating()),
317 "public_notes" => array(
"integer", (
int) $this->
getPublicNotes()),
322 if ($this->
getStartPage() !=
"" && !$a_prevent_start_page_creation)
324 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
326 $start_page->setWikiId($this->
getId());
328 $start_page->create();
333 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
344 function update($a_prevent_start_page_creation =
false)
348 if (!parent::update())
353 $ilDB->update(
"il_wiki_data", array(
354 "is_online" => array(
"integer", $this->
getOnline()),
358 "rating" => array(
"integer", $this->
getRating()),
365 "page_toc" => array(
"integer", $this->
getPageToc())
367 "id" => array(
"integer", $this->
getId())
371 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
373 && !$a_prevent_start_page_creation)
376 $start_page->setWikiId($this->
getId());
378 $start_page->create();
381 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
396 $query =
"SELECT * FROM il_wiki_data WHERE id = ".
397 $ilDB->quote($this->
getId(),
"integer");
398 $set = $ilDB->query(
$query);
399 $rec = $ilDB->fetchAssoc($set);
414 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
431 if (!parent::delete())
437 $query =
"DELETE FROM il_wiki_data".
438 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
439 $ilDB->manipulate(
$query);
442 include_once
"./Services/Notification/classes/class.ilNotification.php";
445 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
458 $res = $ilDB->queryF(
"SELECT id FROM il_wiki_data WHERE short = %s",
459 array(
"text"), array($a_short_title));
460 if ($ilDB->fetchAssoc(
$res))
491 return $roles ? $roles : array();
507 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
547 if ($a_node_id==
$_GET[
"ref_id"])
549 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
550 $parent_type = $parent_obj->getType();
551 if($parent_type == $this->
getType())
553 $a_node_id = (int) $tree->getParentId($a_node_id);
557 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
628 private static function _lookup($a_wiki_id, $a_field)
632 $query =
"SELECT $a_field FROM il_wiki_data WHERE id = ".
633 $ilDB->quote($a_wiki_id,
"integer");
634 $set = $ilDB->query(
$query);
635 $rec = $ilDB->fetchAssoc($set);
636 return $rec[$a_field];
658 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
659 $ilDB->manipulate(
"UPDATE il_wiki_data SET ".
661 " WHERE id = ".$ilDB->quote($a_id,
"integer")
671 include_once
'Services/Search/classes/class.ilQueryParser.php';
674 $query_parser->setCombination(
"or");
675 $query_parser->parse();
677 include_once
'Services/Search/classes/class.ilSearchResult.php';
679 if($query_parser->validate())
682 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
684 $wiki_search->setFilter(array(
'wpg'));
685 $search_result->mergeEntries($wiki_search->performSearch());
688 $entries = $search_result->getEntries();
690 $found_pages = array();
691 foreach($entries as $entry)
693 if ($entry[
"obj_id"] == $a_wiki_id && is_array($entry[
"child"]))
695 foreach($entry[
"child"] as $child)
697 $found_pages[] = array(
"page_id" => $child);
731 $set = $ilDB->query(
"SELECT * FROM il_wiki_imp_pages WHERE ".
732 " wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
" ORDER BY ord ASC "
735 $imp_pages = array();
737 while ($rec = $ilDB->fetchAssoc($set))
754 $set = $ilDB->query(
"SELECT MAX(ord) as m FROM il_wiki_imp_pages WHERE ".
755 " wiki_id = ".$ilDB->quote($a_wiki_id,
"integer")
758 $rec = $ilDB->fetchAssoc($set);
759 return (
int) $rec[
"m"];
779 $ilDB->manipulate(
"INSERT INTO il_wiki_imp_pages ".
780 "(wiki_id, ord, indent, page_id) VALUES (".
781 $ilDB->quote($this->getId(),
"integer").
",".
782 $ilDB->quote($a_nr,
"integer").
",".
783 $ilDB->quote($a_indent,
"integer").
",".
784 $ilDB->quote($a_page_id,
"integer").
799 $set = $ilDB->query(
"SELECT * FROM il_wiki_imp_pages WHERE ".
800 " wiki_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
801 " page_id = ".$ilDB->quote($a_page_id,
"integer")
803 if ($rec = $ilDB->fetchAssoc($set))
819 $ilDB->manipulate(
"DELETE FROM il_wiki_imp_pages WHERE "
820 .
" wiki_id = ".$ilDB->quote($this->getId(),
"integer")
821 .
" AND page_id = ".$ilDB->quote($a_id,
"integer")
839 foreach ($ipages as $k => $v)
841 if (isset($a_ord[$v[
"page_id"]]))
843 $ipages[$k][
"ord"] = (int) $a_ord[$v[
"page_id"]];
845 if (isset($a_indent[$v[
"page_id"]]))
847 $ipages[$k][
"indent"] = (int) $a_indent[$v[
"page_id"]];
855 foreach ($ipages as $k => $v)
857 if ($ipages[$k][
"indent"] == 2 && $c_indent == 0)
859 $ipages[$k][
"indent"] = 1;
862 $c_indent = $ipages[$k][
"indent"];
867 foreach ($ipages as $k => $v)
869 $ilDB->manipulate($q =
"UPDATE il_wiki_imp_pages SET ".
870 " ord = ".$ilDB->quote($ord,
"integer").
",".
871 " indent = ".$ilDB->quote($v[
"indent"],
"integer").
872 " WHERE wiki_id = ".$ilDB->quote($v[
"wiki_id"],
"integer").
873 " AND page_id = ".$ilDB->quote($v[
"page_id"],
"integer")
893 foreach ($ipages as $k => $v)
895 if ($ipages[$k][
"indent"] == 2 && $c_indent == 0)
897 $ipages[$k][
"indent"] = 1;
900 $c_indent = $ipages[$k][
"indent"];
904 foreach ($ipages as $k => $v)
906 $ilDB->manipulate($q =
"UPDATE il_wiki_imp_pages SET ".
907 " ord = ".$ilDB->quote($ord,
"integer").
908 ", indent = ".$ilDB->quote($v[
"indent"],
"integer").
909 " WHERE wiki_id = ".$ilDB->quote($v[
"wiki_id"],
"integer").
910 " AND page_id = ".$ilDB->quote($v[
"page_id"],
"integer")
945 $new_obj->setTitle($this->
getTitle());
960 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
964 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
965 $new_id = $style_obj->ilClone();
966 $new_obj->setStyleSheetId($new_id);
971 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
973 if (count($pages) > 0)
978 $start_page->delete();
981 foreach ($pages as $p)
985 $new_page->setTitle($page->getTitle());
986 $new_page->setWikiId($new_obj->getId());
987 $new_page->setTitle($page->getTitle());
988 $new_page->setBlocked($page->getBlocked());
989 $new_page->setRating($page->getRating());
992 $page->copy($new_page->getId(),
"", 0,
true);
996 $map[$p[
"id"]] = $new_page->getId();
1002 $new_obj->addImportantPage($map[$ip[
"page_id"]], $ip[
"ord"], $ip[
"indent"]);
1006 include_once(
"./Services/Rating/classes/class.ilRatingCategory.php");
1010 $new_rc->setParentId($new_obj->getId());
1011 $new_rc->setTitle($rc[
"title"]);
1012 $new_rc->setDescription($rc[
"description"]);