ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilAdvancedMDRecordTranslation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
28  public const TABLE_NAME = 'adv_md_record_int';
29 
30  private int $record_id;
31  private string $title;
32  private string $description;
33  private string $lang_key;
34  private bool $lang_default = false;
35 
36  private ilDBInterface $db;
37 
38  public function __construct(
39  int $record_id,
40  string $title,
41  string $description,
42  string $lang_key,
43  bool $lang_default = false
44  ) {
45  global $DIC;
46 
47  $this->db = $DIC->database();
48 
49  $this->record_id = $record_id;
50  $this->title = $title;
51  $this->description = $description;
52  $this->lang_key = $lang_key;
53  $this->lang_default = $lang_default;
54  }
55 
56  public function setTitle(string $title): void
57  {
58  $this->title = $title;
59  }
60 
61  public function setDescription(string $description): void
62  {
63  $this->description = $description;
64  }
65 
66  public function setLangDefault(bool $lang_default): void
67  {
68  $this->lang_default = $lang_default;
69  }
70 
71  public function getLangDefault(): bool
72  {
73  return $this->lang_default;
74  }
75 
76  public function getRecordId(): int
77  {
78  return $this->record_id;
79  }
80 
81  public function setRecordId(int $record_id): void
82  {
83  $this->record_id = $record_id;
84  }
85 
89  public function getTitle(): string
90  {
91  return $this->title;
92  }
93 
97  public function getDescription(): string
98  {
99  return $this->description;
100  }
101 
105  public function getLangKey(): string
106  {
107  return $this->lang_key;
108  }
109 
110  public function update(): void
111  {
112  $query = 'update ' . self::TABLE_NAME . ' ' .
113  'set title = ' . $this->db->quote($this->getTitle(), ilDBConstants::T_TEXT) . ', ' .
114  'description = ' . $this->db->quote($this->getDescription(), ilDBConstants::T_TEXT) . ' ' .
115  'where record_id = ' . $this->db->quote($this->getRecordId(), ilDBConstants::T_INTEGER) . ' ' .
116  'and lang_code = ' . $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT);
117 
118  $this->db->manipulate($query);
119  }
120 
121  public function delete(): void
122  {
123  $query = 'delete from ' . self::TABLE_NAME . ' ' .
124  'where record_id = ' . $this->db->quote($this->getRecordId(), ilDBConstants::T_INTEGER) . ' and ' .
125  'lang_code = ' . $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT);
126  $this->db->manipulate($query);
127  }
128 
129  public function insert(): void
130  {
131  $query = 'insert into ' . self::TABLE_NAME . ' (record_id, title, lang_code, description) ' .
132  'values ( ' .
133  $this->db->quote($this->getRecordId(), ilDBConstants::T_INTEGER) . ', ' .
134  $this->db->quote($this->getTitle(), ilDBConstants::T_TEXT) . ', ' .
135  $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT) . ', ' .
136  $this->db->quote($this->getDescription(), ilDBConstants::T_TEXT) . ' ' .
137  ')';
138  $this->db->manipulate($query);
139  }
140 }
global $DIC
Definition: shib_login.php:26
Class ilAdvancedMDRecordTranslation.
__construct(int $record_id, string $title, string $description, string $lang_key, bool $lang_default=false)