diff options
-rw-r--r-- | engine/lib/elgglib.php | 2 | ||||
-rw-r--r-- | engine/lib/entities.php | 6 | ||||
-rw-r--r-- | engine/lib/views.php | 87 | ||||
-rw-r--r-- | mod/file/search.php | 5 | ||||
-rw-r--r-- | mod/file/views/default/file/css.php | 3 | ||||
-rw-r--r-- | views/default/layout/objects/gallery.php | 73 |
6 files changed, 138 insertions, 38 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index bc0b1b5af..59e641da2 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1709,7 +1709,7 @@ function elgg_http_add_url_query_elements($url, array $elements) { } $url_array['query'] = http_build_query($query); - $string = elgg_http_build_url($url_array); + $string = elgg_http_build_url($url_array, false); return $string; } diff --git a/engine/lib/entities.php b/engine/lib/entities.php index ddbdbe9ab..339b7755d 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1305,6 +1305,7 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti 'full_view' => TRUE, 'list_type_toggle' => FALSE, 'pagination' => TRUE, + 'gallery' => FALSE, ); $options = array_merge($defaults, $options); @@ -1320,8 +1321,9 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti $options['count'] = FALSE; $entities = $getter($options); - return elgg_view_entity_list($entities, $count, $options['offset'], $options['limit'], - $options['full_view'], $options['list_type_toggle'], $options['pagination']); + $options['count'] = $count; + + return elgg_view_entity_list($entities, $options); } /** diff --git a/engine/lib/views.php b/engine/lib/views.php index 87d1a3836..942f1b6a7 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -843,13 +843,16 @@ function elgg_view_annotation(ElggAnnotation $annotation, $full = true, $bypass * @see elgg_list_entities_from_relationships() * @see elgg_list_entities_from_annotations() * - * @param array $entities List of entities - * @param int $count The total number of entities across all pages - * @param int $offset The current indexing offset - * @param int $limit The number of entities to display per page - * @param bool $full_view Whether or not to display the full view (default: true) - * @param bool $list_type_toggle Whether or not to allow users to toggle to gallery view - * @param bool $pagination Whether pagination is offered. + * @param array $entities Array of entities + * @param array $vars Display variables + * 'count' The total number of entities across all pages + * 'offset' The current indexing offset + * 'limit' The number of entities to display per page + * 'full_view' Display the full view of the entities? + * 'list_class' CSS Class applied to the list + * 'pagination' Display pagination? + * 'gallery' Display as gallery? + * 'list_type_toggle' Display the list type toggle? * * @return string The list of entities * @access private @@ -857,41 +860,65 @@ function elgg_view_annotation(ElggAnnotation $annotation, $full = true, $bypass function elgg_view_entity_list($entities, $count, $offset, $limit, $full_view = true, $list_type_toggle = true, $pagination = true) { - $count = (int) $count; - $limit = (int) $limit; - - // do not require views to explicitly pass in the offset if (!is_int($offset)) { $offset = (int)get_input('offset', 0); } - $context = elgg_get_context(); + if (func_num_args() == 2) { + // new function + $defaults = array( + 'items' => $entities, + 'list_class' => 'elgg-entity-list', + 'full_view' => true, + 'pagination' => true, + 'gallery' => false, + 'list_type_toggle' => false, + 'offset' => $offset, + ); + + $vars = array_merge($defaults, $count); - $html = elgg_view('layout/objects/list', array( - 'items' => $entities, - 'count' => $count, - 'offset' => $offset, - 'limit' => $limit, - 'full_view' => $full_view, - 'context' => $context, - 'pagination' => $pagination, - 'list_type_toggle' => $list_type_toggle, - 'list_type' => get_input('listtype', 'list'), - 'list_class' => 'elgg-entity-list', - )); + } else { + // old function - because this is an internal function we can remove + // this in Elgg 1.9 without following the normal deprecation procedures + $vars = array( + 'items' => $entities, + 'count' => (int) $count, + 'offset' => $offset, + 'limit' => (int) $limit, + 'full_view' => $full_view, + 'pagination' => $pagination, + 'gallery' => false, + 'list_type_toggle' => $list_type_toggle, + 'list_class' => 'elgg-entity-list', + ); + } + + $listtype = get_input('listtype', 'list'); + if ($listtype != 'list') { + $vars['gallery'] = true; + } - return $html; + if ($vars['gallery']) { + return elgg_view('layout/objects/gallery', $vars); + } else { + return elgg_view('layout/objects/list', $vars); + } } /** * Returns a rendered list of annotations, plus pagination. This function * should be called by wrapper functions. * - * @param array $annotations List of annotations - * @param int $count The total number of annotations across all pages - * @param int $offset The current indexing offset - * @param int $limit The number of annotations to display per page - * + * @param array $annotations Array of annotations + * @param array $vars Display variables + * 'count' The total number of annotations across all pages + * 'offset' The current indexing offset + * 'limit' The number of annotations to display per page + * 'full_view' Display the full view of the annotation? + * 'list_class' CSS Class applied to the list + * 'offset_key' The url parameter key used for offset + * * @return string The list of annotations * @access private */ diff --git a/mod/file/search.php b/mod/file/search.php index ba6808176..6e63f55f0 100644 --- a/mod/file/search.php +++ b/mod/file/search.php @@ -76,7 +76,6 @@ if ($listtype == "gallery") { $limit = 12; - elgg_push_context('gallery'); } if (!empty($tag)) { @@ -93,10 +92,6 @@ $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset)); } - if ($listtype == "gallery") { - elgg_pop_context(); - } - elgg_pop_context(); $content = "<div class='files'>".$area1.$area2."</div>"; diff --git a/mod/file/views/default/file/css.php b/mod/file/views/default/file/css.php index bd2a30c43..d4d1a2c13 100644 --- a/mod/file/views/default/file/css.php +++ b/mod/file/views/default/file/css.php @@ -24,6 +24,9 @@ -webkit-border-radius: 6px; -moz-border-radius: 6px; } +.file-gallery-item img { + margin: 5px 0; +} .files .entity-listing .entity-listing-info { diff --git a/views/default/layout/objects/gallery.php b/views/default/layout/objects/gallery.php new file mode 100644 index 000000000..29534a450 --- /dev/null +++ b/views/default/layout/objects/gallery.php @@ -0,0 +1,73 @@ +<?php +/** + * Gallery view + * + * @uses $vars['items'] + */ + +$items = $vars['items']; +if (!is_array($items) && sizeof($items) == 0) { + return true; +} + +elgg_push_context('gallery'); + +$offset = $vars['offset']; +$limit = $vars['limit']; +$count = $vars['count']; +$pagination = elgg_get_array_value('pagination', $vars, true); +$full_view = elgg_get_array_value('full_view', $vars, false); +$offset_key = elgg_get_array_value('offset_key', $vars, 'offset'); +$position = elgg_get_array_value('position', $vars, 'after'); + +$num_columns = 4; + + +if ($pagination && $count) { + $nav .= elgg_view('navigation/pagination', array( + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + 'offset_key' => $offset_key, + )); +} + +if ($position == 'before' || $position == 'both') { + echo $nav; +} + +?> +<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> + +<?php +if ($position == 'after' || $position == 'both') { + echo $nav; +} + +elgg_pop_context(); |