aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-11-28 07:50:23 -0500
committerCash Costello <cash.costello@gmail.com>2011-11-28 07:50:23 -0500
commitefdd4b6544e14355f6ae0e6151c6f828271d3913 (patch)
treeddc1de199af538df367e625ab5f3cea420e039cd
parentca5a35607dfb277cecba120ce27eece7c59f270a (diff)
downloadelgg-efdd4b6544e14355f6ae0e6151c6f828271d3913.tar.gz
elgg-efdd4b6544e14355f6ae0e6151c6f828271d3913.tar.bz2
working on album sorting
-rw-r--r--pages/photos/album/sort.php46
-rw-r--r--pages/photos/image/view.php2
-rw-r--r--pages/sortalbum.php38
-rw-r--r--start.php16
-rw-r--r--views/default/forms/photos/album/sort.php28
-rw-r--r--views/default/js/photos/tidypics.php26
-rw-r--r--views/default/tidypics/css.php6
-rw-r--r--views/default/tidypics/sort.php54
-rw-r--r--views/rss/object/album.php4
-rw-r--r--views/rss/object/album/full.php3
10 files changed, 123 insertions, 100 deletions
diff --git a/pages/photos/album/sort.php b/pages/photos/album/sort.php
new file mode 100644
index 000000000..874da4777
--- /dev/null
+++ b/pages/photos/album/sort.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Album sort page
+ *
+ * This displays a listing of all the photos so that they can be sorted
+ */
+
+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
+$owner = $album->getContainerEntity();
+elgg_set_page_owner_guid($owner->getGUID());
+
+$title = elgg_echo('tidypics:sort', array($album->getTitle()));
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->title, $album->getURL());
+elgg_push_breadcrumb($title);
+
+
+$content = elgg_view_form('photos/album/sort', array(), array('album' => $album));
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/pages/photos/image/view.php b/pages/photos/image/view.php
index d9231eb08..f172b7cd6 100644
--- a/pages/photos/image/view.php
+++ b/pages/photos/image/view.php
@@ -21,7 +21,7 @@ $owner = elgg_get_page_owner_entity();
// set up breadcrumbs
elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
-if (elgg_instanceof($page_owner, 'group')) {
+if (elgg_instanceof($owner, 'group')) {
elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
} else {
elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
diff --git a/pages/sortalbum.php b/pages/sortalbum.php
deleted file mode 100644
index 0bbd8159e..000000000
--- a/pages/sortalbum.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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/start.php b/start.php
index 817578607..b24f3cb61 100644
--- a/start.php
+++ b/start.php
@@ -30,6 +30,11 @@ function tidypics_init() {
elgg_extend_view('css/elgg', 'tidypics/css');
elgg_extend_view('css/admin', 'tidypics/css');
+ // Register the JavaScript lib
+ $js = elgg_get_simplecache_url('js', 'photos/tidypics');
+ elgg_register_simplecache_view('js/photos/tidypics');
+ elgg_register_js('tidypics', $js, 'footer');
+
// Add photos link to owner block/hover menus
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tidypics_owner_block_menu');
@@ -87,7 +92,6 @@ function tidypics_init() {
//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");
- //register_action("tidypics/edit", false, "$base_dir/edit.php");
//register_action("tidypics/addtag", false, "$base_dir/addtag.php");
//register_action("tidypics/deletetag", false, "$base_dir/deletetag.php");
@@ -247,6 +251,8 @@ function tidypics_page_handler($page) {
return false;
}
+ elgg_load_js('tidypics');
+
$base = elgg_get_plugins_path() . 'tidypics/pages/photos';
switch ($page[0]) {
case "all": // all site albums
@@ -296,11 +302,9 @@ function tidypics_page_handler($page) {
}
break;
- case "sort": //sort a photo album
- if (isset($page[1])) {
- set_input('guid', $page[1]);
- }
- include($CONFIG->pluginspath . "tidypics/pages/sortalbum.php");
+ case "sort": // sort a photo album
+ set_input('guid', $page[1]);
+ require "$base/album/sort.php";
break;
case "image": //view an image
diff --git a/views/default/forms/photos/album/sort.php b/views/default/forms/photos/album/sort.php
new file mode 100644
index 000000000..524112e0c
--- /dev/null
+++ b/views/default/forms/photos/album/sort.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Album sorting view
+ */
+
+$album = $vars['album'];
+$image_guids = $album->getImageList();
+
+echo '<div>';
+echo elgg_echo('tidypics:sort:instruct');
+echo '</div>';
+
+echo '<div>';
+echo elgg_view('input/hidden', array('name' => 'guids'));
+echo elgg_view('input/hidden', array('name' => 'album_guid', 'value' => $album->guid));
+echo elgg_view('input/submit', array('value' => elgg_echo('save')));
+echo '</div>';
+
+echo '<div class="elgg-foot">';
+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(),
+ ));
+ echo "<li class=\"mam\" id=\"$image_guid\">$img</li>";
+}
+echo '</ul>';
diff --git a/views/default/js/photos/tidypics.php b/views/default/js/photos/tidypics.php
new file mode 100644
index 000000000..509d2116a
--- /dev/null
+++ b/views/default/js/photos/tidypics.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ *
+ */
+
+?>
+
+elgg.provide('elgg.tidypics');
+
+elgg.tidypics.init = function() {
+ $("#tidypics-sort").sortable({
+ opacity: 0.7,
+ revert: true,
+ scroll: true
+ });
+
+ $('.elgg-form-photos-album-sort').submit(function() {
+ var tidypics_guids = [];
+ $("#tidypics-sort li").each(function(index) {
+ tidypics_guids.push($(this).attr('id'));
+ });
+ $('input[name="guids"]').val(tidypics_guids.toString());
+ });
+};
+
+elgg.register_hook_handler('init', 'system', elgg.tidypics.init);
diff --git a/views/default/tidypics/css.php b/views/default/tidypics/css.php
index 542123bd0..82594db0e 100644
--- a/views/default/tidypics/css.php
+++ b/views/default/tidypics/css.php
@@ -22,6 +22,12 @@
width: 120px;
}
+#tidypics-sort li {
+width:153px;
+height:153px;
+}
+
+
<?php
return true;
?>
diff --git a/views/default/tidypics/sort.php b/views/default/tidypics/sort.php
deleted file mode 100644
index 66dd8a999..000000000
--- a/views/default/tidypics/sort.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?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
diff --git a/views/rss/object/album.php b/views/rss/object/album.php
index 0c4606245..f880b56d6 100644
--- a/views/rss/object/album.php
+++ b/views/rss/object/album.php
@@ -3,9 +3,11 @@
* Album RSS view
*
* @uses $vars['entity'] TidypicsAlbum
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
-
$full_view = elgg_extract('full_view', $vars, false);
if ($full_view) {
diff --git a/views/rss/object/album/full.php b/views/rss/object/album/full.php
index 8261e5ce0..b1f5a567b 100644
--- a/views/rss/object/album/full.php
+++ b/views/rss/object/album/full.php
@@ -3,6 +3,9 @@
* List photos in an album for RSS
*
* @uses $vars['entity'] TidypicsAlbum
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
$limit = (int)get_input('limit', 20);