Download complete album als ZIP Download complete album als ZIP
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Download complete album als ZIP

Started by Finswimmer, January 18, 2012, 09:33:00 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Finswimmer

Hi,

I have modified the download script, which lets one download all favorite images.

What to do:
1) copy zip.txt (see attachments) to your coppermine-root
2) rename it to zip.php
3) edit include/themes.inc.php
Find: $param['{ALBUM_NAME}'] = $album_name (around line 2893)
Replace with: $param['{ALBUM_NAME}'] = $album_name . ' <a href=zip.php?aid='.$aid.'>Download album as ZIP-Archive;

Download and install the plugin package as described in the plugin docs.


I know, that this is quick and dirty.

Possible improvements:
- Turn on/off in settings
- Language support
- Better position

But this took me 10minutes to create and I wanted to share it.

Αndré

#1
Thank you for your contribution. As this is no genuine plugin but a mod, this thread won't be moved to the plugin contributions board.

Finswimmer

I have changed the naming of the resulting zip archive.
It is now the album name with spaces replaced by "_".
(I hope no one tries to use special chars as album name...)

Attached is the new file.
(Maybe someone can change the one in the first post with this one?)

Αndré

Quote from: Finswimmer on January 18, 2012, 03:17:31 PM
Attached is the new file.
(Maybe someone can change the one in the first post with this one?)
I just added you to the Contributor group, so you can do this yourself from now on.


Quote from: Finswimmer on January 18, 2012, 03:17:31 PM
I hope no one tries to use special chars as album name...
You can use the function replace_forbidden to automatically replace such characters.

fersauce

Hello Finswimmer

I Tried your contribution in my test-server but after modifiying the include/themes.inc.php I get a blank screen...
I open the include/themes.inc.php with dreamweaver and just after replacing your code, I get a lot of bugs (see attachements)

Please, I need that function in my server. Please, can you help me?

this is my original post http://forum.coppermine-gallery.net/index.php/topic,74287.msg357653.html#msg357653

Thank you.

Finswimmer

@fersauce:
I am sorry the replacing line is incomplete.
Try it with: $param['{ALBUM_NAME}'] = $album_name . ' <a href=zip.php?aid='.$aid.'>Download album as ZIP-Archive';

Notice the last ' in front of ;

@André: Although you have addey me to the Contributor group I cannnot change the attachement nor edit my first post.

Αndré

Quote from: Finswimmer on January 26, 2012, 09:59:25 AM
@André: Although you have addey me to the Contributor group I cannnot change the attachement nor edit my first post.
I just re-checked the permissions. It seems that the additional privileges for "Contributors" are just granted in the contribution boards. However, it's very easy to convert this mod to a plugin by using the plugin hook
$param = CPGPluginAPI::filter('theme_thumbnails_title', $param);


Don't hesitate to ask for help while creating the plugin.

fersauce

Great!  it's OK

I love you!

thank you

Finswimmer

@Andre:

The plugin is working so far with i18n for the "download" string.
But my zip.php is now in plugins/albumdownload/ (before it was in coppermine_root_dir).
So now php complains at
  require('include/init.inc.php');
  include('include/archive.php');
which is the very first part of zip.php (as seen on zipdownload.php)

switching it to:
  require('../../include/init.inc.php');
  include('../../include/archive.php');
results in:
PHP Warning:  require_once(include/inspekt.php): failed to open stream: No such file or directory in /var/www/vhosts/default/htdocs/fotos/include/init.inc.php on line 45
PHP Fatal error:  require_once(): Failed opening required 'include/inspekt.php' (include_path='.:') in /var/www/vhosts/default/htdocs/fotos/include/init.inc.php on line 45

It tries to access include/inspekt.php from within plugins/albumdownloads, which cannot work...

How can I solve this?
Thank you!
Tobi

Αndré

Remove
  require('../../include/init.inc.php');
and access the file via
index.php?file=albumdownload/zip

That way the file runs in cpg's context and init.inc.php has already been included.

Finswimmer

Now it navigates to root_dir/fotos/index.php?file=albumdownload/albumZip.php?aid=2
and shows the normal index.php

Starting the file directly via Firefox leads to:
Notice: Undefined variable: superCage in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 31 Notice: Trying to get property of non-object in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 31 Fatal error: Call to a member function getInt() on a non-object in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 31

I guess this is fine as init.inc.php is not "executed", but why does the redirect via index.php?... does not work?

Thanks!

Αndré

root_dir/fotos/index.php?file=albumdownload/albumZip.php?aid=2
should be something like
root_dir/fotos/index.php?file=albumdownload/zip&aid=2

Attaching the current plugin files might help, so I can have a look at the code and test, too.

Finswimmer

This leads to a long list with the files, ended by:
Fatal error: Class 'zip_file' not found in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 42

Function zip_file is in include/archive.php which should be included...

BTW: Normally, it is foo.php?firstParamater=bar&secondParamater=bar
Is this coppermine-specific?

http://tobiaskaminsky.de/albumdownload.zip


Αndré

In albumZip.php, find
include('../../include/archive.php');
and replace with
require('include/archive.php');

Finswimmer

Great!
Now it works.

Thank you.

I will post the final version of this plugin this afternoon.

Αndré

Moving this thread to the plugin contributions board, so you can use and maintain it as announcement thread.

Some suggestions:
1. The "install & configure" actions (and the corresponding functions) aren't need at all IMHO, as they just add extra click to install the plugins. Most plugins without configuration options directly install the plugins.
2. The current albumZip.php file doesn't check if the current user is allowed to view the album and subsequent files. The best way would be to use
$RESTRICTEDWHERE AND
instead of
WHERE
in albumZip.php, but you have to insert something like
get_meta_album_set(0);
before the first occurrence of that variable. I haven't checked that in detail.

Finswimmer

Hmm.
For non-admin user I need $html['{ALBUM_ID}'].
But it is not written to the array (see include/themes.inc.php:2893).

So what can I do?
I am not allowed to edit this line, or?

Thanks
Tobi

Ps: I still cannot edit my first post *weird*

Αndré

You can get the album ID from the URL. Changing
$html['{ALBUM_NAME}'] = $html['{ALBUM_NAME}'] . ' <a href="index.php?file=albumdownload/albumZip&aid='.$html['{ALBUM_ID}'].'">'.$lang_plugin_albumdownload['albumDownload'].'zip</a>';
to
    $superCage = Inspekt::makeSuperCage();
    if ($superCage->get->getInt('album') > 0) {
        $html['{ALBUM_NAME}'] = $html['{ALBUM_NAME}'] . ' <a href="index.php?file=albumdownload/albumZip&aid='.$superCage->get->getInt('album').'">'.$lang_plugin_albumdownload['albumDownload'].'zip</a>';
    }

should work for all users (haven't tested it). I also added a check to include the buttons just for 'real' album, but not for meta albums.

Αndré

The version I got from you breaks the upload function, as it adds white spaces to the HTML output. Removing the trailing spaces and blank lines from codebase.php fixes that issue.

pols1337

This is an interesting plug-in.  While I haven't installed it yet since it seems like it's still under development, I /support!  Many of my users really want this functionality.