3 declare(strict_types=1);
65 $this->db = $DIC->database();
78 if (!isset(self::$instances[$obj_id])) {
82 return self::$instances[
$obj_id];
97 $this->master_lang = $val;
110 $this->languages = $val;
123 $this->fallback_language = $val;
138 if ($lang !==
"" && (!isset($this->languages[$lang]) || $force)) {
140 foreach ($this->languages as $l) {
141 $l->setDefault(
false);
155 if ($this->fallback_language !==
"" 156 && array_key_exists($this->fallback_language, $this->languages)) {
159 foreach ($this->languages as $l) {
160 if ($l->isDefault()) {
161 return $l->getTitle();
165 if (count($this->languages) == 0) {
179 foreach ($this->languages as $l) {
180 if ($l->isDefault()) {
181 $l->setTitle($title);
190 && array_key_exists($this->fallback_language, $this->languages)) {
193 foreach ($this->languages as $l) {
194 if ($l->isDefault()) {
195 return $l->getDescription();
198 if (count($this->languages) == 0) {
209 ->setDescription($description);
213 foreach ($this->languages as $l) {
214 if ($l->isDefault()) {
215 $l->setDescription($description);
226 foreach ($this->languages as $l) {
227 if ($l->isDefault()) {
228 return $l->getLanguageCode();
237 unset($this->languages[$lang]);
243 $this->content_activated = $val;
254 "SELECT obj_id, master_lang, fallback_lang" . PHP_EOL
255 .
"FROM obj_content_master_lng" . PHP_EOL
256 .
"WHERE obj_id = " . $this->db->quote($this->
getObjId(),
"integer") . PHP_EOL
258 $result = $this->db->query($sql);
259 if ($row = $this->db->fetchAssoc($result)) {
270 "SELECT title, description, lang_code, lang_default" . PHP_EOL
271 .
"FROM object_translation" . PHP_EOL
272 .
"WHERE obj_id = " . $this->db->quote($this->
getObjId(),
"integer") . PHP_EOL
274 $result = $this->db->query($sql);
275 while ($row = $this->db->fetchAssoc($result)) {
276 $this->
addLanguage($row[
"lang_code"], (
string) $row[
"title"], (
string) $row[
"description"], (
bool) $row[
"lang_default"]);
280 public function delete():
void 282 $this->db->manipulate(
283 "DELETE FROM obj_content_master_lng " .
284 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
286 $this->db->manipulate(
287 "DELETE FROM object_translation " .
288 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
294 $this->db->manipulate(
295 "DELETE FROM obj_content_master_lng " .
296 " WHERE obj_id = " . $this->db->quote($this->getObjId(),
"integer")
306 "obj_id" => [
"integer", $this->
getObjId()],
311 $this->db->insert(
"obj_content_master_lng", $values);
321 foreach ($this->languages as $trans) {
323 $trans->setDefault(
true);
325 $trans->setDefault(
false);
332 "obj_id" => [
"integer", $this->
getObjId()],
333 "title" => [
"text", $trans->getTitle()],
334 "description" => [
"text", $trans->getDescription()],
335 "lang_code" => [
"text", $trans->getLanguageCode()],
336 "lang_default" => [
"integer", $trans->isDefault()],
338 $this->db->insert(
"object_translation", $values);
373 isset($langs[$lang]) &&
copy(int $obj_id)
Copy multilingual settings.
deactivateContentTranslation()
setContentActivated(bool $val)
removeLanguage(string $lang)
setDefaultDescription(string $description)
setMasterLanguage(string $val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getEffectiveContentLang(string $lang, string $parent_type)
Get effective language for given language.
static _lookupTitle(int $obj_id)
string $fallback_language
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
setDefaultTitle(string $title)
static getInstance(int $obj_id)
setFallbackLanguage(string $val)
static _lookupDescription(int $obj_id)
addLanguage(string $lang, string $title, string $description, bool $default, bool $force=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...