question on calling archivemodule

jerryh

Joined: 2013-02-04
Posts: 27
Posted: Thu, 2013-02-28 17:44

I am working on extending some modules and reusing the archive module. I saw the previous thread about calling
ArchiveExtractToolkit()::performOperation($mimeType, 'extract', $filename, $destFilename, array());

It appears to be completing performOperation ok, however, I am getting an "Http: Upload failed" message after the archive was called. Trying to track down where the error is coming from. any ideas on tracking this down.

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Thu, 2013-02-28 18:41

Along the same lines... How does ItemAdd module know about archiveupload? When I go through AddItem from WEb, i put in archive uload item, how does it know about handling and archive through there

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2013-03-01 01:15
Quote:
How does ItemAdd module know about archiveupload

first archiveupload registers a factory registration:

$ret = GalleryCoreApi::registerFactoryImplementation(
	    'GalleryToolkit', 'ArchiveExtractToolkit', 'ArchiveUpload',
	    'modules/archiveupload/classes/ArchiveExtractToolkit.class', 'archiveupload', null);

then archiveupload registers a toolkit operation which describes the operation to gallery and the mimetype requirement:

$ret = GalleryCoreApi::registerToolkitOperation('ArchiveUpload',
							array('application/zip'),
							'extract',
							array(),
							'extract files from an archive');

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Fri, 2013-03-01 08:57
 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Fri, 2013-03-01 15:02

Thanks. So when archive toolkit is registered, it is suppose to pick up any files that are of type "application/zip", correct?
So when I go through my "additems" in another module, why does it not recognize the "zip" files and do the same thing?
In another module am I suppose to do the registration again? Trying to connect things....

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Fri, 2013-03-01 15:09

So when registering the toolkit operation, its supposed to be registering like a callback.. When I encounter "application/zip" mime types, use this toolkit/callback. Which sounds great.

So in my situation, when I add a new module to extend ItemAdd to do some additional things, do I need to register
$ret = GalleryCoreApi::registerToolkitOperation('ArchiveUpload',
array('application/zip'),
'extract',
array(),
'extract files from an archive');

with that module so it knows to pick it up?

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Fri, 2013-03-01 15:42

Probably better to copy whatever class/methods you want from archiveupload into your new module, keep everything within one module and use the example code as a guide to registering things.

--
dakanji.com

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2013-03-01 15:46

Gallery is built on a foundation of Object Oriented Programming (OOP) - no module is "aware" of another.
So when an item is added gallery core module asks "which toolkits are registered to handle this mimetype or the operation we need to perform next"

All we know here is that you're extending itemAdd. We have no other details except maybe you're interested in extracting.
My advice is to find a module that does something similar to what you want and read through it's code.
You could also let us in on what type of extending you are doing and we may have more advice.

-s
________________________________
All New jQuery Minislideshow for G2/G3