Elgg  Version 1.11
gallery.php
Go to the documentation of this file.
1 <?php
2 
20 $items = $vars['items'];
22 $pagination = elgg_extract('pagination', $vars, true);
23 $position = elgg_extract('position', $vars, 'after');
24 $no_results = elgg_extract('no_results', $vars, '');
25 
26 if (!$items && $no_results) {
27  if ($no_results instanceof Closure) {
28  echo $no_results();
29  return;
30  }
31  echo "<p class='elgg-no-results'>$no_results</p>";
32  return;
33 }
34 
35 if (!is_array($items) || count($items) == 0) {
36  return;
37 }
38 
39 elgg_push_context('gallery');
40 
41 $list_classes = ['elgg-gallery'];
42 if (isset($vars['gallery_class'])) {
43  $list_classes[] = $vars['gallery_class'];
44 }
45 
46 $item_classes = ['elgg-item'];
47 if (isset($vars['item_class'])) {
48  $item_classes[] = $vars['item_class'];
49 }
50 
51 $nav = ($pagination) ? elgg_view('navigation/pagination', $vars) : '';
52 
54 foreach ($items as $item) {
55  $item_view = elgg_view_list_item($item, $vars);
56  if (!$item_view) {
57  continue;
58  }
59 
60  $li_attrs = ['class' => $item_classes];
61 
62  if ($item instanceof \ElggEntity) {
63  $li_attrs['id'] = "elgg-{$item->getType()}-{$item->getGUID()}";
64  } else if (is_callable(array($item, 'getType'))) {
65  $li_attrs['id'] = "item-{$item->getType()}-{$item->id}";
66  }
67 
68  $list_items .= elgg_format_element('li', $li_attrs, $item_view);
69 }
70 
71 if ($position == 'before' || $position == 'both') {
72  echo $nav;
73 }
74 
76 
77 if ($position == 'after' || $position == 'both') {
78  echo $nav;
79 }
80 
$items
Gallery view.
Definition: gallery.php:20
$pagination
Definition: gallery.php:22
$count
Definition: gallery.php:21
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
if(isset($vars['item_class'])) $nav
Definition: gallery.php:51
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:215
elgg_view_list_item($item, array $vars=array())
View an item in a list.
Definition: views.php:1378
$item
Definition: item.php:12
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: pageowner.php:234
elgg echo
Translates a string.
Definition: languages.js:43
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$no_results
Definition: gallery.php:24
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:224
$position
Definition: gallery.php:23
if(isset($vars['gallery_class'])) $item_classes
Definition: gallery.php:46
$list_items
Definition: gallery.php:53
$list_classes
Definition: gallery.php:41
if(file_exists($welcome)) $vars
Definition: upgrade.php:93