ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilContainerSessionsContentGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilContainerSessionsContentGUI:
+ Collaboration diagram for ilContainerSessionsContentGUI:

Public Member Functions

 renderItemList ()
 
- Public Member Functions inherited from ilContainerContentGUI
 getContainerObject ()
 
 getContainerGUI ()
 
 setOutput ()
 This method sets the output of the right and main column in the global standard template. More...
 
 getMainContent ()
 Get content HTML for main column, this one may be overwritten in derived classes. More...
 
 determinePageEmbeddedBlocks (string $a_container_page_html)
 Determine all blocks that are embedded in the container page. More...
 
 addEmbeddedBlock (string $block_type, $block_parameter)
 Add embedded block. More...
 
 getEmbeddedBlocks ()
 
 renderPageEmbeddedBlocks ()
 
 renderItem (array $a_item_data, int $a_position=0, bool $a_force_icon=false, string $a_pos_prefix="", string $item_group_list_presentation="")
 Render an item. More...
 
 renderCard (array $a_item_data, int $a_position=0, bool $a_force_icon=false, string $a_pos_prefix="")
 
 insertPageEmbeddedBlocks (string $a_output_html)
 Insert blocks into container page. More...
 
 getSingleTypeBlockAsynch (string $type)
 Render single block. More...
 
 getGroupedObjTypes ()
 Get grouped repository object types. More...
 
 getIntroduction ()
 
 getItemGroupsHTML (int $a_pos=0)
 
 renderItemGroup (array $a_itgr)
 

Protected Member Functions

 initRenderer ()
 
 getBlockPostfix (string $type)
 
 getBlockPrefix (string $type)
 
 renderSessionLimitLink (bool $a_previous=true)
 
 initSessionPresentationLimitation ()
 
 isItemHidden (string $type, int $ref_id)
 
- Protected Member Functions inherited from ilContainerContentGUI
 getViewMode ()
 
 getRightColumnHTML ()
 
 getCenterColumnHTML ()
 
 initRenderer ()
 Init container renderer. More...
 
 getItemGUI (array $item_data)
 
 hasForcedOrderByStartDate (string $type)
 
 getUniqueItemId (array $a_item_data)
 

Protected Attributes

array $visible_sessions = []
 
bool $session_link_next = false
 
bool $session_link_prev = false
 
bool $session_limitation_initialised = false
 
- Protected Attributes inherited from ilContainerContentGUI
ILIAS Container Content ItemPresentationManager $item_presentation
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
ilObjUser $user
 
ilLanguage $lng
 
ilAccessHandler $access
 
ilDBInterface $db
 
ilRbacSystem $rbacsystem
 
ilSetting $settings
 
ilObjectDefinition $obj_definition
 
int $details_level = self::DETAILS_DEACTIVATED
 
ilContainerRenderer $renderer
 
ilLogger $log
 
int $view_mode
 
array $embedded_block = []
 
array $items = []
 
array $list_gui = []
 
ClipboardManager $clipboard
 
StandardGUIRequest $request
 
ItemManager $item_manager
 
BlockSessionRepository $block_repo
 
int $block_limit = 0
 
array $type_grps = []
 
int $force_details
 
ilContainerUserFilter $container_user_filter
 

Additional Inherited Members

- Data Fields inherited from ilContainerContentGUI
const DETAILS_DEACTIVATED = 0
 
const DETAILS_TITLE = 1
 
const DETAILS_ALL = 2
 
const VIEW_MODE_LIST = 0
 
const VIEW_MODE_TILE = 1
 
ilContainerGUI $container_gui
 
ilContainer $container_obj
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Shows all items in one block.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilContainerSessionsContentGUI.php.

Member Function Documentation

◆ getBlockPostfix()

ilContainerSessionsContentGUI::getBlockPostfix ( string  $type)
protected

Definition at line 45 of file class.ilContainerSessionsContentGUI.php.

References initSessionPresentationLimitation(), and renderSessionLimitLink().

Referenced by initRenderer().

45  : string
46  {
47  if ($type === "sess") {
49  if ($this->session_link_next) {
50  return (string) $this->renderSessionLimitLink(false);
51  }
52  }
53  return "";
54  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBlockPrefix()

ilContainerSessionsContentGUI::getBlockPrefix ( string  $type)
protected

Definition at line 56 of file class.ilContainerSessionsContentGUI.php.

References initSessionPresentationLimitation(), and renderSessionLimitLink().

Referenced by initRenderer().

56  : string
57  {
58  if ($type === "sess") {
60  if ($this->session_link_prev) {
61  return (string) $this->renderSessionLimitLink(true);
62  }
63  }
64  return "";
65  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initRenderer()

ilContainerSessionsContentGUI::initRenderer ( )
protected

Definition at line 31 of file class.ilContainerSessionsContentGUI.php.

References $ref_id, getBlockPostfix(), getBlockPrefix(), isItemHidden(), and renderer().

Referenced by renderItemList().

31  : void
32  {
33  parent::initRenderer();
34  $this->renderer->setBlockPostfixClosure(function (string $type) {
35  return $this->getBlockPostfix($type);
36  });
37  $this->renderer->setBlockPrefixClosure(function (string $type) {
38  return $this->getBlockPrefix($type);
39  });
40  $this->renderer->setItemHiddenClosure(function (string $type, int $ref_id) {
41  return $this->isItemHidden($type, $ref_id);
42  });
43  }
renderer()
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSessionPresentationLimitation()

ilContainerSessionsContentGUI::initSessionPresentationLimitation ( )
protected

Definition at line 122 of file class.ilContainerSessionsContentGUI.php.

References ilContainerContentGUI\$access, $container, ilContainerContentGUI\$container_obj, $DIC, $ref_id, ilContainerContentGUI\$request, ilContainerContentGUI\$user, ilDateTime\_after(), ilDateTime\_before(), ilDateTime\_within(), ilObjectFactory\getInstanceByRefId(), ilObjUser\getPref(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_UNIX, null, ilArrayUtil\sortArray(), ilContainer\VIEW_INHERIT, and ilObjUser\writePref().

Referenced by getBlockPostfix(), getBlockPrefix(), and isItemHidden().

122  : void
123  {
124  global $DIC;
125  if ($this->session_limitation_initialised) {
126  return;
127  }
128  $this->session_limitation_initialised = true;
129 
130 
132 
133 
134  $mode_manager = $DIC->container()->internal()->domain()->content()->mode($container);
135  $session_ref_ids = $this->item_presentation->getRefIdsOfType("sess");
136 
137  // see #38780
138  if (!in_array($container->getType(), ["grp", "crs"])) {
139  $this->visible_sessions = $session_ref_ids;
140  return;
141  }
142 
143  $user = $DIC->user();
144  $access = $DIC->access();
145  $tree = $DIC->repositoryTree();
146  $request = $DIC->container()
147  ->internal()
148  ->gui()
149  ->standardRequest();
150 
151  $limit_sessions = false;
152  if (!$mode_manager->isAdminMode() &&
153  count($session_ref_ids) > 0 &&
154  $container->isSessionLimitEnabled()) {
155  $limit_sessions = true;
156  }
157 
158  if ($container->getViewMode() === ilContainer::VIEW_INHERIT) {
159  $parent = $tree->checkForParentType($container->getRefId(), 'crs');
160  $crs = ilObjectFactory::getInstanceByRefId($parent, false);
161  if (!$crs instanceof ilObjCourse) {
162  return;
163  }
164 
165  if (!$container->isSessionLimitEnabled()) {
166  $limit_sessions = false;
167  }
168  $limit_next = $crs->getNumberOfNextSessions();
169  $limit_prev = $crs->getNumberOfPreviousSessions();
170  } else {
171  $limit_next = $container->getNumberOfNextSessions();
172  $limit_prev = $container->getNumberOfPreviousSessions();
173  }
174 
175  if (!$limit_sessions) {
176  $this->visible_sessions = $session_ref_ids;
177  return;
178  }
179 
180  // do session limit
181  if ($request->getPreviousSession() !== null) {
182  $user->writePref(
183  'crs_sess_show_prev_' . $container->getId(),
184  (string) $request->getPreviousSession()
185  );
186  }
187  if ($request->getNextSession() !== null) {
188  $user->writePref(
189  'crs_sess_show_next_' . $container->getId(),
190  (string) $request->getNextSession()
191  );
192  }
193 
194  $sessions = array_map(function ($ref_id) {
195  return $this->item_presentation->getRawDataByRefId($ref_id);
196  }, $session_ref_ids);
197  $sessions = ilArrayUtil::sortArray($sessions, 'start', 'ASC', true, false);
198  //$sessions = ilUtil::sortArray($this->items['sess'],'start','ASC',true,false);
199  $today = new ilDate(date('Ymd'), IL_CAL_DATE);
200  $previous = $current = $next = [];
201  foreach ($sessions as $key => $item) {
202  $start = new ilDateTime($item['start'], IL_CAL_UNIX);
203  $end = new ilDateTime($item['end'], IL_CAL_UNIX);
204 
205  if (ilDateTime::_within($today, $start, $end, IL_CAL_DAY)) {
206  $current[] = $item;
207  } elseif (ilDateTime::_before($start, $today, IL_CAL_DAY)) {
208  $previous[] = $item;
209  } elseif (ilDateTime::_after($start, $today, IL_CAL_DAY)) {
210  $next[] = $item;
211  }
212  }
213 
214  $num_previous_remove = max(
215  count($previous) - $limit_prev,
216  0
217  );
218  while ($num_previous_remove--) {
219  if (!$user->getPref('crs_sess_show_prev_' . $container->getId())) {
220  array_shift($previous);
221  }
222  $this->session_link_prev = true;
223  }
224 
225  $num_next_remove = max(
226  count($next) - $limit_next,
227  0
228  );
229  while ($num_next_remove--) {
230  if (!$user->getPref('crs_sess_show_next_' . $container->getId())) {
231  array_pop($next);
232  }
233  // @fixme
234  $this->session_link_next = true;
235  }
236 
237  $sessions = array_merge($previous, $current, $next);
238  $this->visible_sessions = array_map(static function ($item) {
239  return (int) $item["ref_id"];
240  }, $sessions);
241  }
writePref(string $a_keyword, string $a_value)
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
const IL_CAL_UNIX
$container
Definition: wac.php:36
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const IL_CAL_DAY
$ref_id
Definition: ltiauth.php:65
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
getPref(string $a_keyword)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: shib_login.php:22
const IL_CAL_DATE
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check whether an date is within a date duration given by start and end.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isItemHidden()

ilContainerSessionsContentGUI::isItemHidden ( string  $type,
int  $ref_id 
)
protected

Definition at line 243 of file class.ilContainerSessionsContentGUI.php.

References initSessionPresentationLimitation().

Referenced by initRenderer().

243  : bool
244  {
245  if ($type === "sess") {
247  return !in_array($ref_id, $this->visible_sessions, true);
248  }
249  return false;
250  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderItemList()

ilContainerSessionsContentGUI::renderItemList ( )

Definition at line 67 of file class.ilContainerSessionsContentGUI.php.

References initRenderer(), and renderer().

67  : string
68  {
69  $this->initRenderer();
70  return $this->renderer->renderItemBlockSequence($this->item_presentation->getItemBlockSequence());
71  }
renderer()
+ Here is the call graph for this function:

◆ renderSessionLimitLink()

ilContainerSessionsContentGUI::renderSessionLimitLink ( bool  $a_previous = true)
protected

Definition at line 73 of file class.ilContainerSessionsContentGUI.php.

References ilContainerContentGUI\$ctrl, ilContainerContentGUI\$lng, ilContainerContentGUI\$tpl, ilContainerContentGUI\$user, ILIAS\UICore\GlobalTemplate\get(), ilContainerContentGUI\getContainerGUI(), ilContainerContentGUI\getContainerObject(), ILIAS\Survey\Mode\getId(), ilLanguage\loadLanguageModule(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), ILIAS\UICore\GlobalTemplate\setVariable(), and ilLanguage\txt().

Referenced by getBlockPostfix(), and getBlockPrefix().

75  : string {
76  $lng = $this->lng;
77  $ilUser = $this->user;
78  $ilCtrl = $this->ctrl;
79 
80  $lng->loadLanguageModule('crs');
81 
82  $tpl = new ilTemplate(
83  'tpl.container_list_item.html',
84  true,
85  true,
86  "components/ILIAS/Container"
87  );
88  $tpl->setVariable('DIV_CLASS', 'ilContainerListItemOuter');
89  $tpl->setCurrentBlock('item_title_linked');
90 
91  if ($a_previous) {
92  $prefp = $ilUser->getPref('crs_sess_show_prev_' . $this->getContainerObject()->getId());
93 
94  if ($prefp) {
95  $tpl->setVariable('TXT_TITLE_LINKED', $lng->txt('crs_link_hide_prev_sessions'));
96  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()), 'crs_prev_sess', (int) !$prefp);
97  $tpl->setVariable('HREF_TITLE_LINKED', $ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI()), 'view'));
98  } else {
99  $tpl->setVariable('TXT_TITLE_LINKED', $lng->txt('crs_link_show_all_prev_sessions'));
100  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()), 'crs_prev_sess', (int) !$prefp);
101  $tpl->setVariable('HREF_TITLE_LINKED', $ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI()), 'view'));
102  }
103  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
104  } else {
105  $prefn = $ilUser->getPref('crs_sess_show_next_' . $this->getContainerObject()->getId());
106 
107  if ($prefn) {
108  $tpl->setVariable('TXT_TITLE_LINKED', $lng->txt('crs_link_hide_next_sessions'));
109  } else {
110  $tpl->setVariable('TXT_TITLE_LINKED', $lng->txt('crs_link_show_all_next_sessions'));
111  }
112  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()), 'crs_next_sess', (int) !$prefn);
113  $tpl->setVariable('HREF_TITLE_LINKED', $ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI()), 'view'));
114  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
115  }
117 
118  return $tpl->get();
119  }
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
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...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
ilGlobalTemplateInterface $tpl
loadLanguageModule(string $a_module)
Load language module.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $session_limitation_initialised

bool ilContainerSessionsContentGUI::$session_limitation_initialised = false
protected

Definition at line 29 of file class.ilContainerSessionsContentGUI.php.

◆ $session_link_next

bool ilContainerSessionsContentGUI::$session_link_next = false
protected

Definition at line 27 of file class.ilContainerSessionsContentGUI.php.

◆ $session_link_prev

bool ilContainerSessionsContentGUI::$session_link_prev = false
protected

Definition at line 28 of file class.ilContainerSessionsContentGUI.php.

◆ $visible_sessions

array ilContainerSessionsContentGUI::$visible_sessions = []
protected

Definition at line 26 of file class.ilContainerSessionsContentGUI.php.


The documentation for this class was generated from the following file: