ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLMObjTranslation.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected $lang;
15 protected $title;
16 protected $create_date;
17 protected $last_update;
18
25 function __construct($a_id = 0, $a_lang = "")
26 {
27 if ($a_id > 0 && $a_lang != "")
28 {
29 $this->setId($a_id);
30 $this->setLang($a_lang);
31 $this->read();
32 }
33 }
34
40 function setId($a_val)
41 {
42 $this->id = $a_val;
43 }
44
50 function getId()
51 {
52 return $this->id;
53 }
54
60 function setLang($a_val)
61 {
62 $this->lang = $a_val;
63 }
64
70 function getLang()
71 {
72 return $this->lang;
73 }
74
80 function setTitle($a_val)
81 {
82 $this->title = $a_val;
83 }
84
90 function getTitle()
91 {
92 return $this->title;
93 }
94
100 function getCreateDate()
101 {
102 return $this->create_date;
103 }
104
110 function getLastUpdate()
111 {
112 return $this->last_update;
113 }
114
118 function read()
119 {
120 global $ilDB;
121
122 $set = $ilDB->query("SELECT * FROM lm_data_transl ".
123 " WHERE id = ".$ilDB->quote($this->getId(), "integer").
124 " AND lang = ".$ilDB->quote($this->getLang(), "text")
125 );
126 $rec = $ilDB->fetchAssoc($set);
127 $this->setTitle($rec["title"]);
128 $this->create_date = $rec["create_date"];
129 $this->last_update = $rec["last_update"];
130 }
131
135 function save()
136 {
137 global $ilDB;
138
139 if (!self::exists($this->getId(), $this->getLang()))
140 {
141 $ilDB->manipulate("INSERT INTO lm_data_transl ".
142 "(id, lang, title, create_date, last_update) VALUES (".
143 $ilDB->quote($this->getId(), "integer").",".
144 $ilDB->quote($this->getLang(), "text").",".
145 $ilDB->quote($this->getTitle(), "text").",".
146 $ilDB->now().",".
147 $ilDB->now().
148 ")");
149 }
150 else
151 {
152 $ilDB->manipulate("UPDATE lm_data_transl SET ".
153 " title = ".$ilDB->quote($this->getTitle(), "text").",".
154 " last_update = ".$ilDB->now().
155 " WHERE id = ".$ilDB->quote($this->getId(), "integer").
156 " AND lang = ".$ilDB->quote($this->getLang(), "text")
157 );
158 }
159 }
160
168 static function exists($a_id, $a_lang)
169 {
170 global $ilDB;
171
172 $set = $ilDB->query("SELECT * FROM lm_data_transl ".
173 " WHERE id = ".$ilDB->quote($a_id, "integer").
174 " AND lang = ".$ilDB->quote($a_lang, "text")
175 );
176 if($rec = $ilDB->fetchAssoc($set))
177 {
178 return true;
179 }
180 return false;
181 }
182
189 static function copy($a_source_id, $a_target_id)
190 {
191 global $ilDB;
192
193 $set = $ilDB->query("SELECT * FROM lm_data_transl ".
194 " WHERE id = ".$ilDB->quote($a_source_id, "integer")
195 );
196 while ($rec = $ilDB->fetchAssoc($set))
197 {
198 $lmobjtrans = new ilLMObjTranslation($a_target_id, $rec["lang"]);
199 $lmobjtrans->setTitle($rec["title"]);
200 $lmobjtrans->save();
201 }
202 }
203
204}
205
206?>
Translation information on lm object.
static copy($a_source_id, $a_target_id)
Copy all translations of an object.
static exists($a_id, $a_lang)
Check for existence.
getCreateDate()
Get create date.
getLastUpdate()
Get update date.
__construct($a_id=0, $a_lang="")
Constructor.
save()
Save (inserts if not existing, otherwise updates)
global $ilDB