Member
Member
weed   28-02-2007, 22:06
#1

Hi zenformuns

i have to admit, i am very sorry for my bad english

I think it would be nice, to be able to download a whole Gallery as a zipfile. Gallery2 has such a feauture and it is used very often for our photo galleries.

Maybe it is not very difficult to add; a zip on the fly for a complete folder would be enough. A Download basket is - imho - oversized, a simple click to get a whole folder would be a cool hack :-)

My PHP skills are as bad as my english, otherwise i would do such a hack myself ;-)

Developer
Developer
trisweb   28-02-2007, 23:15
#2

Excellent idea! Submit it as an enhancement in the bugtracker :-)

Member
Member
demosthenes705   05-03-2007, 03:11
#3

I got some code, if you would like to try it. It does use a created zip class that someone made, I am not sure how you feel about using other peoples work in your own work.

Member
Member
weed   05-03-2007, 13:21
#4

sound cool - where to find it?

Developer
Developer
trisweb   05-03-2007, 19:06
#5

Is the Zip class licensed under the GPL? Then it's ok!

Member
Member
demosthenes705   05-03-2007, 23:35
#6

http://www.devco.net/code/zipfile.inc.txt

there is the code.

Here is what I did

`function getAlbumListForZip(){

$albumList = mysql_query("SELECT title, folder FROM ".prefix("albums")."") or die(mysql_error());

echo '';

echo '[hr]';

echo 'Album to create ZIP File From: ';

while ($albums = mysql_fetch_array($albumList)){

  echo ''.$albums['title'].'';

  echo "r";

}

echo '';

echo "r
Include Cache";

echo "r
";

echo '';

}`

then I did this

`}else if ($page == "createzip"){

  require_once('class-zipfile.php'); 

if (isset($_POST['all'])){

$albumList = mysql_query("SELECT `folder` FROM ".prefix("albums")."") or die(mysql_error());

while($albums = mysql_fetch_array($albumList)){

  $zipfile = new zipfile();  

 $zipfile -> add_dir("/");

// add the binary data stored in the string 'filedata'

  if ($handle = opendir('../albums/'.$albums['folder'].'/')) {

    while (false !== ($file = readdir($handle))) {

      if ($file != "." && $file != "..") {

        $zipfile -> add_file($file, $file);

        echo $file." was added to the zip for ".$albums['folder']."n

";

      }

    }

    closedir($handle);

    if (file_exists($zipfilename)){

  unset($zipfilename);

}

$filename = "albums/".$albums['folder']."/pictures.zip";

$albumName = $albums['folder'];

$fd = fopen ('../'.$filename, "wb");

$out = fwrite ($fd, $zipfile -> file());

fclose ($fd);

$updateZip = mysql_query("UPDATE ".prefix("albums")." SET `zipFile` = '$filename' WHERE `folder` = '".$albums['folder']."'") or die(mysql_error());

  }

}

}

if (isset($_POST['submit'])){

//print_r($_POST);

 $zipfile = new zipfile();  

 $zipfile -> add_dir("/");

// add the binary data stored in the string 'filedata'

if ($handle = opendir('../albums/'.$_POST['albumName'].'/')) {

   while (false !== ($file = readdir($handle))) {

     if ($file != "." && $file != "..") {

       $zipfile -> add_file($file, $file);

       echo $file." was added to the zipn";

     }

   }

 closedir($handle);

} 

if (isset($_POST['thumbnail'])){

  if ($handle = opendir('../cache/'.$_POST['albumName'].'/')) {

   while (false !== ($file = readdir($handle))) {

     if ($file != "." && $file != "..") {

       $zipfile -> add_file($file, $file);

       echo $file." was added to the zipn";

     }

   }

   closedir($handle);

  }

}

if (file_exists($zipfilename)){

  unset($zipfilename);

}

$filename = "albums/".$_POST['albumName']."/pictures.zip";

$albumName = $_POST['albumName'];

$fd = fopen ('../'.$filename, "wb");

$out = fwrite ($fd, $zipfile -> file());

fclose ($fd);

$updateZip = mysql_query("UPDATE ".prefix("albums")." SET `zipFile` = '$filename' WHERE `folder` = '".$_POST['albumName']."'") or die(mysql_error());

//echo $updateZip;

}`

If you need help, i can explain

Member
Member
demosthenes705   06-03-2007, 03:12
#7

sorry for the double post, i added a table in the albums table called zipFile, its varchar 50. there is probably a better way to do that but.... then in album.php (under theme)

`

Member
Member
mannkind   15-04-2007, 22:51
#8

I was interested in this feature as well, so I decided to give it a try. The code given above didn't appeal to me, so I did something a little different. I'm not caching the zipfile nor am I making any trips to the database.

Changes:

  • index.php: 2 lines
  • functions.php: 1 function to zip the album, ~18 lines
  • template-functions.php: 1 function to display a link, ~5 lines
  • New Class: zipfile, Location: zen/zip/zipfile.php

You can see the example at: http://mu.thenullpointer.net

Steps:

  1. Visit a specific album
  2. Under the pictures (above the geocoded map, if there is one) there is a link "Download a zip file of this album"
  3. Click link to download the zipfile.
Member
Member
lordcoffee   17-04-2007, 09:46
#9

@ mannkind: Your changes sounds very easy to do. Is it possible to get your changes?

Member
Member
mannkind   19-04-2007, 03:05
#10

Well, I would be willing to provide the changes I made. It would be provided as-is without warranty.

Member
Member
lordcoffee   19-04-2007, 08:57
#11

I need no warranty ;-) Thanks for sharing!

Member
Member
lordcoffee   23-04-2007, 10:27
#12

@mannkind: Did you upload some files anywhere? It would be very nice to have this feature.

Member
Member
mannkind   24-04-2007, 02:21
#13

@lordcoffee

I apologize for not responding sooner.

The patch is at http://www.zenphoto.org/trac/wiki/ZenphotoHacks#AlbumZip

Hopefully that'll work for you. Works for me haha

Member
Member
lordcoffee   24-04-2007, 07:44
#14

@mannkind: Thanks one more time! I have a little problem with that "patch-thing". I've saved the code in a "zp108_zip.diff"-file. I can upload it via ftp into my zen folder. But how do "run patch -p1 < zp108_zip.diff"??? Sorry for noob-questions :-)

Member
Member
dwn   24-04-2007, 16:03
#15

@lordcoffe: that command will make patch to your zenphoto installation according to zp108_zip.diff file. What you need is to have some kind of SSH or TELNET access to your server and run that command in shell. If you can't do this, than let me know and i will upload modified files (for latest SVN) somewhere for you.

@mannkind: i am using latest SVN code and patching failed on it. so i did it manually, i can give you output of it, if you want. but i don't have it right now with me. so let me know. everything else works fine - thanks for sharing the code

Member
Member
mannkind   25-04-2007, 01:43
#16

@lordcoffee, @dwn

Well there I go, assuming things. You'd think I'd know better.

  1. I assumed that lordcoffee would have access to the patch command in some way
  2. I assumed that patching against the latest release would be better than patching against the SVN (although that is where I did my original code at -- I just ported it to the release code).

sigh

I apologize lordcoffee and dwn.

Member
Member
xemino   07-08-2009, 23:50
#17

is there a plugin for this? couldn't find anything. i would like to integrate this download function.

Unregistered
Unregistered
Guest   08-08-2009, 04:59
#18

i am using latest SVN code and patching failed on it. so i did it manually, i can give you output of it, if you want. but i don't have it right now with me. so let me know.

Administrator
Administrator
acrylian   08-08-2009, 08:46
#19

@xemino: You will have to add the function printAlbumZip() to your theme's album.php or image.php

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.