ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilPDSelectedItemsBlockViewGUI Class Reference

Class ilPDSelectedItemsBlockViewGUI. More...

+ Inheritance diagram for ilPDSelectedItemsBlockViewGUI:
+ Collaboration diagram for ilPDSelectedItemsBlockViewGUI:

Public Member Functions

 getScreenId ()
 
 getTitle ()
 
 getMinimumDetailLevelForSection ()
 
 supportsSelectAll ()
 
 getIntroductionHtml ()
 
 getGroups ()
 
 mayRemoveItem ($refId)
 
 setIsInManageMode (bool $isInManageMode)
 
 isInManageMode ()
 
 getItemGroups ()
 

Static Public Member Functions

static bySettings (ilPDSelectedItemsBlockViewSettings $viewSettings)
 

Protected Member Functions

 isRootNode ($refId)
 
 getRepositoryTitle ()
 
 preloadItemGroups (array $item_groups)
 
 groupItemsByType ()
 
 groupItemsByStartDate ()
 
 groupItemsByLocation ()
 

Protected Attributes

 $viewSettings
 
 $provider
 
 $lng
 
 $tree
 
 $object_cache
 
 $accessHandler
 
 $isInManageMode = false
 

Private Member Functions

 __construct (ilPDSelectedItemsBlockViewSettings $viewSettings, ilPDSelectedItemsBlockProvider $provider)
 ilPDSelectedItemsBlockViewGUI constructor. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilPDSelectedItemsBlockViewGUI::__construct ( ilPDSelectedItemsBlockViewSettings  $viewSettings,
ilPDSelectedItemsBlockProvider  $provider 
)
private

ilPDSelectedItemsBlockViewGUI constructor.

Parameters
ilPDSelectedItemsBlockViewSettings$viewSettings
ilPDSelectedItemsBlockProvider$provider

Definition at line 47 of file class.ilPDSelectedItemsBlockViewGUI.php.

48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->tree = $DIC->repositoryTree();
53 $this->object_cache = $DIC['ilObjDataCache'];
54 $this->accessHandler = $DIC->rbac()->system();
55
56 $this->viewSettings = $viewSettings;
57 $this->provider = $provider;
58 }
$DIC
Definition: xapitoken.php:46

References $DIC, $provider, and $viewSettings.

Member Function Documentation

◆ bySettings()

static ilPDSelectedItemsBlockViewGUI::bySettings ( ilPDSelectedItemsBlockViewSettings  $viewSettings)
static
Parameters
ilPDSelectedItemsBlockViewSettings$viewSettings
Returns
self

Definition at line 137 of file class.ilPDSelectedItemsBlockViewGUI.php.

138 {
139 if ($viewSettings->isMembershipsViewActive()) {
143 );
144 }
145
149 );
150 }

References $viewSettings.

Referenced by ilFavouritesListGUI\__construct(), ilPDMembershipBlockGUI\initViewSettings(), and ilPDSelectedItemsBlockGUI\initViewSettings().

+ Here is the caller graph for this function:

◆ getGroups()

ilPDSelectedItemsBlockViewGUI::getGroups ( )
abstract
Returns
ilPDSelectedItemsBlockGroup[]

Reimplemented in ilPDSelectedItemsBlockMembershipsViewGUI, and ilPDSelectedItemsBlockSelectedItemsViewGUI.

Referenced by getItemGroups().

+ Here is the caller graph for this function:

◆ getIntroductionHtml()

ilPDSelectedItemsBlockViewGUI::getIntroductionHtml ( )
abstract

◆ getItemGroups()

ilPDSelectedItemsBlockViewGUI::getItemGroups ( )
Returns
ilPDSelectedItemsBlockGroup[]

Definition at line 125 of file class.ilPDSelectedItemsBlockViewGUI.php.

126 {
127 $items_groups = $this->getGroups();
128 $this->preloadItemGroups($items_groups);
129
130 return $items_groups;
131 }

References getGroups(), and preloadItemGroups().

+ Here is the call graph for this function:

◆ getMinimumDetailLevelForSection()

ilPDSelectedItemsBlockViewGUI::getMinimumDetailLevelForSection ( )
Returns
int

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

74 {
75 if ($this->viewSettings->isSortedByLocation()) {
76 return 1;
77 }
78
79 return 3;
80 }

◆ getRepositoryTitle()

ilPDSelectedItemsBlockViewGUI::getRepositoryTitle ( )
protected
Returns
string

Definition at line 164 of file class.ilPDSelectedItemsBlockViewGUI.php.

165 {
166 $nd = $this->tree->getNodeData($this->tree->getRootId());
167 $title = $nd['title'];
168
169 if ($title == 'ILIAS') {
170 $title = $this->lng->txt('repository');
171 }
172
173 return $title;
174 }
$nd
Definition: error.php:12

References $nd.

Referenced by groupItemsByLocation().

+ Here is the caller graph for this function:

◆ getScreenId()

ilPDSelectedItemsBlockViewGUI::getScreenId ( )
abstract

◆ getTitle()

ilPDSelectedItemsBlockViewGUI::getTitle ( )
abstract

◆ groupItemsByLocation()

ilPDSelectedItemsBlockViewGUI::groupItemsByLocation ( )
protected
Returns
ilPDSelectedItemsBlockGroup[]

Definition at line 323 of file class.ilPDSelectedItemsBlockViewGUI.php.

324 {
325 $grouped_items = array();
326
327 $items = $this->provider->getItems();
328
329 $parent_ref_ids = array_values(array_unique(array_map(function ($item) {
330 return $item['parent_ref'];
331 }, $items)));
332 $this->object_cache->preloadReferenceCache($parent_ref_ids);
333
334 foreach ($items as $key => $item) {
335 if (!array_key_exists('grp_' . $item['parent_ref'], $grouped_items)) {
336 $group = new ilPDSelectedItemsBlockGroup();
337 /* The parent objects of items grouped by location do not need an image (per current concept), so
338 we do not determine images to reduced the runtime/memory */
339 if ($this->isRootNode($item['parent_ref'])) {
340 $group->setLabel($this->getRepositoryTitle());
341 } else {
342 $group->setLabel($this->object_cache->lookupTitle($this->object_cache->lookupObjId($item['parent_ref'])));
343 }
344 $grouped_items['grp_' . $item['parent_ref']] = $group;
345 }
346
347 $grouped_items['grp_' . $item['parent_ref']]->pushItem($item);
348 }
349
350 return $grouped_items;
351 }
Class ilPDSelectedItemsBlockGroup.

References getRepositoryTitle(), and isRootNode().

Referenced by ilPDSelectedItemsBlockMembershipsViewGUI\getGroups(), and ilPDSelectedItemsBlockSelectedItemsViewGUI\getGroups().

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

◆ groupItemsByStartDate()

ilPDSelectedItemsBlockViewGUI::groupItemsByStartDate ( )
protected
Returns
ilPDSelectedItemsBlockGroup[]

Definition at line 232 of file class.ilPDSelectedItemsBlockViewGUI.php.

233 {
234 $items = $this->provider->getItems();
235
236 if (0 == count($items)) {
237 return array();
238 }
239
240 $groups = array(
241 'upcoming' => array(),
242 'ongoing' => array(),
243 'ended' => array(),
244 'not_dated' => array()
245 );
246 foreach ($items as $key => $item) {
247 if ($item['start'] && $item['start']->get(IL_CAL_UNIX) > 0 && $item['start'] instanceof ilDateTime) {
248 if ($item['start']->get(IL_CAL_UNIX) > time()) {
249 $groups['upcoming'][] = $item;
250 } elseif ($item['end']->get(IL_CAL_UNIX) > time()) {
251 $groups['ongoing'][] = $item;
252 } else {
253 $groups['ended'][] = $item;
254 }
255 } else {
256 $groups['not_dated'][] = $item;
257 }
258 }
259
260 uasort($groups['upcoming'], function ($left, $right) {
261 if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
262 return -1;
263 } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
264 return 1;
265 }
266
267 return strcmp($left['title'], $right['title']);
268 });
269
270 uasort($groups['ongoing'], function ($left, $right) {
271 if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
272 return 1;
273 } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
274 return -1;
275 }
276
277 return strcmp($left['title'], $right['title']);
278 });
279
280 uasort($groups['ended'], function ($left, $right) {
281 if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
282 return 1;
283 } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
284 return -1;
285 }
286
287 return strcmp($left['title'], $right['title']);
288 });
289
290 uasort($groups['not_dated'], function ($left, $right) {
291 return strcmp($left['title'], $right['title']);
292 });
293
294 $upcoming = new ilPDSelectedItemsBlockGroup();
295 $upcoming->setLabel($this->lng->txt('pd_upcoming'));
296 $upcoming->setItems($groups['upcoming']);
297
298 $ongoing = new ilPDSelectedItemsBlockGroup();
299 $ongoing->setLabel($this->lng->txt('pd_ongoing'));
300 $ongoing->setItems($groups['ongoing']);
301
302 $ended = new ilPDSelectedItemsBlockGroup();
303 $ended->setLabel($this->lng->txt('pd_ended'));
304 $ended->setItems($groups['ended']);
305
306 $not_dated = new ilPDSelectedItemsBlockGroup();
307 $not_dated->setLabel($this->lng->txt('pd_not_date'));
308 $not_dated->setItems($groups['not_dated']);
309
310 return array_filter([
311 $upcoming,
312 $ongoing,
313 $ended,
314 $not_dated
315 ], function (ilPDSelectedItemsBlockGroup $group) {
316 return count($group->getItems()) > 0;
317 });
318 }
const IL_CAL_UNIX
@classDescription Date and time handling

References ilPDSelectedItemsBlockGroup\getItems(), and IL_CAL_UNIX.

Referenced by ilPDSelectedItemsBlockMembershipsViewGUI\getGroups().

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

◆ groupItemsByType()

ilPDSelectedItemsBlockViewGUI::groupItemsByType ( )
protected
Returns
ilPDSelectedItemsBlockGroup[]

Definition at line 199 of file class.ilPDSelectedItemsBlockViewGUI.php.

200 {
201 global $DIC;
202
203 $objDefinition = $DIC["objDefinition"];
204
205 $object_types_by_container = $DIC['objDefinition']->getGroupedRepositoryObjectTypes(array('cat', 'crs', 'grp', 'fold'));
206
207 $grouped_items = array();
208
209 foreach ($object_types_by_container as $container_object_type => $container_data) {
210 $group = new ilPDSelectedItemsBlockGroup();
211 // Icons are currently not determined for section header objects
212 if (!$objDefinition->isPlugin($container_object_type)) {
213 $title = $this->lng->txt('objs_' . $container_object_type);
214 } else {
215 include_once("./Services/Component/classes/class.ilPlugin.php");
216 $pl = ilObjectPlugin::getPluginObjectByType($container_object_type);
217 $title = $pl->txt("objs_" . $container_object_type);
218 }
219
220 $group->setLabel($title);
221 $group->setItems($this->provider->getItems($container_data['objs']));
222
223 $grouped_items[] = $group;
224 }
225
226 return $grouped_items;
227 }
static getPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin.

References $DIC, and ilObjectPlugin\getPluginObjectByType().

Referenced by ilPDSelectedItemsBlockMembershipsViewGUI\getGroups(), and ilPDSelectedItemsBlockSelectedItemsViewGUI\getGroups().

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

◆ isInManageMode()

ilPDSelectedItemsBlockViewGUI::isInManageMode ( )
Returns
bool

Definition at line 117 of file class.ilPDSelectedItemsBlockViewGUI.php.

References $isInManageMode.

Referenced by setIsInManageMode().

+ Here is the caller graph for this function:

◆ isRootNode()

ilPDSelectedItemsBlockViewGUI::isRootNode (   $refId)
protected
Parameters
int$refId
Returns
bool

Definition at line 156 of file class.ilPDSelectedItemsBlockViewGUI.php.

157 {
158 return $this->tree->getRootId() == $refId;
159 }
$refId
Definition: xapitoken.php:42

References $refId.

Referenced by groupItemsByLocation().

+ Here is the caller graph for this function:

◆ mayRemoveItem()

ilPDSelectedItemsBlockViewGUI::mayRemoveItem (   $refId)
Parameters
int$refId
Returns
bool

Reimplemented in ilPDSelectedItemsBlockMembershipsViewGUI.

Definition at line 101 of file class.ilPDSelectedItemsBlockViewGUI.php.

102 {
103 return true;
104 }

◆ preloadItemGroups()

ilPDSelectedItemsBlockViewGUI::preloadItemGroups ( array  $item_groups)
protected
Parameters
ilPDSelectedItemsBlockGroup[]$item_groups

Definition at line 179 of file class.ilPDSelectedItemsBlockViewGUI.php.

180 {
181 require_once 'Services/Object/classes/class.ilObjectListGUIPreloader.php';
183
184 $obj_ids = [];
185 foreach ($item_groups as $item_group) {
186 foreach ($item_group->getItems() as $item) {
187 $obj_ids[] = $item['obj_id'];
188 $listPreloader->addItem($item['obj_id'], $item['type'], $item['ref_id']);
189 }
190 }
191
192 $listPreloader->preload();
194 }
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
Preloader for object list GUIs.

References ilObjectListGUI\CONTEXT_PERSONAL_DESKTOP, and ilAdvancedMDValues\preloadByObjIds().

Referenced by getItemGroups().

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

◆ setIsInManageMode()

ilPDSelectedItemsBlockViewGUI::setIsInManageMode ( bool  $isInManageMode)
Parameters
bool$isInManageMode

Definition at line 109 of file class.ilPDSelectedItemsBlockViewGUI.php.

References $isInManageMode, and isInManageMode().

+ Here is the call graph for this function:

◆ supportsSelectAll()

ilPDSelectedItemsBlockViewGUI::supportsSelectAll ( )
abstract

Field Documentation

◆ $accessHandler

ilPDSelectedItemsBlockViewGUI::$accessHandler
protected

Definition at line 37 of file class.ilPDSelectedItemsBlockViewGUI.php.

◆ $isInManageMode

ilPDSelectedItemsBlockViewGUI::$isInManageMode = false
protected

Definition at line 40 of file class.ilPDSelectedItemsBlockViewGUI.php.

Referenced by isInManageMode(), and setIsInManageMode().

◆ $lng

ilPDSelectedItemsBlockViewGUI::$lng
protected

Definition at line 22 of file class.ilPDSelectedItemsBlockViewGUI.php.

◆ $object_cache

ilPDSelectedItemsBlockViewGUI::$object_cache
protected

Definition at line 32 of file class.ilPDSelectedItemsBlockViewGUI.php.

◆ $provider

ilPDSelectedItemsBlockViewGUI::$provider
protected

Definition at line 17 of file class.ilPDSelectedItemsBlockViewGUI.php.

Referenced by __construct().

◆ $tree

ilPDSelectedItemsBlockViewGUI::$tree
protected

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

◆ $viewSettings

ilPDSelectedItemsBlockViewGUI::$viewSettings
protected

Definition at line 12 of file class.ilPDSelectedItemsBlockViewGUI.php.

Referenced by __construct(), and bySettings().


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