aboutsummaryrefslogtreecommitdiff
path: root/views/default/page/components/gallery.php
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/page/components/gallery.php')
-rw-r--r--views/default/page/components/gallery.php66
1 files changed, 34 insertions, 32 deletions
diff --git a/views/default/page/components/gallery.php b/views/default/page/components/gallery.php
index f57cc99ba..e8b3f477e 100644
--- a/views/default/page/components/gallery.php
+++ b/views/default/page/components/gallery.php
@@ -2,13 +2,21 @@
/**
* Gallery view
*
- * @uses $vars['items']
+ * Implemented as an unorder list
*
- * @todo not complete - number of columns
+ * @uses $vars['items'] Array of ElggEntity or ElggAnnotation objects
+ * @uses $vars['offset'] Index of the first list item in complete list
+ * @uses $vars['limit'] Number of items per page
+ * @uses $vars['count'] Number of items in the complete list
+ * @uses $vars['pagination'] Show pagination? (default: true)
+ * @uses $vars['position'] Position of the pagination: before, after, or both
+ * @uses $vars['full_view'] Show the full view of the items (default: false)
+ * @uses $vars['gallery_class'] Additional CSS class for the <ul> element
+ * @uses $vars['item_class'] Additional CSS class for the <li> elements
*/
$items = $vars['items'];
-if (!is_array($items) && sizeof($items) == 0) {
+if (!is_array($items) || sizeof($items) == 0) {
return true;
}
@@ -18,13 +26,20 @@ $offset = $vars['offset'];
$limit = $vars['limit'];
$count = $vars['count'];
$pagination = elgg_extract('pagination', $vars, true);
-$full_view = elgg_extract('full_view', $vars, false);
$offset_key = elgg_extract('offset_key', $vars, 'offset');
$position = elgg_extract('position', $vars, 'after');
-$num_columns = 4;
+$gallery_class = 'elgg-gallery';
+if (isset($vars['gallery_class'])) {
+ $gallery_class = "$gallery_class {$vars['gallery_class']}";
+}
+$item_class = 'elgg-item';
+if (isset($vars['item_class'])) {
+ $item_class = "$item_class {$vars['item_class']}";
+}
+$nav = '';
if ($pagination && $count) {
$nav .= elgg_view('navigation/pagination', array(
'offset' => $offset,
@@ -39,33 +54,20 @@ if ($position == 'before' || $position == 'both') {
}
?>
-<table class="elgg-gallery">
-<?php
-
-$col = 0;
-foreach ($items as $item) {
- if ($col == 0) {
- echo '<tr>';
- }
- $col++;
-
- echo '<td>';
- echo elgg_view_list_item($item, $full_view, $vars);
- echo "</td>";
-
- if ($col == $num_columns) {
- echo '</tr>';
- $col = 0;
- }
-}
-
-if ($col > 0) {
- echo '</tr>';
-}
-
-?>
-
-</table>
+<ul class="<?php echo $gallery_class; ?>">
+ <?php
+ foreach ($items as $item) {
+ if (elgg_instanceof($item)) {
+ $id = "elgg-{$item->getType()}-{$item->getGUID()}";
+ } else {
+ $id = "item-{$item->getType()}-{$item->id}";
+ }
+ echo "<li id=\"$id\" class=\"$item_class\">";
+ echo elgg_view_list_item($item, $vars);
+ echo "</li>";
+ }
+ ?>
+</ul>
<?php
if ($position == 'after' || $position == 'both') {