ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilWikiPageTemplate.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 const TYPE_ALL = 0;
15 const TYPE_NEW_PAGES = 1;
17
18 protected $wiki_id;
19 protected $ilDB;
20
26 function __construct($a_wiki_id)
27 {
28 global $ilDB;
29
30 $this->wiki_id = $a_wiki_id;
31 $this->db = $ilDB;
32 }
33
37 function getAllInfo($a_type = self::TYPE_ALL)
38 {
39 $and = "";
40 if ($a_type == self::TYPE_NEW_PAGES)
41 {
42 $and = " AND t.new_pages = ".$this->db->quote(1, "integer");
43 }
44 if ($a_type == self::TYPE_ADD_TO_PAGE)
45 {
46 $and = " AND t.add_to_page = ".$this->db->quote(1, "integer");
47 }
48
49 $set = $this->db->query($q = "SELECT t.wiki_id, t.wpage_id, p.title, t.new_pages, t.add_to_page FROM wiki_page_template t JOIN il_wiki_page p ON ".
50 " (t.wpage_id = p.id) ".
51 " WHERE t.wiki_id = ".$this->db->quote($this->wiki_id, "integer").
52 $and
53 );
54 $templates = array();
55 while ($rec = $this->db->fetchAssoc($set))
56 {
57 $templates[] = $rec;
58 }
59 return $templates;
60 }
61
67 function save($a_id, $a_new_pages = 0, $a_add_to_page = 0)
68 {
69 if ($a_id <= 0)
70 {
71 return;
72 }
73
74 $set = $this->db->query("SELECT * FROM wiki_page_template ".
75 " WHERE wiki_id = ".$this->db->quote($this->wiki_id, "integer").
76 " AND wpage_id = ".$this->db->quote($a_id, "integer")
77 );
78 if (!$this->db->fetchAssoc($set))
79 {
80 $this->db->manipulate("INSERT INTO wiki_page_template ".
81 "(wiki_id, wpage_id, new_pages, add_to_page) VALUES (".
82 $this->db->quote($this->wiki_id, "integer").",".
83 $this->db->quote($a_id, "integer").",".
84 $this->db->quote($a_new_pages, "integer").",".
85 $this->db->quote($a_add_to_page, "integer").
86 ")");
87 }
88 else
89 {
90 $this->db->manipulate("UPDATE wiki_page_template SET ".
91 " new_pages = ".$this->db->quote($a_new_pages, "integer").",".
92 " add_to_page = ".$this->db->quote($a_add_to_page, "integer").
93 " WHERE wiki_id = ".$this->db->quote($this->wiki_id, "integer").
94 " AND wpage_id = ".$this->db->quote($a_id, "integer")
95 );
96 }
97 }
98
104 function remove($a_id)
105 {
106 $this->db->manipulate("DELETE FROM wiki_page_template WHERE ".
107 " wiki_id = ".$this->db->quote($this->wiki_id, "integer").
108 " AND wpage_id = ".$this->db->quote($a_id, "integer")
109 );
110 }
111
118 function isPageTemplate($a_id)
119 {
120 $set = $this->db->query("SELECT t.wpage_id".
121 " FROM wiki_page_template t".
122 " JOIN il_wiki_page p ON ".
123 " (t.wpage_id = p.id) ".
124 " WHERE t.wiki_id = ".$this->db->quote($this->wiki_id, "integer").
125 " AND p.id = ".$this->db->quote($a_id, "integer"));
126 return (bool)$this->db->numRows($set);
127 }
128
129}
130
131?>
isPageTemplate($a_id)
Is page set as template?
save($a_id, $a_new_pages=0, $a_add_to_page=0)
Add wiki page template.
getAllInfo($a_type=self::TYPE_ALL)
Get all info.
__construct($a_wiki_id)
Constructor.