ILIAS  release_8 Revision v8.24
class.ilMDCreator.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/*
6 +-----------------------------------------------------------------------------+
7 | ILIAS open source |
8 +-----------------------------------------------------------------------------+
9 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
10 | |
11 | This program is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU General Public License |
13 | as published by the Free Software Foundation; either version 2 |
14 | of the License, or (at your option) any later version. |
15 | |
16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | GNU General Public License for more details. |
20 | |
21 | You should have received a copy of the GNU General Public License |
22 | along with this program; if not, write to the Free Software |
23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24 +-----------------------------------------------------------------------------+
25*/
26
35{
36 protected ilMD $md_obj;
37
38 /*
39 * rbac_id ref_id of rbac object (e.g for page objects the obj_id of the content object)
40 */
41 private int $rbac_id;
42
43 /*
44 * obj_id (e.g for structure objects the obj_id of the structure object)
45 */
46 private int $obj_id;
47
48 /*
49 * type of the object (e.g st,pg,crs ...)
50 */
51 public string $obj_type;
52
53 private string $structure = '';
54 private string $catalog = '';
55 private string $entry = '';
56 private string $keyword = '';
57 private string $title = '';
58 private string $description = '';
59 private string $title_lng = '';
60
61 public function __construct(int $a_rbac_id, int $a_obj_id, string $a_type)
62 {
63 if ($a_obj_id === 0) {
64 $a_obj_id = $a_rbac_id;
65 }
66
67 $this->rbac_id = $a_rbac_id;
68 $this->obj_id = $a_obj_id;
69 $this->obj_type = $a_type;
70
71 $this->md_obj = new ilMD($a_rbac_id, $a_obj_id, $a_type);
72 }
73
74 // SET/GET
75 public function setTitle(string $a_title): void
76 {
77 $this->title = $a_title;
78 }
79
80 public function getTitle(): string
81 {
82 return $this->title;
83 }
84
85 public function setDescription(string $a_desc): void
86 {
87 $this->description = $a_desc;
88 }
89
90 public function getDescription(): string
91 {
92 return $this->description;
93 }
94
95 public function setTitleLanguage(string $a_lng): void
96 {
97 $this->title_lng = $a_lng;
98 }
99
101 {
102 return new ilMDLanguageItem($this->title_lng);
103 }
104
105 public function setDescriptionLanguage(string $a_lng): void
106 {
107 $this->title_lng = $a_lng;
108 }
109
111 {
112 return new ilMDLanguageItem($this->title_lng);
113 }
114
115 public function setLanguage(string $a_lng): void
116 {
117 $this->title_lng = $a_lng;
118 }
119
120 public function getLanguage(): ilMDLanguageItem
121 {
122 return new ilMDLanguageItem($this->title_lng);
123 }
124
125 public function setKeyword(string $a_key): void
126 {
127 $this->keyword = $a_key;
128 }
129
130 public function getKeyword(): string
131 {
132 return $this->keyword;
133 }
134
135 public function getRBACId(): int
136 {
137 return $this->rbac_id;
138 }
139
140 public function getObjId(): int
141 {
142 return $this->obj_id;
143 }
144
145 public function getObjType(): string
146 {
147 return $this->obj_type;
148 }
149
150 public function setKeywordLanguage(string $a_lng): void
151 {
152 $this->title_lng = $a_lng;
153 }
154
156 {
157 return new ilMDLanguageItem($this->title_lng);
158 }
159
160 public function setCatalog(string $a_cat): void
161 {
162 $this->catalog = $a_cat;
163 }
164
165 public function getCatalog(): string
166 {
167 return $this->catalog ?: 'ILIAS';
168 }
169
170 public function setEntry(string $a_entry): void
171 {
172 $this->entry = $a_entry;
173 }
174
175 public function getEntry(): string
176 {
177 return $this->entry ?: 'il__' . $this->getObjType() . '_' . $this->getObjId();
178 }
179
180 public function setStructure(string $a_structure): void
181 {
182 $this->structure = $a_structure;
183 }
184
185 public function getStructure(): string
186 {
187 return $this->structure ?: 'Hierarchical';
188 }
189
190 public function create(): void
191 {
192 $this->__createGeneral();
193 }
194
195 // PROTECTED
196 public function __createGeneral(): bool
197 {
198 $md_gen = $this->md_obj->addGeneral();
199
200 $md_gen->setStructure($this->getStructure());
201 $md_gen->setTitle($this->getTitle());
202 $md_gen->setTitleLanguage($this->getTitleLanguage());
203 $md_gen->save();
204
205 $md_ide = $md_gen->addIdentifier();
206 $md_ide->setCatalog($this->getCatalog());
207 $md_ide->setEntry($this->getEntry());
208 $md_ide->save();
209
210 $md_lng = $md_gen->addLanguage();
211 $md_lng->setLanguage($this->getLanguage());
212 $md_lng->save();
213
214 $md_des = $md_gen->addDescription();
215 $md_des->setDescription($this->getDescription());
216 $md_des->setDescriptionLanguage($this->getDescriptionLanguage());
217 $md_des->save();
218
219 $md_key = $md_gen->addKeyword();
220 $md_key->setKeyword($this->getKeyword());
221 $md_key->setKeywordLanguage($this->getKeywordLanguage());
222 $md_key->save();
223
224 return true;
225 }
226}
setTitle(string $a_title)
setDescription(string $a_desc)
setKeywordLanguage(string $a_lng)
setTitleLanguage(string $a_lng)
setDescriptionLanguage(string $a_lng)
setLanguage(string $a_lng)
setKeyword(string $a_key)
setStructure(string $a_structure)
__construct(int $a_rbac_id, int $a_obj_id, string $a_type)
setCatalog(string $a_cat)
setEntry(string $a_entry)