]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
added a proper gallery view - still need to wire up the elgg_view_list_item functions...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 31 Dec 2010 02:57:09 +0000 (02:57 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 31 Dec 2010 02:57:09 +0000 (02:57 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7784 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php
engine/lib/entities.php
engine/lib/views.php
mod/file/search.php
mod/file/views/default/file/css.php
views/default/layout/objects/gallery.php [new file with mode: 0644]

index bc0b1b5aff5a5aafb900efd52a29f94bb338bb61..59e641da29486c6cf946f46d9338c202aaaef56b 100644 (file)
@@ -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;
 }
index ddbdbe9ab2ac02cb9d4e5598c036885cdbf6883e..339b7755d00986ba59e4f26fdaa6184a0511595d 100644 (file)
@@ -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);
 }
 
 /**
index 87d1a383616d7f70d38ad7abdac6203becc01eea..942f1b6a7c2474a87575f4dac0ba43d834811cc6 100644 (file)
@@ -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
  */
index ba680817686521c314504d458483b5618801f6f3..6e63f55f0580dfd7baf4407e6f70f86e07d121f5 100644 (file)
@@ -76,7 +76,6 @@
 
                if ($listtype == "gallery") {
                        $limit = 12;
-                       elgg_push_context('gallery');
                }
 
                if (!empty($tag)) {
                        $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>";
index bd2a30c43c4266e27cc2e57d3f559298f97e5aa7..d4d1a2c134e49d0b9ab0b9f63315af9d90e16878 100644 (file)
@@ -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 (file)
index 0000000..29534a4
--- /dev/null
@@ -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();