ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilContainer.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\News\Service as News;
22
30class ilContainer extends ilObject
31{
32 protected News $news;
33 protected \ILIAS\Style\Content\DomainService $content_style_domain;
34 // container view constants
35 public const VIEW_SESSIONS = 0;
36 public const VIEW_OBJECTIVE = 1;
37 public const VIEW_TIMING = 2;
38 public const VIEW_ARCHIVE = 3;
39 public const VIEW_SIMPLE = 4;
40 public const VIEW_BY_TYPE = 5;
41 public const VIEW_INHERIT = 6;
42
44
45 public const SORT_TITLE = 0;
46 public const SORT_MANUAL = 1;
47 public const SORT_ACTIVATION = 2;
48 public const SORT_INHERIT = 3;
49 public const SORT_CREATION = 4;
50
51 public const SORT_DIRECTION_ASC = 0;
52 public const SORT_DIRECTION_DESC = 1;
53
56
60
61 public const TILE_NORMAL = 0;
62 public const TILE_SMALL = 1;
63 public const TILE_LARGE = 2;
64 public const TILE_EXTRA_LARGE = 3;
65 public const TILE_FULL = 4;
66
67 public static bool $data_preloaded = false;
68 protected \ILIAS\Container\InternalDomainService $domain;
69
72 protected ilObjUser $user;
73 public array $items = [];
75 protected int $order_type = 0;
76 protected bool $hiddenfilesfound = false;
77 protected bool $news_timeline = false;
78 protected bool $news_timeline_auto_entries = false;
80 protected ?Translations $obj_trans = null;
81 protected int $style_id = 0;
82 protected bool $news_timeline_landing_page = false;
83 protected bool $news_block_activated = false;
84 protected bool $use_news = false;
86
87 protected ?array $type_grps = null;
88
89 public function __construct(int $a_id = 0, bool $a_reference = true)
90 {
92 global $DIC;
93
94 $this->db = $DIC->database();
95 $this->log = $DIC["ilLog"];
96 $this->access = $DIC->access();
97 $this->error = $DIC["ilErr"];
98 $this->rbacsystem = $DIC->rbac()->system();
99 $this->tree = $DIC->repositoryTree();
100 $this->user = $DIC->user();
101 $this->obj_definition = $DIC["objDefinition"];
102 $this->news = $DIC->news();
103
104
105 $this->setting = $DIC["ilSetting"];
106 parent::__construct($a_id, $a_reference);
107
108 $this->recommended_content_manager = new ilRecommendedContentManager();
109 $this->content_style_domain = $DIC->contentStyle()->domain();
110 $this->domain = $DIC->container()->internal()->domain();
111 }
112
116 public function getTileSizes(): array
117 {
119 return [
120 self::TILE_SMALL => $lng->txt("cont_tile_size_1"),
121 self::TILE_NORMAL => $lng->txt("cont_tile_size_0"),
122 self::TILE_LARGE => $lng->txt("cont_tile_size_2"),
123 self::TILE_EXTRA_LARGE => $lng->txt("cont_tile_size_3"),
124 self::TILE_FULL => $lng->txt("cont_tile_size_4")
125 ];
126 }
127
129 {
130 return $this->obj_trans;
131 }
132
134 {
135 $this->obj_trans = $obj_trans;
136 }
137
138 // <webspace_dir>/container_data.
139 public function createContainerDirectory(): void
140 {
141 $webspace_dir = ilFileUtils::getWebspaceDir();
142 $cont_dir = $webspace_dir . "/container_data";
143 if (!is_dir($cont_dir)) {
144 ilFileUtils::makeDir($cont_dir);
145 }
146 $obj_dir = $cont_dir . "/obj_" . $this->getId();
147 if (!is_dir($obj_dir)) {
148 ilFileUtils::makeDir($obj_dir);
149 }
150 }
151
152 public function getContainerDirectory(): string
153 {
154 return self::_getContainerDirectory($this->getId());
155 }
156
157 public static function _getContainerDirectory(int $a_id): string
158 {
159 return ilFileUtils::getWebspaceDir() . "/container_data/obj_" . $a_id;
160 }
161
162 // Set Found hidden files (set by getSubItems).
163 public function setHiddenFilesFound(bool $a_hiddenfilesfound): void
164 {
165 $this->hiddenfilesfound = $a_hiddenfilesfound;
166 }
167
168 public function getHiddenFilesFound(): bool
169 {
171 }
172
173 public function getStyleSheetId(): int
174 {
175 return $this->style_id;
176 }
177
178 public function setStyleSheetId(int $a_style_id): void
179 {
180 $this->style_id = $a_style_id;
181 }
182
183 public function setNewsTimeline(bool $a_val): void
184 {
185 $this->news_timeline = $a_val;
186 }
187
188 public function getNewsTimeline(): bool
189 {
191 }
192
193 public function setNewsTimelineAutoEntries(bool $a_val): void
194 {
195 $this->news_timeline_auto_entries = $a_val;
196 }
197
198 public function getNewsTimelineAutoEntries(): bool
199 {
201 }
202
203 public function setNewsTimelineLandingPage(bool $a_val): void
204 {
205 $this->news_timeline_landing_page = $a_val;
206 }
207
208 public function getNewsTimelineLandingPage(): bool
209 {
211 }
212
213 public function isNewsTimelineEffective(): bool
214 {
215 if (!$this->news->isGloballyActivated()) {
216 return false;
217 }
218 if ($this->getUseNews() && $this->getNewsTimeline()) {
219 return true;
220 }
221 return false;
222 }
223
225 {
226 if ($this->getUseNews() && $this->getNewsTimeline() && $this->getNewsTimelineLandingPage()) {
227 return true;
228 }
229 return false;
230 }
231
232
233 public function setNewsBlockActivated(bool $a_val): void
234 {
235 $this->news_block_activated = $a_val;
236 }
237
238 public function getNewsBlockActivated(): bool
239 {
241 }
242
243 public function setUseNews(bool $a_val): void
244 {
245 $this->use_news = $a_val;
246 }
247
248 public function getUseNews(): bool
249 {
250 return $this->use_news;
251 }
252
253 public static function _lookupContainerSetting(
254 int $a_id,
255 string $a_keyword,
256 ?string $a_default_value = null
257 ): string {
258 global $DIC;
259
260 $ilDB = $DIC->database();
261
262 $q = "SELECT value FROM container_settings WHERE " .
263 " id = " . $ilDB->quote($a_id, 'integer') . " AND " .
264 " keyword = " . $ilDB->quote($a_keyword, 'text');
265 $set = $ilDB->query($q);
266 $rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
267
268 if (isset($rec['value'])) {
269 return $rec["value"];
270 }
271
272 return $a_default_value ?? '';
273 }
274
275 public static function _hasContainerSetting(
276 int $a_id,
277 string $a_keyword
278 ): string {
279 global $DIC;
280
281 $ilDB = $DIC->database();
282
283 $q = "SELECT value FROM container_settings WHERE " .
284 " id = " . $ilDB->quote($a_id, 'integer') . " AND " .
285 " keyword = " . $ilDB->quote($a_keyword, 'text');
286 $set = $ilDB->query($q);
287 $rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
288
289 return (bool) $rec;
290 }
291
292 public static function _writeContainerSetting(
293 int $a_id,
294 string $a_keyword,
295 string $a_value
296 ): void {
297 global $DIC;
298
299 $ilDB = $DIC->database();
300
301 $query = "DELETE FROM container_settings WHERE " .
302 "id = " . $ilDB->quote($a_id, 'integer') . " " .
303 "AND keyword = " . $ilDB->quote($a_keyword, 'text');
304 $ilDB->manipulate($query);
305
307 $log->debug("Write container setting, id: " . $a_id . ", keyword: " . $a_keyword . ", value: " . $a_value);
308
309 $query = "INSERT INTO container_settings (id, keyword, value) VALUES (" .
310 $ilDB->quote($a_id, 'integer') . ", " .
311 $ilDB->quote($a_keyword, 'text') . ", " .
312 $ilDB->quote($a_value, 'text') .
313 ")";
314
315 $ilDB->manipulate($query);
316 }
317
322 public static function _getContainerSettings(int $a_id): array
323 {
324 global $DIC;
325
326 $ilDB = $DIC->database();
327
328 $res = [];
329
330 $sql = "SELECT keyword, value FROM container_settings WHERE " .
331 " id = " . $ilDB->quote($a_id, 'integer');
332 $set = $ilDB->query($sql);
333 while ($row = $ilDB->fetchAssoc($set)) {
334 $res[$row["keyword"]] = $row["value"];
335 }
336
337 return $res;
338 }
339
340 public static function _deleteContainerSettings(
341 int $a_id,
342 string $a_keyword = "",
343 bool $a_keyword_like = false
344 ): void {
345 global $DIC;
346
347 $ilDB = $DIC->database();
348
349 if (!$a_id) {
350 return;
351 }
352
353 $sql = "DELETE FROM container_settings WHERE " .
354 " id = " . $ilDB->quote($a_id, 'integer');
355 if ($a_keyword !== "") {
356 if (!$a_keyword_like) {
357 $sql .= " AND keyword = " . $ilDB->quote($a_keyword, "text");
358 } else {
359 $sql .= " AND " . $ilDB->like("keyword", "text", $a_keyword);
360 }
361 }
362 $ilDB->manipulate($sql);
363 }
364
365 public static function _exportContainerSettings(
366 ilXmlWriter $a_xml,
367 int $a_obj_id
368 ): void {
369 // container settings
370 $settings = self::_getContainerSettings($a_obj_id);
371 if (count($settings)) {
372 $a_xml->xmlStartTag("ContainerSettings");
373
374 foreach ($settings as $keyword => $value) {
375 // :TODO: proper custom icon export/import
376 if (
377 stripos($keyword, "icon") !== false
378 && $keyword !== 'hide_header_icon_and_title'
379 ) {
380 continue;
381 }
382
383 $a_xml->xmlStartTag(
384 'ContainerSetting',
385 [
386 'id' => $keyword,
387 ]
388 );
389
390 $a_xml->xmlData((string) $value);
391 $a_xml->xmlEndTag("ContainerSetting");
392 }
393
394 $a_xml->xmlEndTag("ContainerSettings");
395 }
396 }
397
406 public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ?ilObject
407 {
409 $new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);
410
412
413 // translations
414 $ot = $this->getObjectProperties()->clonePropertyTranslations($new_obj->getId())
415 ->withDefaultTitle($new_obj->getTitle());
416 $new_obj->getObjectProperties()->storePropertyTranslations($ot);
417 $new_obj->setObjectTranslation($ot);
418 if ($ot->getDefaultDescription() !== "") {
419 $new_obj->setDescription($ot->getDefaultDescription());
420 }
421 $log->debug("**1**" . count($new_obj->getObjectTranslation()->getLanguages()));
422 $log->debug("ilContainer: cloning translations from " . $this->getId() . " to " .
423 $new_obj->getId());
424
425 #18624 - copy all sorting settings
426 ilContainerSortingSettings::_cloneSettings($this->getId(), $new_obj->getId());
427
428 // copy content page
430 "cont",
431 $this->getId()
432 )) {
433 $orig_page = new ilContainerPage($this->getId());
434 $orig_page->copy($new_obj->getId(), "cont", $new_obj->getId());
435 }
436
437 // #20614 - copy style
438 $this->content_style_domain->styleForRefId($this->getRefId())->cloneTo($new_obj->getId());
439
440 // #10271 - copy start objects page
442 "cstr",
443 $this->getId()
444 )) {
445 $orig_page = new ilContainerStartObjectsPage($this->getId());
446 $orig_page->copy($new_obj->getId(), "cstr", $new_obj->getId());
447 }
448
449 // #10271
450 foreach (self::_getContainerSettings($this->getId()) as $keyword => $value) {
451 self::_writeContainerSetting($new_obj->getId(), (string) $keyword, (string) $value);
452 }
453
454 $new_obj->setNewsTimeline($this->getNewsTimeline());
455 $new_obj->setNewsBlockActivated($this->getNewsBlockActivated());
456 $new_obj->setUseNews($this->getUseNews());
457 $new_obj->setNewsTimelineAutoEntries($this->getNewsTimelineAutoEntries());
458 $new_obj->setNewsTimelineLandingPage($this->getNewsTimelineLandingPage());
459 ilBlockSetting::cloneSettingsOfBlock("news", $this->getId(), $new_obj->getId());
460 $mom_noti = new ilMembershipNotifications($this->getRefId());
461 $mom_noti->cloneSettings($new_obj->getRefId());
462
463 // clone filter fields
464 $container_filter_service = new ilContainerFilterService();
465 $container_filter_service->cloneFilterFields($this->getRefId(), $new_obj->getRefId());
466
467 return $new_obj;
468 }
469
478 public function cloneDependencies(int $target_id, int $copy_id): bool
479 {
480 $ilLog = $this->log;
481
482 parent::cloneDependencies($target_id, $copy_id);
483
484 ilContainerSorting::_getInstance($this->getId())->cloneSorting($target_id, $copy_id);
485
486 // fix internal links to other objects
487 self::fixInternalLinksAfterCopy($target_id, $copy_id, $this->getRefId());
488
489 // fix item group references in page content
491
492 $olp = ilObjectLP::getInstance($this->getId());
493 $collection = $olp->getCollectionInstance();
494 if ($collection) {
495 $collection->cloneCollection($target_id, $copy_id);
496 }
497
498 return true;
499 }
500
512 public function cloneAllObject(
513 string $session_id,
514 string $client_id,
515 string $new_type,
516 int $ref_id,
517 int $clone_source,
518 array $options,
519 bool $soap_call = false,
520 int $a_submode = 1
521 ): array {
522 $ilLog = $this->log;
523 $ilUser = $this->user;
524
525 // Save wizard options
527 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
528 $wizard_options->saveOwner($ilUser->getId());
529 $wizard_options->saveRoot($clone_source);
530
531 // add entry for source container
532 $wizard_options->initContainer($clone_source, $ref_id);
533
534 foreach ($options as $source_id => $option) {
535 $wizard_options->addEntry($source_id, $option);
536 }
537 $wizard_options->read();
538 $wizard_options->storeTree($clone_source);
539
540 if ($a_submode === ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
541 ilLoggerFactory::getLogger('obj')->info('Copy content only...');
542 ilLoggerFactory::getLogger('obj')->debug('Added mapping, source ID: ' . $clone_source . ', target ID: ' . $ref_id);
543 $wizard_options->read();
544 $wizard_options->dropFirstNode();
545 $wizard_options->appendMapping($clone_source, $ref_id);
546 }
547
548
549 #print_r($options);
550 // Duplicate session to avoid logout problems with backgrounded SOAP calls
551 $new_session_id = ilSession::_duplicate($session_id);
552 // Start cloning process using soap call
553 $soap_client = new ilSoapClient();
554 $soap_client->setResponseTimeout($soap_client->getResponseTimeout());
555 $soap_client->enableWSDL(true);
556
557 $ilLog->write(__METHOD__ . ': Trying to call Soap client...');
558 if ($soap_client->init()) {
559 ilLoggerFactory::getLogger('obj')->info('Calling soap clone method');
560 $res = $soap_client->call('ilClone', [$new_session_id . '::' . $client_id, $copy_id]);
561 } else {
562 ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
563 $wizard_options->disableSOAP();
564 $wizard_options->read();
565 $res = ilSoapFunctions::ilClone($new_session_id . '::' . $client_id, $copy_id);
566 }
567 return [
568 'copy_id' => $copy_id,
569 'ref_id' => (int) $res
570 ];
571 }
572
578 public function delete(): bool
579 {
580 // always call parent delete function first!!
581 if (!parent::delete()) {
582 return false;
583 }
584 // delete translations
585 $this->getObjectProperties()->deletePropertyTranslations();
586
587 // delete content page
588 $this->domain->page($this)->deletePage();
589
590 return true;
591 }
592
593 public function getViewMode(): int
594 {
595 return self::VIEW_BY_TYPE;
596 }
597
598 public function getOrderType(): int
599 {
600 return $this->order_type ?: self::SORT_TITLE;
601 }
602
603 public function setOrderType(int $a_value): void
604 {
605 $this->order_type = $a_value;
606 }
607
608 public function isClassificationFilterActive(): bool
609 {
610 // apply container classification filters
611 $classification = $this->domain->classification($this->getRefId());
612 foreach (ilClassificationProvider::getValidProviders($this->getRefId(), $this->getId(), $this->getType()) as $class_provider) {
613 $id = get_class($class_provider);
614 $current = $classification->getSelectionOfProvider($id);
615 if ($current) {
616 return true;
617 }
618 }
619 return false;
620 }
621
626 public function filteredSubtree(): bool
627 {
628 if ($this->isClassificationFilterActive() && in_array($this->getType(), ["grp", "crs"])) {
629 return true;
630 }
631 return false;
632 }
633
637 protected function getInitialSubitems(): array
638 {
639 $tree = $this->tree;
640 if ($this->filteredSubtree()) {
641 $objects = $tree->getSubTree($tree->getNodeData($this->getRefId()));
642 } else {
643 $objects = $tree->getChilds($this->getRefId(), "title");
644 }
645 return $objects;
646 }
647
651 public function getSubItems(
652 bool $a_admin_panel_enabled = false,
653 bool $a_include_side_block = false,
654 int $a_get_single = 0,
655 ?ilContainerUserFilter $container_user_filter = null
656 ): array {
657 $objDefinition = $this->obj_definition;
658
659 // Caching
660 if (
661 isset($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
662 is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
663 !$a_get_single
664 ) {
665 return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
666 }
667
668 $objects = $this->getInitialSubitems();
669 $objects = $this->applyContainerUserFilter($objects, $container_user_filter);
670 $objects = self::getCompleteDescriptions($objects);
671
672 // apply container classification filters
673 $classification = $this->domain->classification($this->getRefId());
674 foreach (ilClassificationProvider::getValidProviders($this->getRefId(), $this->getId(), $this->getType()) as $class_provider) {
675 $id = get_class($class_provider);
676 $current = $classification->getSelectionOfProvider($id);
677 if ($current) {
678 $class_provider->setSelection($current);
679 $filtered = $class_provider->getFilteredObjects();
680 $objects = array_filter($objects, static function (array $i) use ($filtered): bool {
681 return (is_array($filtered) && in_array($i["obj_id"], $filtered));
682 });
683 }
684 }
685
686 $found = false;
687 $all_ref_ids = [];
688
689 $preloader = null;
690 if (!self::$data_preloaded) {
692 }
693
694 $sort = ilContainerSorting::_getInstance($this->getId());
695
696 // TODO: check this
697 // get items attached to a session
698
699 $classification_filter_active = $this->isClassificationFilterActive();
700 foreach ($objects as $key => $object) {
701 // see #41377, this ensures session materials to be preloaded
702 if (!self::$data_preloaded) {
703 if ($object["type"] === "sess") {
704 $ev_items = ilObjectActivation::getItemsByEvent((int) $object["obj_id"]);
705 foreach ($ev_items as $ev_item) {
706 $preloader->addItem((int) $ev_item["obj_id"], $ev_item["type"], $ev_item["ref_id"]);
707 }
708 }
709 }
710 if ($a_get_single > 0 && $object["child"] != $a_get_single) {
711 continue;
712 }
713
714 // hide object types in devmode
715 if ($object["type"] === "adm" || $object["type"] === "rolf" || $objDefinition->getDevMode($object["type"])) {
716 continue;
717 }
718
719 // remove inactive plugins
720 if ($objDefinition->isInactivePlugin($object["type"])) {
721 continue;
722 }
723 // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
724 if (in_array(
725 $object['type'],
726 ['file', 'fold', 'cat'],
727 true
728 ) && ilObjFileAccess::_isFileHidden((string) $object['title'])) {
729 $this->setHiddenFilesFound(true);
730 if (!$a_admin_panel_enabled) {
731 continue;
732 }
733 }
734 // END WebDAV: Don't display hidden Files, Folders and Categories
735
736 if (!self::$data_preloaded) {
737 $preloader->addItem((int) $object["obj_id"], $object["type"], $object["child"]);
738 }
739
740 // filter side block items
741 if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
742 continue;
743 }
744
745 $all_ref_ids[] = (int) $object["child"];
746 }
747
748 // data preloader
749 if (!self::$data_preloaded) {
750 $preloader->preload();
751 unset($preloader);
752
753 self::$data_preloaded = true;
754 }
755
756 foreach ($objects as $key => $object) {
757 // see above, objects were filtered
758 if (!in_array($object["child"], $all_ref_ids)) {
759 continue;
760 }
761
762 // group object type groups together (e.g. learning resources)
763 $type = $objDefinition->getGroupOfObj($object["type"]);
764 if ($type == "") {
765 $type = $object["type"];
766 }
767
768 // this will add activation properties
769 $this->addAdditionalSubItemInformation($object);
770
771 $this->items[$type][$key] = $object;
772
773 $this->items["_all"][$key] = $object;
774 if ($object["type"] !== "sess") {
775 $this->items["_non_sess"][$key] = $object;
776 }
777 }
778 $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]
779 = $sort->sortItems($this->items);
780
781 return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
782 }
783
787 public function gotItems(): bool
788 {
789 if (isset($this->items["_all"]) && is_array($this->items["_all"]) && count($this->items["_all"]) > 0) {
790 return true;
791 }
792 return false;
793 }
794
799 public function addAdditionalSubItemInformation(array &$object): void
800 {
801 }
802
803 // Get grouped repository object types.
804 public function getGroupedObjTypes(): array
805 {
806 $objDefinition = $this->obj_definition;
807
808 if (empty($this->type_grps)) {
809 $this->type_grps = $objDefinition::getGroupedRepositoryObjectTypes($this->getType());
810 }
811 return $this->type_grps;
812 }
813
814 public function enablePageEditing(): bool
815 {
816 $ilSetting = $this->setting;
817
818 // @todo: this will need a more general approach
819 if ($ilSetting->get("enable_cat_page_edit")) {
820 return true;
821 }
822 return false;
823 }
824
825 public function create(): int
826 {
827 global $DIC;
828
829 $lng = $DIC->language();
830
831 $ret = parent::create();
832
833 // set translation object, since we have an object id now
834 $this->obj_trans = $this->getObjectProperties()->getPropertyTranslations();
835
836 // add default translation
837 $this->addTranslation(
838 $this->getTitle(),
839 $this->getLongDescription(),
840 $lng->getDefaultLanguage(),
841 '1'
842 );
843
844 if (($this->getStyleSheetId()) > 0) {
845 //ilObjStyleSheet::writeStyleUsage($this->getId(), $this->getStyleSheetId());
846 }
847
849 $log->debug("Create Container, id: " . $this->getId());
850
851 self::_writeContainerSetting($this->getId(), "news_timeline", (string) ((int) $this->getNewsTimeline()));
852 self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (string) ((int) $this->getNewsTimelineAutoEntries()));
853 self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (string) ((int) $this->getNewsTimelineLandingPage()));
854 self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (string) ((int) $this->getNewsBlockActivated()));
855 self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (string) ((int) $this->getUseNews()));
856
857 return $ret;
858 }
859
860 public function putInTree(int $parent_ref_id): void
861 {
862 parent::putInTree($parent_ref_id);
863
864 // copy title, icon actions visibilities
865 if (self::_lookupContainerSetting(ilObject::_lookupObjId($parent_ref_id), "hide_header_icon_and_title")) {
866 self::_writeContainerSetting($this->getId(), "hide_header_icon_and_title", '1');
867 }
868 if (self::_lookupContainerSetting(ilObject::_lookupObjId($parent_ref_id), "hide_top_actions")) {
869 self::_writeContainerSetting($this->getId(), "hide_top_actions", '1');
870 }
871 }
872
873 public function update(): bool
874 {
875 $ret = parent::update();
876
878 $log->debug("**5**" . count($this->getObjectProperties()->getPropertyTranslations()->getLanguages()));
879
880 $this->getObjectProperties()->storePropertyTranslations(
881 $this->getObjectProperties()->getPropertyTranslations()
882 ->withDefaultTitle($this->getTitle())
883 ->withDefaultDescription($this->getLongDescription())
884 );
885
887 $log->debug(":::::::::::::::::::::::::::");
888 $log->logStack(10);
889
890 //ilObjStyleSheet::writeStyleUsage($this->getId(), $this->getStyleSheetId());
891
893 $log->debug("Update Container, id: " . $this->getId());
894
895 self::_writeContainerSetting($this->getId(), "news_timeline", (string) ((int) $this->getNewsTimeline()));
896 self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (string) (int) $this->getNewsTimelineAutoEntries());
897 self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (string) ((int) ($this->getNewsTimelineLandingPage())));
898 self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (string) ((int) $this->getNewsBlockActivated()));
899 self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (string) ((int) $this->getUseNews()));
900
901 return $ret;
902 }
903
904 public function read(): void
905 {
906 parent::read();
907
908 $this->setOrderType(ilContainerSortingSettings::_lookupSortMode($this->getId()));
909
910 //$this->setStyleSheetId(ilObjStyleSheet::lookupObjectStyle($this->getId()));
911
912 $this->readContainerSettings();
913 $this->obj_trans = $this->getObjectProperties()->getPropertyTranslations();
914 }
915
916 public function readContainerSettings(): void
917 {
918 $this->setNewsTimeline((bool) self::_lookupContainerSetting($this->getId(), "news_timeline"));
919 $this->setNewsTimelineAutoEntries((bool) self::_lookupContainerSetting($this->getId(), "news_timeline_incl_auto"));
920 $this->setNewsTimelineLandingPage((bool) self::_lookupContainerSetting($this->getId(), "news_timeline_landing_page"));
921 $this->setNewsBlockActivated((bool) self::_lookupContainerSetting(
922 $this->getId(),
924 $this->setting->get('block_activated_news', '1')
925 ));
926 $this->setUseNews((bool) self::_lookupContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, '1') &&
927 $this->news->isGloballyActivated());
928 }
929
930
935 public static function getCompleteDescriptions(array $objects): array
936 {
937 global $DIC;
938
939 $ilSetting = $DIC->settings();
940 $ilObjDataCache = $DIC["ilObjDataCache"];
941
942 // using long descriptions?
943 $short_desc = $ilSetting->get("rep_shorten_description");
944 $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
945 if (!$short_desc || (int) $short_desc_max_length !== ilObject::DESC_LENGTH) {
946 // using (part of) shortened description
947 if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::DESC_LENGTH) {
948 foreach ($objects as $key => $object) {
949 $objects[$key]["description"] = ilStr::shortenTextExtended(
950 $object["description"],
951 (int) $short_desc_max_length,
952 true
953 );
954 }
955 }
956 // using (part of) long description
957 else {
958 $obj_ids = [];
959 foreach ($objects as $key => $object) {
960 $obj_ids[] = $object["obj_id"];
961 }
962 if (count($obj_ids)) {
963 $long_desc = ilObject::getLongDescriptions($obj_ids);
964 foreach ($objects as $key => $object) {
965 // #12166 - keep translation, ignore long description
966 if ($ilObjDataCache->isTranslatedDescription((int) $object["obj_id"])) {
967 $long_desc[$object["obj_id"]] = $object["description"];
968 }
969 if ($short_desc && $short_desc_max_length) {
970 $long_desc[$object["obj_id"]] = ilStr::shortenTextExtended(
971 $long_desc[$object["obj_id"]] ?? '',
972 (int) $short_desc_max_length,
973 true
974 );
975 }
976 $objects[$key]["description"] = $long_desc[$object["obj_id"]] ?? '';
977 }
978 }
979 }
980 }
981 return $objects;
982 }
983
984 protected static function fixInternalLinksAfterCopy(
985 int $a_target_id,
986 int $a_copy_id,
987 int $a_source_ref_id
988 ): void {
989 global $DIC;
990
992 $obj_definition = $DIC["objDefinition"];
993
994 $obj_id = ilObject::_lookupObjId($a_target_id);
995 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
996 $mapping = $cwo->getMappings();
997
998 if (ilContainerPage::_exists("cont", $obj_id)) {
999 $pg = new ilContainerPage($obj_id);
1000 $pg->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1001 $pg->update(true, true);
1002 foreach (ilContainerPage::lookupTranslations("cont", $obj_id) as $trans) {
1003 if ($trans !== "-" && ilContainerPage::_exists("cont", $obj_id, $trans, true)) {
1004 $pg = new ilContainerPage($obj_id, 0, $trans);
1005 $pg->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1006 $pg->update(true, true);
1007 }
1008 }
1009 }
1010
1011 foreach ($mapping as $old_ref_id => $new_ref_id) {
1012 if (!is_numeric($old_ref_id) || !is_numeric($new_ref_id)) {
1013 continue;
1014 }
1015
1016 $type = ilObject::_lookupType($new_ref_id, true);
1017 $class = 'il' . $obj_definition->getClassName($type) . 'PageCollector';
1018 $loc = $obj_definition->getLocation($type);
1019 $file = $loc . '/class.' . $class . '.php';
1020
1021 if (is_file($file)) {
1023 $coll = new $class();
1024 foreach ($coll->getAllPageIds(ilObject::_lookupObjId($new_ref_id)) as $page_id) {
1025 if (ilPageObject::_exists($page_id['parent_type'], $page_id['id'], $page_id['lang'])) {
1027 $page = ilPageObjectFactory::getInstance($page_id['parent_type'], $page_id['id'], 0, $page_id['lang']);
1028 $page->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1029 $page->update(true, true);
1030 }
1031 }
1032 }
1033 }
1034 }
1035
1036 // Remove all translations of container
1037 public function removeTranslations(): void
1038 {
1039 $this->getObjectProperties()->deletePropertyTranslations();
1040 }
1041
1042 public function deleteTranslation(string $a_lang): void
1043 {
1044 $this->obj_trans = $this->obj_trans->withoutLanguage($a_lang);
1045 $this->getObjectProperties()->storePropertyTranslations($this->obj_trans);
1046 }
1047
1048 public function addTranslation(
1049 string $a_title,
1050 string $a_desc,
1051 string $a_lang,
1052 string $a_lang_default
1053 ): void {
1054 if (empty($a_title)) {
1055 $a_title = "NO TITLE";
1056 }
1057
1058 $this->obj_trans = $this->obj_trans->withLanguage(
1059 new Language(
1060 $a_lang,
1061 $a_title,
1062 $a_desc,
1063 (bool) $a_lang_default
1064 )
1065 );
1066 $this->getObjectProperties()->storePropertyTranslations($this->obj_trans);
1067 }
1068
1069 protected function applyContainerUserFilter(
1070 array $objects,
1071 ?ilContainerUserFilter $container_user_filter = null
1072 ): array {
1073 $filter = $this->domain->content()->filter(
1074 $objects,
1075 $container_user_filter,
1076 !self::_lookupContainerSetting($this->getId(), "filter_show_empty", false)
1077 );
1078 return $filter->apply();
1079 }
1080}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$classification
Class handles translation mode for an object.
error(string $a_errmsg)
static cloneSettingsOfBlock(string $block_type, int $block_id, int $new_block_id)
static getValidProviders(int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
Get all valid providers (for parent container)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Container page object.
static _cloneSettings(int $a_old_id, int $a_new_id)
static _getInstance(int $a_obj_id)
Container start objects page object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilContainer.
ILIAS Style Content DomainService $content_style_domain
cloneAllObject(string $session_id, string $client_id, string $new_type, int $ref_id, int $clone_source, array $options, bool $soap_call=false, int $a_submode=1)
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
const SORT_DIRECTION_DESC
setUseNews(bool $a_val)
ilObjectDefinition $obj_definition
ilRecommendedContentManager $recommended_content_manager
ilRbacSystem $rbacsystem
static getCompleteDescriptions(array $objects)
overwrites description fields to long or short description in an assoc array keys needed (obj_id and ...
deleteTranslation(string $a_lang)
cloneDependencies(int $target_id, int $copy_id)
Clone object dependencies (container sorting)
create()
note: title, description and type should be set when this function is called
setNewsTimelineAutoEntries(bool $a_val)
const SORT_NEW_ITEMS_ORDER_ACTIVATION
Translations $obj_trans
bool $news_timeline_auto_entries
setOrderType(int $a_value)
setStyleSheetId(int $a_style_id)
setObjectTranslation(?Translations $obj_trans)
addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default)
setNewsBlockActivated(bool $a_val)
static _getContainerSettings(int $a_id)
filteredSubtree()
Note grp/crs currently allow to filter in their whole subtrees Catetories only their direct childs.
const SORT_NEW_ITEMS_ORDER_TITLE
const SORT_NEW_ITEMS_ORDER_CREATION
setNewsTimelineLandingPage(bool $a_val)
addAdditionalSubItemInformation(array &$object)
Add additional information to sub item, e.g.
getSubItems(bool $a_admin_panel_enabled=false, bool $a_include_side_block=false, int $a_get_single=0, ?ilContainerUserFilter $container_user_filter=null)
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
setHiddenFilesFound(bool $a_hiddenfilesfound)
static _hasContainerSetting(int $a_id, string $a_keyword)
bool $news_timeline_landing_page
const SORT_NEW_ITEMS_POSITION_BOTTOM
ilAccessHandler $access
ILIAS Container InternalDomainService $domain
static _getContainerDirectory(int $a_id)
setNewsTimeline(bool $a_val)
const SORT_NEW_ITEMS_POSITION_TOP
const SORT_DIRECTION_ASC
ilSetting $setting
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)
static bool $data_preloaded
isNewsTimelineLandingPageEffective()
static _exportContainerSettings(ilXmlWriter $a_xml, int $a_obj_id)
applyContainerUserFilter(array $objects, ?ilContainerUserFilter $container_user_filter=null)
bool $news_block_activated
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance(int $a_copy_id)
const FETCHMODE_ASSOC
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
Membership notification settings.
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.
static fixContainerItemGroupRefsAfterCloning(ilContainer $a_source_container, int $a_copy_id)
User class.
static getItemsByEvent(int $event_id)
Get session material / event items.
parses the objects.xml it handles the xml-description of all ilias objects
getClassName(string $obj_name)
static getInstance(int $obj_id)
Preloader for object list GUIs.
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
ilLanguage $lng
const DESC_LENGTH
static getLongDescriptions(array $obj_ids)
static _lookupObjId(int $ref_id)
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static lookupTranslations(string $a_parent_type, int $a_id)
Lookup translations.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _duplicate(string $a_session_id)
Duplicate session.
ILIAS Setting Class.
static ilClone(string $sid, int $copy_identifier)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlEndTag(string $tag)
Writes an endtag.
xmlData(string $data, bool $encode=true, bool $escape=true)
Writes data.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$client_id
Definition: ltiauth.php:67
$ref_id
Definition: ltiauth.php:66
$log
Definition: ltiresult.php:34
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $lng
Definition: privfeed.php:31
global $ilSetting
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:25