ILIAS  release_8 Revision v8.24
class.ilAdvancedMDFieldTranslation.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
6
12{
13 public const TABLE_NAME = 'adv_md_field_int';
14
15 private int $field_id;
16 private string $title;
17 private string $description;
18 private string $lang_key;
19
21
25 public function __construct(int $field_id, string $title, string $description, string $lang_key)
26 {
27 global $DIC;
28
29 $this->db = $DIC->database();
30
31 $this->field_id = $field_id;
32 $this->title = $title;
33 $this->description = $description;
34 $this->lang_key = $lang_key;
35 }
36
37 public function setTitle(string $title): void
38 {
39 $this->title = $title;
40 }
41
42 public function setDescription(string $description): void
43 {
44 $this->description = $description;
45 }
46
47 public function getFieldId(): int
48 {
49 return $this->field_id;
50 }
51
52 public function getTitle(): string
53 {
54 return $this->title;
55 }
56
57 public function getDescription(): string
58 {
59 return $this->description;
60 }
61
62 public function getLangKey(): string
63 {
64 return $this->lang_key;
65 }
66
67 public function update(): void
68 {
69 $query = 'select * from ' . self::TABLE_NAME . ' ' .
70 'where field_id = ' . $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER) . ' ' .
71 'and lang_code = ' . $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT) . ' ';
72 $res = $this->db->query($query);
73 if (!$res->numRows()) {
74 $this->insert();
75 return;
76 }
77
78 $query = 'update ' . self::TABLE_NAME . ' ' .
79 'set title = ' . $this->db->quote($this->getTitle(), ilDBConstants::T_TEXT) . ', ' .
80 'description = ' . $this->db->quote($this->getDescription(), ilDBConstants::T_TEXT) . ' ' .
81 'where field_id = ' . $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER) . ' ' .
82 'and lang_code = ' . $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT);
83
84 $this->db->manipulate($query);
85 }
86
87 public function delete(): void
88 {
89 $query = 'delete from ' . self::TABLE_NAME . ' ' .
90 'where field_id = ' . $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER) . ' and ' .
91 'lang_code = ' . $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT);
92 $this->db->manipulate($query);
93 }
94
95 public function insert(): void
96 {
97 $query = 'insert into ' . self::TABLE_NAME . ' (field_id, title, lang_code, description) ' .
98 'values ( ' .
99 $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER) . ', ' .
100 $this->db->quote($this->getTitle(), ilDBConstants::T_TEXT) . ', ' .
101 $this->db->quote($this->getLangKey(), ilDBConstants::T_TEXT) . ', ' .
102 $this->db->quote($this->getDescription(), ilDBConstants::T_TEXT) . ' ' .
103 ')';
104 $this->db->manipulate($query);
105 }
106}
Class ilAdvancedMDFieldTranslation.
__construct(int $field_id, string $title, string $description, string $lang_key)
ilAdvancedMDFieldTranslation constructor.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query