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 ;-)
Comments
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 '
';
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
`<?php<br />
$album = mysql_query("SELECT `zipFile` FROM ".prefix("albums")." WHERE `title` = '".getAlbumTitle()."'") or die(mysql_error());
$zipFile = mysql_fetch_array($album);
if ($zipFile[0] != ''){
echo 'Download Images in .zip format Here';
}
?>`
here are the order of the files
first block of code = admin-functions.php
second block of code = admin.php
add tab to the menu
then this past code add to the bottom of album.php right above the </div><div id="credit">
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.
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: 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;)
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.
<URLs removed by moderator>