ILIAS  release_8 Revision v8.24
class.ilObjItemGroup.php
Go to the documentation of this file.
1<?php
2
24{
26 protected int $access_type;
27 protected int $access_begin;
28 protected int $access_end;
29 protected bool $access_visibility;
30 protected ?ilItemGroupAR $item_data_ar = null;
31
32 public function __construct(
33 int $a_id = 0,
34 bool $a_reference = true
35 ) {
36 global $DIC;
37
38 $this->log = $DIC["ilLog"];
39 $tree = $DIC->repositoryTree();
40 $objDefinition = $DIC["objDefinition"];
41 $ilDB = $DIC->database();
42
43 $this->tree = $tree;
44 $this->obj_def = $objDefinition;
45 $this->db = $ilDB;
46
47 $this->item_data_ar = new ilItemGroupAR();
48
49 parent::__construct($a_id, $a_reference);
50 }
51
52 public function setId($a_id): void
53 {
54 parent::setId($a_id);
55 $this->item_data_ar->setId($a_id);
56 }
57
58 public function initType(): void
59 {
60 $this->type = "itgr";
61 }
62
63 public function setHideTitle(bool $a_val): void
64 {
65 $this->item_data_ar->setHideTitle($a_val);
66 }
67
68 public function getHideTitle(): bool
69 {
70 return $this->item_data_ar->getHideTitle();
71 }
72
76 public function setBehaviour(int $a_val): void
77 {
78 $this->item_data_ar->setBehaviour($a_val);
79 }
80
81 public function getListPresentation(): string
82 {
83 return $this->item_data_ar->getListPresentation();
84 }
85
86 public function setListPresentation(string $a_val): void
87 {
88 $this->item_data_ar->setListPresentation($a_val);
89 }
90
91 public function getTileSize(): int
92 {
93 return $this->item_data_ar->getTileSize();
94 }
95
96 public function setTileSize(int $a_val): void
97 {
98 $this->item_data_ar->setTileSize($a_val);
99 }
100
101 public function getBehaviour(): int
102 {
103 return $this->item_data_ar->getBehaviour();
104 }
105
106 protected function doRead(): void
107 {
108 $this->item_data_ar = new ilItemGroupAR($this->getId());
109 }
110
111 protected function doCreate(bool $clone_mode = false): void
112 {
113 global $DIC;
114
115 if ($this->getId()) {
116 $this->item_data_ar->setId($this->getId());
117 $this->item_data_ar->create();
118 }
119
120 $lng = $DIC->language();
121
122 // add default translation
123 $obj_trans = ilObjectTranslation::getInstance($this->getId());
124 $obj_trans->addLanguage(
126 $this->getTitle(),
127 $this->getDescription(),
128 true,
129 true
130 );
131 $obj_trans->save();
132 }
133
134 protected function doUpdate(): void
135 {
136 if ($this->getId()) {
137 $this->item_data_ar->update();
138
139 $trans = ilObjectTranslation::getInstance($this->getId());;
140 $trans->setDefaultTitle($this->getTitle());
141 $trans->setDefaultDescription($this->getLongDescription());
142 $trans->save();
143 }
144 }
145
146 protected function doDelete(): void
147 {
148 if ($this->getId()) {
149 $this->item_data_ar->delete();
150 }
151 }
152
153 protected function doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id = null): void
154 {
155 assert($new_obj instanceof ilObjItemGroup);
156 $new_obj->setHideTitle($this->getHideTitle());
157 $new_obj->setBehaviour($this->getBehaviour());
158 $new_obj->setListPresentation($this->getListPresentation());
159 $new_obj->setTileSize($this->getTileSize());
160
161
162 // translations
164 $ot->copy($new_obj->getId());
165 $ot2 = ilObjectTranslation::getInstance($new_obj->getId());
166 $ot2->read();
167 if ($ot2->getDefaultTitle() !== "") {
168 $new_obj->setTitle($ot2->getDefaultTitle());
169 }
170 if ($ot2->getDefaultDescription() !== "") {
171 $new_obj->setDescription($ot2->getDefaultDescription());
172 }
173
174 $new_obj->update();
175 }
176
177 public function cloneDependencies(int $a_target_id, int $a_copy_id): bool
178 {
179 parent::cloneDependencies($a_target_id, $a_copy_id);
180
181 $ig_items = new ilItemGroupItems($a_target_id);
182 $ig_items->cloneItems($this->getRefId(), $a_copy_id);
183
184 return true;
185 }
186
188 ilContainer $a_source_container,
189 int $a_copy_id
190 ): void {
191 global $DIC;
192
193 $ilLog = $DIC["ilLog"];
194
195 $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType());
196
197 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
198 $mappings = $cwo->getMappings();
199
200 $new_container_ref_id = $mappings[$a_source_container->getRefId()];
201 $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-');
202 $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id);
203
204 $ilLog->write(__METHOD__ . ': 3' . $new_container_obj_id . '-');
205 if (ilPageObject::_exists("cont", $new_container_obj_id)) {
206 $ilLog->write(__METHOD__ . ': 4');
207 $new_page = new ilContainerPage($new_container_obj_id);
208 $new_page->buildDom();
210 $new_page->update();
211 }
212 $ilLog->write(__METHOD__ . ': 5');
213 }
214
215 public static function lookupHideTitle(int $a_id): bool
216 {
217 return (bool) self::lookup($a_id, "hide_title");
218 }
219
220 public static function lookupBehaviour(int $a_id): int
221 {
222 return (int) self::lookup($a_id, "behaviour");
223 }
224
225 protected static function lookup(int $a_id, string $a_key): string
226 {
227 global $DIC;
228
229 $ilDB = $DIC->database();
230
231 $set = $ilDB->query(
232 "SELECT " . $a_key . " FROM itgr_data " .
233 " WHERE id = " . $ilDB->quote($a_id, "integer")
234 );
235 $rec = $ilDB->fetchAssoc($set);
236 return $rec[$a_key];
237 }
238}
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...
static _getInstance(int $a_copy_id)
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...
getDefaultLanguage()
Return default language.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectDefinition $obj_def
doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
doCreate(bool $clone_mode=false)
static lookupBehaviour(int $a_id)
ilItemGroupAR $item_data_ar
__construct(int $a_id=0, bool $a_reference=true)
Constructor.
setListPresentation(string $a_val)
cloneDependencies(int $a_target_id, int $a_copy_id)
Clone object dependencies.
static lookupHideTitle(int $a_id)
static fixContainerItemGroupRefsAfterCloning(ilContainer $a_source_container, int $a_copy_id)
setHideTitle(bool $a_val)
static lookup(int $a_id, string $a_key)
setBehaviour(int $a_val)
Set behaviour (see ilItemGroupBehaviour)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
static getInstance(int $obj_id)
ilLanguage $lng
ilTree $tree
setTitle(string $title)
getLongDescription()
get object long description (stored in object_description)
static _lookupObjId(int $ref_id)
setDescription(string $desc)
static modifyItemGroupRefIdsByMapping(ilPageObject $a_page, array $mappings)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc