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 ;-)
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.
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
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)
`
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:
You can see the example at: http://mu.thenullpointer.net
Steps:
@ mannkind: Your changes sounds very easy to do. Is it possible to get your changes?
I need no warranty ;-) Thanks for sharing!
@mannkind: Did you upload some files anywhere? It would be very nice to have this feature.
@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
@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 :-)
@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
@lordcoffee, @dwn
Well there I go, assuming things. You'd think I'd know better.
sigh
I apologize lordcoffee and dwn.
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.