aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/sortalbum.php18
-rw-r--r--languages/en.php6
-rw-r--r--pages/sortalbum.php38
-rw-r--r--pages/viewalbum.php3
-rw-r--r--start.php8
-rw-r--r--views/default/tidypics/css.php20
-rw-r--r--views/default/tidypics/sort.php54
7 files changed, 146 insertions, 1 deletions
diff --git a/actions/sortalbum.php b/actions/sortalbum.php
new file mode 100644
index 000000000..1aa0e052f
--- /dev/null
+++ b/actions/sortalbum.php
@@ -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
diff --git a/languages/en.php b/languages/en.php
index 2bb18d959..b2c88b27c 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -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
index 000000000..0bbd8159e
--- /dev/null
+++ b/pages/sortalbum.php
@@ -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);
diff --git a/pages/viewalbum.php b/pages/viewalbum.php
index fe3c5bc62..870596769 100644
--- a/pages/viewalbum.php
+++ b/pages/viewalbum.php
@@ -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');
diff --git a/start.php b/start.php
index 4d2b12798..1401c2c2c 100644
--- 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");
diff --git a/views/default/tidypics/css.php b/views/default/tidypics/css.php
index f7dd256a1..abcdc86a9 100644
--- a/views/default/tidypics/css.php
+++ b/views/default/tidypics/css.php
@@ -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
index 000000000..66dd8a999
--- /dev/null
+++ b/views/default/tidypics/sort.php
@@ -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