Elgg  Version 4.3
gallery.php
Go to the documentation of this file.
1 <?php
20 $pagination = elgg_extract('pagination', $vars, true);
21 $position = elgg_extract('position', $vars, 'after');
22 
23 if (!$items) {
24  echo elgg_view('page/components/no_results', $vars);
25  return;
26 }
27 
28 if (!is_array($items) || count($items) == 0) {
29  return;
30 }
31 
32 elgg_push_context('gallery');
33 
34 $list_classes = elgg_extract_class($vars, 'elgg-gallery', 'gallery_class');
35 
36 $item_classes = elgg_extract_class($vars, 'elgg-item', 'item_class');
37 
38 $nav = ($pagination) ? elgg_view('navigation/pagination', $vars) : '';
39 
40 $index = 0;
42 foreach ($items as $item) {
43  $item_view_vars = $vars;
44  $item_view_vars['list_item_index'] = $index;
45  $item_view = elgg_view_list_item($item, $item_view_vars);
46  if (!$item_view) {
47  continue;
48  }
49 
50  $li_attrs = ['class' => $item_classes];
51 
52  if ($item instanceof \ElggEntity) {
53  $li_attrs['id'] = "elgg-{$item->getType()}-{$item->getGUID()}";
54  } else if (is_callable([$item, 'getType'])) {
55  $li_attrs['id'] = "item-{$item->getType()}-{$item->id}";
56  }
57 
59  $index++;
60 }
61 
62 if ($position == 'before' || $position == 'both') {
63  echo $nav;
64 }
65 
66 if (empty($list_items)) {
67  // there are scenarios where item views do not output html. In those cases show the no results info
68  echo elgg_view('page/components/no_results', $vars);
69 } else {
71 }
72 
73 if ($position == 'after' || $position == 'both') {
74  echo $nav;
75 }
76 
if(!$items) $item
Definition: delete.php:13
$items
Gallery view.
Definition: gallery.php:19
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: context.php:52
$pagination
Definition: gallery.php:20
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:569
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: context.php:62
elgg_view_list_item($item, array $vars=[])
View an item in a list.
Definition: views.php:1266
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
$li_attrs
Definition: item.php:13
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:547
$position
Definition: gallery.php:21
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24
$index
Definition: gallery.php:40
$item_classes
Definition: gallery.php:36
$nav
Definition: gallery.php:38
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179
if($item->getSelected()) $item_view
Definition: item.php:67
$list_items
Definition: gallery.php:41
$list_classes
Definition: gallery.php:34