ILIAS  release_8 Revision v8.23
ilPDSelectedItemsBlockViewGUI 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 ilPDSelectedItemsBlockViewGUI:
+ Collaboration diagram for ilPDSelectedItemsBlockViewGUI:

Public Member Functions

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

Static Public Member Functions

static bySettings (ilPDSelectedItemsBlockViewSettings $viewSettings)
 

Protected Member Functions

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

Protected Attributes

ilPDSelectedItemsBlockViewSettings $viewSettings
 
ilPDSelectedItemsBlockProvider $provider
 
ilLanguage $lng
 
ilTree $tree
 
ilObjectDataCache $object_cache
 
ilRbacSystem $accessHandler
 
bool $isInManageMode = false
 

Private Member Functions

 __construct (ilPDSelectedItemsBlockViewSettings $viewSettings, ilPDSelectedItemsBlockProvider $provider)
 

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, $provider, $viewSettings, getGroups(), getIntroductionHtml(), getScreenId(), getTitle(), ILIAS\Repository\lng(), and supportsSelectAll().

30  {
31  global $DIC;
32 
33  $this->lng = $DIC->language();
34  $this->tree = $DIC->repositoryTree();
35  $this->object_cache = $DIC['ilObjDataCache'];
36  $this->accessHandler = $DIC->rbac()->system();
37 
38  $this->viewSettings = $viewSettings;
39  $this->provider = $provider;
40  }
ilPDSelectedItemsBlockViewSettings $viewSettings
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ bySettings()

static ilPDSelectedItemsBlockViewGUI::bySettings ( ilPDSelectedItemsBlockViewSettings  $viewSettings)
static

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

References ilPDSelectedItemsBlockViewSettings\getActor(), and ilPDSelectedItemsBlockViewSettings\isMembershipsViewActive().

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

82  {
83  if ($viewSettings->isMembershipsViewActive()) {
85  $viewSettings,
87  );
88  }
89 
91  $viewSettings,
93  );
94  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGroups()

ilPDSelectedItemsBlockViewGUI::getGroups ( )
abstract
Returns
ilPDSelectedItemsBlockGroup[]

Referenced by __construct(), and getItemGroups().

+ Here is the caller graph for this function:

◆ getIntroductionHtml()

ilPDSelectedItemsBlockViewGUI::getIntroductionHtml ( )
abstract

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getItemGroups()

ilPDSelectedItemsBlockViewGUI::getItemGroups ( )
Returns
ilPDSelectedItemsBlockGroup[]

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

References getGroups(), and preloadItemGroups().

73  : array
74  {
75  $items_groups = $this->getGroups();
76  $this->preloadItemGroups($items_groups);
77 
78  return $items_groups;
79  }
+ Here is the call graph for this function:

◆ getRepositoryTitle()

ilPDSelectedItemsBlockViewGUI::getRepositoryTitle ( )
protected

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

References $nd, and ILIAS\Repository\lng().

Referenced by ilPDSelectedItemsBlockSelectedItemsViewGUI\getIntroductionHtml(), and groupItemsByLocation().

101  : string
102  {
103  $nd = $this->tree->getNodeData($this->tree->getRootId());
104  $title = $nd['title'];
105 
106  if ($title == 'ILIAS') {
107  $title = $this->lng->txt('repository');
108  }
109 
110  return $title;
111  }
$nd
Definition: error.php:12
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScreenId()

ilPDSelectedItemsBlockViewGUI::getScreenId ( )
abstract

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getTitle()

ilPDSelectedItemsBlockViewGUI::getTitle ( )
abstract

Referenced by __construct().

+ Here is the caller graph for this function:

◆ groupItemsByLocation()

ilPDSelectedItemsBlockViewGUI::groupItemsByLocation ( )
protected
Returns
ilPDSelectedItemsBlockGroup[]

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

References ILIAS\LTI\ToolProvider\$key, getRepositoryTitle(), and isRootNode().

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

258  : array
259  {
260  $grouped_items = array();
261 
262  $items = $this->provider->getItems();
263 
264  $parent_ref_ids = array_values(array_unique(array_map(function ($item) {
265  return $item['parent_ref'];
266  }, $items)));
267  $this->object_cache->preloadReferenceCache($parent_ref_ids);
268 
269  foreach ($items as $key => $item) {
270  if (!array_key_exists('grp_' . $item['parent_ref'], $grouped_items)) {
271  $group = new ilPDSelectedItemsBlockGroup();
272  /* The parent objects of items grouped by location do not need an image (per current concept), so
273  we do not determine images to reduced the runtime/memory */
274  if ($this->isRootNode($item['parent_ref'])) {
275  $group->setLabel($this->getRepositoryTitle());
276  } else {
277  $group->setLabel($this->object_cache->lookupTitle($this->object_cache->lookupObjId((int) $item['parent_ref'])));
278  }
279  $grouped_items['grp_' . $item['parent_ref']] = $group;
280  }
281 
282  $grouped_items['grp_' . $item['parent_ref']]->pushItem($item);
283  }
284 
285  return $grouped_items;
286  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
+ 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 167 of file class.ilPDSelectedItemsBlockViewGUI.php.

References ILIAS\LTI\ToolProvider\$key, ilPDSelectedItemsBlockGroup\getItems(), IL_CAL_UNIX, and ILIAS\Repository\lng().

Referenced by ilPDSelectedItemsBlockMembershipsViewGUI\getGroups().

167  : array
168  {
169  $items = $this->provider->getItems();
170 
171  if (0 == count($items)) {
172  return array();
173  }
174 
175  $groups = array(
176  'upcoming' => array(),
177  'ongoing' => array(),
178  'ended' => array(),
179  'not_dated' => array()
180  );
181  foreach ($items as $key => $item) {
182  if ($item['start'] && $item['start']->get(IL_CAL_UNIX) > 0 && $item['start'] instanceof ilDateTime) {
183  if ($item['start']->get(IL_CAL_UNIX) > time()) {
184  $groups['upcoming'][] = $item;
185  } elseif ($item['end']->get(IL_CAL_UNIX) > time()) {
186  $groups['ongoing'][] = $item;
187  } else {
188  $groups['ended'][] = $item;
189  }
190  } else {
191  $groups['not_dated'][] = $item;
192  }
193  }
194 
195  uasort($groups['upcoming'], function ($left, $right) {
196  if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
197  return -1;
198  } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
199  return 1;
200  }
201 
202  return strcmp($left['title'], $right['title']);
203  });
204 
205  uasort($groups['ongoing'], function ($left, $right) {
206  if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
207  return 1;
208  } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
209  return -1;
210  }
211 
212  return strcmp($left['title'], $right['title']);
213  });
214 
215  uasort($groups['ended'], function ($left, $right) {
216  if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
217  return 1;
218  } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
219  return -1;
220  }
221 
222  return strcmp($left['title'], $right['title']);
223  });
224 
225  uasort($groups['not_dated'], function ($left, $right) {
226  return strcmp($left['title'], $right['title']);
227  });
228 
229  $upcoming = new ilPDSelectedItemsBlockGroup();
230  $upcoming->setLabel($this->lng->txt('pd_upcoming'));
231  $upcoming->setItems($groups['upcoming']);
232 
233  $ongoing = new ilPDSelectedItemsBlockGroup();
234  $ongoing->setLabel($this->lng->txt('pd_ongoing'));
235  $ongoing->setItems($groups['ongoing']);
236 
237  $ended = new ilPDSelectedItemsBlockGroup();
238  $ended->setLabel($this->lng->txt('pd_ended'));
239  $ended->setItems($groups['ended']);
240 
241  $not_dated = new ilPDSelectedItemsBlockGroup();
242  $not_dated->setLabel($this->lng->txt('pd_not_date'));
243  $not_dated->setItems($groups['not_dated']);
244 
245  return array_filter([
246  $upcoming,
247  $ongoing,
248  $ended,
249  $not_dated
250  ], function (ilPDSelectedItemsBlockGroup $group) {
251  return count($group->getItems()) > 0;
252  });
253  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
string $key
Consumer key/client ID value.
Definition: System.php:193
+ 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 135 of file class.ilPDSelectedItemsBlockViewGUI.php.

References $DIC, ilObjectPlugin\getPluginObjectByType(), and ILIAS\Repository\lng().

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

135  : array
136  {
137  global $DIC;
138 
139  $objDefinition = $DIC["objDefinition"];
140 
141  $object_types_by_container = $DIC['objDefinition']->getGroupedRepositoryObjectTypes(array('cat', 'crs', 'grp', 'fold'));
142 
143  $grouped_items = array();
144 
145  foreach ($object_types_by_container as $container_object_type => $container_data) {
146  $group = new ilPDSelectedItemsBlockGroup();
147  // Icons are currently not determined for section header objects
148  if (!$objDefinition->isPlugin($container_object_type)) {
149  $title = $this->lng->txt('objs_' . $container_object_type);
150  } else {
151  $pl = ilObjectPlugin::getPluginObjectByType($container_object_type);
152  $title = $pl->txt("objs_" . $container_object_type);
153  }
154 
155  $group->setLabel($title);
156  $group->setItems($this->provider->getItems($container_data['objs']));
157 
158  $grouped_items[] = $group;
159  }
160 
161  return $grouped_items;
162  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInManageMode()

ilPDSelectedItemsBlockViewGUI::isInManageMode ( )

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

References $isInManageMode.

Referenced by setIsInManageMode().

65  : bool
66  {
67  return $this->isInManageMode;
68  }
+ Here is the caller graph for this function:

◆ isRootNode()

ilPDSelectedItemsBlockViewGUI::isRootNode ( int  $refId)
protected

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

References $refId.

Referenced by groupItemsByLocation().

96  : bool
97  {
98  return $this->tree->getRootId() == $refId;
99  }
$refId
Definition: xapitoken.php:58
+ Here is the caller graph for this function:

◆ mayRemoveItem()

ilPDSelectedItemsBlockViewGUI::mayRemoveItem ( int  $refId)

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

55  : bool
56  {
57  return true;
58  }

◆ preloadItemGroups()

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

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

References ilObjectListGUI\CONTEXT_PERSONAL_DESKTOP, ILIAS\Repository\int(), and ilAdvancedMDValues\preloadByObjIds().

Referenced by getItemGroups().

117  {
119 
120  $obj_ids = [];
121  foreach ($item_groups as $item_group) {
122  foreach ($item_group->getItems() as $item) {
123  $obj_ids[] = (int) $item['obj_id'];
124  $listPreloader->addItem($item['obj_id'], $item['type'], $item['ref_id']);
125  }
126  }
127 
128  $listPreloader->preload();
130  }
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIsInManageMode()

ilPDSelectedItemsBlockViewGUI::setIsInManageMode ( bool  $isInManageMode)

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

References $isInManageMode, and isInManageMode().

+ Here is the call graph for this function:

◆ sortItemsByAlphabetInOneGroup()

ilPDSelectedItemsBlockViewGUI::sortItemsByAlphabetInOneGroup ( )
protected
Returns
ilPDSelectedItemsBlockGroup[]

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

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

291  : array
292  {
293  $items = array_values($this->provider->getItems());
294 
295  usort($items, static function (array $first, array $second): int {
296  return strnatcmp(strtolower($first['title']), strtolower($second['title']));
297  });
298 
299  $group = new ilPDSelectedItemsBlockGroup();
300  array_map([$group, 'pushItem'], $items);
301 
302  return [$group];
303  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ supportsSelectAll()

ilPDSelectedItemsBlockViewGUI::supportsSelectAll ( )
abstract

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $accessHandler

ilRbacSystem ilPDSelectedItemsBlockViewGUI::$accessHandler
protected

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

◆ $isInManageMode

bool ilPDSelectedItemsBlockViewGUI::$isInManageMode = false
protected

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

Referenced by isInManageMode(), and setIsInManageMode().

◆ $lng

ilLanguage ilPDSelectedItemsBlockViewGUI::$lng
protected

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

◆ $object_cache

ilObjectDataCache ilPDSelectedItemsBlockViewGUI::$object_cache
protected

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

◆ $provider

ilPDSelectedItemsBlockProvider ilPDSelectedItemsBlockViewGUI::$provider
protected

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

Referenced by __construct().

◆ $tree

ilTree ilPDSelectedItemsBlockViewGUI::$tree
protected

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

◆ $viewSettings

ilPDSelectedItemsBlockViewSettings ilPDSelectedItemsBlockViewGUI::$viewSettings
protected

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

Referenced by __construct().


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