8 include_once
"./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 = $a_rating;
81 $this->public_notes = $a_val;
99 $this->imp_pages = $a_val;
109 return $this->imp_pages;
129 return $this->startpage;
139 $this->shorttitle = $a_shorttitle;
149 return $this->shorttitle;
159 $this->introduction = $a_introduction;
169 return $this->introduction;
177 return $this->style_id;
185 $this->style_id = $a_style_id;
195 $this->page_toc = $a_val;
205 return $this->page_toc;
211 function create($a_prevent_start_page_creation =
false)
217 $ilDB->insert(
"il_wiki_data", array(
218 "id" => array(
"integer", $this->
getId()),
219 "is_online" => array(
"integer", (
int) $this->
getOnline()),
222 "rating" => array(
"integer", (
int) $this->
getRating()),
223 "public_notes" => array(
"integer", (
int) $this->
getPublicNotes()),
228 if ($this->
getStartPage() !=
"" && !$a_prevent_start_page_creation)
230 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
232 $start_page->setWikiId($this->
getId());
234 $start_page->create();
239 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
250 function update($a_prevent_start_page_creation =
false)
254 if (!parent::update())
259 $ilDB->update(
"il_wiki_data", array(
260 "is_online" => array(
"integer", $this->
getOnline()),
263 "rating" => array(
"integer", $this->
getRating()),
267 "page_toc" => array(
"integer", $this->
getPageToc())
269 "id" => array(
"integer", $this->
getId())
273 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
275 && !$a_prevent_start_page_creation)
278 $start_page->setWikiId($this->
getId());
280 $start_page->create();
283 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
298 $query =
"SELECT * FROM il_wiki_data WHERE id = ".
299 $ilDB->quote($this->
getId(),
"integer");
300 $set = $ilDB->query(
$query);
301 $rec = $ilDB->fetchAssoc($set);
312 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
329 if (!parent::delete())
335 $query =
"DELETE FROM il_wiki_data".
336 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
337 $ilDB->manipulate(
$query);
340 include_once
"./Services/Notification/classes/class.ilNotification.php";
343 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
356 $res = $ilDB->queryF(
"SELECT id FROM il_wiki_data WHERE short = %s",
357 array(
"text"), array($a_short_title));
358 if ($ilDB->fetchAssoc(
$res))
389 return $roles ? $roles : array();
405 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
445 if ($a_node_id==
$_GET[
"ref_id"])
447 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
448 $parent_type = $parent_obj->getType();
449 if($parent_type == $this->
getType())
451 $a_node_id = (int) $tree->getParentId($a_node_id);
455 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
490 private static function _lookup($a_wiki_id, $a_field)
494 $query =
"SELECT $a_field FROM il_wiki_data WHERE id = ".
495 $ilDB->quote($a_wiki_id,
"integer");
496 $set = $ilDB->query(
$query);
497 $rec = $ilDB->fetchAssoc($set);
498 return $rec[$a_field];
520 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
521 $ilDB->manipulate(
"UPDATE il_wiki_data SET ".
523 " WHERE id = ".$ilDB->quote($a_id,
"integer")
533 include_once
'Services/Search/classes/class.ilQueryParser.php';
536 $query_parser->setCombination(
"or");
537 $query_parser->parse();
539 include_once
'Services/Search/classes/class.ilSearchResult.php';
541 if($query_parser->validate())
544 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
546 $wiki_search->setFilter(array(
'wpg'));
547 $search_result->mergeEntries($wiki_search->performSearch());
550 $entries = $search_result->getEntries();
552 $found_pages = array();
553 foreach($entries as $entry)
555 if ($entry[
"obj_id"] == $a_wiki_id && is_array($entry[
"child"]))
557 foreach($entry[
"child"] as $child)
559 $found_pages[] = $child;
593 $set = $ilDB->query(
"SELECT * FROM il_wiki_imp_pages WHERE ".
594 " wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
" ORDER BY ord ASC "
597 $imp_pages = array();
599 while ($rec = $ilDB->fetchAssoc($set))
616 $set = $ilDB->query(
"SELECT MAX(ord) as m FROM il_wiki_imp_pages WHERE ".
617 " wiki_id = ".$ilDB->quote($a_wiki_id,
"integer")
620 $rec = $ilDB->fetchAssoc($set);
621 return (
int) $rec[
"m"];
638 $ilDB->manipulate(
"INSERT INTO il_wiki_imp_pages ".
639 "(wiki_id, ord, indent, page_id) VALUES (".
640 $ilDB->quote($this->getId(),
"integer").
",".
641 $ilDB->quote($nr,
"integer").
",".
642 $ilDB->quote(0,
"integer").
",".
643 $ilDB->quote($a_page_id,
"integer").
658 $set = $ilDB->query(
"SELECT * FROM il_wiki_imp_pages WHERE ".
659 " wiki_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
660 " page_id = ".$ilDB->quote($a_page_id,
"integer")
662 if ($rec = $ilDB->fetchAssoc($set))
678 $ilDB->manipulate(
"DELETE FROM il_wiki_imp_pages WHERE "
679 .
" wiki_id = ".$ilDB->quote($this->getId(),
"integer")
680 .
" AND page_id = ".$ilDB->quote($a_id,
"integer")
698 foreach ($ipages as $k => $v)
700 if (isset($a_ord[$v[
"page_id"]]))
702 $ipages[$k][
"ord"] = (int) $a_ord[$v[
"page_id"]];
704 if (isset($a_indent[$v[
"page_id"]]))
706 $ipages[$k][
"indent"] = (int) $a_indent[$v[
"page_id"]];
714 foreach ($ipages as $k => $v)
716 if ($ipages[$k][
"indent"] == 2 && $c_indent == 0)
718 $ipages[$k][
"indent"] = 1;
721 $c_indent = $ipages[$k][
"indent"];
726 foreach ($ipages as $k => $v)
728 $ilDB->manipulate($q =
"UPDATE il_wiki_imp_pages SET ".
729 " ord = ".$ilDB->quote($ord,
"integer").
",".
730 " indent = ".$ilDB->quote($v[
"indent"],
"integer").
731 " WHERE wiki_id = ".$ilDB->quote($v[
"wiki_id"],
"integer").
732 " AND page_id = ".$ilDB->quote($v[
"page_id"],
"integer")
752 foreach ($ipages as $k => $v)
754 if ($ipages[$k][
"indent"] == 2 && $c_indent == 0)
756 $ipages[$k][
"indent"] = 1;
759 $c_indent = $ipages[$k][
"indent"];
763 foreach ($ipages as $k => $v)
765 $ilDB->manipulate($q =
"UPDATE il_wiki_imp_pages SET ".
766 " ord = ".$ilDB->quote($ord,
"integer").
767 ", indent = ".$ilDB->quote($v[
"indent"],
"integer").
768 " WHERE wiki_id = ".$ilDB->quote($v[
"wiki_id"],
"integer").
769 " AND page_id = ".$ilDB->quote($v[
"page_id"],
"integer")