ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilXHTMLPage.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
17{
18 var $id = 0;
19 var $content = "";
20
26 function ilXHTMLPage($a_id = 0)
27 {
28 if ($a_id > 0)
29 {
30 $this->setId($a_id);
31 $this->read();
32 }
33 }
34
40 function getId()
41 {
42 return $this->id;
43 }
44
50 function setId($a_id)
51 {
52 $this->id = $a_id;
53 }
54
60 function getContent()
61 {
62 return $this->content;
63 }
64
70 function setContent($a_content)
71 {
72 $this->content = $a_content;
73 }
74
78 function read()
79 {
80 global $ilDB;
81
82 $set = $ilDB->query("SELECT * FROM xhtml_page WHERE id = ".
83 $ilDB->quote($this->getId(), "integer"));
84 if ($rec = $ilDB->fetchAssoc($set))
85 {
86 $this->setContent($rec["content"]);
87 }
88 }
89
93 function _lookupContent($a_id)
94 {
95 global $ilDB;
96
97 $set = $ilDB->query("SELECT content FROM xhtml_page WHERE id = ".
98 $ilDB->quote($a_id, "integer"));
99 if ($rec = $ilDB->fetchAssoc($set))
100 {
101 return $rec["content"];
102 }
103 }
104
108 function _lookupSavedContent($a_id)
109 {
110 global $ilDB;
111
112 $set = $ilDB->query("SELECT save_content FROM xhtml_page WHERE id = ".
113 $ilDB->quote($a_id, "integer"));
114 if ($rec = $ilDB->fetchAssoc($set))
115 {
116 return $rec["save_content"];
117 }
118 }
119
123 function save()
124 {
125 global $ilDB;
126
127 if ($this->getId() > 0)
128 {
129 $old_content = ilXHTMLPage::_lookupContent($this->getId());
130 $ilDB->update("xhtml_page", array(
131 "content" => array("clob", $this->getContent()),
132 "save_content" => array("clob", $old_content)
133 ), array (
134 "id" => array("integer", $this->getId())
135 ));
136 }
137 else
138 {
139 $this->setId($ilDB->nextId("xhtml_page"));
140 $ilDB->insert("xhtml_page", array(
141 "id" => array("integer", $this->getId()),
142 "content" => array("clob", $this->getContent())
143 ));
144 }
145 }
146
150 function undo()
151 {
152 global $ilDB;
153
154 if ($this->getId() > 0)
155 {
156 $content = ilXHTMLPage::_lookupContent($this->getId());
157 $save_content = ilXHTMLPage::_lookupSavedContent($this->getId());
158 $ilDB->update("xhtml_page", array(
159 "content" => array("clob", $save_content),
160 "save_content" => array("clob", $content)
161 ), array (
162 "id" => array("integer", $this->getId())
163 ));
164 }
165 }
166
170 function clear()
171 {
172 global $ilDB;
173
174 if ($this->getId() > 0)
175 {
176 $this->setContent("");
177 $this->save();
178 }
179 }
180
181}
182?>
XHTML Page class.
_lookupSavedContent($a_id)
Lookup Saved Content.
setId($a_id)
Set page ID.
getId()
Get page ID.
setContent($a_content)
Set content of page.
clear()
Clear page.
getContent()
Get content of page.
undo()
Undo last change.
ilXHTMLPage($a_id=0)
Constructor.
read()
Read page data from database.
save()
Save the page.
_lookupContent($a_id)
Lookup Content.
global $ilDB