ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 Init container renderer. More...
 
 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.

45 : string
46 {
47 if ($type === "sess") {
49 if ($this->session_link_next) {
50 return (string) $this->renderSessionLimitLink(false);
51 }
52 }
53 return "";
54 }

References initSessionPresentationLimitation(), and renderSessionLimitLink().

Referenced by initRenderer().

+ 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.

56 : string
57 {
58 if ($type === "sess") {
60 if ($this->session_link_prev) {
61 return (string) $this->renderSessionLimitLink(true);
62 }
63 }
64 return "";
65 }

References initSessionPresentationLimitation(), and renderSessionLimitLink().

Referenced by initRenderer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initRenderer()

ilContainerSessionsContentGUI::initRenderer ( )
protected

Init container renderer.

Reimplemented from ilContainerContentGUI.

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

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:66

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

Referenced by renderItemList().

+ 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.

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) {
183 'crs_sess_show_prev_' . $container->getId(),
184 (string) $request->getPreviousSession()
185 );
186 }
187 if ($request->getNextSession() !== null) {
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 }
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DAY
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
@classDescription Date and time handling
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.
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 _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.
Class for single dates.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPref(string $a_keyword)
writePref(string $keyword, string $value)
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:26
$container
@noRector
Definition: wac.php:37

References $container, $DIC, $ref_id, ilDateTime\_after(), ilDateTime\_before(), ilDateTime\_within(), ilObjectFactory\getInstanceByRefId(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_UNIX, ilArrayUtil\sortArray(), and ilContainer\VIEW_INHERIT.

Referenced by getBlockPostfix(), and getBlockPrefix().

+ 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.

243 : bool
244 {
245 if ($type === "sess") {
247 return !in_array($ref_id, $this->visible_sessions, true);
248 }
249 return false;
250 }

References $ref_id.

Referenced by initRenderer().

+ Here is the caller graph for this function:

◆ renderItemList()

ilContainerSessionsContentGUI::renderItemList ( )

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

67 : string
68 {
69 $this->initRenderer();
70 return $this->renderer->renderItemBlockSequence($this->item_presentation->getItemBlockSequence());
71 }

References initRenderer(), and 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.

75 : string {
77 $ilUser = $this->user;
78 $ilCtrl = $this->ctrl;
79
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 }
ilGlobalTemplateInterface $tpl
loadLanguageModule(string $a_module)
Load language module.
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...
special template class to simplify handling of ITX/PEAR
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

Referenced by getBlockPostfix(), and getBlockPrefix().

+ 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: