]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
sorting albums added back
authorcash <cash.costello@gmail.com>
Tue, 3 Jan 2012 02:00:16 +0000 (21:00 -0500)
committercash <cash.costello@gmail.com>
Tue, 3 Jan 2012 02:00:16 +0000 (21:00 -0500)
actions/edit.php [deleted file]
actions/photos/album/sort.php [moved from actions/sortalbum.php with 72% similarity]
languages/en.php
lib/tidypics.php
start.php
views/default/forms/photos/album/sort.php
views/default/object/album/full.php

diff --git a/actions/edit.php b/actions/edit.php
deleted file mode 100644 (file)
index df65448..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-/**
- * Tidypics edit album/image action
- *
- */
-
-// Make sure we're logged in 
-gatekeeper();
-
-// Get input data
-$guid    = (int) get_input('guid');  // guid of image or album
-$title   = get_input('tidypicstitle');
-$body    = get_input('tidypicsbody');
-$access  = get_input('access_id');
-$tags    = get_input('tidypicstags');
-$subtype = get_input('subtype');
-$cover   = get_input('cover');
-if (is_array($cover)) {
-       $cover = $cover[0];
-}
-
-$container_guid = get_input('container_guid');
-
-// Make sure we actually have permission to edit
-$entity = get_entity($guid);
-if (!$entity->canEdit()) {
-       forward();
-}
-
-// Get owning user/group
-$owner = get_entity($entity->getOwner());
-
-// change access only if access is different from current
-if ($subtype == 'album' && $entity->access_id != $access) {
-       $entity->access_id = $access;
-
-       //get images from album and update access on image entities
-       $images = elgg_get_entities(array(
-               "type" => "object",
-               "subtype" => "image",
-               "container_guid" => $guid,
-               "limit" => ELGG_ENTITIES_NO_VALUE,
-       ));
-       foreach ($images as $im) {
-               $im->access_id = $access;
-               $im->save();
-       }
-}
-
-
-// Set its title and description appropriately
-$entity->title = $title;
-$entity->description = $body;
-
-// Before we can set metadata, we need to save the entity
-if (!$entity->save()) {
-       register_error(elgg_echo("album:error"));
-       $entity->delete();
-       forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
-}
-
-// Now let's add tags
-$tagarray = string_to_tag_array($tags);
-$entity->clearMetadata('tags');
-if (is_array($tagarray)) {
-       $entity->tags = $tagarray;
-}
-
-//if cover meta is sent from image save as metadata
-if ($subtype == 'image' && $cover == elgg_echo('album:cover')) {
-       $album = get_entity($container_guid);
-       $album->setCoverImageGuid($entity->guid);
-}
-
-// Success message
-if ($subtype == 'album') {
-       system_message(elgg_echo("album:edited"));
-       // plugins can register to be told when a Tidypics album has been updated
-       trigger_elgg_event('update', 'tp_album', $entity);
-} else {
-       system_message(elgg_echo('images:edited'));
-       // plugins can register to be told when a Tidypics image has been updated
-       trigger_elgg_event('update', 'tp_image', $entity);
-}
-
-forward($entity->getURL());
similarity index 72%
rename from actions/sortalbum.php
rename to actions/photos/album/sort.php
index 1aa0e052fa13e1bdfb5b5afbfc41a21d5f81daa8..613747784e756b87df22edee26d8c0b34a09b2cf 100644 (file)
@@ -14,5 +14,5 @@ $guids = explode(',', $guids);
 
 $album->setImageList($guids);
 
-system_message(sprintf(elgg_echo('tidypics:album:sorted'), $album->title));
+system_message(elgg_echo('tidypics:album:sorted', array($album->title)));
 forward($album->getURL());
\ No newline at end of file
index 2276e4b12da0017871ee7c201a1b940d38ceda27..6f3de51ef51d4582439a172a7a040c12f8d42e6c 100644 (file)
@@ -96,7 +96,7 @@ $english = array(
                        'album:addpix' => "Add photos to album",
                        'album:edit' => "Edit album",
                        'album:delete' => "Delete album",
-                       'album:sort' => "Sort album",
+                       'album:sort' => "Sort",
                        'image:edit' => "Edit image",
                        'image:delete' => "Delete image",
                        'image:download' => "Download image",
index 4e56ae829cde7f171a3c2e62893d1374a9284f99..7426a048e399726efff58631662dfbd739ffbcf2 100644 (file)
@@ -141,6 +141,56 @@ function tidypics_is_upgrade_available() {
        }
 }
 
+/**
+ * This lists the photos in an album as sorted by metadata
+ *
+ * @param array $options
+ * @return string
+ */
+function tidypics_list_photos(array $options = array()) {
+       global $autofeed;
+       $autofeed = true;
+
+       $defaults = array(
+               'offset' => (int) max(get_input('offset', 0), 0),
+               'limit' => (int) max(get_input('limit', 10), 0),
+               'full_view' => true,
+               'list_type_toggle' => false,
+               'pagination' => true,
+       );
+
+       $options = array_merge($defaults, $options);
+
+       $options['count'] = true;
+       $count = elgg_get_entities($options);
+
+       $album = get_entity($options['container_guid']);
+       if ($album) {
+               $guids = $album->getImageList();
+               $guids = array_slice($guids, $options['offset'], $options['limit']);
+               $options['guids'] = $guids;
+               unset($options['container_guid']);
+       }
+       $options['count'] = false;
+       $entities = elgg_get_entities($options);
+
+       $keys = array();
+       foreach ($entities as $entity) {
+               $keys[] = $entity->guid;
+       }
+       $entities = array_combine($keys, $entities);
+
+       $sorted_entities = array();
+       foreach ($guids as $guid) {
+               if (isset($entities[$guid])) {
+                       $sorted_entities[] = $entities[$guid];
+               }
+       }
+
+       return elgg_view_entity_list($sorted_entities, $options);
+}
+
+
 /*********************************************************************
  * the functions below replace broken core functions or add functions 
  * that could/should exist in the core
index 1df04876a5c17116f9b50bfeb6ba98e76bf0ec6b..cebd033b0f3804831200949413d2861c757b606a 100644 (file)
--- a/start.php
+++ b/start.php
@@ -88,13 +88,13 @@ function tidypics_init() {
        // Register actions
        $base_dir = elgg_get_plugins_path() . 'tidypics/actions/photos';
        elgg_register_action("photos/album/save", "$base_dir/album/save.php");
+       elgg_register_action("photos/album/sort", "$base_dir/album/sort.php");
        elgg_register_action("photos/delete", "$base_dir/delete.php");
        elgg_register_action("photos/image/upload", "$base_dir/image/upload.php");
        elgg_register_action("photos/image/save", "$base_dir/image/save.php");
        elgg_register_action("photos/batch/edit", "$base_dir/batch/edit.php");
        //register_action("tidypics/ajax_upload", true, "$base_dir/ajax_upload.php");
        //register_action("tidypics/ajax_upload_complete", true, "$base_dir/ajax_upload_complete.php");
-       //register_action("tidypics/sortalbum", false, "$base_dir/sortalbum.php");
        elgg_register_action("photos/image/tag", "$base_dir/image/tag.php");
        //register_action("tidypics/deletetag", false, "$base_dir/deletetag.php");
 
@@ -317,9 +317,19 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) {
                        'name' => 'slideshow',
                        'text' => elgg_echo('album:slideshow'),
                        'href' => $slideshow_link,
-                       'priority' => 90,
+                       'priority' => 80,
                );
                $return[] = ElggMenuItem::factory($options);
+
+               if ($entity->canEdit()) {
+                       $options = array(
+                               'name' => 'sort',
+                               'text' => elgg_echo('album:sort'),
+                               'href' => "photos/sort/" . $entity->getGUID(),
+                               'priority' => 90,
+                       );
+                       $return[] = ElggMenuItem::factory($options);
+               }
        }
 
        return $return;
index 524112e0c26d56dd5e70f54831c25ae54c06ce57..49bd016aa852071762c3bc057fb4d2f963a568ad 100644 (file)
@@ -21,7 +21,7 @@ echo '<ul id="tidypics-sort" class="elgg-gallery">';
 foreach ($image_guids as $image_guid) {
        $image = get_entity($image_guid);
        $img = elgg_view('output/img', array(
-               'src' => $image->getSrcURL(),
+               'src' => $image->getIconURL(),
        ));
        echo "<li class=\"mam\" id=\"$image_guid\">$img</li>";
 }
index e350d232772d00a18103308307b003b1bc7d0ae1..ceb8b97aa16a5f6fd4e467556c91131e2c0281e4 100644 (file)
@@ -48,9 +48,7 @@ if ($album->description) {
                'class' => 'mbm',
        ));
 }
-$body .= elgg_list_entities(array(
-       'type' => 'object',
-       'subtype' => 'image',
+$body .= tidypics_list_photos(array(
        'container_guid' => $album->getGUID(),
        'limit' => 16,
        'full_view' => false,