53 $ilDB = $DIC->database();
60 include_once(
"./Services/Object/exceptions/class.ilObjectException.php");
75 if (!isset(self::$instances[$a_obj_id])) {
79 return self::$instances[$a_obj_id];
90 $this->obj_id = $a_val;
110 $this->master_lang = $a_val;
130 $this->languages = $a_val;
149 $this->fallback_language = $a_val;
170 public function addLanguage($a_lang, $a_title, $a_description, $a_default, $a_force =
false)
172 if ($a_lang !=
"" && (!isset($this->languages[$a_lang]) || $a_force)) {
174 foreach ($this->languages as $k => $l) {
175 $this->languages[$k][
"lang_default"] =
false;
178 $this->languages[$a_lang] = array(
"lang_code" => $a_lang,
"lang_default" => $a_default,
179 "title" => $a_title,
"description" => $a_description);
193 foreach ($this->languages as $l) {
194 if ($l[
"lang_default"]) {
199 if (count($this->languages) == 0) {
215 foreach ($this->languages as $k => $l) {
216 if ($l[
"lang_default"]) {
217 $this->languages[$k][
"title"] = $a_title;
233 foreach ($this->languages as $l) {
234 if ($l[
"lang_default"]) {
235 return $l[
"description"];
238 if (count($this->languages) == 0) {
254 foreach ($this->languages as $k => $l) {
255 if ($l[
"lang_default"]) {
256 $this->languages[$k][
"description"] = $a_description;
272 foreach ($this->languages as $l) {
273 if ($l[
"lang_default"]) {
274 return $l[
"lang_code"];
289 unset($this->languages[$a_lang]);
301 $this->content_activated = $a_val;
319 $set = $this->db->query(
320 "SELECT * FROM obj_content_master_lng " .
321 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
323 if ($rec = $this->db->fetchAssoc($set)) {
332 $set = $this->db->query(
333 "SELECT * FROM object_translation " .
334 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
336 while ($rec = $this->db->fetchAssoc($set)) {
337 $this->
addLanguage($rec[
"lang_code"], $rec[
"title"], $rec[
"description"], $rec[
"lang_default"]);
344 public function delete()
346 $this->db->manipulate(
347 "DELETE FROM obj_content_master_lng " .
348 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
350 $this->db->manipulate(
351 "DELETE FROM object_translation " .
352 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
361 $this->db->manipulate(
362 "DELETE FROM obj_content_master_lng " .
363 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
375 $this->db->manipulate(
"INSERT INTO obj_content_master_lng " .
376 "(obj_id, master_lang, fallback_lang) VALUES (" .
377 $this->db->quote($this->getObjId(),
"integer") .
"," .
378 $this->db->quote($this->getMasterLanguage(),
"text") .
"," .
379 $this->db->quote($this->getFallbackLanguage(),
"text") .
384 "description" =>
"",
"lang_code" => $this->
getMasterLanguage(),
"lang_default" => 1);
386 foreach ($this->languages as $l => $trans) {
388 $this->languages[$l][
"lang_default"] = 1;
390 $this->languages[$l][
"lang_default"] = 0;
395 $this->db->manipulate($t =
"INSERT INTO object_translation " .
396 "(obj_id, title, description, lang_code, lang_default) VALUES (" .
397 $this->db->quote($this->getObjId(),
"integer") .
"," .
398 $this->db->quote($trans[
"title"],
"text") .
"," .
399 $this->db->quote($trans[
"description"],
"text") .
"," .
400 $this->db->quote($l,
"text") .
"," .
401 $this->db->quote($trans[
"lang_default"],
"integer") .
413 public function copy($a_obj_id)
441 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.
setFallbackLanguage($a_val)
Set fallback language.
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.
getFallbackLanguage()
Get fallback 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.