singapore: the smallest big galery
home » forum » Mods » Moving images via admin

You are not logged in.

#1 2006-12-19 19:33:12

forty two
Member

Moving images via admin

Similar to the move/copy album, is there a way to move/copy images?  I only ask because the person whom I build for doesn't have FTP access.  That and I want to learn Singapore inside and out as to start helping out with the dev.  Woot.

edit:

Would I be able to take this code (from admin.class.php):

Code:

  /**
   * Moves or copies galleries.
   *
   * @return int|false  number of galleries moved; false otherwise
   */
  function moveMultipleGalleries()
  {
    $totalGalleriesMoved = 0;
    foreach($_REQUEST["sgGalleries"] as $galleryId) {
      $source = $this->config->base_path.$this->config->pathto_galleries.$galleryId;
      $target = $this->config->base_path.$this->config->pathto_galleries.$_REQUEST['sgMoveTarget'].'/'.basename($galleryId);
      if(file_exists($target)) {
        $this->pushError($this->translator->_g("Unable to copy/move gallery '%s' because the target gallery already exists.", $galleryId));
      } elseif($this->isSubPath($source, $target, false)) {
        $this->pushError($this->translator->_g("Unable to copy/move gallery '%s' because the target is a child of the source.", $galleryId));
      //} elseif(!is_writable($target)) {
      //  $this->pushError($this->translator->_g("Unable to copy/move gallery '%s': the target is not writable", $galleryId));
      } else {
        if($_REQUEST["sgMoveType"] == 'move') { //Move
          $current = rename($source, $target);
        } else { //Copy
          $current = $this->copyDir($source, $target);
        }
        if($current === false) $this->pushError($this->translator->_g("Unable to copy/move gallery '%s' because the operation failed.", $galleryId));
        else $totalGalleriesMoved++;
      }
    }

and be able to modify it to work with single/multiple images within an album?

Last edited by forty two (2006-12-20 03:46:23)

Offline

 

#2 2007-01-02 16:57:06

forty two
Member

Re: Moving images via admin

I just realized there was a post about this elsewhere.  So is it safe to assume that taking all the code and functions that are designed to Move or Copy Galleries can't just be modded to Copy or Move Images.  I figure if that was the case it would probably have been done.  Is there any reason why that doesn't work?  And does it have something to do with the CSV files?

Offline

 

#3 2007-01-03 12:26:49

pavian
Moderator

Re: Moving images via admin

hmm well..actually it should be like this:
(1) get fullpath of image
(2) copy image to the other directory
(3) in former directory delete image

Basically it works like the above function, but, well a little different. You would need to change the function and the interface to moving files instead of folders.

Offline

 

#4 2007-01-04 01:12:25

Egypt Urnash
Member

Re: Moving images via admin

pavian, wouldn't doing a mv be better than a copy/delete? Less data to move around, and the date on the file won't change - important for those who might be doing sort by date!

i'd swear I've moved images with Singapore, but maybe I'm hallucinating...

Offline

 

#5 2007-01-04 01:40:56

pavian
Moderator

Re: Moving images via admin

hmm moving is copying and deleting ;-) Basically I just illustrated it like this, because if you use the function for deleting there is no problem with the csv-file :-)

Offline

 

#6 2007-01-08 16:36:34

forty two
Member

Re: Moving images via admin

right.  so, if it's a matter of finding all the copy/move album bits of code and modding them to do the same but for image(s) is there more then one file that does this?  i think i've found 2 already.  the admin.class.php and i think i saw something in the singapore.class.php.  or is there a better way to do this?  please advice before i start breaking stuff. wink

@egypt: I swear i've moved imaegs with Singapore as well.  maybe we're hallucinating together. hehe.

Offline

 

#7 2007-01-09 18:45:30

forty two
Member

Re: Moving images via admin

I noticed in a couple other posts inquiring about this topic that Tamlyn had said this was a high priority, well those posts are 2004/2005 posts, so is this something that's being worked on for the next release or is this no longer high priority?

Offline

 

#8 2007-01-09 18:46:52

pavian
Moderator

Re: Moving images via admin

Neither - the thing is that no one is currently working beyond support - sorry :-(

Right now I hope to be able to have some time for singapore soon.

Offline

 

#9 2007-01-10 18:07:01

forty two
Member

Re: Moving images via admin

Well, I'd definitely love to help with dev.  I've been pulling it apart and looking under the hood.  And I have available time.  This is a great product and needs be supported.  I'm in.  although, questions may arise.

Offline

 

#10 2007-01-12 17:24:14

forty two
Member

Re: Moving images via admin

Okay so I'm just going to start posting what I've been doing on moving images around via the admin here and perhaps it may work.  Perhaps it won't.  So if you don't want to look at lots of busted code or anything of that nature nows your chance to look elsewhere.

Offline

 

#11 2007-01-12 17:28:57

forty two
Member

Re: Moving images via admin

So I started by finding

Code:

function moveMultipleGalleries()

in admin.class.php and simply changed out the code to this:

Code:

 function moveMultipleImages()
  {
    $totalImagesMoved = 0;
    foreach($_REQUEST["sgImages"] as $imageId) {
      $source = $this->config->base_path.$this->config->pathto_galleries.$imageId;
      $target = $this->config->base_path.$this->config->pathto_galleries.$_REQUEST['sgMoveTarget'].'/'.basename($imageId);
      if(file_exists($target)) {
        $this->pushError($this->translator->_g("Unable to copy/move image '%s' because the target image already exists.", $imageId));
      } elseif($this->isSubPath($source, $target, false)) {
        $this->pushError($this->translator->_g("Unable to copy/move gallery '%s' because the target is a child of the source.", $imageId));
      //} elseif(!is_writable($target)) {
      //  $this->pushError($this->translator->_g("Unable to copy/move image '%s': the target is not writable", $galleryId));
      } else {
        if($_REQUEST["sgMoveType"] == 'move') { //Move
          $current = rename($source, $target);
        } else { //Copy
          $current = $this->copyDir($source, $target);
        }
        if($current === false) $this->pushError($this->translator->_g("Unable to copy/move image '%s' because the operation failed.", $imageId));
        else $totalImagesMoved++;
      }
    }
    
    //load target image
    if($totalImagesMoved)
      $this->selectGallery($_REQUEST['sgMoveTarget']);
    
    return $totalImagesMoved;
  }

which did not break anything when I uploaded it (to a testing server).  My next step is to move into the admin templates and edit multimove.tpl.php.  If anyone knows of any other files which use the multimove function please do tell.

Offline

 

#12 2007-01-12 22:21:28

Paul
Member

Re: Moving images via admin

One consideration: how are you going to go about editing the metadata? It would be great if Singapore had a verdadero re-indexing widget, but it only has the thumbnail generator, which doesn't do the same job Please sign the petition to have this feature worked on here: http://www.sgal.org/forum/viewtopic.php?id=1742. So you're going have to edit the metadata files somehow, removing the info from the "old" album and inserting it to the "new" album.

If you can manage to do that, you may as well go on to write a global re-indexing tool for Singapore smile

Offline

 

#13 2007-01-14 15:33:30

forty two
Member

Re: Moving images via admin

the end result of this will be to move the images and the metadata.  here's hoping eh?  smile

Offline

 

#14 2007-03-03 04:13:19

DC
Administrator

Re: Moving images via admin

I was thinking the same thing a client asked me hey how can I move a few images from one gal to another so ya thats one very wanted and needed feature. I am going to also look at your code whan I get a chance.

In the older version i found lots of eorrs when a file was deleted by hand or moved via ftp it would leave old data in the file and you would get a division by zero err I dont see that prob in this newer version.

But im sure problems could arise if the data in the file and the images did not match correctly.

Let us all know how far you get with that mod.
sounds promising.

DC

Last edited by DC (2007-03-03 04:14:00)


To code or not to code that is the question?

Did my response help you out? Consider donating by buying me a slice, Whats this? Read More!
http://www.clickcraft.net/slice.php

Offline

 

#15 2007-03-06 16:21:21

forty two
Member

Re: Moving images via admin

Well I can get as far as:
1) Get full path of image. Copy.
2) Get full path of directory wanting to paste into. Move.
3) Delete the original image from step one.

This is done basically by copying and pasting the move/copy/delete gallery/galleries function and editing a couple lines here and there.  Nothing fancy at all.  Actually compared to the original code I think mine is fairly messy.  I'm just having problems moving the image metadata.  I think what's needed to happen is:

1)Get full path of image, copy (delete after move).  In CSV find find by image name, copy line (delete after move).

2)Move into new directory, paste image (delete original).  In CSV paste copied line to the bottom of document (delete original).

3)In original directory delete appropriate thumbnails and clean up gallery.

@Pavian, Rossh or Egypt: if that sounds correct or completely wrong please let me know.

I know the higher ups are real good and busy.  I am as well, however, I think I have managed to free up some time to start working on this amazing little app again.

Offline