ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilContainer.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 // note: the values are derived from ilObjCourse constants
25 // to enable easy migration from course view setting to container view setting
26 
27 require_once "./Services/Object/classes/class.ilObject.php";
28 
39 class ilContainer extends ilObject
40 {
44  protected $db;
45 
49  protected $log;
50 
54  protected $access;
55 
59  protected $error;
60 
64  protected $rbacsystem;
65 
69  protected $tree;
70 
74  protected $user;
75 
79  protected $obj_definition;
80 
81  protected $order_type = 0;
82  protected $hiddenfilesfound = false;
83  protected $news_timeline = false;
84  protected $news_timeline_auto_entries = false;
85 
86  // container view constants
87  const VIEW_SESSIONS = 0;
88  const VIEW_OBJECTIVE = 1;
89  const VIEW_TIMING = 2;
90  const VIEW_ARCHIVE = 3;
91  const VIEW_SIMPLE = 4;
92  const VIEW_BY_TYPE = 5;
93  const VIEW_INHERIT = 6;
94 
95  const VIEW_DEFAULT = self::VIEW_BY_TYPE;
96 
97 
98  const SORT_TITLE = 0;
99  const SORT_MANUAL = 1;
100  const SORT_ACTIVATION = 2;
101  const SORT_INHERIT = 3;
102  const SORT_CREATION = 4;
103 
106 
109 
113 
114 
115  public static $data_preloaded = false;
116 
120  protected $setting;
121 
122  public function __construct($a_id = 0, $a_reference = true)
123  {
124  global $DIC;
125 
126  $this->db = $DIC->database();
127  $this->log = $DIC["ilLog"];
128  $this->access = $DIC->access();
129  $this->error = $DIC["ilErr"];
130  $this->rbacsystem = $DIC->rbac()->system();
131  $this->tree = $DIC->repositoryTree();
132  $this->user = $DIC->user();
133  $this->obj_definition = $DIC["objDefinition"];
134 
135 
136  $this->setting = $DIC["ilSetting"];
137  parent::__construct($a_id, $a_reference);
138  }
139 
144  public function createContainerDirectory()
145  {
146  $webspace_dir = ilUtil::getWebspaceDir();
147  $cont_dir = $webspace_dir . "/container_data";
148  if (!is_dir($cont_dir)) {
149  ilUtil::makeDir($cont_dir);
150  }
151  $obj_dir = $cont_dir . "/obj_" . $this->getId();
152  if (!is_dir($obj_dir)) {
153  ilUtil::makeDir($obj_dir);
154  }
155  }
156 
162  public function getContainerDirectory()
163  {
164  return $this->_getContainerDirectory($this->getId());
165  }
166 
172  public static function _getContainerDirectory($a_id)
173  {
174  return ilUtil::getWebspaceDir() . "/container_data/obj_" . $a_id;
175  }
176 
183  public function getBigIconPath()
184  {
185  return self::_lookupIconPath($this->getId());
186  }
187 
194  public function getSmallIconPath()
195  {
196  return self::_lookupIconPath($this->getId());
197  }
198 
205  public function getTinyIconPath()
206  {
207  return self::_lookupIconPath($this->getId());
208  }
209 
215  public function getCustomIconPath()
216  {
217  return self::_lookupIconPath($this->getId());
218  }
219 
220 
226  public function setHiddenFilesFound($a_hiddenfilesfound)
227  {
228  $this->hiddenfilesfound = $a_hiddenfilesfound;
229  }
230 
236  public function getHiddenFilesFound()
237  {
239  }
240 
244  public function getStyleSheetId()
245  {
246  return $this->style_id;
247  }
248 
252  public function setStyleSheetId($a_style_id)
253  {
254  $this->style_id = $a_style_id;
255  }
256 
262  public function setNewsTimeline($a_val)
263  {
264  $this->news_timeline = $a_val;
265  }
266 
272  public function getNewsTimeline()
273  {
274  return $this->news_timeline;
275  }
276 
282  public function setNewsTimelineAutoEntries($a_val)
283  {
284  $this->news_timeline_auto_entries = $a_val;
285  }
286 
292  public function getNewsTimelineAutoEntries()
293  {
295  }
296 
302  public function setNewsTimelineLandingPage($a_val)
303  {
304  $this->news_timeline_landing_page = $a_val;
305  }
306 
312  public function getNewsTimelineLandingPage()
313  {
314  return $this->news_timeline_landing_page;
315  }
316 
322  public function isNewsTimelineEffective()
323  {
324  if ($this->getUseNews()) {
325  if ($this->getNewsTimeline()) {
326  return true;
327  }
328  }
329  return false;
330  }
331 
338  {
339  if ($this->getUseNews()) {
340  if ($this->getNewsTimeline()) {
341  if ($this->getNewsTimelineLandingPage()) {
342  return true;
343  }
344  }
345  }
346  return false;
347  }
348 
349 
355  public function setNewsBlockActivated($a_val)
356  {
357  $this->news_block_activated = $a_val;
358  }
359 
365  public function getNewsBlockActivated()
366  {
367  return $this->news_block_activated;
368  }
369 
375  public function setUseNews($a_val)
376  {
377  $this->use_news = $a_val;
378  }
379 
385  public function getUseNews()
386  {
387  return $this->use_news;
388  }
389 
398  public static function _lookupContainerSetting($a_id, $a_keyword, $a_default_value = null)
399  {
400  global $DIC;
401 
402  $ilDB = $DIC->database();
403 
404  $q = "SELECT * FROM container_settings WHERE " .
405  " id = " . $ilDB->quote($a_id, 'integer') . " AND " .
406  " keyword = " . $ilDB->quote($a_keyword, 'text');
407  $set = $ilDB->query($q);
408  $rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
409 
410  if (isset($rec['value'])) {
411  return $rec["value"];
412  }
413  if ($a_default_value === null) {
414  return '';
415  }
416  return $a_default_value;
417  }
418 
424  public static function _writeContainerSetting($a_id, $a_keyword, $a_value)
425  {
426  global $DIC;
427 
428  $ilDB = $DIC->database();
429 
430  $query = "DELETE FROM container_settings WHERE " .
431  "id = " . $ilDB->quote($a_id, 'integer') . " " .
432  "AND keyword = " . $ilDB->quote($a_keyword, 'text');
433  $res = $ilDB->manipulate($query);
434 
436  $log->debug("Write container setting, id: " . $a_id . ", keyword: " . $a_keyword . ", value: " . $a_value);
437 
438  $query = "INSERT INTO container_settings (id, keyword, value) VALUES (" .
439  $ilDB->quote($a_id, 'integer') . ", " .
440  $ilDB->quote($a_keyword, 'text') . ", " .
441  $ilDB->quote($a_value, 'text') .
442  ")";
443 
444  $res = $ilDB->manipulate($query);
445  }
446 
447  public static function _getContainerSettings($a_id)
448  {
449  global $DIC;
450 
451  $ilDB = $DIC->database();
452 
453  $res = array();
454 
455  $sql = "SELECT * FROM container_settings WHERE " .
456  " id = " . $ilDB->quote($a_id, 'integer');
457  $set = $ilDB->query($sql);
458  while ($row = $ilDB->fetchAssoc($set)) {
459  $res[$row["keyword"]] = $row["value"];
460  }
461 
462  return $res;
463  }
464 
465  public static function _deleteContainerSettings($a_id, $a_keyword = null, $a_keyword_like = false)
466  {
467  global $DIC;
468 
469  $ilDB = $DIC->database();
470 
471  if (!$a_id) {
472  return;
473  }
474 
475  $sql = "DELETE FROM container_settings WHERE " .
476  " id = " . $ilDB->quote($a_id, 'integer');
477  if ($a_keyword) {
478  if (!$a_keyword_like) {
479  $sql .= " AND keyword = " . $ilDB->quote($a_keyword, "text");
480  } else {
481  $sql .= " AND " . $ilDB->like("keyword", "text", $a_keyword);
482  }
483  }
484  $ilDB->manipulate($sql);
485  }
486 
487  public static function _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
488  {
489  // container settings
490  $settings = self::_getContainerSettings($a_obj_id);
491  if (sizeof($settings)) {
492  $a_xml->xmlStartTag("ContainerSettings");
493 
494  foreach ($settings as $keyword => $value) {
495  // :TODO: proper custom icon export/import
496  if (stristr($keyword, "icon")) {
497  continue;
498  }
499 
500  $a_xml->xmlStartTag(
501  'ContainerSetting',
502  array(
503  'id' => $keyword,
504  )
505  );
506 
507  $a_xml->xmlData($value);
508  $a_xml->xmlEndTag("ContainerSetting");
509  }
510 
511  $a_xml->xmlEndTag("ContainerSettings");
512  }
513  }
514 
521  public static function _lookupIconPath($a_id, $a_size = "big")
522  {
523  if (ilContainer::_lookupContainerSetting($a_id, "icon_custom")) {
524  $cont_dir = ilContainer::_getContainerDirectory($a_id);
525 
526  $file_name = $cont_dir . "/icon_custom.svg";
527  if (is_file($file_name)) {
528  return $file_name;
529  }
530  }
531 
532  return "";
533  }
534 
538  public function saveIcons($a_custom_icon)
539  {
540  $this->createContainerDirectory();
541  $cont_dir = $this->getContainerDirectory();
542 
543  if ($a_custom_icon != "") {
544  if (is_file($cont_dir . "/icon_custom.svg")) {
545  unlink($cont_dir . "/icon_custom.svg");
546  }
547  $file_name = $cont_dir . "/icon_custom.svg";
548  ilUtil::moveUploadedFile($a_custom_icon, "icon_custom.svg", $file_name);
549 
550  if ($file_name != "" && is_file($file_name)) {
551  ilContainer::_writeContainerSetting($this->getId(), "icon_custom", 1);
552  } else {
553  ilContainer::_writeContainerSetting($this->getId(), "icon_custom", 0);
554  }
555  }
556  }
557 
561  public function removeCustomIcon()
562  {
563  $cont_dir = $this->getContainerDirectory();
564  $small_file_name = $cont_dir . "/icon_custom.svg";
565  @unlink($small_file_name);
566  ilContainer::_writeContainerSetting($this->getId(), "icon_custom", 0);
567  }
568 
577  public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
578  {
580  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
581 
582  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
583  #18624 - copy all sorting settings
584  ilContainerSortingSettings::_cloneSettings($this->getId(), $new_obj->getId());
585 
586  // copy content page
587  include_once("./Services/Container/classes/class.ilContainerPage.php");
589  "cont",
590  $this->getId()
591  )) {
592  $orig_page = new ilContainerPage($this->getId());
593  $orig_page->copy($new_obj->getId(), "cont", $new_obj->getId());
594  }
595 
596  // #20614 - copy style
597  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
598  $style_id = $this->getStyleSheetId();
599  if ($style_id > 0) {
600  if (!!ilObjStyleSheet::_lookupStandard($style_id)) {
601  $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
602  $new_id = $style_obj->ilClone();
603  $new_obj->setStyleSheetId($new_id);
604  $new_obj->update();
605  } else {
606  $new_obj->setStyleSheetId($this->getStyleSheetId());
607  }
608  }
609 
610  // #10271 - copy start objects page
611  include_once("./Services/Container/classes/class.ilContainerStartObjectsPage.php");
613  "cstr",
614  $this->getId()
615  )) {
616  $orig_page = new ilContainerStartObjectsPage($this->getId());
617  $orig_page->copy($new_obj->getId(), "cstr", $new_obj->getId());
618  }
619 
620  // #10271
621  foreach (self::_getContainerSettings($this->getId()) as $keyword => $value) {
622  self::_writeContainerSetting($new_obj->getId(), $keyword, $value);
623 
624  // copy custom icons
625  if ($keyword == "icon_custom" &&
626  $value) {
627  // see saveIcons()
628  $new_obj->createContainerDirectory();
629  $tgt_dir = $new_obj->getContainerDirectory();
630  $src_dir = $this->getContainerDirectory();
631  $file = "icon_custom.svg";
632  $src_file = $src_dir . "/" . $file;
633  if (file_exists($src_file)) {
634  copy($src_file, $tgt_dir . "/" . $file);
635  }
636  }
637  }
638 
639  $new_obj->setNewsTimeline($this->getNewsTimeline());
640  $new_obj->setNewsBlockActivated($this->getNewsBlockActivated());
641  $new_obj->setUseNews($this->getUseNews());
642  $new_obj->setNewsTimelineAutoEntries($this->getNewsTimelineAutoEntries());
643  $new_obj->setNewsTimelineLandingPage($this->getNewsTimelineLandingPage());
644  ilBlockSetting::cloneSettingsOfBlock("news", $this->getId(), $new_obj->getId());
645  $mom_noti = new ilMembershipNotifications($this->getRefId());
646  $mom_noti->cloneSettings($new_obj->getRefId());
647 
648  return $new_obj;
649  }
650 
659  public function cloneDependencies($a_target_id, $a_copy_id)
660  {
661  $ilLog = $this->log;
662 
663  parent::cloneDependencies($a_target_id, $a_copy_id);
664 
665  include_once('./Services/Container/classes/class.ilContainerSorting.php');
666  ilContainerSorting::_getInstance($this->getId())->cloneSorting($a_target_id, $a_copy_id);
667 
668  // fix internal links to other objects
669  ilContainer::fixInternalLinksAfterCopy($a_target_id, $a_copy_id, $this->getRefId());
670 
671  // fix item group references in page content
672  include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
674 
675  include_once('Services/Object/classes/class.ilObjectLP.php');
676  $olp = ilObjectLP::getInstance($this->getId());
677  $collection = $olp->getCollectionInstance();
678  if ($collection) {
679  $collection->cloneCollection($a_target_id, $a_copy_id);
680  }
681 
682  return true;
683  }
684 
699  public function cloneAllObject($session_id, $client_id, $new_type, $ref_id, $clone_source, $options, $soap_call = false, $a_submode = 1)
700  {
701  $ilLog = $this->log;
702 
703  include_once('./Services/Link/classes/class.ilLink.php');
704  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
705 
706  $ilAccess = $this->access;
709  $tree = $this->tree;
711 
712  // Save wizard options
714  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
715  $wizard_options->saveOwner($ilUser->getId());
716  $wizard_options->saveRoot($clone_source);
717 
718  // add entry for source container
719  $wizard_options->initContainer($clone_source, $ref_id);
720 
721  foreach ($options as $source_id => $option) {
722  $wizard_options->addEntry($source_id, $option);
723  }
724  $wizard_options->read();
725  $wizard_options->storeTree($clone_source);
726 
727  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
728  if ($a_submode == ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
729  ilLoggerFactory::getLogger('obj')->info('Copy content only...');
730  ilLoggerFactory::getLogger('obj')->debug('Added mapping, source ID: ' . $clone_source . ', target ID: ' . $ref_id);
731  $wizard_options->read();
732  $wizard_options->dropFirstNode();
733  $wizard_options->appendMapping($clone_source, $ref_id);
734  }
735 
736 
737  #print_r($options);
738  // Duplicate session to avoid logout problems with backgrounded SOAP calls
739  $new_session_id = ilSession::_duplicate($session_id);
740  // Start cloning process using soap call
741  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
742 
743  $soap_client = new ilSoapClient();
744  $soap_client->setResponseTimeout(5);
745  $soap_client->enableWSDL(true);
746 
747  $ilLog->write(__METHOD__ . ': Trying to call Soap client...');
748  if ($soap_client->init()) {
749  ilLoggerFactory::getLogger('obj')->info('Calling soap clone method');
750  $res = $soap_client->call('ilClone', array($new_session_id . '::' . $client_id, $copy_id));
751  } else {
752  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
753  $wizard_options->disableSOAP();
754  $wizard_options->read();
755  include_once('./webservice/soap/include/inc.soap_functions.php');
756  $res = ilSoapFunctions::ilClone($new_session_id . '::' . $client_id, $copy_id);
757  }
758  return array(
759  'copy_id' => $copy_id,
760  'ref_id' => (int) $res
761  );
762  }
763 
767  public function getViewMode()
768  {
770  }
771 
775  public function getOrderType()
776  {
777  return $this->order_type ? $this->order_type : ilContainer::SORT_TITLE;
778  }
779 
780  public function setOrderType($a_value)
781  {
782  $this->order_type = $a_value;
783  }
784 
793  public function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0)
794  {
796  $tree = $this->tree;
797 
798  // Caching
799  if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
800  !$a_get_single) {
801  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
802  }
803 
804  $type_grps = $this->getGroupedObjTypes();
805  $objects = $tree->getChilds($this->getRefId(), "title");
806 
807  $objects = self::getCompleteDescriptions($objects);
808 
809  $found = false;
810  $all_ref_ids = array();
811 
812  if (!self::$data_preloaded) {
813  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
815  }
816 
817  include_once('Services/Container/classes/class.ilContainerSorting.php');
818  $sort = ilContainerSorting::_getInstance($this->getId());
819 
820  // TODO: check this
821  // get items attached to a session
822  include_once './Modules/Session/classes/class.ilEventItems.php';
823  $event_items = ilEventItems::_getItemsOfContainer($this->getRefId());
824 
825  foreach ($objects as $key => $object) {
826  if ($a_get_single > 0 && $object["child"] != $a_get_single) {
827  continue;
828  }
829 
830  // hide object types in devmode
831  if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm"
832  || $object["type"] == "rolf") {
833  continue;
834  }
835 
836  // remove inactive plugins
837  if ($objDefinition->isInactivePlugin($object["type"])) {
838  continue;
839  }
840 
841  // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
842  if (in_array($object['type'], array('file','fold','cat'))) {
843  include_once 'Modules/File/classes/class.ilObjFileAccess.php';
844  if (ilObjFileAccess::_isFileHidden($object['title'])) {
845  $this->setHiddenFilesFound(true);
846  if (!$a_admin_panel_enabled) {
847  continue;
848  }
849  }
850  }
851  // END WebDAV: Don't display hidden Files, Folders and Categories
852 
853  // including event items!
854  if (!self::$data_preloaded) {
855  $preloader->addItem($object["obj_id"], $object["type"], $object["child"]);
856  }
857 
858  // filter out items that are attached to an event
859  if (in_array($object['ref_id'], $event_items)) {
860  continue;
861  }
862 
863  // filter side block items
864  if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
865  continue;
866  }
867 
868  $all_ref_ids[] = $object["child"];
869  }
870 
871  // data preloader
872  if (!self::$data_preloaded) {
873  $preloader->preload();
874  unset($preloader);
875 
876  self::$data_preloaded = true;
877  }
878 
879  foreach ($objects as $key => $object) {
880  // see above, objects were filtered
881  if (!in_array($object["child"], $all_ref_ids)) {
882  continue;
883  }
884 
885  // group object type groups together (e.g. learning resources)
886  $type = $objDefinition->getGroupOfObj($object["type"]);
887  if ($type == "") {
888  $type = $object["type"];
889  }
890 
891  // this will add activation properties
892  $this->addAdditionalSubItemInformation($object);
893 
894  $this->items[$type][$key] = $object;
895 
896  $this->items["_all"][$key] = $object;
897  if ($object["type"] != "sess") {
898  $this->items["_non_sess"][$key] = $object;
899  }
900  }
901 
902  $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]
903  = $sort->sortItems($this->items);
904 
905  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
906  }
907 
911  public function gotItems()
912  {
913  if (is_array($this->items["_all"]) && count($this->items["_all"]) > 0) {
914  return true;
915  }
916  return false;
917  }
918 
923  public function addAdditionalSubItemInformation(&$object)
924  {
925  }
926 
932  public function getGroupedObjTypes()
933  {
935 
936  if (empty($this->type_grps)) {
937  $this->type_grps = $objDefinition->getGroupedRepositoryObjectTypes($this->getType());
938  }
939  return $this->type_grps;
940  }
941 
945  public function enablePageEditing()
946  {
948 
949  // @todo: this will need a more general approach
950  if ($ilSetting->get("enable_cat_page_edit")) {
951  return true;
952  }
953  }
954 
958  public function create()
959  {
960  $ret = parent::create();
961 
962  if (((int) $this->getStyleSheetId()) > 0) {
963  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
965  }
966 
968  $log->debug("Create Container, id: " . $this->getId());
969 
970  self::_writeContainerSetting($this->getId(), "news_timeline", (int) $this->getNewsTimeline());
971  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (int) $this->getNewsTimelineAutoEntries());
972  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (int) $this->getNewsTimelineLandingPage());
973  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
974  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (int) $this->getNewsBlockActivated());
975  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (int) $this->getUseNews());
976 
977  return $ret;
978  }
979 
983  public function update()
984  {
985  $ret = parent::update();
986 
987  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
989 
991  $log->debug("Update Container, id: " . $this->getId());
992 
993  self::_writeContainerSetting($this->getId(), "news_timeline", (int) $this->getNewsTimeline());
994  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (int) $this->getNewsTimelineAutoEntries());
995  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (int) $this->getNewsTimelineLandingPage());
996  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
997  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (int) $this->getNewsBlockActivated());
998  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (int) $this->getUseNews());
999 
1000  return $ret;
1001  }
1002 
1003 
1011  public function read()
1012  {
1013  parent::read();
1014 
1015  include_once("./Services/Container/classes/class.ilContainerSortingSettings.php");
1017 
1018  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1020 
1021  $this->readContainerSettings();
1022  }
1023 
1030  public function readContainerSettings()
1031  {
1032  $this->setNewsTimeline(self::_lookupContainerSetting($this->getId(), "news_timeline"));
1033  $this->setNewsTimelineAutoEntries(self::_lookupContainerSetting($this->getId(), "news_timeline_incl_auto"));
1034  $this->setNewsTimelineLandingPage(self::_lookupContainerSetting($this->getId(), "news_timeline_landing_page"));
1035  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
1036  $this->setNewsBlockActivated(self::_lookupContainerSetting(
1037  $this->getId(),
1039  $this->setting->get('block_activated_news', true)
1040  ));
1041  $this->setUseNews(self::_lookupContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, true));
1042  }
1043 
1044 
1052  public static function getCompleteDescriptions(array $objects)
1053  {
1054  global $DIC;
1055 
1056  $ilSetting = $DIC->settings();
1057  $ilObjDataCache = $DIC["ilObjDataCache"];
1058  // using long descriptions?
1059  $short_desc = $ilSetting->get("rep_shorten_description");
1060  $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
1061  if (!$short_desc || $short_desc_max_length != ilObject::DESC_LENGTH) {
1062  // using (part of) shortened description
1063  if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::DESC_LENGTH) {
1064  foreach ($objects as $key => $object) {
1065  $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true);
1066  }
1067  }
1068  // using (part of) long description
1069  else {
1070  $obj_ids = array();
1071  foreach ($objects as $key => $object) {
1072  $obj_ids[] = $object["obj_id"];
1073  }
1074  if (sizeof($obj_ids)) {
1076  foreach ($objects as $key => $object) {
1077  // #12166 - keep translation, ignore long description
1078  if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) {
1079  $long_desc[$object["obj_id"]] = $object["description"];
1080  }
1081  if ($short_desc && $short_desc_max_length) {
1082  $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true);
1083  }
1084  $objects[$key]["description"] = $long_desc[$object["obj_id"]];
1085  }
1086  }
1087  }
1088  }
1089  return $objects;
1090  }
1091 
1098  protected static function fixInternalLinksAfterCopy($a_target_id, $a_copy_id, $a_source_ref_id)
1099  {
1100  global $DIC;
1101 
1103  $obj_definition = $DIC["objDefinition"];
1104 
1105  $obj_id = ilObject::_lookupObjId($a_target_id);
1106  include_once("./Services/Container/classes/class.ilContainerPage.php");
1107  if (ilContainerPage::_exists("cont", $obj_id)) {
1108  include_once("./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
1109  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1110  $mapping = $cwo->getMappings();
1111  $pg = new ilContainerPage($obj_id);
1112  $pg->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1113  $pg->update(true, true);
1114  foreach ($mapping as $old_ref_id => $new_ref_id) {
1115  if (!is_int($old_ref_id) || !is_int($new_ref_id)) {
1116  continue;
1117  }
1118  $type = ilObject::_lookupType($new_ref_id, true);
1119  $class = "il" . $obj_definition->getClassName($type) . "PageCollector";
1120  $loc = $obj_definition->getLocation($type);
1121  $file = $loc . "/class." . $class . ".php";
1122  if (is_file($file)) {
1123  include_once($file);
1125  $coll = new $class();
1126  foreach ($coll->getAllPageIds(ilObject::_lookupObjId($new_ref_id)) as $page_id) {
1127  if (ilPageObject::_exists($page_id["parent_type"], $page_id["id"], $page_id["lang"])) {
1129  $page = ilPageObjectFactory::getInstance($page_id["parent_type"], $page_id["id"], 0, $page_id["lang"]);
1130  $page->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1131  $page->update(true, true);
1132  }
1133  }
1134  }
1135  }
1136  }
1137  }
1138 } // END class ilContainer
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
setNewsTimelineAutoEntries($a_val)
Set news timeline auto entries.
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
global $ilErr
Definition: raiseError.php:16
getCustomIconPath()
Get path for custom icon.
cloneDependencies($a_target_id, $a_copy_id)
Clone object dependencies (container sorting)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
static _getContainerDirectory($a_id)
Get the container directory.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
const SORT_NEW_ITEMS_POSITION_TOP
setStyleSheetId($a_style_id)
set ID of assigned style sheet object
isNewsTimelineEffective()
Is news timeline effective?
static getLongDescriptions(array $a_obj_ids)
Get long description data.
global $DIC
Definition: saml.php:7
removeCustomIcon()
remove small icon
Container start objects page object.
static _getItemsOfContainer($a_ref_id)
static ilClone($sid, $copy_identifier)
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
getNewsTimelineLandingPage()
Get news timline is landing page.
const DESC_LENGTH
getBigIconPath()
Get path for big icon.
XML writer class.
getTinyIconPath()
Get path for tiny icon.
setHiddenFilesFound($a_hiddenfilesfound)
Set Found hidden files (set by getSubItems).
setNewsBlockActivated($a_val)
Set news block activated.
saveIcons($a_custom_icon)
save container icons
getViewMode()
Get container view mode.
setUseNews($a_val)
Set use news.
getNewsTimelineAutoEntries()
Get news timeline auto entries.
xmlData($data, $encode=true, $escape=true)
Writes data.
static lookupObjectStyle($a_obj_id)
Lookup object style.
user()
Definition: user.php:4
static _cloneSettings($a_old_id, $a_new_id)
Clone settings.
xmlEndTag($tag)
Writes an endtag.
getOrderType()
Get order type default implementation.
getSubItems($a_admin_panel_enabled=false, $a_include_side_block=false, $a_get_single=0)
Get subitems of container.
static _lookupStandard($a_id)
Lookup standard flag.
static _lookupIconPath($a_id, $a_size="big")
lookup icon path
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
Preloader for object list GUIs.
const SORT_NEW_ITEMS_POSITION_BOTTOM
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getContainerDirectory()
Get the container directory.
setNewsTimelineLandingPage($a_val)
Set news timline is landing page.
foreach($_POST as $key=> $value) $res
getId()
get object id public
Container page object.
isNewsTimelineLandingPageEffective()
Is news timeline landing page effective?
static _deleteContainerSettings($a_id, $a_keyword=null, $a_keyword_like=false)
setNewsTimeline($a_val)
Set news timeline.
const SORT_NEW_ITEMS_ORDER_CREATION
getStyleSheetId()
get ID of assigned style sheet object
getNewsTimeline()
Get news timeline.
static _lookupObjId($a_id)
static _getContainerSettings($a_id)
enablePageEditing()
Check whether page editing is allowed for container.
gotItems()
Check whether we got any items.
getHiddenFilesFound()
Get Found hidden files (set by getSubItems).
$ilUser
Definition: imgupload.php:18
static _allocateCopyId()
Allocate a copy for further entries.
Class ilContainer.
$query
cloneAllObject($session_id, $client_id, $new_type, $ref_id, $clone_source, $options, $soap_call=false, $a_submode=1)
clone all objects according to this container
static cloneSettingsOfBlock(string $block_type, int $block_id, int $new_block_id)
Clone block settings.
getType()
get object type public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
const SORT_NEW_ITEMS_ORDER_ACTIVATION
static fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
Fix container item group references after a container has been cloned.
update($pash, $contents, Config $config)
getSmallIconPath()
Get path for small icon.
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
static _duplicate($a_session_id)
Duplicate session.
readContainerSettings()
Read container settings.
addAdditionalSubItemInformation(&$object)
Add additional information to sub item, e.g.
setOrderType($a_value)
global $ilSetting
Definition: privfeed.php:17
__construct($a_id=0, $a_reference=true)
getUseNews()
Get use news.
global $ilDB
$ret
Definition: parser.php:6
getRefId()
get reference id public
static _writeContainerSetting($a_id, $a_keyword, $a_value)
static getLogger($a_component_id)
Get component logger.
static _lookupSortMode($a_obj_id)
lookup sort mode
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static _getInstance($a_obj_id)
get instance by obj_id
$client_id
createContainerDirectory()
Create directory for the container.
getNewsBlockActivated()
Get news block activated.
getGroupedObjTypes()
Get grouped repository object types.
static getInstance($a_obj_id)
const SORT_NEW_ITEMS_ORDER_TITLE
Membership notification settings.
static getWebspaceDir($mode="filesystem")
get webspace directory
$key
Definition: croninfo.php:18
static getCompleteDescriptions(array $objects)
overwrites description fields to long or short description in an assoc array keys needed (obj_id and ...
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20