/** * * Prints a download link for an album zip of the current album (therefore to be used only on album.php/image.php). * This function only creates a download count and then redirects to the original Zenphoto album zip download. * * @param string $linktext * @param object $albumobj * @param bool $fromcache if true get the images from the cache */ function printDownloadAlbumZipURL($linktext = NULL, $albumobj = NULL, $fromcache = NULL) { global $_zp_current_album; $request = parse_url(getRequestURI()); if (isset($request['query'])) { $query = parse_query($request['query']); } else { $query = array(); } if (is_null($albumobj)) { $albumobj = $_zp_current_album; } if (!is_null($albumobj) && !$albumobj->isDynamic()) { $file = $albumobj->name . '.zip'; DownloadList::addListItem($file); if (getOption('downloadList_showdownloadcounter')) { $downloaditem = DownloadList::getListItemFromDB($file); if ($downloaditem) { $downloadcount = ' - ' . sprintf(ngettext('%u download', '%u downloads', $downloaditem['data']), $downloaditem['data']); } else { $downloadcount = ' - ' . gettext('0 downloads'); } $filesize = '<small>' . $downloadcount . '</small>'; } else { $filesize = ''; } if (!empty($linktext)) { $file = $linktext; } $query['download'] = $albumobj->name; $query['albumzip'] = 'true'; if ($fromcache) { $query['fromcache'] = 'true'; } $link = FULLWEBPATH . '/' . preg_replace('~^' . WEBPATH . '/~', '', $request['path']) . '?' . http_build_query($query); echo '<a href="' . html_encode($link) . '" rel="nofollow" class="downloadlist_link">' . html_encode($file) . '</a>' . $filesize; } }
/** * * Prints a download link for an album zip of the current album (therefore to be used only on album.php/image.php). * This function only creates a download count and then redirects to the original album zip download. * * @param string $linktext * @param object $albumobj * @param bool $fromcache if true get the images from the cache */ function printDownloadAlbumZipURL($linktext = NULL, $albumobj = NULL, $fromcache = NULL) { global $_zp_current_album; $request = parse_url(getRequestURI()); if (isset($request['query'])) { $query = parse_query($request['query']); } else { $query = array(); } if (is_null($albumobj)) { $albumobj = $_zp_current_album; } if (!is_null($albumobj)) { $query['albumzip'] = 'true'; if (get_class($albumobj) == 'favorites') { $query['download'] = $file = gettext('My favorites'); $query['user'] = $albumobj->name; $instance = $query['instance'] = $albumobj->instance; if ($instance) { $file .= '[' . $instance . ']'; $query['download'] .= '[' . $instance . ']'; } $file .= '.zip'; } else { $query['download'] = $albumobj->name; $file = $albumobj->name . '.zip'; } if ($fromcache) { $query['fromcache'] = 'true'; } DownloadList::addListItem($file); if (getOption('downloadList_showdownloadcounter')) { $downloaditem = DownloadList::getListItemFromDB($file); if ($downloaditem) { $downloadcount = $downloaditem['data']; } else { $downloadcount = 0; } $filesize = '<small> - ' . sprintf(ngettext('%u download', '%u downloads', $downloadcount), $downloadcount) . '</small>'; } else { $filesize = ''; } if (!empty($linktext)) { $file = $linktext; } $link = preg_replace('~^' . WEBPATH . '/~', '', $request['path']); echo '<a href="' . FULLWEBPATH . '/' . html_encode(pathurlencode($link)) . '?' . http_build_query($query) . '" rel="nofollow class="downloadlist_link"">' . html_encode($file) . '</a>' . $filesize; } }