ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilXHTMLPage.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
37 {
38  var $id = 0;
39  var $content = "";
40 
46  function ilXHTMLPage($a_id = 0)
47  {
48  if ($a_id > 0)
49  {
50  $this->setId($a_id);
51  $this->read();
52  }
53  }
54 
60  function getId()
61  {
62  return $this->id;
63  }
64 
70  function setId($a_id)
71  {
72  $this->id = $a_id;
73  }
74 
80  function getContent()
81  {
82  return $this->content;
83  }
84 
90  function setContent($a_content)
91  {
92  $this->content = $a_content;
93  }
94 
98  function read()
99  {
100  global $ilDB;
101 
102  $set = $ilDB->query("SELECT * FROM xhtml_page WHERE id = ".
103  $ilDB->quote($this->getId()));
104  if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
105  {
106  $this->setContent($rec["content"]);
107  }
108  }
109 
113  function save()
114  {
115  global $ilDB;
116 
117  if ($this->getId() > 0)
118  {
119  $ilDB->query("UPDATE xhtml_page SET ".
120  " save_content = content ".
121  " WHERE id = ".$ilDB->quote($this->getId()));
122  $ilDB->query("UPDATE xhtml_page SET ".
123  "content = ".$ilDB->quote($this->getContent()).
124  " WHERE id = ".$ilDB->quote($this->getId()));
125  }
126  else
127  {
128  $ilDB->query("INSERT INTO xhtml_page (content) VALUES ".
129  "(".$ilDB->quote($this->getContent()).")");
130  $this->setId($ilDB->getLastInsertId());
131  }
132  }
133 
137  function undo()
138  {
139  global $ilDB;
140 
141  if ($this->getId() > 0)
142  {
143  $ilDB->query("UPDATE xhtml_page SET ".
144  " content = save_content ".
145  " WHERE id = ".$ilDB->quote($this->getId()));
146  $ilDB->query("UPDATE xhtml_page SET ".
147  " save_content = ".$ilDB->quote($this->getContent()).
148  " WHERE id = ".$ilDB->quote($this->getId()));
149  }
150  }
151 
155  function clear()
156  {
157  global $ilDB;
158 
159  if ($this->getId() > 0)
160  {
161  $ilDB->query("UPDATE xhtml_page SET ".
162  " save_content = content ".
163  " WHERE id = ".$ilDB->quote($this->getId()));
164  $ilDB->query("UPDATE xhtml_page SET ".
165  " content = ".$ilDB->quote("").
166  " WHERE id = ".$ilDB->quote($this->getId()));
167  $this->setContent("");
168  }
169  }
170 
171 }
172 ?>