48 $ilDB = $DIC->database();
55 include_once(
"./Services/Object/exceptions/class.ilObjectException.php");
70 if (!isset(self::$instances[$a_obj_id])) {
74 return self::$instances[$a_obj_id];
85 $this->obj_id = $a_val;
105 $this->master_lang = $a_val;
125 $this->languages = $a_val;
146 public function addLanguage($a_lang, $a_title, $a_description, $a_default, $a_force =
false)
148 if ($a_lang !=
"" && (!isset($this->languages[$a_lang]) || $a_force)) {
150 foreach ($this->languages as $k =>
$l) {
151 $this->languages[$k][
"lang_default"] =
false;
154 $this->languages[$a_lang] = array(
"lang_code" => $a_lang,
"lang_default" => $a_default,
155 "title" => $a_title,
"description" => $a_description);
166 foreach ($this->languages as
$l) {
167 if ($l[
"lang_default"]) {
171 if (count($this->languages) == 0) {
184 foreach ($this->languages as $k =>
$l) {
185 if (
$l[
"lang_default"]) {
186 $this->languages[$k][
"title"] = $a_title;
198 foreach ($this->languages as
$l) {
199 if ($l[
"lang_default"]) {
200 return $l[
"description"];
203 if (count($this->languages) == 0) {
216 foreach ($this->languages as $k =>
$l) {
217 if (
$l[
"lang_default"]) {
218 $this->languages[$k][
"description"] = $a_description;
230 foreach ($this->languages as
$l) {
231 if ($l[
"lang_default"]) {
232 return $l[
"lang_code"];
247 unset($this->languages[$a_lang]);
259 $this->content_activated = $a_val;
277 $set = $this->db->query(
278 "SELECT * FROM obj_content_master_lng " .
279 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
281 if ($rec = $this->db->fetchAssoc($set)) {
289 $set = $this->db->query(
290 "SELECT * FROM object_translation " .
291 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
293 while ($rec = $this->db->fetchAssoc($set)) {
294 $this->
addLanguage($rec[
"lang_code"], $rec[
"title"], $rec[
"description"], $rec[
"lang_default"]);
301 public function delete()
303 $this->db->manipulate(
304 "DELETE FROM obj_content_master_lng " .
305 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
307 $this->db->manipulate(
308 "DELETE FROM object_translation " .
309 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
318 $this->db->manipulate(
319 "DELETE FROM obj_content_master_lng " .
320 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
332 $this->db->manipulate(
"INSERT INTO obj_content_master_lng " .
333 "(obj_id, master_lang) VALUES (" .
334 $this->db->quote($this->getObjId(),
"integer") .
"," .
335 $this->db->quote($this->getMasterLanguage(),
"text") .
341 "description" =>
"",
"lang_code" => $this->
getMasterLanguage(),
"lang_default" => 1);
343 foreach ($this->languages as
$l => $trans) {
345 $this->languages[
$l][
"lang_default"] = 1;
347 $this->languages[
$l][
"lang_default"] = 0;
353 $this->db->manipulate(
$t =
"INSERT INTO object_translation " .
354 "(obj_id, title, description, lang_code, lang_default) VALUES (" .
355 $this->db->quote($this->getObjId(),
"integer") .
"," .
356 $this->db->quote($trans[
"title"],
"text") .
"," .
357 $this->db->quote($trans[
"description"],
"text") .
"," .
358 $this->db->quote(
$l,
"text") .
"," .
359 $this->db->quote($trans[
"lang_default"],
"integer") .
371 public function copy($a_obj_id)
395 isset($langs[$a_lang]) &&
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
getMasterLanguage()
Get master language.
copy($a_obj_id)
Copy multilinguality settings.
getLanguages()
Get languages.
deactivateContentTranslation()
Deactivate content translation.
__construct($a_obj_id)
Constructor.
setDefaultDescription($a_description)
Set default description.
getEffectiveContentLang($a_lang, $a_parent_type)
Get effective language for given language.
setLanguages(array $a_val)
Set languages.
Base exception class for object service.
addLanguage($a_lang, $a_title, $a_description, $a_default, $a_force=false)
Add language.
static _lookupTitle($a_id)
lookup object title
getDefaultDescription()
Get default description.
setContentActivated($a_val)
Set activated for content.
setObjId($a_val)
Set object id.
getContentActivated()
Get activated for content.
static _lookupDescription($a_id)
lookup object description
setDefaultTitle($a_title)
Set default title.
getDefaultTitle()
Get default title.
removeLanguage($a_lang)
Remove language.
static getInstance($a_obj_id)
Get instance.
getDefaultLanguage()
Get default language.
Class handles translation mode for an object.
setMasterLanguage($a_val)
Set master language.