ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 
 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
 

Private Member Functions

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilPDSelectedItemsBlockViewGUI constructor.

Parameters
ilPDSelectedItemsBlockViewSettings$viewSettings
ilPDSelectedItemsBlockProvider$provider

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

References $DIC, $provider, $viewSettings, getScreenId(), and getTitle().

47  {
48  global $DIC;
49 
50  $this->lng = $DIC->language();
51  $this->tree = $DIC->repositoryTree();
52  $this->object_cache = $DIC['ilObjDataCache'];
53  $this->accessHandler = $DIC->rbac()->system();
54 
55  $this->viewSettings = $viewSettings;
56  $this->provider = $provider;
57  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ bySettings()

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

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

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

Referenced by ilPDSelectedItemsBlockGUI\initViewSettings().

122  {
123  if ($viewSettings->isMembershipsViewActive()) {
124  require_once 'Services/PersonalDesktop/ItemsBlock/classes/class.ilPDSelectedItemsBlockMembershipsViewGUI.php';
125  require_once 'Services/PersonalDesktop/ItemsBlock/classes/class.ilPDSelectedItemsBlockMembershipsProvider.php';
127  $viewSettings,
129  );
130  }
131 
132  require_once 'Services/PersonalDesktop/ItemsBlock/classes/class.ilPDSelectedItemsBlockSelectedItemsViewGUI.php';
133  require_once 'Services/PersonalDesktop/ItemsBlock/classes/class.ilPDSelectedItemsBlockSelectedItemsProvider.php';
135  $viewSettings,
137  );
138  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGroups()

ilPDSelectedItemsBlockViewGUI::getGroups ( )
abstract
Returns
ilPDSelectedItemsBlockGroup[]

Referenced by getItemGroups(), and getMinimumDetailLevelForSection().

+ Here is the caller graph for this function:

◆ getIntroductionHtml()

ilPDSelectedItemsBlockViewGUI::getIntroductionHtml ( )
abstract
Returns
string

Referenced by getMinimumDetailLevelForSection().

+ Here is the caller graph for this function:

◆ getItemGroups()

ilPDSelectedItemsBlockViewGUI::getItemGroups ( )
Returns
ilPDSelectedItemsBlockGroup[]

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

References getGroups(), and preloadItemGroups().

109  {
110  $items_groups = $this->getGroups();
111 
112  $this->preloadItemGroups($items_groups);
113 
114  return $items_groups;
115  }
+ Here is the call graph for this function:

◆ getMinimumDetailLevelForSection()

ilPDSelectedItemsBlockViewGUI::getMinimumDetailLevelForSection ( )
Returns
int

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

References getGroups(), getIntroductionHtml(), and supportsSelectAll().

73  {
74  if ($this->viewSettings->isSortedByLocation()) {
75  return 1;
76  }
77 
78  return 3;
79  }
+ Here is the call graph for this function:

◆ getRepositoryTitle()

ilPDSelectedItemsBlockViewGUI::getRepositoryTitle ( )
protected
Returns
string

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

References $nd, and $title.

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

153  {
154  $nd = $this->tree->getNodeData($this->tree->getRootId());
155  $title = $nd['title'];
156 
157  if ($title == 'ILIAS') {
158  $title = $this->lng->txt('repository');
159  }
160 
161  return $title;
162  }
$nd
Definition: error.php:10
+ Here is the caller graph for this function:

◆ getScreenId()

ilPDSelectedItemsBlockViewGUI::getScreenId ( )
abstract
Returns
string

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getTitle()

ilPDSelectedItemsBlockViewGUI::getTitle ( )
abstract
Returns
string

Referenced by __construct().

+ Here is the caller graph for this function:

◆ groupItemsByLocation()

ilPDSelectedItemsBlockViewGUI::groupItemsByLocation ( )
protected
Returns
ilPDSelectedItemsBlockGroup[]

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

References $key, array, getRepositoryTitle(), and isRootNode().

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

313  {
314  $grouped_items = array();
315 
316  $items = $this->provider->getItems();
317 
318  $parent_ref_ids = array_values(array_unique(array_map(function ($item) {
319  return $item['parent_ref'];
320  }, $items)));
321  $this->object_cache->preloadReferenceCache($parent_ref_ids);
322 
323  foreach ($items as $key => $item) {
324  if (!array_key_exists('grp_' . $item['parent_ref'], $grouped_items)) {
325  $group = new ilPDSelectedItemsBlockGroup();
326  /* The parent objects of items grouped by location do not need an image (per current concept), so
327  we do not determine images to reduced the runtime/memory */
328  if ($this->isRootNode($item['parent_ref'])) {
329  $group->setLabel($this->getRepositoryTitle());
330  } else {
331  $group->setLabel($this->object_cache->lookupTitle($this->object_cache->lookupObjId($item['parent_ref'])));
332  }
333  $grouped_items['grp_' . $item['parent_ref']] = $group;
334  }
335 
336  $grouped_items['grp_' . $item['parent_ref']]->pushItem($item);
337  }
338 
339  return $grouped_items;
340  }
Class ilPDSelectedItemsBlockGroup.
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
+ 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 220 of file class.ilPDSelectedItemsBlockViewGUI.php.

References $key, array, ilPDSelectedItemsBlockGroup\getItems(), IL_CAL_UNIX, and time.

Referenced by ilPDSelectedItemsBlockMembershipsViewGUI\getGroups().

221  {
222  $items = $this->provider->getItems();
223 
224  if (0 == count($items)) {
225  return array();
226  }
227 
228  $groups = array(
229  'upcoming' => array(),
230  'ongoing' => array(),
231  'ended' => array(),
232  'not_dated' => array()
233  );
234 
235  foreach ($items as $key => $item) {
236  if ($item['start'] && $item['start'] && $item['start'] instanceof ilDate) {
237  if ($item['start']->get(IL_CAL_UNIX) > time()) {
238  $groups['upcoming'][] = $item;
239  } elseif ($item['end']->get(IL_CAL_UNIX) > time()) {
240  $groups['ongoing'][] = $item;
241  } else {
242  $groups['ended'][] = $item;
243  }
244  } else {
245  $groups['not_dated'][] = $item;
246  }
247  }
248 
249  uasort($groups['upcoming'], function ($left, $right) {
250  if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
251  return -1;
252  } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
253  return 1;
254  }
255 
256  return strcmp($left['title'], $right['title']);
257  });
258 
259  uasort($groups['ongoing'], function ($left, $right) {
260  if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
261  return 1;
262  } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
263  return -1;
264  }
265 
266  return strcmp($left['title'], $right['title']);
267  });
268 
269  uasort($groups['ended'], function ($left, $right) {
270  if ($left['start']->get(IL_CAL_UNIX) < $right['start']->get(IL_CAL_UNIX)) {
271  return 1;
272  } elseif ($left['start']->get(IL_CAL_UNIX) > $right['start']->get(IL_CAL_UNIX)) {
273  return -1;
274  }
275 
276  return strcmp($left['title'], $right['title']);
277  });
278 
279  uasort($groups['not_dated'], function ($left, $right) {
280  return strcmp($left['title'], $right['title']);
281  });
282 
283  $upcoming = new ilPDSelectedItemsBlockGroup();
284  $upcoming->setLabel($this->lng->txt('pd_upcoming'));
285  $upcoming->setItems($groups['upcoming']);
286 
287  $ongoing = new ilPDSelectedItemsBlockGroup();
288  $ongoing->setLabel($this->lng->txt('pd_ongoing'));
289  $ongoing->setItems($groups['ongoing']);
290 
291  $ended = new ilPDSelectedItemsBlockGroup();
292  $ended->setLabel($this->lng->txt('pd_ended'));
293  $ended->setItems($groups['ended']);
294 
295  $not_dated = new ilPDSelectedItemsBlockGroup();
296  $not_dated->setLabel($this->lng->txt('pd_not_date'));
297  $not_dated->setItems($groups['not_dated']);
298 
299  return array_filter([
300  $upcoming,
301  $ongoing,
302  $ended,
303  $not_dated
304  ], function (ilPDSelectedItemsBlockGroup $group) {
305  return count($group->getItems()) > 0;
306  });
307  }
Class ilPDSelectedItemsBlockGroup.
const IL_CAL_UNIX
Class for single dates.
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$key
Definition: croninfo.php:18
+ 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 187 of file class.ilPDSelectedItemsBlockViewGUI.php.

References $DIC, $title, array, and ilObjectPlugin\getRepoPluginObjectByType().

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

188  {
189  global $DIC;
190 
191  $objDefinition = $DIC["objDefinition"];
192 
193  $object_types_by_container = $DIC['objDefinition']->getGroupedRepositoryObjectTypes(array('cat', 'crs', 'grp', 'fold'));
194 
195  $grouped_items = array();
196 
197  foreach ($object_types_by_container as $container_object_type => $container_data) {
198  $group = new ilPDSelectedItemsBlockGroup();
199  // Icons are currently not determined for section header objects
200  if (!$objDefinition->isPlugin($container_object_type)) {
201  $title = $this->lng->txt('objs_' . $container_object_type);
202  } else {
203  include_once("./Services/Component/classes/class.ilPlugin.php");
204  $pl = ilObjectPlugin::getRepoPluginObjectByType($container_object_type);
205  $title= $pl->txt("objs_" . $container_object_type);
206  }
207 
208  $group->setLabel($title);
209  $group->setItems($this->provider->getItems($container_data['objs']));
210 
211  $grouped_items[] = $group;
212  }
213 
214  return $grouped_items;
215  }
global $DIC
Definition: saml.php:7
Class ilPDSelectedItemsBlockGroup.
static getRepoPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRootNode()

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

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

Referenced by groupItemsByLocation().

145  {
146  return $this->tree->getRootId() == $refId;
147  }
+ Here is the caller graph for this function:

◆ mayRemoveItem()

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

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

101  {
102  return true;
103  }

◆ preloadItemGroups()

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

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

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

Referenced by getItemGroups().

168  {
169  require_once 'Services/Object/classes/class.ilObjectListGUIPreloader.php';
171 
172  $obj_ids = [];
173  foreach ($item_groups as $item_group) {
174  foreach ($item_group->getItems() as $item) {
175  $obj_ids[] = $item['obj_id'];
176  $listPreloader->addItem($item['obj_id'], $item['type'], $item['ref_id']);
177  }
178  }
179 
180  $listPreloader->preload();
182  }
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
Preloader for object list GUIs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportsSelectAll()

ilPDSelectedItemsBlockViewGUI::supportsSelectAll ( )
abstract
Returns
boolean

Referenced by getMinimumDetailLevelForSection().

+ Here is the caller graph for this function:

Field Documentation

◆ $accessHandler

ilPDSelectedItemsBlockViewGUI::$accessHandler
protected

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

◆ $lng

ilPDSelectedItemsBlockViewGUI::$lng
protected

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

◆ $object_cache

ilPDSelectedItemsBlockViewGUI::$object_cache
protected

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

◆ $provider

ilPDSelectedItemsBlockViewGUI::$provider
protected

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

Referenced by __construct().

◆ $tree

ilPDSelectedItemsBlockViewGUI::$tree
protected

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

◆ $viewSettings

ilPDSelectedItemsBlockViewGUI::$viewSettings
protected

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

Referenced by __construct().


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