]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
supporting both basic and flash uploader
authorCash Costello <cash.costello@gmail.com>
Mon, 25 Oct 2010 00:22:20 +0000 (00:22 +0000)
committerCash Costello <cash.costello@gmail.com>
Mon, 25 Oct 2010 00:22:20 +0000 (00:22 +0000)
actions/addalbum.php
actions/ajax_upload.php
actions/upload.php
lib/album.php
pages/edit_multiple.php
pages/upload.php
start.php
views/default/tidypics/css.php
views/default/tidypics/forms/ajax_upload.php
views/default/tidypics/forms/edit_multi.php
views/default/tidypics/forms/upload.php

index bdac9bfbf427c1b490ec62d09613923c4c989fc2..8ddcca1315c0fe30c8f8b43918f0cfea550e052e 100644 (file)
@@ -42,6 +42,8 @@ if (!$album->save()) {
        forward(get_input('forward_url', $_SERVER['HTTP_REFERER']));
 }
 
+mkdir(tp_get_img_dir() . $album->guid, 0755, true);
+
 system_message(elgg_echo("album:created"));
 
 // Remove the album post cache
index 3d44df1998b731d3133978c2e7d416cd7248cf2b..973e4220a92640c4adaf085ccedfcce0a3ea3520 100644 (file)
@@ -33,7 +33,8 @@ $image->setMimeType(tp_upload_get_mimetype($name));
 $image->simpletype = "image";
 $image->access_id = $album->access_id;
 $image->title = substr($name, 0, strrpos($name, '.'));
-$image_guid = $image->save();
+$image->batch = get_input('batch');
+$result = $image->save();
 
 $image->setOriginalFilename($name);
 $image->saveImageFile($temp_file, $file_size);
@@ -43,5 +44,7 @@ $image->saveThumbnails($image_lib);
 
 $album->prependImageList(array($image->guid));
 
+error_log('complete');
+
 echo "1";
 exit;
\ No newline at end of file
index 8dae852778a1ee89cb636ffda0176b7284761b8c..b3ad9ebc305769c1f7ce449382a2e1f272b9c816 100644 (file)
@@ -9,8 +9,8 @@ include_once dirname(dirname(__FILE__)) . "/lib/upload.php";
 
 // Get common variables
 $access_id = (int) get_input("access_id");
-$container_guid = (int) get_input('container_guid', 0);
-$album = get_entity($container_guid);
+$album_guid = (int) get_input('album_guid', 0);
+$album = get_entity($album_guid);
 if (!$album) {
        register_error(elgg_echo('tidypics:baduploadform'));
        forward($_SERVER['HTTP_REFERER']);
@@ -101,7 +101,7 @@ foreach($_FILES as $key => $sent_file) {
 
        //this will save to users folder in /image/ and organize by photo album
        $file = new TidypicsImage();
-       $file->container_guid = $container_guid;
+       $file->container_guid = $album_guid;
        $file->setMimeType($mime);
        $file->simpletype="image";
        $file->access_id = $access_id;
index 916ccbc315db73488d1f9af2de60388c54633477..0d514087578a716b9cbe114d46987272b41fa249 100644 (file)
@@ -210,9 +210,11 @@ class TidypicsAlbum extends ElggObject {
        protected function deleteImages() {
                // get all the images from this album as long as less than 999 images
                $images = get_entities("object", "image", $this->guid, '', 999);
-               foreach ($images as $image) {
-                       if ($image) {
-                               $image->delete();
+               if ($images) {
+                       foreach ($images as $image) {
+                               if ($image) {
+                                       $image->delete();
+                               }
                        }
                }
        }
index ec507ba4b33f50cd8d2d4bf192e3a77b0d819f49..938ac203c9c4c248ee59d859260bda25bf5bbcc5 100644 (file)
@@ -10,38 +10,36 @@ include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
 gatekeeper();
 set_context('photos');
 
-// parse out photo guids
-$file_string = get_input('files');
-$file_array_sent = explode('-', $file_string);
-$new_file_array = array();
-
-// set owner of page based on first photo guid
-$photo_guid = (int)$file_array_sent[0];
-$photo = get_entity($photo_guid);
-
-// set page owner based on owner of photo album
-set_page_owner($photo->owner_guid);
-$album = get_entity($photo->container_guid);
-if ($album) {
-       $owner_guid = $album->container_guid;
-       if ($owner_guid) {
-               set_page_owner($owner_guid);
-       }
-}
+set_page_owner(get_loggedin_userid());
 
-foreach ($file_array_sent as $file_guid) {
-       if ($entity = get_entity($file_guid)) {
-               if ($entity->canEdit()) {
-                       array_push($new_file_array, $file_guid);
-               }
-               if (!$album_guid) {
-                       $album_guid = $entity->container_guid;
+
+$batch = get_input('batch');
+if ($batch) {
+       $images = get_entities_from_metadata('batch', $batch, 'object', 'image', get_loggedin_userid(), 100);
+} else {
+       // parse out photo guids
+       $file_string = get_input('files');
+       $file_array_sent = explode('-', $file_string);
+
+       $images = array();
+       foreach ($file_array_sent as $file_guid) {
+               if ($entity = get_entity($file_guid)) {
+                       if ($entity->canEdit()) {
+                               array_push($images, $entity);
+                       }
                }
        }
 }
 
+if (!$images) {
+       forward($_SERVER['HTTP_REFERER']);
+}
+
+
 $title = elgg_echo('tidypics:editprops');
-$area2 .= elgg_view_title($title);
-$area2 .= elgg_view("tidypics/forms/edit_multi", array('file_array' => $new_file_array, 'album_guid' => $album_guid));
-$body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+$content .= elgg_view_title($title);
+$content .= elgg_view("tidypics/forms/edit_multi", array('images' => $images));
+
+$body = elgg_view_layout('two_column_left_sidebar', '', $content);
 page_draw($title, $body);
index 8e15dd61269b3fd9e1536fb26dafddab13feb0ba..b6a828cf9714adc8236e949cc95c722be7d75030 100644 (file)
@@ -9,11 +9,13 @@ include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
 // must be logged in to upload images
 gatekeeper();
 
-$album_guid = (int) get_input('container_guid');
+$album_guid = (int) get_input('album_guid');
 if (!$album_guid) {
        forward();
 }
 
+$uploader = get_input('uploader', 'ajax');
+
 $album = get_entity($album_guid);
 
 //if album does not exist or user does not have access
@@ -22,9 +24,8 @@ if (!$album || !$album->canEdit()) {
        forward($_SERVER['HTTP_REFERER']);
 }
 
-// set page owner based on container (user or group) 
-$container = $album->container_guid;
-set_page_owner($container);
+// set page owner based on container (user or group)
+set_page_owner($album->container_guid);
 
 $page_owner = page_owner_entity();
 if ($page_owner instanceof ElggGroup) {
@@ -36,8 +37,11 @@ set_context('photos');
 $title = elgg_echo('album:addpix') . ': ' . $album->title;
 $area2 .= elgg_view_title($title);
 
-$area2 .= elgg_view("tidypics/forms/upload", array('album' => $album_guid ) );
-//$area2 .= elgg_view("tidypics/forms/ajax_upload", array('album' => $album_guid ) );
+if ($uploader == 'basic') {
+       $area2 .= elgg_view("tidypics/forms/upload", array('album' => $album));
+} else {
+       $area2 .= elgg_view("tidypics/forms/ajax_upload", array('album' => $album));
+}
 
 $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
 
index 9b3dab08f8e24ce34b3b2b233b6b418f62e612b1..a50f23c57cc689629d18e9893e5cc4b4b0e76dd3 100644 (file)
--- a/start.php
+++ b/start.php
@@ -263,7 +263,10 @@ function tidypics_page_handler($page) {
 
                        case "upload": //upload images to album
                                if (isset($page[1])) {
-                                       set_input('container_guid', $page[1]);
+                                       set_input('album_guid', $page[1]);
+                               }
+                               if (isset($page[2])) {
+                                       set_input('uploader', 'basic');
                                }
                                include($CONFIG->pluginspath . "tidypics/pages/upload.php");
                                break;
@@ -275,6 +278,13 @@ function tidypics_page_handler($page) {
                                include($CONFIG->pluginspath . "tidypics/pages/edit.php");
                                break;
 
+                       case "batch": //update titles and descriptions
+                               if (isset($page[1])) {
+                                       set_input('batch', $page[1]);
+                               }
+                               include($CONFIG->pluginspath . "tidypics/pages/edit_multiple.php");
+                               break;
+
                        case "friends": // albums of friends
                                if (isset($page[1])) {
                                        set_input('username', $page[1]);
index 9e5a5c68d410ad77ec2451a7665014cfc73aa20c..ea2081da69ba073b45442156b4e9d71cce9b7ff2 100644 (file)
@@ -304,7 +304,7 @@ list-style: none;
 .uploadifyQueueItem {
 background-color:#F5F5F5;
 border:2px solid #E5E5E5;
-font:11px Verdana,Geneva,sans-serif;
+font-size:11px;
 margin-top:5px;
 padding:10px;
 width:350px;
@@ -322,4 +322,27 @@ width:100%;
 background-color: #0099FF;
 width: 1px;
 height: 3px;
-}
\ No newline at end of file
+}
+
+#tidypics_uploader {
+position:relative;
+width:400px;
+}
+
+#tidypics_choose_button {
+position:absolute;
+top:0;
+left:0;
+z-index:0;
+display:block;
+float:left;
+}
+
+#tidypics_flash_uploader {
+position:relative;
+z-index:100;
+}
+
+#uploadifyQueue {
+margin-bottom: 20px;
+}
index b71068a13de07fc00147c7d833c0065a389e951e..25c65857074907ba29385d7b5d610b22fac3f508 100644 (file)
@@ -2,13 +2,14 @@
 
 extend_view('metatags', 'tidypics/js/uploader');
 
-$container_guid = get_input('container_guid');
-$album = get_entity($vars['album']);
+$album = $vars['album'];
 $access_id = $album->access_id;
 
 $ts = time();
 $token = generate_action_token($ts);
 
+$batch = time();
+
 
 $maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics');
 if (!$maxfilesize) {
@@ -36,29 +37,46 @@ if ($quota) {
 
 <div class="contentWrapper">
 
-<p>Instructions here for uploading images using Ajax/Flash</p>
-<input id="upload_file" name="upload_file" type="file" />
-<a href="javascript:$('#upload_file').uploadifyUpload();">Upload Files</a> |
-<a href="javascript:$('#upload_file').uploadifyClearQueue();">Clear Queue</a>
+       <p>Instructions here for uploading images using Ajax/Flash</p>
+
+       <div id="tidypics_uploader">
+               <a id="tidypics_choose_button">Choose images</a>
+               <div id="tidypics_flash_uploader">
+                       <input type="file" id="uploadify" name="uploadify" />
+               </div>
+       </div>
+
+<a href="javascript:$('#uploadify').uploadifyUpload();">Upload Files</a>
+<!--
+<a href="javascript:$('#uploadify').uploadifyClearQueue();">Clear Queue</a>
+-->
+<br />
+<a href="<?php echo $vars['url']; ?>pg/photos/batch/<?php echo $batch; ?>">Add titles and descriptions</a>
+<br />
+<a href="<?php echo current_page_url(); ?>/basic">Basic uploader</a>
+
 
 </div>
 
 <script type="text/javascript">
-$("#upload_file").uploadify({
+$("#uploadify").uploadify({
        'uploader'     : '<?php echo $vars['url']; ?>mod/tidypics/vendors/uploadify/uploadify.swf',
        'script'       : '<?php echo $vars['url']; ?>action/tidypics/ajax_upload/',
        'scriptData'   : {
                                                'album_guid'   : '<?php echo $album->guid; ?>',
                                                '__elgg_token' : '<?php echo $token; ?>',
                                                '__elgg_ts'    : '<?php echo $ts; ?>',
-                                               'Elgg'   : '<?php echo session_id(); ?>'
+                                               'Elgg'         : '<?php echo session_id(); ?>',
+                                               'batch'        : '<?php echo $batch; ?>'
                                         },
        'fileDataName' : 'Image',
        'cancelImg'  : '/_images/cancel.png',
        'multi'      : true,
        'auto'       : false,
        'fileDesc'   : '<?php echo elgg_echo('tidypics:upload:filedesc'); ?>',
-       'fileExt'    : '*.jpg;*.jpeg;*.png;*.gif'
+       'fileExt'    : '*.jpg;*.jpeg;*.png;*.gif',
+       'wmode'      : 'transparent',
+       'buttonImg'  : " "
 });
 </script>
 
index 8c3e4024203a92b5c3408c0a07c07875ac3b1755..aba6fd324b273ee46f323821c4de64f40a7d4bcb 100644 (file)
@@ -2,26 +2,25 @@
 /**
  * form for mass editing all uploaded images
  */
+
+$images = $vars['images'];
+$album = get_entity($images[0]->container_guid);
+
 ?>
 <div class="contentWrapper">
 <form action="<?php echo $vars['url']; ?>action/tidypics/edit_multi" method="post">
 <?php
-
-       $file_array = $vars['file_array'];
        
        // make sure one of the images becomes the cover if there isn't one already
-       $album_entity = get_entity($vars['album_guid']);
-       if (!$album_entity->getCoverImageGuid()) {
+       if (!$album->getCoverImageGuid()) {
                $no_cover = true;
        }
        
-       foreach ($file_array as $key => $file_guid) {
-               $entity = get_entity($file_guid);
-               $guid = $entity->guid;
-               $body = $entity->description;
-               $title = $entity->title;
-               $tags = $entity->tags;
-               $container_guid = $entity->container_guid;
+       foreach ($images as $key => $image) {
+               $guid = $image->guid;
+               $body = $image->description;
+               $title = $image->title;
+               $tags = $image->tags;
                
                // first one is default cover if there isn't one already
                if ($no_cover) {
@@ -54,7 +53,7 @@
        }
        
 ?>
-<input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" />
+<input type="hidden" name="container_guid" value="<?php echo $album->guid; ?>" />
 <p><input type="submit" name="submit" value="<?php echo elgg_echo('save'); ?>" /></p>
 </form>
 </div>
\ No newline at end of file
index 691d9701bd5ddc3fb9f4d4e35b9c977fdeb7e14c..5a9703171ed72b97b85d74b21336c452202f43d1 100644 (file)
@@ -3,8 +3,7 @@ global $CONFIG;
 
 //this is for image uploads only. Image edits are handled by edit.php form
 
-$container_guid = get_input('container_guid');
-$album = get_entity($vars['album']);
+$album = $vars['album'];
 $access_id = $album->access_id;
 
 $maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics');
@@ -59,8 +58,8 @@ if ($quota) {
 </p>
 <p>
        <?php
-       if ($container_guid) {
-               echo '<input type="hidden" name="container_guid" value="' . $container_guid . '" />';
+       if ($album) {
+               echo '<input type="hidden" name="album_guid" value="' . $album->guid . '" />';
        }
        if ($access_id) {
                echo '<input type="hidden" name="access_id" value="' . $access_id . '" />';