Elgg  Version 1.10
gallery.php
Go to the documentation of this file.
1 <?php
19 $items = $vars['items'];
20 $offset = $vars['offset'];
21 $limit = $vars['limit'];
22 $count = $vars['count'];
23 $base_url = elgg_extract('base_url', $vars, '');
24 $pagination = elgg_extract('pagination', $vars, true);
25 $offset_key = elgg_extract('offset_key', $vars, 'offset');
26 $position = elgg_extract('position', $vars, 'after');
27 $no_results = elgg_extract('no_results', $vars, '');
28 
29 if (!$items && $no_results) {
30  if ($no_results instanceof Closure) {
31  echo $no_results();
32  return;
33  }
34  echo "<p>$no_results</p>";
35  return;
36 }
37 
38 if (!is_array($items) || count($items) == 0) {
39  return;
40 }
41 
42 elgg_push_context('gallery');
43 
44 $gallery_class = 'elgg-gallery';
45 if (isset($vars['gallery_class'])) {
46  $gallery_class = "$gallery_class {$vars['gallery_class']}";
47 }
48 
49 $item_class = 'elgg-item';
50 if (isset($vars['item_class'])) {
51  $item_class = "$item_class {$vars['item_class']}";
52 }
53 
54 $nav = '';
55 if ($pagination && $count) {
56  $nav .= elgg_view('navigation/pagination', array(
57  'base_url' => $base_url,
58  'offset' => $offset,
59  'count' => $count,
60  'limit' => $limit,
61  'offset_key' => $offset_key,
62  ));
63 }
64 
65 if ($position == 'before' || $position == 'both') {
66  echo $nav;
67 }
68 
69 ?>
70 <ul class="<?php echo $gallery_class; ?>">
71  <?php
72  foreach ($items as $item) {
73  if (elgg_instanceof($item)) {
74  $id = "elgg-{$item->getType()}-{$item->getGUID()}";
75  } else {
76  $id = "item-{$item->getType()}-{$item->id}";
77  }
78  echo "<li id=\"$id\" class=\"$item_class\">";
80  echo "</li>";
81  }
82  ?>
83 </ul>
84 
85 <?php
86 if ($position == 'after' || $position == 'both') {
87  echo $nav;
88 }
89 
ul
Definition: admin.php:44
$limit
Definition: gallery.php:21
$items
Gallery view.
Definition: gallery.php:19
$offset
Definition: gallery.php:20
$offset_key
Definition: gallery.php:25
$pagination
Definition: gallery.php:24
$count
Definition: gallery.php:22
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:1349
if(isset($vars['item_class'])) $nav
Definition: gallery.php:54
$gallery_class
Definition: gallery.php:44
elgg_view_list_item($item, array $vars=array())
View an item in a list.
Definition: views.php:1347
if(isset($vars['gallery_class'])) $item_class
Definition: gallery.php:49
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
Definition: entities.php:921
$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
$base_url
Definition: gallery.php:23
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$no_results
Definition: gallery.php:27
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:224
$position
Definition: gallery.php:26
if(!$collection_name) $id
Definition: add.php:17
if(file_exists($welcome)) $vars
Definition: upgrade.php:93