]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
integrated Jeff's batch code into trunk
authorCash Costello <cash.costello@gmail.com>
Sun, 31 Oct 2010 12:47:25 +0000 (12:47 +0000)
committerCash Costello <cash.costello@gmail.com>
Sun, 31 Oct 2010 12:47:25 +0000 (12:47 +0000)
actions/ajax_upload_complete.php
actions/upload.php
languages/en.php
views/default/river/object/image/create.php
views/default/river/object/tidypics_batch/create.php [new file with mode: 0644]
views/default/tidypics/forms/ajax_upload.php
views/default/tidypics/forms/settings.php

index 0912854a3e6a61383234e7d7d9cfe60f9c4907b2..b66b563e3e9bd3fcf69cb1eb7f0ff9d7caac9a2c 100644 (file)
@@ -21,6 +21,29 @@ if ($album->new_album == TP_NEW_ALBUM) {
        add_to_river('river/object/album/create', 'create', $album->owner_guid, $album->guid);
 }
 
+$params = array(
+       'type'            => 'object',
+       'subtype'         => 'image',
+       'metadata_names'  => 'batch',
+       'metadata_values' => get_input('batch'),
+);
+$images = elgg_get_entities_from_metadata($params);
+if ($images) {
+       // Create a new batch object to contain these photos
+       $batch = new ElggObject();
+       $batch->subtype = "tidypics_batch";
+       $batch->access_id = ACCESS_PUBLIC;
+       $batch->container_guid = $album->guid;
+       if ($batch->save()) {
+               foreach ($images as $image) {
+                       add_entity_relationship($image->guid, "belongs_to_batch", $batch->getGUID());
+               }
+               if (get_plugin_setting('img_river_view', 'tidypics') == "batch") {
+                       add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+               }
+       }
+}
+
 // plugins can register to be told when a Tidypics album has had images added
 trigger_elgg_event('upload', 'tp_album', $album);
 
index b3ad9ebc305769c1f7ce449382a2e1f272b9c816..f2b626f01cb1b06298910559e78873ffaa4aca72 100644 (file)
@@ -120,11 +120,6 @@ foreach($_FILES as $key => $sent_file) {
        $file->extractExifData();
        $file->saveThumbnails($image_lib);
 
-       //keep one file handy so we can add a notice to the river if single image option selected
-       if (!$file_for_river) {
-               $file_for_river = $file;
-       }
-
        array_push($uploaded_images, $file->guid);
 
        // plugins can register to be told when a new image has been uploaded
@@ -171,11 +166,24 @@ if (count($not_uploaded) > 0) {
        system_message(elgg_echo('tidypics:upl_success'));
 }
 
+if (count($uploaded_images)) {
+       // Create a new batch object to contain these photos
+       $batch = new ElggObject();
+       $batch->subtype = "tidypics_batch";
+       $batch->access_id = $access_id;
+       $batch->container_guid = $album_guid;
 
-if (count($uploaded_images) && $img_river_view == "1") {
-       add_to_river('river/object/image/create', 'create', $file_for_river->getObjectOwnerGUID(), $file_for_river->getGUID());
+       if ($batch->save()) {
+               foreach ($uploaded_images as $uploaded_guid) {
+                       add_entity_relationship($uploaded_guid, "belongs_to_batch", $batch->getGUID());
+               }
+               if ($img_river_view == "batch") {
+                       add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+               }
+       }
 }
 
+
 if (count($uploaded_images) > 0) {
        $album->prependImageList($uploaded_images);
 }
index 26ef79605ae0b96a42f974cfedbf38e7cc594fd7..2bb18d959aaa0e1614acddddaa590cbbac7861b2 100644 (file)
@@ -164,7 +164,8 @@ The photo can be viewed here: %s",
 
                        //images
                        'image:river:created' => "%s added the photo %s to album %s",
-                       'image:river:item' => "an photo",
+                       'image:river:created:multiple' => "%s added %u photos to album %s",
+                       'image:river:item' => "a photo",
                        'image:river:annotate' => "a comment on the photo",
                        'image:river:tagged' => "%s tagged %s in the photo %s",
                        'image:river:tagged:unknown' => "%s tagged %s in a photo",
index 8a0a8deffc0bc5f18c097391982c8d5e04f27240..9de043e9112983758a93a214497bc507e635d596 100644 (file)
@@ -5,7 +5,7 @@ $image = get_entity($vars['item']->object_guid);
 if ($image->title) {
        $title = $image->title;
 } else {
-       $title = "untitled";
+       $title = elgg_echo("untitled");
 }
 
 $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
diff --git a/views/default/river/object/tidypics_batch/create.php b/views/default/river/object/tidypics_batch/create.php
new file mode 100644 (file)
index 0000000..e7a4d14
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+$performed_by = get_entity($vars['item']->subject_guid);
+$batch = get_entity($vars['item']->object_guid);
+$album = get_entity($batch->container_guid);
+
+if (!$batch || !$album) {
+       return true;
+}
+
+// Get images related to this batch
+$images = elgg_get_entities_from_relationship(array(
+                       'relationship' => 'belongs_to_batch',
+                       'relationship_guid' => $batch->getGUID(),
+                       'inverse_relationship' => true,
+                       'types' => array('object'),
+                       'subtypes' => array('image'),
+                       'offset' => 0,
+               ));
+
+// nothing to show
+if (!$images) {
+       return true;
+}
+
+$user_link = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+$album_link = "<a href='" . $album->getURL() . "'>" . $album->title . "</a>";
+if (count($images) > 1) {
+       $image_text = elgg_echo("image:river:created:multiple");
+       $string = sprintf($image_text, $user_link, count($images), $album_link);
+} else {
+       $image_text = elgg_echo("image:river:created");
+       $title = $images[0]->title;
+       if (!$title) {
+               $title = elgg_echo("untitled");
+       }
+       $image_link = "<a href=\"" . $images[0]->getURL() . "\">" . $title . "</a>";
+       $string = sprintf($image_text, $user_link, $image_link, $album_link);
+}
+
+$string .= "<div class=\"river_content\">";
+
+if (count($images)) {
+       foreach($images as $image) {
+               $string .= "<a href=\"" . $image->getURL() . "\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover"  alt="thumbnail"/> </a>';
+       }
+}
+
+$string .= "</div>";
+
+echo $string;
index c703d293bc08ea5afff67f0b0a57bf80c81022a2..c81c9173d2242f7babaab93ee91092b84b44939c 100644 (file)
@@ -112,7 +112,8 @@ $("#uploadify").uploadify({
                        { 
                                album_guid   : '<?php echo $album->guid; ?>',
                                __elgg_token : '<?php echo $token; ?>',
-                               __elgg_ts    : '<?php echo $ts; ?>'
+                               __elgg_ts    : '<?php echo $ts; ?>',
+                               batch        : '<?php echo $batch; ?>'
                        }
                );
        },
index dc5c02f15b6b02d607feabac7e303905db762c5b..c8a1b4bd90beda1dbfa71d3dbf1be6a06567dc23 100644 (file)
@@ -93,7 +93,7 @@ $form_body .= elgg_view('input/pulldown', array(
 ));
 $form_body .= '<br/>Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.</p>';
 
-if (is_callable('exec') && !in_array('exec',$disablefunc)) {
+if (is_callable('exec') && !in_array('exec', $disablefunc)) {
        // Image Magick Path
        $im_path = $plugin->im_path;
        if(!$im_path) {
@@ -108,14 +108,14 @@ if (is_callable('exec') && !in_array('exec',$disablefunc)) {
 $form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:river') . '</h3>';
 $img_river_view = $plugin->img_river_view;
 if (!$img_river_view) {
-       $img_river_view = '1';
+       $img_river_view = 'batch';
 }
 $form_body .= '<p>' . elgg_echo('tidypics:settings:img_river_view');
 $form_body .= elgg_view('input/pulldown', array(
                'internalname' => 'params[img_river_view]',
                'options_values' => array(
                                'all' => 'all',
-                               '1' => '1',
+                               'batch' => '1',
                                'none' => 'none',
                ),
                'value' => $img_river_view