ItemRotate, the ability to rotate multiple Photos at once

xobes

Joined: 2007-08-31
Posts: 12
Posted: Fri, 2007-08-31 14:06

I am new to these forums, this is my first post. I looked around yesterday for a G2 module that would allow me to rotate a group of Photos all at once (similar to the delete and move group commands). Since I could not find none, I hacked one together.

I am not a professional coder, though I like to code. My solution is what I called it, a hack, and at that it's probably not very well written.

I stopped working on it when I got it to successfully rotate several images at once. I'm sure that there are bugs that can be exposed, bad coding style, and all the things you'd expect from a novice coder.

That said, I'm looking for the right place to submit my code to the masses since so many people have requested group editing capabilities. The thing I use the most is the rotate (counter clockwise to be specific), but I implemented C 90*, 180*, and CC 90* all at the same time (since that was easy enough to do).

I had to modify (add a chunk of code) to modules/core/module.inc, as well as create two new files (copy and edit from ItemMove* and ItemEditRotate*). I created: modules/core/ItemRotate.inc and modules/core/templates/ItemRotate.tpl (note: I'm at work, not at home, I can't log into my machine at home and thus I may not have recalled the exact paths or all the details correctly.)

I would like to know where the appropriate place to submit my changes would be. I realize that the effort I have made will probably be ignored as there is a more powerful, broad editing patch underway.

I learned everything I needed to know to code this last night -- don't expect it to be bug-free, I don't have a clue where I may have overlooked something that will destroy my gallery. I would love to hear from one of the gallery developers as to what I can do to make my contribution more useful to everyone and possibily get it added (high hopes) in a cleaned up form to the main gallery2 tree.

If you can tell me where I need to post my files I'll post them. In the mean time, they'll stay on my computer.

- AZ

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2007-08-31 15:10

You are welcome to post your files here in this thread. With some directions to implement.
As well as add a patch file to:
http://sourceforge.net/tracker/?group_id=7130&atid=307130
If you keep the patch up to date with the latest version it has a much better chance of being added to the core.

If you post it here be prepared for support and bug reports.

Thanks for your contribution I know that it is a feature people want.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
xobes

Joined: 2007-08-31
Posts: 12
Posted: Fri, 2007-08-31 16:13

I might try to submit a patch later, another option is to treat it like a module... Though I'm not sure how to do that. Truth be told, I've been using gallery for only a couple weeks now.

I will probably post my files here later tonight. If people are interested in it I may work on it further. Presently, it does what I need and can probably be expanded to do more than just basic rotation.

Thanks for the tip!

- AZ

 
xobes

Joined: 2007-08-31
Posts: 12
Posted: Fri, 2007-08-31 22:47

Note: I would recommend that you edit your version of module.inc instead of using mine directly.

You will need to add:

Quote:
if (!$isRoot && isset($permissions[$itemId]['core.delete']) && ($itemTypeNames[0]=="Photo")) {
/* Specific translations: _('Rotate Album') _('Rotate Photo') _('Rotate Movie') */
$links[$itemId][] =
array('text' => $this->_translate(
array('text' => 'Rotate %s', 'arg1' => $itemTypeNames[0]),
$itemTypeNames[2]),
'params' => array('view' => 'core.ItemAdmin',
'subView' => 'core.ItemRotate',
'itemId' => $item->getParentId(),
'selectedId' => $itemId,
'return' => 1));
//print "<pre>az: itemTypeNames[0] = " . $itemTypeNames[0] . "</pre>\n";
}

modules/core/module.inc
modules/core/ItemRotate.inc
modules/core/templates/ItemRotate.tpl

The remaining two files are new (copied and heavily edited)

- AZ

 
xobes

Joined: 2007-08-31
Posts: 12
Posted: Sat, 2007-09-01 00:59

This will need further testing, it seems to only work (not error out and say someone s making a conflicting change) after an item has already been rotated. I think it might have something to do with the serialnumber, or the optional argument "preferred" to the GalleryCoreApi::applyToolkitOperation function.

It does work though, after I use the default method to rotate one photo.

 
heinztomato

Joined: 2008-02-11
Posts: 3
Posted: Thu, 2008-09-18 08:36

Thank you so much. You saved me A LOT OF TIME doing stupid boring things :)

Worked great for me.

 
sveirs
sveirs's picture

Joined: 2008-12-24
Posts: 1
Posted: Wed, 2008-12-24 08:00

Thanks! It worked well for me as well.

For those new to the modules directory out there (like me), one clarification:

You need to cut and paste the above code snippet into the right section of modules/core/modules.inc, specifically the block of code that generates the various options within the drop-down menu below each photo (e.g. "Add Photo to Cart" "Delete Photo" ...). In my version of Gallery2 this block of code starts with:

$links = array();
foreach ($items as $item) {

Within that foreach loop, there is a sequence of code blocks that are similar to the above snippet -- each is associated with a different option in the drop-down menu. I put the snippet at the end of this sequence of code blocks and -presto- the "Rotate Photo" pops up at the end of the list after "Move Photo" after I reload the web page (thereby running the new version of modules.inc). Obviously you could put the rotation snippet first in the sequence and have the "Rotate Photo" option appear at the top of the drop-down list (e.g before "Add Photo to Cart" in my case).

Here's to open source! And to xobes.

 
Helmo

Joined: 2009-04-03
Posts: 1
Posted: Fri, 2009-04-03 09:44

Many thanks for this.

I only had to make a minor modification to get it working in a non-English interface. The use of "Photo" should in my opinion be replaced with $this->_translate("Photo").

A patch against Gallery 2.3 is attached.

 
squirrelproductions

Joined: 2004-12-02
Posts: 8
Posted: Sat, 2009-07-18 22:45

Thank you so much for this. This will surely save me hours of work by being able to rotate images in batches instead of individually.

 
dtto

Joined: 2006-05-15
Posts: 8
Posted: Mon, 2010-01-04 00:24

I had this working at some point, but now it seems to be broken. Is anyone else having a similar issue?

 
Jonreynolds

Joined: 2008-03-09
Posts: 96
Posted: Wed, 2010-09-01 22:47

You star xobes!

This is why I love the open source community so much!

Thank you!