ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilContainer.php
Go to the documentation of this file.
1 <?php
2 
19 use ILIAS\News\Service as News;
22 
30 class 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 
43  public const VIEW_DEFAULT = self::VIEW_BY_TYPE;
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 
54  public const SORT_NEW_ITEMS_POSITION_TOP = 0;
56 
57  public const SORT_NEW_ITEMS_ORDER_TITLE = 0;
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;
79  protected ilSetting $setting;
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  {
118  $lng = $this->lng;
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 
128  public function getObjectTranslation(): ?Translations
129  {
130  return $this->obj_trans;
131  }
132 
133  public function setObjectTranslation(?Translations $obj_trans): void
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  {
190  return $this->news_timeline;
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 
224  public function isNewsTimelineLandingPageEffective(): bool
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  return true;
588  }
589 
590  public function getViewMode(): int
591  {
592  return self::VIEW_BY_TYPE;
593  }
594 
595  public function getOrderType(): int
596  {
597  return $this->order_type ?: self::SORT_TITLE;
598  }
599 
600  public function setOrderType(int $a_value): void
601  {
602  $this->order_type = $a_value;
603  }
604 
605  public function isClassificationFilterActive(): bool
606  {
607  // apply container classification filters
608  $classification = $this->domain->classification($this->getRefId());
609  foreach (ilClassificationProvider::getValidProviders($this->getRefId(), $this->getId(), $this->getType()) as $class_provider) {
610  $id = get_class($class_provider);
611  $current = $classification->getSelectionOfProvider($id);
612  if ($current) {
613  return true;
614  }
615  }
616  return false;
617  }
618 
623  public function filteredSubtree(): bool
624  {
625  if ($this->isClassificationFilterActive() && in_array($this->getType(), ["grp", "crs"])) {
626  return true;
627  }
628  return false;
629  }
630 
634  protected function getInitialSubitems(): array
635  {
636  $tree = $this->tree;
637  if ($this->filteredSubtree()) {
638  $objects = $tree->getSubTree($tree->getNodeData($this->getRefId()));
639  } else {
640  $objects = $tree->getChilds($this->getRefId(), "title");
641  }
642  return $objects;
643  }
644 
648  public function getSubItems(
649  bool $a_admin_panel_enabled = false,
650  bool $a_include_side_block = false,
651  int $a_get_single = 0,
652  ?ilContainerUserFilter $container_user_filter = null
653  ): array {
654  $objDefinition = $this->obj_definition;
655 
656  // Caching
657  if (
658  isset($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
659  is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
660  !$a_get_single
661  ) {
662  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
663  }
664 
665  $objects = $this->getInitialSubitems();
666  $objects = $this->applyContainerUserFilter($objects, $container_user_filter);
667  $objects = self::getCompleteDescriptions($objects);
668 
669  // apply container classification filters
670  $classification = $this->domain->classification($this->getRefId());
671  foreach (ilClassificationProvider::getValidProviders($this->getRefId(), $this->getId(), $this->getType()) as $class_provider) {
672  $id = get_class($class_provider);
673  $current = $classification->getSelectionOfProvider($id);
674  if ($current) {
675  $class_provider->setSelection($current);
676  $filtered = $class_provider->getFilteredObjects();
677  $objects = array_filter($objects, static function (array $i) use ($filtered): bool {
678  return (is_array($filtered) && in_array($i["obj_id"], $filtered));
679  });
680  }
681  }
682 
683  $found = false;
684  $all_ref_ids = [];
685 
686  $preloader = null;
687  if (!self::$data_preloaded) {
689  }
690 
691  $sort = ilContainerSorting::_getInstance($this->getId());
692 
693  // TODO: check this
694  // get items attached to a session
695 
696  $classification_filter_active = $this->isClassificationFilterActive();
697  foreach ($objects as $key => $object) {
698  // see #41377, this ensures session materials to be preloaded
699  if (!self::$data_preloaded) {
700  if ($object["type"] === "sess") {
701  $ev_items = ilObjectActivation::getItemsByEvent((int) $object["obj_id"]);
702  foreach ($ev_items as $ev_item) {
703  $preloader->addItem((int) $ev_item["obj_id"], $ev_item["type"], $ev_item["ref_id"]);
704  }
705  }
706  }
707  if ($a_get_single > 0 && $object["child"] != $a_get_single) {
708  continue;
709  }
710 
711  // hide object types in devmode
712  if ($object["type"] === "adm" || $object["type"] === "rolf" || $objDefinition->getDevMode($object["type"])) {
713  continue;
714  }
715 
716  // remove inactive plugins
717  if ($objDefinition->isInactivePlugin($object["type"])) {
718  continue;
719  }
720  // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
721  if (in_array(
722  $object['type'],
723  ['file', 'fold', 'cat'],
724  true
725  ) && ilObjFileAccess::_isFileHidden((string) $object['title'])) {
726  $this->setHiddenFilesFound(true);
727  if (!$a_admin_panel_enabled) {
728  continue;
729  }
730  }
731  // END WebDAV: Don't display hidden Files, Folders and Categories
732 
733  if (!self::$data_preloaded) {
734  $preloader->addItem((int) $object["obj_id"], $object["type"], $object["child"]);
735  }
736 
737  // filter side block items
738  if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
739  continue;
740  }
741 
742  $all_ref_ids[] = (int) $object["child"];
743  }
744 
745  // data preloader
746  if (!self::$data_preloaded) {
747  $preloader->preload();
748  unset($preloader);
749 
750  self::$data_preloaded = true;
751  }
752 
753  foreach ($objects as $key => $object) {
754  // see above, objects were filtered
755  if (!in_array($object["child"], $all_ref_ids)) {
756  continue;
757  }
758 
759  // group object type groups together (e.g. learning resources)
760  $type = $objDefinition->getGroupOfObj($object["type"]);
761  if ($type == "") {
762  $type = $object["type"];
763  }
764 
765  // this will add activation properties
766  $this->addAdditionalSubItemInformation($object);
767 
768  $this->items[$type][$key] = $object;
769 
770  $this->items["_all"][$key] = $object;
771  if ($object["type"] !== "sess") {
772  $this->items["_non_sess"][$key] = $object;
773  }
774  }
775  $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]
776  = $sort->sortItems($this->items);
777 
778  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
779  }
780 
784  public function gotItems(): bool
785  {
786  if (isset($this->items["_all"]) && is_array($this->items["_all"]) && count($this->items["_all"]) > 0) {
787  return true;
788  }
789  return false;
790  }
791 
796  public function addAdditionalSubItemInformation(array &$object): void
797  {
798  }
799 
800  // Get grouped repository object types.
801  public function getGroupedObjTypes(): array
802  {
803  $objDefinition = $this->obj_definition;
804 
805  if (empty($this->type_grps)) {
806  $this->type_grps = $objDefinition::getGroupedRepositoryObjectTypes($this->getType());
807  }
808  return $this->type_grps;
809  }
810 
811  public function enablePageEditing(): bool
812  {
814 
815  // @todo: this will need a more general approach
816  if ($ilSetting->get("enable_cat_page_edit")) {
817  return true;
818  }
819  return false;
820  }
821 
822  public function create(): int
823  {
824  global $DIC;
825 
826  $lng = $DIC->language();
827 
828  $ret = parent::create();
829 
830  // set translation object, since we have an object id now
831  $this->obj_trans = $this->getObjectProperties()->getPropertyTranslations();
832 
833  // add default translation
834  $this->addTranslation(
835  $this->getTitle(),
836  $this->getDescription(),
838  '1'
839  );
840 
841  if (($this->getStyleSheetId()) > 0) {
842  //ilObjStyleSheet::writeStyleUsage($this->getId(), $this->getStyleSheetId());
843  }
844 
846  $log->debug("Create Container, id: " . $this->getId());
847 
848  self::_writeContainerSetting($this->getId(), "news_timeline", (string) ((int) $this->getNewsTimeline()));
849  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (string) ((int) $this->getNewsTimelineAutoEntries()));
850  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (string) ((int) $this->getNewsTimelineLandingPage()));
851  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (string) ((int) $this->getNewsBlockActivated()));
852  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (string) ((int) $this->getUseNews()));
853 
854  return $ret;
855  }
856 
857  public function putInTree(int $parent_ref_id): void
858  {
859  parent::putInTree($parent_ref_id);
860 
861  // copy title, icon actions visibilities
862  if (self::_lookupContainerSetting(ilObject::_lookupObjId($parent_ref_id), "hide_header_icon_and_title")) {
863  self::_writeContainerSetting($this->getId(), "hide_header_icon_and_title", '1');
864  }
865  if (self::_lookupContainerSetting(ilObject::_lookupObjId($parent_ref_id), "hide_top_actions")) {
866  self::_writeContainerSetting($this->getId(), "hide_top_actions", '1');
867  }
868  }
869 
870  public function update(): bool
871  {
872  $ret = parent::update();
873 
875  $log->debug("**5**" . count($this->getObjectProperties()->getPropertyTranslations()->getLanguages()));
876 
877  $this->getObjectProperties()->storePropertyTranslations(
878  $this->getObjectProperties()->getPropertyTranslations()
879  ->withDefaultTitle($this->getTitle())
880  ->withDefaultDescription($this->getLongDescription())
881  );
882 
884  $log->debug(":::::::::::::::::::::::::::");
885  $log->logStack(10);
886 
887  //ilObjStyleSheet::writeStyleUsage($this->getId(), $this->getStyleSheetId());
888 
890  $log->debug("Update Container, id: " . $this->getId());
891 
892  self::_writeContainerSetting($this->getId(), "news_timeline", (string) ((int) $this->getNewsTimeline()));
893  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (string) (int) $this->getNewsTimelineAutoEntries());
894  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (string) ((int) ($this->getNewsTimelineLandingPage())));
895  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (string) ((int) $this->getNewsBlockActivated()));
896  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (string) ((int) $this->getUseNews()));
897 
898  return $ret;
899  }
900 
901  public function read(): void
902  {
903  parent::read();
904 
906 
907  //$this->setStyleSheetId(ilObjStyleSheet::lookupObjectStyle($this->getId()));
908 
909  $this->readContainerSettings();
910  $this->obj_trans = $this->getObjectProperties()->getPropertyTranslations();
911  }
912 
913  public function readContainerSettings(): void
914  {
915  $this->setNewsTimeline((bool) self::_lookupContainerSetting($this->getId(), "news_timeline"));
916  $this->setNewsTimelineAutoEntries((bool) self::_lookupContainerSetting($this->getId(), "news_timeline_incl_auto"));
917  $this->setNewsTimelineLandingPage((bool) self::_lookupContainerSetting($this->getId(), "news_timeline_landing_page"));
918  $this->setNewsBlockActivated((bool) self::_lookupContainerSetting(
919  $this->getId(),
921  $this->setting->get('block_activated_news', '1')
922  ));
923  $this->setUseNews((bool) self::_lookupContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, '1') &&
924  $this->news->isGloballyActivated());
925  }
926 
927 
932  public static function getCompleteDescriptions(array $objects): array
933  {
934  global $DIC;
935 
936  $ilSetting = $DIC->settings();
937  $ilObjDataCache = $DIC["ilObjDataCache"];
938 
939  // using long descriptions?
940  $short_desc = $ilSetting->get("rep_shorten_description");
941  $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
942  if (!$short_desc || (int) $short_desc_max_length !== ilObject::DESC_LENGTH) {
943  // using (part of) shortened description
944  if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::DESC_LENGTH) {
945  foreach ($objects as $key => $object) {
946  $objects[$key]["description"] = ilStr::shortenTextExtended(
947  $object["description"],
948  (int) $short_desc_max_length,
949  true
950  );
951  }
952  }
953  // using (part of) long description
954  else {
955  $obj_ids = [];
956  foreach ($objects as $key => $object) {
957  $obj_ids[] = $object["obj_id"];
958  }
959  if (count($obj_ids)) {
961  foreach ($objects as $key => $object) {
962  // #12166 - keep translation, ignore long description
963  if ($ilObjDataCache->isTranslatedDescription((int) $object["obj_id"])) {
964  $long_desc[$object["obj_id"]] = $object["description"];
965  }
966  if ($short_desc && $short_desc_max_length) {
967  $long_desc[$object["obj_id"]] = ilStr::shortenTextExtended(
968  $long_desc[$object["obj_id"]] ?? '',
969  (int) $short_desc_max_length,
970  true
971  );
972  }
973  $objects[$key]["description"] = $long_desc[$object["obj_id"]] ?? '';
974  }
975  }
976  }
977  }
978  return $objects;
979  }
980 
981  protected static function fixInternalLinksAfterCopy(
982  int $a_target_id,
983  int $a_copy_id,
984  int $a_source_ref_id
985  ): void {
986  global $DIC;
987 
989  $obj_definition = $DIC["objDefinition"];
990 
991  $obj_id = ilObject::_lookupObjId($a_target_id);
992  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
993  $mapping = $cwo->getMappings();
994 
995  if (ilContainerPage::_exists("cont", $obj_id)) {
996  $pg = new ilContainerPage($obj_id);
997  $pg->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
998  $pg->update(true, true);
999  }
1000 
1001  foreach ($mapping as $old_ref_id => $new_ref_id) {
1002  if (!is_numeric($old_ref_id) || !is_numeric($new_ref_id)) {
1003  continue;
1004  }
1005 
1006  $type = ilObject::_lookupType($new_ref_id, true);
1007  $class = 'il' . $obj_definition->getClassName($type) . 'PageCollector';
1008  $loc = $obj_definition->getLocation($type);
1009  $file = $loc . '/class.' . $class . '.php';
1010 
1011  if (is_file($file)) {
1013  $coll = new $class();
1014  foreach ($coll->getAllPageIds(ilObject::_lookupObjId($new_ref_id)) as $page_id) {
1015  if (ilPageObject::_exists($page_id['parent_type'], $page_id['id'], $page_id['lang'])) {
1017  $page = ilPageObjectFactory::getInstance($page_id['parent_type'], $page_id['id'], 0, $page_id['lang']);
1018  $page->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1019  $page->update(true, true);
1020  }
1021  }
1022  }
1023  }
1024  }
1025 
1026  // Remove all translations of container
1027  public function removeTranslations(): void
1028  {
1029  $this->getObjectProperties()->deletePropertyTranslations();
1030  }
1031 
1032  public function deleteTranslation(string $a_lang): void
1033  {
1034  $this->obj_trans = $this->obj_trans->withoutLanguage($a_lang);
1035  $this->getObjectProperties()->storePropertyTranslations($this->obj_trans);
1036  }
1037 
1038  public function addTranslation(
1039  string $a_title,
1040  string $a_desc,
1041  string $a_lang,
1042  string $a_lang_default
1043  ): void {
1044  if (empty($a_title)) {
1045  $a_title = "NO TITLE";
1046  }
1047 
1048  $this->obj_trans = $this->obj_trans->withLanguage(
1049  new Language(
1050  $a_lang,
1051  $a_title,
1052  $a_desc,
1053  (bool) $a_lang_default
1054  )
1055  );
1056  $this->getObjectProperties()->storePropertyTranslations($this->obj_trans);
1057  }
1058 
1059  protected function applyContainerUserFilter(
1060  array $objects,
1061  ?ilContainerUserFilter $container_user_filter = null
1062  ): array {
1063  $filter = $this->domain->content()->filter(
1064  $objects,
1065  $container_user_filter,
1066  !self::_lookupContainerSetting($this->getId(), "filter_show_empty", false)
1067  );
1068  return $filter->apply();
1069  }
1070 }
setStyleSheetId(int $a_style_id)
static getWebspaceDir(string $mode="filesystem")
get webspace directory
$res
Definition: ltiservices.php:66
static _duplicate(string $a_session_id)
Duplicate session.
string $type
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
const SORT_NEW_ITEMS_POSITION_TOP
static getLogger(string $a_component_id)
Get component logger.
ILIAS Container InternalDomainService $domain
setHiddenFilesFound(bool $a_hiddenfilesfound)
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...
applyContainerUserFilter(array $objects, ?ilContainerUserFilter $container_user_filter=null)
logStack(?int $level=null, string $message='', array $context=[])
static getItemsByEvent(int $event_id)
Get session material / event items.
addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default)
static ilClone(string $sid, int $copy_identifier)
ilAccessHandler $access
getSubItems(bool $a_admin_panel_enabled=false, bool $a_include_side_block=false, int $a_get_single=0, ?ilContainerUserFilter $container_user_filter=null)
getDefaultLanguage()
Return default language.
Container start objects page object.
xmlData(string $data, bool $encode=true, bool $escape=true)
Writes data.
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
Class handles translation mode for an object.
const DESC_LENGTH
filteredSubtree()
Note grp/crs currently allow to filter in their whole subtrees Catetories only their direct childs...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilTree $tree
putInTree(int $parent_ref_id)
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
ilObjectDefinition $obj_definition
setNewsBlockActivated(bool $a_val)
setOrderType(int $a_value)
addAdditionalSubItemInformation(array &$object)
Add additional information to sub item, e.g.
static _lookupObjId(int $ref_id)
ilRbacSystem $rbacsystem
xmlEndTag(string $tag)
Writes an endtag.
cloneDependencies(int $target_id, int $copy_id)
Clone object dependencies (container sorting)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setNewsTimelineLandingPage(bool $a_val)
static getLongDescriptions(array $obj_ids)
const SORT_NEW_ITEMS_POSITION_BOTTOM
Container page object.
isNewsTimelineLandingPageEffective()
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
const SORT_NEW_ITEMS_ORDER_CREATION
ilLanguage $lng
global $DIC
Definition: shib_login.php:26
getClassName(string $obj_name)
static _hasContainerSetting(int $a_id, string $a_keyword)
deleteTranslation(string $a_lang)
static _allocateCopyId()
Allocate a copy for further entries.
Class ilContainer.
bool $news_timeline_landing_page
static _getContainerDirectory(int $a_id)
static cloneSettingsOfBlock(string $block_type, int $block_id, int $new_block_id)
static _exportContainerSettings(ilXmlWriter $a_xml, int $a_obj_id)
setNewsTimeline(bool $a_val)
static fixContainerItemGroupRefsAfterCloning(ilContainer $a_source_container, int $a_copy_id)
Translations $obj_trans
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
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)
const SORT_NEW_ITEMS_ORDER_ACTIVATION
string $long_desc
$classification
bool $news_timeline_auto_entries
setUseNews(bool $a_val)
global $ilSetting
Definition: privfeed.php:31
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
const SORT_DIRECTION_DESC
ilRecommendedContentManager $recommended_content_manager
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
static _getInstance(int $a_obj_id)
static _cloneSettings(int $a_old_id, int $a_new_id)
$q
Definition: shib_logout.php:23
setObjectTranslation(?Translations $obj_trans)
getLongDescription()
get object long description (stored in object_description)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
$client_id
Definition: ltiauth.php:66
ilLogger $log
setNewsTimelineAutoEntries(bool $a_val)
static _getInstance(int $a_copy_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
const SORT_DIRECTION_ASC
debug(string $message, array $context=[])
ILIAS Style Content DomainService $content_style_domain
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
bool $news_block_activated
static _lookupType(int $id, bool $reference=false)
static getValidProviders(int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
Get all valid providers (for parent container)
const SORT_NEW_ITEMS_ORDER_TITLE
static getInstance(int $obj_id)
Membership notification settings.
static getCompleteDescriptions(array $objects)
overwrites description fields to long or short description in an assoc array keys needed (obj_id and ...
ilSetting $setting
static _getContainerSettings(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static bool $data_preloaded