]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
working on album sorting
authorCash Costello <cash.costello@gmail.com>
Mon, 28 Nov 2011 12:50:23 +0000 (07:50 -0500)
committerCash Costello <cash.costello@gmail.com>
Mon, 28 Nov 2011 12:50:23 +0000 (07:50 -0500)
pages/photos/album/sort.php [new file with mode: 0644]
pages/photos/image/view.php
pages/sortalbum.php [deleted file]
start.php
views/default/forms/photos/album/sort.php [new file with mode: 0644]
views/default/js/photos/tidypics.php [new file with mode: 0644]
views/default/tidypics/css.php
views/default/tidypics/sort.php [deleted file]
views/rss/object/album.php
views/rss/object/album/full.php

diff --git a/pages/photos/album/sort.php b/pages/photos/album/sort.php
new file mode 100644 (file)
index 0000000..874da47
--- /dev/null
@@ -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);
index d9231eb08797aa2a07bd73a668b219b5d86bf7af..f172b7cd69b70a4a5ba4e17eae3c48bb992d064a 100644 (file)
@@ -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 (file)
index 0bbd815..0000000
+++ /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);
index 817578607884759d17d971cddc4bcefdeaa1186a..b24f3cb617ea60bc2bbc45772bf33283ab55463c 100644 (file)
--- 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 (file)
index 0000000..524112e
--- /dev/null
@@ -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 (file)
index 0000000..509d211
--- /dev/null
@@ -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);
index 542123bd0f95868329b056c3e501dd7da1a83a45..82594db0e87440611287f03448c8d90fc427912b 100644 (file)
        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 (file)
index 66dd8a9..0000000
+++ /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
index 0c46062459fa1dfa706e010ae2504b4ac267358c..f880b56d6dbc8cc779cd483b84f645624acee6b9 100644 (file)
@@ -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) {
index 8261e5ce05d5808f63c781a5637570b7687f4826..b1f5a567b40dca87c5e24b16d6ed80c228901b24 100644 (file)
@@ -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);