ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public static $data_preloaded = false;
115 
119  protected $setting;
120 
124  protected $obj_trans = null;
125 
126  public function __construct($a_id = 0, $a_reference = true)
127  {
128  global $DIC;
129 
130  $this->db = $DIC->database();
131  $this->log = $DIC["ilLog"];
132  $this->access = $DIC->access();
133  $this->error = $DIC["ilErr"];
134  $this->rbacsystem = $DIC->rbac()->system();
135  $this->tree = $DIC->repositoryTree();
136  $this->user = $DIC->user();
137  $this->obj_definition = $DIC["objDefinition"];
138 
139 
140  $this->setting = $DIC["ilSetting"];
141  parent::__construct($a_id, $a_reference);
142  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
143 
144  if ($this->getId() > 0) {
145  $this->obj_trans = ilObjectTranslation::getInstance($this->getId());
146  }
147  }
148 
153  public function getObjectTranslation()
154  {
155  return $this->obj_trans;
156  }
157 
163  {
164  $this->obj_trans = $obj_trans;
165  }
166 
171  public function createContainerDirectory()
172  {
173  $webspace_dir = ilUtil::getWebspaceDir();
174  $cont_dir = $webspace_dir . "/container_data";
175  if (!is_dir($cont_dir)) {
176  ilUtil::makeDir($cont_dir);
177  }
178  $obj_dir = $cont_dir . "/obj_" . $this->getId();
179  if (!is_dir($obj_dir)) {
180  ilUtil::makeDir($obj_dir);
181  }
182  }
183 
189  public function getContainerDirectory()
190  {
191  return $this->_getContainerDirectory($this->getId());
192  }
193 
199  public static function _getContainerDirectory($a_id)
200  {
201  return ilUtil::getWebspaceDir() . "/container_data/obj_" . $a_id;
202  }
203 
209  public function setHiddenFilesFound($a_hiddenfilesfound)
210  {
211  $this->hiddenfilesfound = $a_hiddenfilesfound;
212  }
213 
219  public function getHiddenFilesFound()
220  {
222  }
223 
227  public function getStyleSheetId()
228  {
229  return $this->style_id;
230  }
231 
235  public function setStyleSheetId($a_style_id)
236  {
237  $this->style_id = $a_style_id;
238  }
239 
245  public function setNewsTimeline($a_val)
246  {
247  $this->news_timeline = $a_val;
248  }
249 
255  public function getNewsTimeline()
256  {
257  return $this->news_timeline;
258  }
259 
265  public function setNewsTimelineAutoEntries($a_val)
266  {
267  $this->news_timeline_auto_entries = $a_val;
268  }
269 
275  public function getNewsTimelineAutoEntries()
276  {
278  }
279 
285  public function setNewsTimelineLandingPage($a_val)
286  {
287  $this->news_timeline_landing_page = $a_val;
288  }
289 
295  public function getNewsTimelineLandingPage()
296  {
297  return $this->news_timeline_landing_page;
298  }
299 
305  public function isNewsTimelineEffective()
306  {
307  if ($this->getUseNews()) {
308  if ($this->getNewsTimeline()) {
309  return true;
310  }
311  }
312  return false;
313  }
314 
321  {
322  if ($this->getUseNews()) {
323  if ($this->getNewsTimeline()) {
324  if ($this->getNewsTimelineLandingPage()) {
325  return true;
326  }
327  }
328  }
329  return false;
330  }
331 
332 
338  public function setNewsBlockActivated($a_val)
339  {
340  $this->news_block_activated = $a_val;
341  }
342 
348  public function getNewsBlockActivated()
349  {
350  return $this->news_block_activated;
351  }
352 
358  public function setUseNews($a_val)
359  {
360  $this->use_news = $a_val;
361  }
362 
368  public function getUseNews()
369  {
370  return $this->use_news;
371  }
372 
381  public static function _lookupContainerSetting($a_id, $a_keyword, $a_default_value = null)
382  {
383  global $DIC;
384 
385  $ilDB = $DIC->database();
386 
387  $q = "SELECT * FROM container_settings WHERE " .
388  " id = " . $ilDB->quote($a_id, 'integer') . " AND " .
389  " keyword = " . $ilDB->quote($a_keyword, 'text');
390  $set = $ilDB->query($q);
391  $rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
392 
393  if (isset($rec['value'])) {
394  return $rec["value"];
395  }
396  if ($a_default_value === null) {
397  return '';
398  }
399  return $a_default_value;
400  }
401 
407  public static function _writeContainerSetting($a_id, $a_keyword, $a_value)
408  {
409  global $DIC;
410 
411  $ilDB = $DIC->database();
412 
413  $query = "DELETE FROM container_settings WHERE " .
414  "id = " . $ilDB->quote($a_id, 'integer') . " " .
415  "AND keyword = " . $ilDB->quote($a_keyword, 'text');
416  $res = $ilDB->manipulate($query);
417 
419  $log->debug("Write container setting, id: " . $a_id . ", keyword: " . $a_keyword . ", value: " . $a_value);
420 
421  $query = "INSERT INTO container_settings (id, keyword, value) VALUES (" .
422  $ilDB->quote($a_id, 'integer') . ", " .
423  $ilDB->quote($a_keyword, 'text') . ", " .
424  $ilDB->quote($a_value, 'text') .
425  ")";
426 
427  $res = $ilDB->manipulate($query);
428  }
429 
430  public static function _getContainerSettings($a_id)
431  {
432  global $DIC;
433 
434  $ilDB = $DIC->database();
435 
436  $res = array();
437 
438  $sql = "SELECT * FROM container_settings WHERE " .
439  " id = " . $ilDB->quote($a_id, 'integer');
440  $set = $ilDB->query($sql);
441  while ($row = $ilDB->fetchAssoc($set)) {
442  $res[$row["keyword"]] = $row["value"];
443  }
444 
445  return $res;
446  }
447 
448  public static function _deleteContainerSettings($a_id, $a_keyword = null, $a_keyword_like = false)
449  {
450  global $DIC;
451 
452  $ilDB = $DIC->database();
453 
454  if (!$a_id) {
455  return;
456  }
457 
458  $sql = "DELETE FROM container_settings WHERE " .
459  " id = " . $ilDB->quote($a_id, 'integer');
460  if ($a_keyword) {
461  if (!$a_keyword_like) {
462  $sql .= " AND keyword = " . $ilDB->quote($a_keyword, "text");
463  } else {
464  $sql .= " AND " . $ilDB->like("keyword", "text", $a_keyword);
465  }
466  }
467  $ilDB->manipulate($sql);
468  }
469 
470  public static function _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
471  {
472  // container settings
473  $settings = self::_getContainerSettings($a_obj_id);
474  if (sizeof($settings)) {
475  $a_xml->xmlStartTag("ContainerSettings");
476 
477  foreach ($settings as $keyword => $value) {
478  // :TODO: proper custom icon export/import
479  if (stristr($keyword, "icon")) {
480  continue;
481  }
482 
483  $a_xml->xmlStartTag(
484  'ContainerSetting',
485  array(
486  'id' => $keyword,
487  )
488  );
489 
490  $a_xml->xmlData($value);
491  $a_xml->xmlEndTag("ContainerSetting");
492  }
493 
494  $a_xml->xmlEndTag("ContainerSettings");
495  }
496  }
497 
506  public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
507  {
509  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
510 
511  // translations
512  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
513  $ot = ilObjectTranslation::getInstance($this->getId());
514  $ot->copy($new_obj->getId());
515 
516  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
517  #18624 - copy all sorting settings
518  ilContainerSortingSettings::_cloneSettings($this->getId(), $new_obj->getId());
519 
520  // copy content page
521  include_once("./Services/Container/classes/class.ilContainerPage.php");
523  "cont",
524  $this->getId()
525  )) {
526  $orig_page = new ilContainerPage($this->getId());
527  $orig_page->copy($new_obj->getId(), "cont", $new_obj->getId());
528  }
529 
530  // #20614 - copy style
531  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
532  $style_id = $this->getStyleSheetId();
533  if ($style_id > 0) {
534  if (!!ilObjStyleSheet::_lookupStandard($style_id)) {
535  $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
536  $new_id = $style_obj->ilClone();
537  $new_obj->setStyleSheetId($new_id);
538  $new_obj->update();
539  } else {
540  $new_obj->setStyleSheetId($this->getStyleSheetId());
541  }
542  }
543 
544  // #10271 - copy start objects page
545  include_once("./Services/Container/classes/class.ilContainerStartObjectsPage.php");
547  "cstr",
548  $this->getId()
549  )) {
550  $orig_page = new ilContainerStartObjectsPage($this->getId());
551  $orig_page->copy($new_obj->getId(), "cstr", $new_obj->getId());
552  }
553 
554  // #10271
555  foreach (self::_getContainerSettings($this->getId()) as $keyword => $value) {
556  self::_writeContainerSetting($new_obj->getId(), $keyword, $value);
557  }
558 
559  $new_obj->setNewsTimeline($this->getNewsTimeline());
560  $new_obj->setNewsBlockActivated($this->getNewsBlockActivated());
561  $new_obj->setUseNews($this->getUseNews());
562  $new_obj->setNewsTimelineAutoEntries($this->getNewsTimelineAutoEntries());
563  $new_obj->setNewsTimelineLandingPage($this->getNewsTimelineLandingPage());
564  ilBlockSetting::cloneSettingsOfBlock("news", $this->getId(), $new_obj->getId());
565  $mom_noti = new ilMembershipNotifications($this->getRefId());
566  $mom_noti->cloneSettings($new_obj->getRefId());
567 
568  return $new_obj;
569  }
570 
579  public function cloneDependencies($a_target_id, $a_copy_id)
580  {
581  $ilLog = $this->log;
582 
583  parent::cloneDependencies($a_target_id, $a_copy_id);
584 
585  include_once('./Services/Container/classes/class.ilContainerSorting.php');
586  ilContainerSorting::_getInstance($this->getId())->cloneSorting($a_target_id, $a_copy_id);
587 
588  // fix internal links to other objects
589  ilContainer::fixInternalLinksAfterCopy($a_target_id, $a_copy_id, $this->getRefId());
590 
591  // fix item group references in page content
592  include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
594 
595  include_once('Services/Object/classes/class.ilObjectLP.php');
596  $olp = ilObjectLP::getInstance($this->getId());
597  $collection = $olp->getCollectionInstance();
598  if ($collection) {
599  $collection->cloneCollection($a_target_id, $a_copy_id);
600  }
601 
602  return true;
603  }
604 
619  public function cloneAllObject($session_id, $client_id, $new_type, $ref_id, $clone_source, $options, $soap_call = false, $a_submode = 1)
620  {
621  $ilLog = $this->log;
622 
623  include_once('./Services/Link/classes/class.ilLink.php');
624  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
625 
626  $ilAccess = $this->access;
629  $tree = $this->tree;
631 
632  // Save wizard options
634  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
635  $wizard_options->saveOwner($ilUser->getId());
636  $wizard_options->saveRoot($clone_source);
637 
638  // add entry for source container
639  $wizard_options->initContainer($clone_source, $ref_id);
640 
641  foreach ($options as $source_id => $option) {
642  $wizard_options->addEntry($source_id, $option);
643  }
644  $wizard_options->read();
645  $wizard_options->storeTree($clone_source);
646 
647  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
648  if ($a_submode == ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
649  ilLoggerFactory::getLogger('obj')->info('Copy content only...');
650  ilLoggerFactory::getLogger('obj')->debug('Added mapping, source ID: ' . $clone_source . ', target ID: ' . $ref_id);
651  $wizard_options->read();
652  $wizard_options->dropFirstNode();
653  $wizard_options->appendMapping($clone_source, $ref_id);
654  }
655 
656 
657  #print_r($options);
658  // Duplicate session to avoid logout problems with backgrounded SOAP calls
659  $new_session_id = ilSession::_duplicate($session_id);
660  // Start cloning process using soap call
661  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
662 
663  $soap_client = new ilSoapClient();
664  $soap_client->setResponseTimeout(5);
665  $soap_client->enableWSDL(true);
666 
667  $ilLog->write(__METHOD__ . ': Trying to call Soap client...');
668  if ($soap_client->init()) {
669  ilLoggerFactory::getLogger('obj')->info('Calling soap clone method');
670  $res = $soap_client->call('ilClone', array($new_session_id . '::' . $client_id, $copy_id));
671  } else {
672  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
673  $wizard_options->disableSOAP();
674  $wizard_options->read();
675  include_once('./webservice/soap/include/inc.soap_functions.php');
676  $res = ilSoapFunctions::ilClone($new_session_id . '::' . $client_id, $copy_id);
677  }
678  return array(
679  'copy_id' => $copy_id,
680  'ref_id' => (int) $res
681  );
682  }
683 
689  public function delete()
690  {
691  // always call parent delete function first!!
692  if (!parent::delete()) {
693  return false;
694  }
695  // delete translations
696  $this->obj_trans->delete();
697 
698  return true;
699  }
700 
704  public function getViewMode()
705  {
707  }
708 
712  public function getOrderType()
713  {
714  return $this->order_type ? $this->order_type : ilContainer::SORT_TITLE;
715  }
716 
717  public function setOrderType($a_value)
718  {
719  $this->order_type = $a_value;
720  }
721 
730  public function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0)
731  {
733  $tree = $this->tree;
734 
735  // Caching
736  if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
737  !$a_get_single) {
738  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
739  }
740 
741  $type_grps = $this->getGroupedObjTypes();
742  $objects = $tree->getChilds($this->getRefId(), "title");
743 
744  $objects = self::getCompleteDescriptions($objects);
745 
746  $found = false;
747  $all_ref_ids = array();
748 
749  if (!self::$data_preloaded) {
750  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
752  }
753 
754  include_once('Services/Container/classes/class.ilContainerSorting.php');
755  $sort = ilContainerSorting::_getInstance($this->getId());
756 
757  // TODO: check this
758  // get items attached to a session
759  include_once './Modules/Session/classes/class.ilEventItems.php';
760  $event_items = ilEventItems::_getItemsOfContainer($this->getRefId());
761 
762  foreach ($objects as $key => $object) {
763  if ($a_get_single > 0 && $object["child"] != $a_get_single) {
764  continue;
765  }
766 
767  // hide object types in devmode
768  if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm"
769  || $object["type"] == "rolf") {
770  continue;
771  }
772 
773  // remove inactive plugins
774  if ($objDefinition->isInactivePlugin($object["type"])) {
775  continue;
776  }
777 
778  // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
779  if (in_array($object['type'], array('file','fold','cat'))) {
780  include_once 'Modules/File/classes/class.ilObjFileAccess.php';
781  if (ilObjFileAccess::_isFileHidden($object['title'])) {
782  $this->setHiddenFilesFound(true);
783  if (!$a_admin_panel_enabled) {
784  continue;
785  }
786  }
787  }
788  // END WebDAV: Don't display hidden Files, Folders and Categories
789 
790  // including event items!
791  if (!self::$data_preloaded) {
792  $preloader->addItem($object["obj_id"], $object["type"], $object["child"]);
793  }
794 
795  // filter out items that are attached to an event
796  if (in_array($object['ref_id'], $event_items)) {
797  continue;
798  }
799 
800  // filter side block items
801  if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
802  continue;
803  }
804 
805  $all_ref_ids[] = $object["child"];
806  }
807 
808  // data preloader
809  if (!self::$data_preloaded) {
810  $preloader->preload();
811  unset($preloader);
812 
813  self::$data_preloaded = true;
814  }
815 
816  foreach ($objects as $key => $object) {
817  // see above, objects were filtered
818  if (!in_array($object["child"], $all_ref_ids)) {
819  continue;
820  }
821 
822  // group object type groups together (e.g. learning resources)
823  $type = $objDefinition->getGroupOfObj($object["type"]);
824  if ($type == "") {
825  $type = $object["type"];
826  }
827 
828  // this will add activation properties
829  $this->addAdditionalSubItemInformation($object);
830 
831  $this->items[$type][$key] = $object;
832 
833  $this->items["_all"][$key] = $object;
834  if ($object["type"] != "sess") {
835  $this->items["_non_sess"][$key] = $object;
836  }
837  }
838 
839  $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]
840  = $sort->sortItems($this->items);
841 
842  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
843  }
844 
848  public function gotItems()
849  {
850  if (is_array($this->items["_all"]) && count($this->items["_all"]) > 0) {
851  return true;
852  }
853  return false;
854  }
855 
860  public function addAdditionalSubItemInformation(&$object)
861  {
862  }
863 
869  public function getGroupedObjTypes()
870  {
872 
873  if (empty($this->type_grps)) {
874  $this->type_grps = $objDefinition->getGroupedRepositoryObjectTypes($this->getType());
875  }
876  return $this->type_grps;
877  }
878 
882  public function enablePageEditing()
883  {
885 
886  // @todo: this will need a more general approach
887  if ($ilSetting->get("enable_cat_page_edit")) {
888  return true;
889  }
890  }
891 
895  public function create()
896  {
897  global $DIC;
898 
899  $lng = $DIC->language();
900 
901  $ret = parent::create();
902 
903  // set translation object, since we have an object id now
904  $this->obj_trans = ilObjectTranslation::getInstance($this->getId());
905 
906  // add default translation
907  $this->addTranslation(
908  $this->getTitle(),
909  $this->getDescription(),
910  $lng->getDefaultLanguage(),
911  true
912  );
913 
914  if (((int) $this->getStyleSheetId()) > 0) {
915  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
917  }
918 
920  $log->debug("Create Container, id: " . $this->getId());
921 
922  self::_writeContainerSetting($this->getId(), "news_timeline", (int) $this->getNewsTimeline());
923  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (int) $this->getNewsTimelineAutoEntries());
924  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (int) $this->getNewsTimelineLandingPage());
925  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
926  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (int) $this->getNewsBlockActivated());
927  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (int) $this->getUseNews());
928 
929  return $ret;
930  }
931 
935  public function putInTree($a_parent_ref)
936  {
937  parent::putInTree($a_parent_ref);
938 
939  // copy title, icon actions visibilities
940  if (self::_lookupContainerSetting(ilObject::_lookupObjId($a_parent_ref), "hide_header_icon_and_title")) {
941  self::_writeContainerSetting($this->getId(), "hide_header_icon_and_title", true);
942  }
943  if (self::_lookupContainerSetting(ilObject::_lookupObjId($a_parent_ref), "hide_top_actions")) {
944  self::_writeContainerSetting($this->getId(), "hide_top_actions", true);
945  }
946  }
947 
951  public function update()
952  {
953  $ret = parent::update();
954 
955  $trans = $this->getObjectTranslation();
956  $trans->setDefaultTitle($this->getTitle());
957  $trans->setDefaultDescription($this->getLongDescription());
958  $trans->save();
959 
960  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
962 
964  $log->debug("Update Container, id: " . $this->getId());
965 
966  self::_writeContainerSetting($this->getId(), "news_timeline", (int) $this->getNewsTimeline());
967  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (int) $this->getNewsTimelineAutoEntries());
968  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (int) $this->getNewsTimelineLandingPage());
969  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
970  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (int) $this->getNewsBlockActivated());
971  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (int) $this->getUseNews());
972 
973  return $ret;
974  }
975 
976 
984  public function read()
985  {
986  parent::read();
987 
988  include_once("./Services/Container/classes/class.ilContainerSortingSettings.php");
990 
991  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
993 
994  $this->readContainerSettings();
995  $this->obj_trans = ilObjectTranslation::getInstance($this->getId());
996  }
997 
1004  public function readContainerSettings()
1005  {
1006  $this->setNewsTimeline(self::_lookupContainerSetting($this->getId(), "news_timeline"));
1007  $this->setNewsTimelineAutoEntries(self::_lookupContainerSetting($this->getId(), "news_timeline_incl_auto"));
1008  $this->setNewsTimelineLandingPage(self::_lookupContainerSetting($this->getId(), "news_timeline_landing_page"));
1009  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
1010  $this->setNewsBlockActivated(self::_lookupContainerSetting(
1011  $this->getId(),
1013  $this->setting->get('block_activated_news', true)
1014  ));
1015  $this->setUseNews(self::_lookupContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, true));
1016  }
1017 
1018 
1026  public static function getCompleteDescriptions(array $objects)
1027  {
1028  global $DIC;
1029 
1030  $ilSetting = $DIC->settings();
1031  $ilObjDataCache = $DIC["ilObjDataCache"];
1032  // using long descriptions?
1033  $short_desc = $ilSetting->get("rep_shorten_description");
1034  $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
1035  if (!$short_desc || $short_desc_max_length != ilObject::DESC_LENGTH) {
1036  // using (part of) shortened description
1037  if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::DESC_LENGTH) {
1038  foreach ($objects as $key => $object) {
1039  $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true);
1040  }
1041  }
1042  // using (part of) long description
1043  else {
1044  $obj_ids = array();
1045  foreach ($objects as $key => $object) {
1046  $obj_ids[] = $object["obj_id"];
1047  }
1048  if (sizeof($obj_ids)) {
1050  foreach ($objects as $key => $object) {
1051  // #12166 - keep translation, ignore long description
1052  if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) {
1053  $long_desc[$object["obj_id"]] = $object["description"];
1054  }
1055  if ($short_desc && $short_desc_max_length) {
1056  $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true);
1057  }
1058  $objects[$key]["description"] = $long_desc[$object["obj_id"]];
1059  }
1060  }
1061  }
1062  }
1063  return $objects;
1064  }
1065 
1072  protected static function fixInternalLinksAfterCopy($a_target_id, $a_copy_id, $a_source_ref_id)
1073  {
1074  global $DIC;
1075 
1077  $obj_definition = $DIC["objDefinition"];
1078 
1079  $obj_id = ilObject::_lookupObjId($a_target_id);
1080  include_once("./Services/Container/classes/class.ilContainerPage.php");
1081 
1082  include_once("./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
1083  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1084  $mapping = $cwo->getMappings();
1085 
1086  if (ilContainerPage::_exists("cont", $obj_id)) {
1087  $pg = new ilContainerPage($obj_id);
1088  $pg->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1089  $pg->update(true, true);
1090  }
1091 
1092  foreach ($mapping as $old_ref_id => $new_ref_id) {
1093  if (!is_numeric($old_ref_id) || !is_numeric($new_ref_id)) {
1094  continue;
1095  }
1096 
1097  $type = ilObject::_lookupType($new_ref_id, true);
1098  $class = 'il' . $obj_definition->getClassName($type) . 'PageCollector';
1099  $loc = $obj_definition->getLocation($type);
1100  $file = $loc . '/class.' . $class . '.php';
1101 
1102  if (is_file($file)) {
1104  $coll = new $class();
1105  foreach ($coll->getAllPageIds(ilObject::_lookupObjId($new_ref_id)) as $page_id) {
1106  if (ilPageObject::_exists($page_id['parent_type'], $page_id['id'], $page_id['lang'])) {
1108  $page = ilPageObjectFactory::getInstance($page_id['parent_type'], $page_id['id'], 0, $page_id['lang']);
1109  $page->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1110  $page->update(true, true);
1111  }
1112  }
1113  }
1114  }
1115  }
1116 
1120  public function removeTranslations()
1121  {
1122  $this->obj_trans->delete();
1123  }
1124 
1130  public function deleteTranslation($a_lang)
1131  {
1132  $this->obj_trans->removeLanguage($a_lang);
1133  $this->obj_trans->save();
1134  }
1135 
1145  public function addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
1146  {
1147  if (empty($a_title)) {
1148  $a_title = "NO TITLE";
1149  }
1150 
1151  $this->obj_trans->addLanguage($a_lang, $a_title, $a_desc, $a_lang_default, true);
1152  $this->obj_trans->save();
1153 
1154  return true;
1155  }
1156 }
deleteTranslation($a_lang)
Delete translation.
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)
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.
removeTranslations()
Remove all translations of container.
const SORT_NEW_ITEMS_POSITION_TOP
addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
Add translation.
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
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
XML writer class.
setHiddenFilesFound($a_hiddenfilesfound)
Set Found hidden files (set by getSubItems).
setNewsBlockActivated($a_val)
Set news block activated.
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.
$ilErr
Definition: raiseError.php:18
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 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
setObjectTranslation(ilObjectTranslation $obj_trans)
Get object translation.
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.
putInTree($a_parent_ref)
getTitle()
get object title public
getDescription()
get object description
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.
getObjectTranslation()
Get object translation.
getType()
get object type public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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 ...
$row
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)
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.
static getInstance($a_obj_id)
Get instance.
global $ilDB
$ret
Definition: parser.php:6
getLongDescription()
get object long description (stored in object_description)
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
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.
Class handles translation mode for an object.