8 include_once
"./Services/Object/classes/class.ilObject.php";
9 include_once
"./Modules/Wiki/classes/class.ilWikiUtil.php";
10 include_once
"./Services/AdvancedMetaData/interfaces/interface.ilAdvancedMetaDataSubItems.php";
32 function ilObjWiki($a_id = 0,$a_call_by_reference =
true)
35 $this->
ilObject($a_id,$a_call_by_reference);
45 $this->online = $a_online;
65 $this->rating_overall = (bool)$a_rating;
75 return $this->rating_overall;
85 $this->rating = (bool)$a_rating;
105 $this->rating_block = (bool)$a_rating;
115 return $this->rating_block;
125 $this->rating_new_pages = (bool)$a_rating;
135 return $this->rating_new_pages;
145 $this->rating_categories = (bool)$a_rating;
155 return $this->rating_categories;
163 $this->public_notes = $a_val;
181 $this->imp_pages = $a_val;
191 return $this->imp_pages;
211 return $this->startpage;
221 $this->shorttitle = $a_shorttitle;
231 return $this->shorttitle;
241 $this->introduction = $a_introduction;
251 return $this->introduction;
259 return $this->style_id;
267 $this->style_id = $a_style_id;
277 $this->page_toc = $a_val;
287 return $this->page_toc;
297 $this->empty_page_templ = $a_val;
317 if ($a_ref_id > 0 && $a_ref_id == OH_REF_ID)
327 function create($a_prevent_start_page_creation =
false)
333 $ilDB->insert(
"il_wiki_data", array(
334 "id" => array(
"integer", $this->
getId()),
335 "is_online" => array(
"integer", (
int) $this->
getOnline()),
338 "rating" => array(
"integer", (
int) $this->
getRating()),
339 "public_notes" => array(
"integer", (
int) $this->
getPublicNotes()),
345 if ($this->
getStartPage() !=
"" && !$a_prevent_start_page_creation)
347 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
349 $start_page->setWikiId($this->
getId());
351 $start_page->create();
356 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
367 function update($a_prevent_start_page_creation =
false)
371 if (!parent::update())
376 $ilDB->update(
"il_wiki_data", array(
377 "is_online" => array(
"integer", $this->
getOnline()),
381 "rating" => array(
"integer", $this->
getRating()),
388 "page_toc" => array(
"integer", $this->
getPageToc()),
391 "id" => array(
"integer", $this->
getId())
395 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
397 && !$a_prevent_start_page_creation)
400 $start_page->setWikiId($this->
getId());
402 $start_page->create();
405 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
420 $query =
"SELECT * FROM il_wiki_data WHERE id = ".
421 $ilDB->quote($this->
getId(),
"integer");
422 $set = $ilDB->query(
$query);
423 $rec = $ilDB->fetchAssoc($set);
439 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
456 if (!parent::delete())
462 $query =
"DELETE FROM il_wiki_data".
463 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
464 $ilDB->manipulate(
$query);
467 include_once
"./Services/Notification/classes/class.ilNotification.php";
470 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
483 $res = $ilDB->queryF(
"SELECT id FROM il_wiki_data WHERE short = %s",
484 array(
"text"), array($a_short_title));
485 if ($ilDB->fetchAssoc(
$res))
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")
948 if(!$cp_options->isRootNode($this->getRefId()))
953 $new_obj->setTitle($this->
getTitle());
968 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
972 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
973 $new_id = $style_obj->ilClone();
974 $new_obj->setStyleSheetId($new_id);
979 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
981 if (count($pages) > 0)
986 $start_page->delete();
989 foreach ($pages as $p)
993 $new_page->setTitle($page->getTitle());
994 $new_page->setWikiId($new_obj->getId());
995 $new_page->setTitle($page->getTitle());
996 $new_page->setBlocked($page->getBlocked());
997 $new_page->setRating($page->getRating());
998 $new_page->hideAdvancedMetadata($page->isAdvancedMetadataHidden());
1001 $page->copy($new_page->getId(),
"", 0,
true);
1005 $map[$p[
"id"]] = $new_page->getId();
1011 $new_obj->addImportantPage($map[$ip[
"page_id"]], $ip[
"ord"], $ip[
"indent"]);
1015 include_once(
"./Services/Rating/classes/class.ilRatingCategory.php");
1019 $new_rc->setParentId($new_obj->getId());
1020 $new_rc->setTitle($rc[
"title"]);
1021 $new_rc->setDescription($rc[
"description"]);
1037 include_once(
"./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
1058 if ($a_template_page == 0)
1062 include_once(
"./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
1065 if (count($ts) == 1)
1068 $a_template_page =
$t[
"wpage_id"];
1075 $page->setWikiId($this->
getId());
1079 $page->setRating(
true);
1083 $page->setWikiRefId($this->
getRefId());
1087 if ($a_template_page > 0)
1090 $orig->copy($page->getId());
1093 include_once
"Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
1110 if($a_sub_type ==
"wpg")
1112 $lng->loadLanguageModule(
"wiki");
1113 include_once
"./Modules/Wiki/classes/class.ilWikiPage.php";