From c685684d47f7c0a1946393ee121551ad67dde3db Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 31 Dec 2010 02:57:09 +0000 Subject: added a proper gallery view - still need to wire up the elgg_view_list_item functions and remove the use of context git-svn-id: http://code.elgg.org/elgg/trunk@7784 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 2 +- engine/lib/entities.php | 6 ++- engine/lib/views.php | 87 +++++++++++++++++++++----------- mod/file/search.php | 5 -- mod/file/views/default/file/css.php | 3 ++ views/default/layout/objects/gallery.php | 73 +++++++++++++++++++++++++++ 6 files changed, 138 insertions(+), 38 deletions(-) create mode 100644 views/default/layout/objects/gallery.php 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 = "
".$area1.$area2."
"; 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 @@ + $offset, + 'count' => $count, + 'limit' => $limit, + 'offset_key' => $offset_key, + )); +} + +if ($position == 'before' || $position == 'both') { + echo $nav; +} + +?> + +'; + } + $col++; + + echo '"; + + if ($col == $num_columns) { + echo ''; + $col = 0; + } +} + +if ($col > 0) { + echo ''; +} + +?> + + + +