Elgg  Version 1.9
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 $pagination = elgg_extract('pagination', $vars, true);
24 $offset_key = elgg_extract('offset_key', $vars, 'offset');
25 $position = elgg_extract('position', $vars, 'after');
26 $no_results = elgg_extract('no_results', $vars, '');
27 
28 if (!$items && $no_results) {
29  echo "<p>$no_results</p>";
30  return;
31 }
32 
33 if (!is_array($items) || count($items) == 0) {
34  return;
35 }
36 
37 elgg_push_context('gallery');
38 
39 $gallery_class = 'elgg-gallery';
40 if (isset($vars['gallery_class'])) {
41  $gallery_class = "$gallery_class {$vars['gallery_class']}";
42 }
43 
44 $item_class = 'elgg-item';
45 if (isset($vars['item_class'])) {
46  $item_class = "$item_class {$vars['item_class']}";
47 }
48 
49 $nav = '';
50 if ($pagination && $count) {
51  $nav .= elgg_view('navigation/pagination', array(
52  'offset' => $offset,
53  'count' => $count,
54  'limit' => $limit,
55  'offset_key' => $offset_key,
56  ));
57 }
58 
59 if ($position == 'before' || $position == 'both') {
60  echo $nav;
61 }
62 
63 ?>
64 <ul class="<?php echo $gallery_class; ?>">
65  <?php
66  foreach ($items as $item) {
67  if (elgg_instanceof($item)) {
68  $id = "elgg-{$item->getType()}-{$item->getGUID()}";
69  } else {
70  $id = "item-{$item->getType()}-{$item->id}";
71  }
72  echo "<li id=\"$id\" class=\"$item_class\">";
74  echo "</li>";
75  }
76  ?>
77 </ul>
78 
79 <?php
80 if ($position == 'after' || $position == 'both') {
81  echo $nav;
82 }
83 
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:24
$pagination
Definition: gallery.php:23
$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:1464
if(isset($vars['item_class'])) $nav
Definition: gallery.php:49
$gallery_class
Definition: gallery.php:39
elgg_view_list_item($item, array $vars=array())
View an item in a list.
Definition: views.php:1345
if(isset($vars['gallery_class'])) $item_class
Definition: gallery.php:44
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an ElggEntity and optionally for type and subtype.
Definition: entities.php:1886
$item
Definition: item.php:12
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: pageowner.php:255
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:26
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:243
$position
Definition: gallery.php:25
if(!$collection_name) $id
Definition: add.php:17
if(file_exists($welcome)) $vars
Definition: upgrade.php:93