ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjWorkspaceRootFolder.php
Go to the documentation of this file.
1<?php
2
23{
24 public function __construct(
25 int $a_id = 0,
26 bool $a_reference = true
27 ) {
28 global $DIC;
29 parent::__construct($a_id, $a_reference);
30
31 $this->db = $DIC->database();
32 }
33
34 protected function initType(): void
35 {
36 $this->type = "wsrt";
37 }
38
42 public function getTranslations(): array
43 {
45
46 $q = "SELECT * FROM object_translation WHERE obj_id = " .
47 $ilDB->quote($this->getId(), 'integer') . " ORDER BY lang_default DESC";
48 $r = $ilDB->query($q);
49
50 $num = 0;
51
52 $data["Fobject"] = array();
53 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
54 $data["Fobject"][$num] = array("title" => $row->title,
55 "desc" => $row->description,
56 "lang" => $row->lang_code
57 );
58 $num++;
59 }
60
61 // first entry is always the default language
62 $data["default_language"] = 0;
63
64 return $data ?: array();
65 }
66
67 // remove all Translations of current category
68 public function removeTranslations(): void
69 {
71
72 $query = "DELETE FROM object_translation WHERE obj_id= " .
73 $ilDB->quote($this->getId(), 'integer');
74 $ilDB->manipulate($query);
75 }
76
77 // add a new translation to current category
78 public function addTranslation(
79 string $a_title,
80 string $a_desc,
81 string $a_lang,
82 string $a_lang_default
83 ): void {
84 $ilDB = $this->db;
85
86 if (empty($a_title)) {
87 $a_title = "NO TITLE";
88 }
89
90 $query = "INSERT INTO object_translation " .
91 "(obj_id,title,description,lang_code,lang_default) " .
92 "VALUES " .
93 "(" . $ilDB->quote($this->getId(), 'integer') . "," .
94 $ilDB->quote($a_title, 'text') . "," .
95 $ilDB->quote($a_desc, 'text') . "," .
96 $ilDB->quote($a_lang, 'text') . "," .
97 $ilDB->quote($a_lang_default, 'integer') . ")";
98 $ilDB->manipulate($query);
99 }
100}
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...
__construct(int $a_id=0, bool $a_reference=true)
Constructor.
addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default)
getTranslations()
get all translations from this category
ilDBInterface $db
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23