]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
First cut at a album sorting interface
authorCash Costello <cash.costello@gmail.com>
Sun, 31 Oct 2010 20:03:50 +0000 (20:03 +0000)
committerCash Costello <cash.costello@gmail.com>
Sun, 31 Oct 2010 20:03:50 +0000 (20:03 +0000)
actions/sortalbum.php [new file with mode: 0644]
languages/en.php
pages/sortalbum.php [new file with mode: 0644]
pages/viewalbum.php
start.php
views/default/tidypics/css.php
views/default/tidypics/sort.php [new file with mode: 0644]

diff --git a/actions/sortalbum.php b/actions/sortalbum.php
new file mode 100644 (file)
index 0000000..1aa0e05
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Sorting album action - takes a comma separated list of image guids
+ */
+
+$album_guid = get_input('album_guid');
+$album = get_entity($album_guid);
+if (!$album) {
+       
+}
+
+$guids = get_input('guids');
+$guids = explode(',', $guids);
+
+$album->setImageList($guids);
+
+system_message(sprintf(elgg_echo('tidypics:album:sorted'), $album->title));
+forward($album->getURL());
\ No newline at end of file
index 2bb18d959aaa0e1614acddddaa590cbbac7861b2..b2c88b27c52ba59702f868d38a6a7a3c436ef102 100644 (file)
@@ -49,6 +49,7 @@ $english = array(
                        'tidypics:stats' => 'Stats',
                        'tidypics:nophotosingroup' => 'This groups does not have any photos yet',
                        'tidypics:upgrade' => 'Upgrade',
+                       'tidypics:sort' => 'Sorting the %s album',
 
                        'flickr:setup' => 'Flickr Setup',
                        'flickr:usernamesetup' => 'Please enter your Flickr username here:',
@@ -97,6 +98,7 @@ $english = array(
                        'album:addpix' => "Add photos to album",
                        'album:edit' => "Edit album",
                        'album:delete' => "Delete album",
+                       'album:sort' => "Sort album",
 
                        'image:edit' => "Edit image",
                        'image:delete' => "Delete image",
@@ -116,6 +118,9 @@ $english = array(
                        'tidypics:uploader:filedesc' => 'Image files (jpeg, png, gif)',
                        'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: choosing, uploading, and describing them. If you do not have Flash, there is also a <a href="%s">basic uploader</a> available.',
                        'tidypics:uploader:basic' => 'You can upload up to 10 photos at a time (%s MB maximum per photo)',
+
+                       'tidypics:sort:instruct' => 'Sort the album photos by dragging and dropping the images. Then click the save button.',
+
                //views
 
                        'image:total' => "Images in album:",
@@ -195,6 +200,7 @@ The photo can be viewed here: %s",
                        'album:delete:confirm' => "Are you sure you want to delete this album?",
                        'album:created' => "Your new album has been created.",
                        'tidypics:settings:save:ok' => 'Successfully saved the Tidypics plugin settings',
+                       'tidypics:album:sorted' => 'The album %s is sorted',
 
                        'tidypics:upgrade:success' => 'Upgrade of Tidypics a success',
                        
diff --git a/pages/sortalbum.php b/pages/sortalbum.php
new file mode 100644 (file)
index 0000000..0bbd815
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Tidypics Album Sort Page
+ *
+ * This displays a listing of all the photos so that they can be sorted
+ */
+
+// if this page belongs to a closed group, prevent anyone outside group from seeing
+if (is_callable('group_gatekeeper')) {
+       group_gatekeeper();
+}
+
+// get the album entity
+$album_guid = (int) get_input('guid');
+$album = get_entity($album_guid);
+
+// panic if we can't get it
+if (!$album) {
+       forward();
+}
+
+// container should always be set, but just in case
+if ($album->container_guid) {
+       set_page_owner($album->container_guid);
+} else {
+       set_page_owner($album->owner_guid);
+}
+
+$owner = page_owner_entity();
+
+$title = sprintf(elgg_echo('tidypics:sort'), $album->title);
+
+$content = elgg_view_title($title);
+$content .= elgg_view('tidypics/sort', array('album' => $album));
+
+$body = elgg_view_layout('two_column_left_sidebar', '', $content);
+
+page_draw($title, $body);
index fe3c5bc624fa44295e0b34d0b112a32214836e03..870596769c6b2932a0f0c041b86cb7a8b77346c1 100644 (file)
@@ -54,6 +54,9 @@ if (can_write_to_container(0, $album->container_guid)) {
        add_submenu_item(       elgg_echo('album:addpix'),
                        $CONFIG->wwwroot . 'pg/photos/upload/' . $album_guid,
                        'photos');
+       add_submenu_item(       elgg_echo('album:sort'),
+                       $CONFIG->wwwroot . 'pg/photos/sort/' . $album_guid,
+                       'photos');
        add_submenu_item(       elgg_echo('album:edit'),
                        $CONFIG->wwwroot . 'pg/photos/edit/' . $album_guid,
                        'photos');
index 4d2b127983fa3a214774de2cc047d54fbdc495a4..1401c2c2c62c52d63547c116ff4b165e4204880b 100644 (file)
--- a/start.php
+++ b/start.php
@@ -257,6 +257,13 @@ function tidypics_page_handler($page) {
                                include($CONFIG->pluginspath . "tidypics/pages/viewalbum.php");
                                break;
 
+                       case "sort": //sort a photo album
+                               if (isset($page[1])) {
+                                       set_input('guid', $page[1]);
+                               }
+                               include($CONFIG->pluginspath . "tidypics/pages/sortalbum.php");
+                               break;
+
                        case "new":  //create new album
                                if (isset($page[1])) {
                                        set_input('username', $page[1]);
@@ -532,6 +539,7 @@ register_action("tidypics/upload", false, $CONFIG->pluginspath . "tidypics/actio
 register_action("tidypics/ajax_upload", true, $CONFIG->pluginspath . "tidypics/actions/ajax_upload.php");
 register_action("tidypics/ajax_upload_complete", true, $CONFIG->pluginspath . "tidypics/actions/ajax_upload_complete.php");
 register_action("tidypics/addalbum", false, $CONFIG->pluginspath. "tidypics/actions/addalbum.php");
+register_action("tidypics/sortalbum", false, $CONFIG->pluginspath. "tidypics/actions/sortalbum.php");
 register_action("tidypics/edit", false, $CONFIG->pluginspath. "tidypics/actions/edit.php");
 register_action("tidypics/delete", false, $CONFIG->pluginspath. "tidypics/actions/delete.php");
 register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php");
index f7dd256a1678a8464e27a64c13093dc0c65edcc5..abcdc86a9a6d4df30822694f853952ca3b710fcc 100644 (file)
@@ -384,4 +384,22 @@ float: right;
 .uploadifyError {
 border: 2px solid #FBCBBC;
 background-color: #FDE5DD;
-}
\ No newline at end of file
+}
+
+#tidypics_album_sort {
+padding:0;
+margin:0;
+}
+
+#tidypics_album_sort li {
+float:left;
+margin:3px;
+width:161px;
+height:161px;
+}
+
+#tidypics_album_sort img {
+border:1px solid #dedede;
+padding:4px;
+}
+
diff --git a/views/default/tidypics/sort.php b/views/default/tidypics/sort.php
new file mode 100644 (file)
index 0000000..66dd8a9
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Album sorting view
+ */
+
+$album = $vars['album'];
+$image_guids = $album->getImageList();
+
+// create submission form
+$body = elgg_view('input/hidden', array('internalname' => 'guids'));
+$body .= elgg_view('input/hidden', array('internalname' => 'album_guid', 'value' => $album->guid));
+$body .= elgg_view('input/submit', array('value' => elgg_echo('save')));
+?>
+<div class="contentWrapper">
+       <div>
+               <?php echo elgg_echo('tidypics:sort:instruct'); ?>
+       </div>
+       <?php
+       $params = array(
+               'internalid' => 'tidypics_sort_form',
+               'action'     => "{$vars['url']}action/tidypics/sortalbum",
+               'body'       => $body,
+       );
+       echo elgg_view('input/form', $params);
+       ?>
+
+       <ul id="tidypics_album_sort">
+               <?php
+               foreach ($image_guids as $image_guid) {
+                       $image = get_entity($image_guid);
+                       $url = "{$vars['url']}pg/photos/thumbnail/$image_guid/small/";
+                       echo "<li id=\"$image_guid\"><img src=\"$url\" /></li>";
+               }
+               ?>
+       </ul>
+       <div class="clearfloat"></div>
+</div>
+
+<script type="text/javascript">
+$("#tidypics_album_sort").sortable(
+       {
+               opacity: 0.7,
+               revert: true,
+               scroll: true
+       }
+);
+$('#tidypics_sort_form').submit(function() {
+       var tidypics_guids = [];
+       $("#tidypics_album_sort li").each(function(index) {
+               tidypics_guids.push($(this).attr('id'));
+       });
+       $('input[name="guids"]').val(tidypics_guids.toString());
+});
+</script>
\ No newline at end of file