function getSubalbumImages($folder) { global $imagelist; if (hasDyanmicAlbumSuffix($folder)) { return; } $album = new Album($gallery, $folder); $images = $album->getImages(); foreach ($images as $image) { $imagelist[] = '/' . $folder . '/' . $image; } $albums = $album->getSubalbums(); foreach ($albums as $folder) { getSubalbumImages($folder); } }
static function printSlideShow($heading = true, $speedctl = false, $albumobj = "", $imageobj = "", $width = "", $height = "") { if (!isset($_POST['albumid']) and !is_object($albumobj)) { echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>"; echo "</div></body></html>"; exit; } global $_zp_flash_player, $_zp_current_image, $_zp_current_album, $_zp_gallery; //getting the image to start with if (!empty($_POST['imagenumber']) and !is_object($imageobj)) { $imagenumber = $_POST['imagenumber'] - 1; // slideshows starts with 0, but zp with 1. } elseif (is_object($imageobj)) { makeImageCurrent($imageobj); $imagenumber = imageNumber() - 1; } else { $imagenumber = 0; } // set pagenumber to 0 if not called via POST link if (isset($_POST['pagenr'])) { $pagenumber = sanitize_numeric($_POST['pagenr']); } else { $pagenumber = 0; } // getting the number of images if (!empty($_POST['numberofimages'])) { $numberofimages = sanitize_numeric($_POST['numberofimages']); } elseif (is_object($albumobj)) { $numberofimages = $albumobj->getNumImages(); } //getting the album to show if (!empty($_POST['albumid']) and !is_object($albumobj)) { $albumid = sanitize_numeric($_POST['albumid']); } elseif (is_object($albumobj)) { $albumid = $albumobj->id; } else { $albumid = -1; } // setting the image size if (!empty($width) and !empty($height)) { $width = sanitize_numeric($width); $height = sanitize_numeric($height); } else { $width = getOption("slideshow_width"); $height = getOption("slideshow_height"); } $option = getOption("slideshow_mode"); // jQuery Cycle slideshow config // get slideshow data $gallery = new Gallery(); if ($albumid <= 0) { // search page $dynamic = 2; $search = new SearchEngine(); $params = $_POST['preserve_search_params']; $search->setSearchParams($params); $images = $search->getImages(0); $searchwords = $search->words; $searchdate = $search->dates; $searchfields = $search->fields; $page = $search->page; if (empty($_POST['imagenumber'])) { $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . abs($albumid)); $album = new Album($gallery, $albumq['folder']); $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page); //$returnpath = rewrite_path('/'.pathurlencode($album->name).'/page/'.$pagenumber,'/index.php?album='.urlencode($album->name).'&page='.$pagenumber); } else { $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page); } $albumtitle = gettext('Search'); } else { $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid); $album = new Album($gallery, $albumq['folder']); $albumtitle = $album->getTitle(); if (!checkAlbumPassword($albumq['folder'], $hint)) { echo gettext("This album is password protected!"); exit; } $dynamic = $album->isDynamic(); $images = $album->getImages(0); // return path to get back to the page we called the slideshow from if (empty($_POST['imagenumber'])) { $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber); } else { $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode($_POST['imagefile']) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile'])); } } // slideshow display section switch ($option) { case "jQuery": $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp'); ?> <script type="text/javascript"> $(document).ready(function(){ $(function() { var ThisGallery = '<?php echo html_encode($albumtitle); ?> '; var ImageList = new Array(); var TitleList = new Array(); var DescList = new Array(); var ImageNameList = new Array(); var DynTime=(<?php echo getOption("slideshow_timeout"); ?> ) * 1.0; // force numeric <?php for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) { if ($dynamic) { $filename = $images[$idx]['filename']; $album = new Album($gallery, $images[$idx]['folder']); $image = newImage($album, $filename); } else { $filename = $images[$idx]; $image = newImage($album, $filename); } $ext = is_valid($filename, $validtypes); if ($ext) { makeImageCurrent($image); $img = getCustomSizedImageMaxSpace($width, $height); //$img = WEBPATH . '/' . ZENFOLDER . '/i.php?a=' . pathurlencode($image->album->name) . '&i=' . urlencode($filename) . '&s=' . $imagesize; echo 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n"; echo 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n"; if (getOption("slideshow_showdesc")) { $desc = $image->getDesc(); $desc = str_replace("\r\n", '<br />', $desc); $desc = str_replace("\r", '<br />', $desc); echo 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n"; } else { echo 'DescList[' . $cntr . '] = "";' . "\n"; } if ($idx == $numberofimages - 1) { $idx = -1; } echo 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n"; $cntr++; } } echo "\n"; $numberofimages = $cntr; ?> var countOffset = <?php echo $imagenumber; ?> ; var totalSlideCount = <?php echo $numberofimages; ?> ; var currentslide = 2; function onBefore(curr, next, opts) { //$(next).parent().animate({opacity: 0}); if (opts.timeout != DynTime) { opts.timeout = DynTime; } if (!opts.addSlide) return; var currentImageNum = currentslide; currentslide++; if (currentImageNum == totalSlideCount) { opts.addSlide = null; return; } var relativeSlot = (currentslide + countOffset) % totalSlideCount; if (relativeSlot == 0) {relativeSlot = totalSlideCount;} var htmlblock = "<span class='slideimage'><h4><strong>" + ThisGallery + ":</strong> "; htmlblock += TitleList[currentImageNum] + " (" + relativeSlot + "/" + totalSlideCount + ")</h4>"; htmlblock += "<img src='" + ImageList[currentImageNum] + "'/>"; htmlblock += "<p class='imgdesc'>" + DescList[currentImageNum] + "</p></span>"; opts.addSlide(htmlblock); } function onAfter(curr, next, opts){ <?php if (!isMyALbum($album->name, ALL_RIGHTS)) { ?> //Only register at hit count the first time the image is viewed. if ($(next).attr( 'viewed') != 1) { $.get("<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow/slideshow-counter.php?album=<?php echo pathurlencode($album->name); ?> &img="+ImageNameList[opts.currSlide]); $(next).attr( 'viewed', 1 ); } <?php } ?> //THE MISSING LINE $(next).parent().height( $(next).find('img').height() + $(next).find('p').height() + $(next).find('h4').height() + 40 ); //.animate({opacity: 1}, 'normal', 'linear'); //getOption('slideshow_onafter'); //make it generic //END MISSING LINE } $('#slides').cycle({ fx: '<?php echo getOption("slideshow_effect"); ?> ', speed: <?php echo getOption("slideshow_speed"); ?> , timeout: DynTime, next: '#next', prev: '#prev', cleartype: 1, before: onBefore, after: onAfter }); $('#speed').change(function () { DynTime = this.value; return false; }); $('#pause').click(function() { $('#slides').cycle('pause'); return false; }); $('#play').click(function() { $('#slides').cycle('resume'); return false; }); }); }); // Documentready() </script> <div id="slideshow" align="center"> <?php // 7/21/08dp if ($speedctl) { echo '<div id="speedcontrol">'; // just to keep it away from controls for sake of this demo $minto = getOption("slideshow_speed"); while ($minto % 500 != 0) { $minto += 100; if ($minto > 10000) { break; } // emergency bailout! } $dflttimeout = getOption("slideshow_timeout"); /* don't let min timeout = speed */ $thistimeout = $minto == getOption("slideshow_speed") ? $minto + 250 : $minto; echo 'Select Speed: <select id="speed" name="speed">'; while ($thistimeout <= 60000) { // "around" 1 minute :) echo "<option value={$thistimeout} " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>"; /* put back timeout to even increments of .5 */ if ($thistimeout % 500 != 0) { $thistimeout -= 250; } $thistimeout += $thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000); } echo "</select> </div>"; } if (!is_object($albumobj)) { // disable controls if calling the slideshow directly on homepage for example ?> <div id="controls"> <div><span><a href="#" id="prev" title="<?php echo gettext("Previous"); ?> "></a></span> <a href="<?php echo $returnpath; ?> " id="stop" title="<?php echo gettext("Stop and return to album or image page"); ?> "></a> <a href="#" id="pause" title="<?php echo gettext("Pause (to stop the slideshow without returning)"); ?> "></a> <a href="#" id="play" title="<?php echo gettext("Play"); ?> "></a> <a href="#" id="next" title="<?php echo gettext("Next"); ?> "></a> </div> </div> <?php } ?> <div id="slides" class="pics"> <?php if ($cntr > 1) { $cntr = 1; } for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) { if ($idx >= $numberofimages) { $idx = 0; } if ($dynamic) { $folder = $images[$idx]['folder']; $dalbum = new Album($gallery, $folder); $filename = $images[$idx]['filename']; $image = newImage($dalbum, $filename); $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename); } else { $folder = $album->name; $filename = $images[$idx]; //$filename = $animage; $image = newImage($album, $filename); $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename); } $ext = is_valid($filename, $validtypes); if ($ext) { $imgnr++; echo "<span class='slideimage'><h4><strong>" . $albumtitle . gettext(":") . "</strong> " . $image->getTitle() . " (" . ($idx + 1) . "/" . $numberofimages . ")</h4>"; if ($ext == "3gp") { echo '</a> <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> <param name="src" value="' . $imagepath . '"/> <param name="autoplay" value="false" /> <param name="type" value="video/quicktime" /> <param name="controller" value="true" /> <embed src="' . $imagepath . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed> </object> <a>'; } elseif ($ext == "mov") { echo '</a> <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> <param name="src" value="' . $imagepath . '"/> <param name="autoplay" value="false" /> <param name="type" value="video/quicktime" /> <param name="controller" value="true" /> <embed src="' . $imagepath . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed> </object> <a>'; } else { makeImageCurrent($image); printCustomSizedImageMaxSpace($alt = '', $width, $height, NULL, NULL, false); //echo "<img src='".WEBPATH."/".ZENFOLDER."/i.php?a=".urlencode($folder)."&i=".urlencode($filename)."&s=".$imagesize."' alt='".html_encode($image->getTitle())."' title='".html_encode($image->getTitle())."' />\n"; } if (getOption("slideshow_showdesc")) { $desc = $image->getDesc(); $desc = str_replace("\r\n", '<br />', $desc); $desc = str_replace("\r", '<br />', $desc); echo "<p class='imgdesc'>" . $desc . "</p>"; } echo "</span>"; } } break; case "flash": if ($heading) { echo "<span class='slideimage'><h4><strong>" . $albumtitle . "</strong> (" . $numberofimages . " images) | <a style='color: white' href='" . $returnpath . "' title='" . gettext("back") . "'>" . gettext("back") . "</a></h4>"; } echo "<span id='slideshow'></span>"; ?> <script type="text/javascript"> $("#slideshow").flashembed({ src:'<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /flowplayer/FlowPlayerLight.swf', width:<?php echo getOption("slideshow_flow_player_width"); ?> , height:<?php echo getOption("slideshow_flow_player_height"); ?> }, {config: { autoPlay: true, useNativeFullScreen: true, playList: [ <?php echo "\n"; $count = 0; foreach ($images as $animage) { if ($dynamic) { $folder = $animage['folder']; $filename = $animage['filename']; $salbum = new Album($_zp_gallery, $folder); $image = newImage($salbum, $filename); $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($salbum->name) . "/" . urlencode($filename); } else { $folder = $album->name; $filename = $animage; $image = newImage($album, $filename); $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . pathurlencode($filename); } $ext = is_valid($filename, array('jpg', 'jpeg', 'gif', 'png', 'flv', 'mp3', 'mp4')); if ($ext) { if ($ext == "flv" || $ext == "mp3" || $ext == "mp4") { $duration = ""; } else { $duration = ", duration: " . getOption("slideshow_speed") / 10; } if ($count > 0) { echo ",\n"; } echo "{ url: '" . FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename) . "'" . $duration . " }"; $count++; } } echo "\n"; ?> ], showPlayListButtons: true, showStopButton: true, controlBarBackgroundColor: 0, showPlayListButtons: true, controlsOverVideo: 'ease', controlBarBackgroundColor: '<?php echo getOption('flow_player_controlbarbackgroundcolor'); ?> ', controlsAreaBorderColor: '<?php echo getOption('flow_player_controlsareabordercolor'); ?> ' }} ); </script> <?php echo "</span>"; echo "<p>"; printf(gettext("Click on %s on the right in the player control bar to view full size."), "<img style='position: relative; top: 4px; border: 1px solid gray' src='" . WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/slideshow/flowplayerfullsizeicon.png' />"); echo "</p>"; break; } ?> </div> </div> <?php }
/** * A helper function that only prints a item of the loop within printAlbumStatistic() * Not for standalone use. * * @param array $album the array that getAlbumsStatistic() submitted * @param string $option "popular" for the most popular albums, * "latest" for the latest uploaded, * "mostrated" for the most voted, * "toprated" for the best voted * "latestupdated" for the latest updated * @param bool $showtitle if the album title should be shown * @param bool $showdate if the album date should be shown * @param bool $showdesc if the album description should be shown * @param integer $desclength the length of the description to be shown * @param string $showstatistic "hitcounter" for showing the hitcounter (views), * "rating" for rating, * "rating+hitcounter" for both. * @param integer $width the width/cropwidth of the thumb if crop=true else $width is longest size. (Default 85px) * @param integer $height the height/cropheight of the thumb if crop=true else not used. (Default 85px) * @param bool $crop 'true' (default) if the thumb should be cropped, 'false' if not * @param bool $firstimglink 'false' (default) if the album thumb link should lead to the album page, 'true' if to the first image of theh album if the album itself has images */ function printAlbumStatisticItem($album, $option, $showtitle = false, $showdate = false, $showdesc = false, $desclength = 40, $showstatistic = '', $width = 85, $height = 85, $crop = true, $firstimglink = false) { global $_zp_gallery; $tempalbum = new Album($_zp_gallery, $album['folder']); if ($firstimglink && $tempalbum->getNumImages() != 0) { $firstimage = $tempalbum->getImages(1); // need only the first so don't get all $firstimage = $firstimage[0]; $modrewritesuffix = getOption('mod_rewrite_image_suffix'); $imagepath = html_encode(rewrite_path("/" . $firstimage . $modrewritesuffix, "&image=" . $firstimage, false)); } else { $imagepath = ""; } $albumpath = html_encode(rewrite_path("/" . pathurlencode($tempalbum->name) . $imagepath, "index.php?album=" . pathurlencode($tempalbum->name) . $imagepath)); echo "<li><a href=\"" . $albumpath . "\" title=\"" . html_encode($tempalbum->getTitle()) . "\">\n"; $albumthumb = $tempalbum->getAlbumThumbImage(); $thumb = newImage($tempalbum, $albumthumb->filename); if ($crop) { echo "<img src=\"" . html_encode($albumthumb->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, TRUE)) . "\" alt=\"" . html_encode($albumthumb->getTitle()) . "\" /></a>\n<br />"; } else { echo "<img src=\"" . html_encode($albumthumb->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE)) . "\" alt=\"" . html_encode($albumthumb->getTitle()) . "\" /></a>\n<br />"; } if ($showtitle) { echo "<h3><a href=\"" . $albumpath . "\" title=\"" . html_encode($tempalbum->getTitle()) . "\">\n"; echo $tempalbum->getTitle() . "</a></h3>\n"; } if ($showdate) { if ($option === "latestupdated") { $filechangedate = filectime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($tempalbum->name)); $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $tempalbum->getAlbumID() . " AND `show` = 1 ORDER BY id DESC"); $lastuploaded = query("SELECT COUNT(*) FROM " . prefix('images') . " WHERE albumid = " . $tempalbum->getAlbumID() . " AND mtime = " . $latestimage['mtime']); $row = db_fetch_row($lastuploaded); $count = $row[0]; echo "<p>" . sprintf(gettext("Last update: %s"), zpFormattedDate(DATE_FORMAT, $filechangedate)) . "</p>"; if ($count <= 1) { $image = gettext("image"); } else { $image = gettext("images"); } echo "<span>" . sprintf(gettext('%1$u new %2$s'), $count, $image) . "</span>"; } else { echo "<p>" . zpFormattedDate(DATE_FORMAT, strtotime($tempalbum->getDateTime())) . "</p>"; } } if ($showstatistic === "rating" or $showstatistic === "rating+hitcounter") { $votes = $tempalbum->get("total_votes"); $value = $tempalbum->get("total_value"); if ($votes != 0) { $rating = round($value / $votes, 1); } echo "<p>" . sprintf(gettext('Rating: %1$u (Votes: %2$u)'), $rating, $tempalbum->get("total_votes")) . "</p>"; } if ($showstatistic === "hitcounter" or $showstatistic === "rating+hitcounter") { $hitcounter = $tempalbum->get("hitcounter"); if (empty($hitcounter)) { $hitcounter = "0"; } echo "<p>" . sprintf(gettext("Views: %u"), $hitcounter) . "</p>"; } if ($showdesc) { echo shortenContent($tempalbum->getDesc(), $desclength, ' (...)'); } echo "</li>"; }
<?php /** * xspf playlist for flv player * * @author Malte Müller (acrylian), Stephen Billard (sbillard) * @version 1.0.5 * @package plugins */ header("content-type:text/xml;charset=utf-8"); require_once "../../zp-core/template-functions.php"; $albumid = sanitize_numeric($_GET["albumid"]); $albumresult = query_single_row("SELECT folder from " . prefix('albums') . " WHERE id = " . $albumid); $album = new Album(new Gallery(), $albumresult['folder']); $playlist = $album->getImages(); echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n"; echo "<title>Sample XSPF Playlist</title>"; echo "<info>http://www.what.de</info>"; echo "<annotation>An example of a playlist with commercial</annotation>"; echo "<trackList>\n"; $imgextensions = array(".jpg", ".jpeg", ".gif", ".png"); foreach ($playlist as $item) { $image = newImage($album, $item); $ext = strtolower(strrchr($item, ".")); if ($ext == ".flv" || $ext == ".mp3" || $ext == ".mp4") { $videoThumb = $image->objectsThumb; if (!empty($videoThumb)) { $videoThumb = '../../' . getAlbumFolder('') . $album->name . "/" . $videoThumb; } echo "\t<track>\n"; echo "\t\t<title>" . $image->getTitle() . " (" . $ext . ")</title>\n";
<form name="albumedit" AUTOCOMPLETE=OFF action="?page=edit&action=save<?php echo $albumdir; ?> " method="POST"> <input type="hidden" name="totalalbums" value="<?php echo sizeof($albums); ?> " /> <?php $currentalbum = 0; foreach ($albums as $folder) { $currentalbum++; $album = new Album($gallery, $folder); $images = $album->getImages(); echo "\n<!-- " . $album->name . " -->\n"; ?> <div class="innerbox" style="padding: 15px;"> <?php printAlbumEditForm($currentalbum, $album); ?> </div> <br /> <?php } ?> </form> </div> <?php
/** * currently this splitts only sitemaps for albums and its images. Spliting the images itself requires a major rework... * * Gets links to all images for all albums (album by album) * * @return string */ function getSitemapImages() { global $_zp_gallery, $sitemap_number; $data = ''; $sitemap_locales = generateLanguageList(); $imagechangefreq = getOption('sitemap_changefreq_images'); $imagelastmod = getOption('sitemap_lastmod_images'); $limit = sitemap_getDBLimit(1); $albums = array(); getSitemapAlbumList($_zp_gallery, $albums, 'passImages'); $offset = $sitemap_number - 1; $albums = array_slice($albums, $offset, SITEMAP_CHUNK); if ($albums) { $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>'); $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'); foreach ($albums as $album) { set_time_limit(120); // Extend script timeout to allow for gathering the images. $albumobj = new Album($_zp_gallery, $album['folder']); $images = $albumobj->getImages(); // print plain images links if available if ($images) { foreach ($images as $image) { $imageobj = newImage($albumobj, $image); $ext = strtolower(strrchr($imageobj->filename, ".")); if (getOption('sitemap_google')) { if ($ext == '.mp3' || $ext == '.txt' || $ext == '.html' || $ext == '.htm') { // since the Google extensions do not cover audio we list mp3s extra to not exclude them! $printimage = true; } else { $printimage = false; } } else { $printimage = true; } if ($printimage) { $date = sitemap_getDateformat($imageobj, $imagelastmod); if (sitemap_multilingual()) { foreach ($sitemap_locales as $locale) { $path = FULLWEBPATH . '/' . rewrite_path($locale . '/' . pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&image=' . urlencode($imageobj->filename), false); $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n\t</url>"); } } else { $path = FULLWEBPATH . '/' . rewrite_path(pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&image=' . urlencode($imageobj->filename), false); $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n\t</url>"); } } } } } $data .= sitemap_echonl('</urlset>'); // End off the <urlset> tag } return $data; }
/** * Processes the check box bulk actions for albums * */ function processAlbumBulkActions() { global $gallery; $action = sanitize($_POST['checkallaction']); $ids = $_POST['ids']; $total = count($ids); $message = NULL; if ($action != 'noaction') { if ($total > 0) { if ($action == 'addtags' || $action == 'alltags') { foreach ($_POST as $key => $value) { $key = postIndexDecode($key); if (substr($key, 0, 10) == 'mass_tags_') { if ($value) { $tags[] = substr($key, 10); } } } $tags = sanitize($tags, 3); } $n = 0; foreach ($ids as $albumname) { $n++; $albumobj = new Album($gallery, $albumname); switch ($action) { case 'deleteall': $albumobj->remove(); break; case 'showall': $albumobj->setShow(1); break; case 'hideall': $albumobj->setShow(0); break; case 'commentson': $albumobj->setCommentsAllowed(1); break; case 'commentsoff': $albumobj->setCommentsAllowed(0); break; case 'resethitcounter': $albumobj->set('hitcounter', 0); break; case 'addtags': $mytags = array_unique(array_merge($tags, $albumobj->getTags())); $albumobj->setTags($mytags); break; case 'cleartags': $albumobj->setTags(array()); break; case 'alltags': $images = $albumobj->getImages(); foreach ($images as $imagename) { $imageobj = newImage($albumobj, $imagename); $mytags = array_unique(array_merge($tags, $imageobj->getTags())); $imageobj->setTags($mytags); $imageobj->save(); } break; case 'clearalltags': $images = $albumobj->getImages(); foreach ($images as $imagename) { $imageobj = newImage($albumobj, $imagename); $imageobj->setTags(array()); $imageobj->save(); } break; } $albumobj->save(); } } return $action; } }
/** * Returns a randomly selected image from the album or its subalbums. (May be NULL if none exists) * * @param mixed $rootAlbum optional album object/folder from which to get the image. * @param bool $daily set to true to change picture only once a day. * @param bool $showunpublished set true to consider all images * * @return object */ function getRandomImagesAlbum($rootAlbum = NULL, $daily = false, $showunpublished = false) { global $_zp_current_album, $_zp_gallery, $_zp_current_search; if (empty($rootAlbum)) { $album = $_zp_current_album; } else { if (is_object($rootAlbum)) { $album = $rootAlbum; } else { $album = new Album($_zp_gallery, $rootAlbum); } } if ($daily && ($potd = getOption('picture_of_the_day:' . $album->name))) { $potd = unserialize($potd); if (date('Y-m-d', $potd['day']) == date('Y-m-d')) { $rndalbum = new Album($_zp_gallery, $potd['folder']); $image = newImage($rndalbum, $potd['filename']); if ($image->exists) { return $image; } } } $image = NULL; if ($album->isDynamic()) { $images = $album->getImages(0); shuffle($images); while (count($images) > 0) { $result = array_pop($images); if (is_valid_image($result['filename'])) { $image = newImage(new Album(new Gallery(), $result['folder']), $result['filename']); } } } else { $albumfolder = $album->getFolder(); if ($album->isMyItem(LIST_RIGHTS) || $showunpublished) { $imageWhere = ''; $albumNotWhere = ''; $albumInWhere = ''; } else { $imageWhere = " AND " . prefix('images') . ".show=1"; $albumNotWhere = getProtectedAlbumsWhere(); $albumInWhere = prefix('albums') . ".show=1"; } $query = "SELECT id FROM " . prefix('albums') . " WHERE "; if ($albumInWhere) { $query .= $albumInWhere . ' AND '; } $query .= "folder LIKE " . db_quote($albumfolder . '%'); $result = query_full_array($query); if (is_array($result) && count($result) > 0) { $albumInWhere = prefix('albums') . ".id in ("; foreach ($result as $row) { $albumInWhere = $albumInWhere . $row['id'] . ", "; } $albumInWhere = ' AND ' . substr($albumInWhere, 0, -2) . ')'; $c = 0; while (is_null($image) && $c < 10) { $result = query_single_row('SELECT COUNT(*) AS row_count ' . ' FROM ' . prefix('images') . ', ' . prefix('albums') . ' WHERE ' . prefix('albums') . '.folder!="" AND ' . prefix('images') . '.albumid = ' . prefix('albums') . '.id ' . $albumInWhere . $albumNotWhere . $imageWhere); $rand_row = rand(0, $result['row_count'] - 1); $result = query_single_row('SELECT ' . prefix('images') . '.filename, ' . prefix('albums') . '.folder ' . ' FROM ' . prefix('images') . ', ' . prefix('albums') . ' WHERE ' . prefix('images') . '.albumid = ' . prefix('albums') . '.id ' . $albumInWhere . $albumNotWhere . $imageWhere . ' LIMIT ' . $rand_row . ', 1'); $imageName = $result['filename']; if (is_valid_image($imageName)) { $image = newImage(new Album(new Gallery(), $result['folder']), $imageName); } $c++; } } } if ($daily && is_object($image)) { $potd = array('day' => time(), 'folder' => $result['folder'], 'filename' => $result['filename']); setThemeOption('picture_of_the_day:' . $album->name, serialize($potd)); } return $image; }
/** For every album in the gallery, look for its file. Delete from the database * if the file does not exist. Do the same for images. Clean up comments that have * been left orphaned. * * Returns true if the operation was interrupted because it was taking too long * * @param bool $cascade garbage collect every image and album in the gallery. * @param bool $complete garbage collect every image and album in the *database* - completely cleans the database. * @param int $restart Image ID to restart scan from * @return bool */ function garbageCollect($cascade = true, $complete = false, $restart = '') { if (empty($restart)) { setOption('last_garbage_collect', time()); /* clean the comments table */ $this->commentClean('images'); $this->commentClean('albums'); $this->commentClean('news'); $this->commentClean('pages'); // clean up obj_to_tag $dead = array(); $result = query_full_array("SELECT * FROM " . prefix('obj_to_tag')); if (is_array($result)) { foreach ($result as $row) { $dbtag = query_single_row("SELECT * FROM " . prefix('tags') . " WHERE `id`='" . $row['tagid'] . "'"); if (!$dbtag) { $dead['id'] = $row['id']; } switch ($row['type']) { case 'album': $tbl = 'albums'; break; default: $tbl = $row['type']; break; } $dbtag = query_single_row("SELECT * FROM " . prefix($tbl) . " WHERE `id`='" . $row['objectid'] . "'"); if (!$dbtag) { $dead['id'] = $row['id']; } } } if (!empty($dead)) { query('DELETE FROM ' . prefix('obj_to_tag') . ' WHERE `id`=' . implode(' OR `id`=', $dead)); } // clean up admin_to_object $dead = array(); $result = query_full_array("SELECT * FROM " . prefix('admin_to_object')); if (is_array($result)) { foreach ($result as $row) { $dbtag = query_single_row("SELECT * FROM " . prefix('administrators') . " WHERE `id`='" . $row['adminid'] . "'"); if (!$dbtag) { $dead['id'] = $row['id']; } switch ($row['type']) { case 'album': $tbl = 'albums'; break; default: $tbl = $row['type']; break; } $dbtag = query_single_row("SELECT * FROM " . prefix($tbl) . " WHERE `id`='" . $row['objectid'] . "'"); if (!$dbtag) { $dead['id'] = $row['id']; } } } if (!empty($dead)) { query('DELETE FROM ' . prefix('admin_to_object') . ' WHERE `id`=' . implode(' OR `id`=', $dead)); } // clean up news2cat $dead = array(); $result = query_full_array("SELECT * FROM " . prefix('news2cat')); if (is_array($result)) { foreach ($result as $row) { $dbtag = query_single_row("SELECT * FROM " . prefix('news') . " WHERE `id`='" . $row['news_id'] . "'"); if (!$dbtag) { $dead['id'] = $row['id']; } $dbtag = query_single_row("SELECT * FROM " . prefix('news_categories') . " WHERE `id`='" . $row['cat_id'] . "'"); if (!$dbtag) { $dead['id'] = $row['id']; } } } if (!empty($dead)) { query('DELETE FROM ' . prefix('news2cat') . ' WHERE `id`=' . implode(' OR `id`=', $dead)); } // Check for the existence of top-level albums (subalbums handled recursively). $sql = "SELECT * FROM " . prefix('albums'); $result = query($sql); $dead = array(); $live = array(''); // purge the root album if it exists $deadalbumthemes = array(); // Load the albums from disk while ($row = db_fetch_assoc($result)) { $valid = file_exists($albumpath = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($row['folder'])) && (hasDynamicAlbumSuffix($albumpath) || is_dir($albumpath) && strpos($albumpath, '/./') === false && strpos($albumpath, '/../') === false); if (!$valid || in_array($row['folder'], $live)) { $dead[] = $row['id']; if ($row['album_theme'] !== '') { // orphaned album theme options table $deadalbumthemes[$row['id']] = $row['folder']; } } else { $live[] = $row['folder']; } } if (count($dead) > 0) { /* delete the dead albums from the DB */ $first = array_pop($dead); $sql1 = "DELETE FROM " . prefix('albums') . " WHERE `id`='{$first}'"; $sql2 = "DELETE FROM " . prefix('images') . " WHERE `albumid`='{$first}'"; $sql3 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid`='{$first}'"; $sql4 = "DELETE FROM " . prefix('obj_to_tag') . " WHERE `type`='albums' AND `objectid`='{$first}'"; foreach ($dead as $albumid) { $sql1 .= " OR `id` = '{$albumid}'"; $sql2 .= " OR `albumid` = '{$albumid}'"; $sql3 .= " OR `ownerid` = '{$albumid}'"; $sql4 .= " OR `objectid` = '{$albumid}'"; } $n = query($sql1); if (!$complete && $n && $cascade) { query($sql2); query($sql3); query($sql4); } } if (count($deadalbumthemes) > 0) { // delete the album theme options tables for dead albums foreach ($deadalbumthemes as $id => $deadtable) { $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `ownerid`=' . $id; query($sql, false); } } } if ($complete) { if (empty($restart)) { /* refresh 'metadata' albums */ $albumids = query_full_array("SELECT `id`, `mtime`, `folder`, `dynamic` FROM " . prefix('albums')); foreach ($albumids as $analbum) { if (($mtime = filemtime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($analbum['folder']))) > $analbum['mtime']) { // refresh $album = new Album($this, $analbum['folder']); $album->set('mtime', $mtime); if ($album->isDynamic()) { $data = file_get_contents($album->localpath); while (!empty($data)) { $data1 = trim(substr($data, 0, $i = strpos($data, "\n"))); if ($i === false) { $data1 = $data; $data = ''; } else { $data = substr($data, $i + 1); } if (strpos($data1, 'WORDS=') !== false) { $words = "words=" . urlencode(substr($data1, 6)); } if (strpos($data1, 'THUMB=') !== false) { $thumb = trim(substr($data1, 6)); } if (strpos($data1, 'FIELDS=') !== false) { $fields = "&searchfields=" . trim(substr($data1, 7)); } } if (!empty($words)) { if (empty($fields)) { $fields = '&searchfields=tags'; } } $album->set('search_params', $words . $fields); $album->set('thumb', $thumb); } $album->save(); zp_apply_filter('album_refresh', $album); } } /* Delete all image entries that don't belong to an album at all. */ $albumids = query_full_array("SELECT `id` FROM " . prefix('albums')); /* all the album IDs */ $idsofalbums = array(); foreach ($albumids as $row) { $idsofalbums[] = $row['id']; } $imageAlbums = query_full_array("SELECT DISTINCT `albumid` FROM " . prefix('images')); /* albumids of all the images */ $albumidsofimages = array(); foreach ($imageAlbums as $row) { $albumidsofimages[] = $row['albumid']; } $orphans = array_diff($albumidsofimages, $idsofalbums); /* albumids of images with no album */ if (count($orphans) > 0) { /* delete dead images from the DB */ $firstrow = array_pop($orphans); $sql = "DELETE FROM " . prefix('images') . " WHERE `albumid`='" . $firstrow . "'"; foreach ($orphans as $id) { $sql .= " OR `albumid`='" . $id . "'"; } query($sql); // Then go into existing albums recursively to clean them... very invasive. foreach ($this->getAlbums(0) as $folder) { $album = new Album($this, $folder); if (!$album->isDynamic()) { if (is_null($album->getDateTime())) { // see if we can get one from an image $images = $album->getImages(0, 0, 'date', 'DESC'); if (count($images) > 0) { $image = newImage($album, array_shift($images)); $album->setDateTime($image->getDateTime()); } } $album->garbageCollect(true); $album->preLoad(); } $album->save(); zp_apply_filter('album_refresh', $album); } } } /* Look for image records where the file no longer exists. While at it, check for images with IPTC data to update the DB */ $start = array_sum(explode(" ", microtime())); // protect against too much processing. if (!empty($restart)) { $restartwhere = ' WHERE `id`>' . $restart . ' AND `mtime`=0'; } else { $restartwhere = ' WHERE `mtime`=0'; } define('RECORD_LIMIT', 5); $sql = 'SELECT * FROM ' . prefix('images') . $restartwhere . ' ORDER BY `id` LIMIT ' . (RECORD_LIMIT + 2); $images = query_full_array($sql); if (count($images) > 0) { $c = 0; foreach ($images as $image) { $sql = 'SELECT `folder` FROM ' . prefix('albums') . ' WHERE `id`="' . $image['albumid'] . '";'; $row = query_single_row($sql); $imageName = internalToFilesystem(ALBUM_FOLDER_SERVERPATH . $row['folder'] . '/' . $image['filename']); if (file_exists($imageName)) { $mtime = filemtime($imageName); if ($image['mtime'] != $mtime) { // file has changed since we last saw it $imageobj = newImage(new Album($this, $row['folder']), $image['filename']); $imageobj->set('mtime', $mtime); $imageobj->updateMetaData(); // prime the EXIF/IPTC fields $imageobj->updateDimensions(); // update the width/height & account for rotation $imageobj->save(); zp_apply_filter('image_refresh', $imageobj); } } else { $sql = 'DELETE FROM ' . prefix('images') . ' WHERE `id`="' . $image['id'] . '";'; $result = query($sql); $sql = 'DELETE FROM ' . prefix('comments') . ' WHERE `type` IN (' . zp_image_types('"') . ') AND `ownerid` ="' . $image['id'] . '";'; $result = query($sql); } if (++$c >= RECORD_LIMIT) { return $image['id']; // avoide excessive processing } } } } return false; }
/** * emits the html for editing album information * called in edit album and mass edit *@param string param1 the index of the entry in mass edit or '0' if single album *@param object param2 the album object *@since 1.1.3 */ function printAlbumEditForm($index, $album) { // Note: This is some pretty confusing spaghetti code with all the echo statements. // Please refactor it so the HTML is readable and easily editable. // FYI: It's perfectly acceptable to drop out of php-parsing mode in a function. // See the move/copy/rename block for an example. global $sortby, $gallery, $_zp_loggedin, $mcr_albumlist, $albumdbfields, $imagedbfields; $tagsort = getTagOrder(); if ($index == 0) { if (isset($saved)) { $album->setSubalbumSortType('manual'); } $suffix = $prefix = ''; } else { $prefix = "{$index}-"; $suffix = "_{$index}"; echo "<p><em><strong>" . $album->name . "</strong></em></p>"; } echo "\n<input type=\"hidden\" name=\"" . $prefix . "folder\" value=\"" . $album->name . "\" />"; echo "\n" . '<input type="hidden" name="tagsort" value=' . $tagsort . ' />'; echo "\n<table>"; echo "\n<td width = \"60%\">\n<table>\n<tr>"; echo "\n<tr>"; echo "<td align=\"right\" valign=\"top\" width=\"150\">" . gettext("Album Title") . ": </td>"; echo '<td>'; print_language_string_list($album->get('title'), $prefix . "albumtitle", false); echo "</td></tr>\n"; echo '<tr><td></td>'; $hc = $album->get('hitcounter'); if (empty($hc)) { $hc = '0'; } echo "<td>"; echo sprintf(gettext("Hit counter: %u"), $hc) . " <input type=\"checkbox\" name=\"reset_hitcounter\"> Reset"; $tv = $album->get('total_value'); $tc = $album->get('total_votes'); echo ' '; if ($tc > 0) { $hc = $tv / $tc; printf(gettext('Rating: <strong>%u</strong>'), $hc); echo "<label for=\"" . $prefix . "reset_rating\"><input type=\"checkbox\" id=\"" . $prefix . "reset_rating\" name=\"" . $prefix . "reset_rating\" value=1> " . gettext("Reset") . "</label> "; } else { echo gettext("Rating: Unrated"); } echo "</td>"; echo '</tr>'; echo "\n<tr><td align=\"right\" valign=\"top\">" . gettext("Album Description:") . " </td> <td>"; print_language_string_list($album->get('desc'), $prefix . "albumdesc", true, NULL, 'texteditor'); echo "</td></tr>"; echo "\n<tr><td align=\"right\" value=\"top\">" . gettext("Album guest user:"******"\n<td><input type='text' size='48' name='" . $prefix . "albumuser' value='" . $album->getUser() . "' /></td></tr>"; echo "\n<tr>"; echo "\n<td align=\"right\">" . gettext("Album password:"******" <br/>" . gettext("repeat:") . " </td>"; echo "\n<td>"; $x = $album->getPassword(); if (!empty($x)) { $x = ' '; } echo "\n<input type=\"password\" size=\"48\" name=\"" . $prefix . "albumpass\""; echo "\nvalue=\"" . $x . '" /><br/>'; echo "\n<input type=\"password\" size=\"48\" name=\"" . $prefix . "albumpass_2\""; echo "\nvalue=\"" . $x . '" />'; echo "\n</td>"; echo "\n</tr>"; echo "\n<tr><td align=\"right\" valign=\"top\">" . gettext("Password hint:") . " </td> <td>"; print_language_string_list($album->get('password_hint'), $prefix . "albumpass_hint", false); echo "</td></tr>"; $d = $album->getDateTime(); if ($d == "0000-00-00 00:00:00") { $d = ""; } echo "\n<tr><td align=\"right\" valign=\"top\">" . gettext("Date:") . " </td> <td width = \"400\"><input type=\"text\" size='48' name=\"" . $prefix . "albumdate\" value=\"" . $d . '" /></td></tr>'; echo "\n<tr><td align=\"right\" valign=\"top\">" . gettext("Location:") . " </td> <td>"; print_language_string_list($album->get('place'), $prefix . "albumplace", false); echo "</td></tr>"; echo "\n<tr><td align=\"right\" valign=\"top\">" . gettext("Custom data:") . "</td><td>"; print_language_string_list($album->get('custom_data'), $prefix . "album_custom_data", true); echo "</td></tr>"; $sort = $sortby; if (!$album->isDynamic()) { $sort[gettext('Manual')] = 'manual'; } $sort[gettext('Custom')] = 'custom'; echo "\n<tr>"; echo "\n<td align=\"right\" valign=\"top\">" . gettext("Sort subalbums by:") . " </td>"; echo "\n<td>"; // script to test for what is selected $javaprefix = 'js_' . preg_replace("/[^a-z0-9_]/", "", strtolower($prefix)); ?> <table> <tr> <td> <select id="sortselect" name="<?php echo $prefix; ?> subalbumsortby" onchange="update_direction(this,'<?php echo $javaprefix; ?> album_direction_div','<?php echo $javaprefix; ?> album_custom_div')"> <?php if (is_null($album->getParent())) { $globalsort = gettext("gallery album sort order"); } else { $globalsort = gettext("parent album subalbum sort order"); } echo "\n<option value =''>{$globalsort}</option>"; $cvt = $type = strtolower($album->get('subalbum_sort_type')); generateListFromArray(array($type), $sort, false, true); ?> </select> </td> <td> <?php if ($type == 'manual' || $type == '') { $dsp = 'none'; } else { $dsp = 'block'; } echo "\n<span id=\"" . $javaprefix . "album_direction_div\" style=\"display:" . $dsp . "\">"; echo " " . gettext("Descending") . " <input type=\"checkbox\" name=\"" . $prefix . "album_sortdirection\" value=\"1\""; if ($album->getSortDirection('album')) { echo "CHECKED"; } echo ">"; echo '</span>'; $flip = array_flip($sort); if (empty($type) || isset($flip[$type])) { $dsp = 'none'; } else { $dsp = 'block'; } ?> </td> </tr> <script type="text/javascript"> $(function () { $('#<?php echo $javaprefix; ?> customalbumsort').tagSuggest({ tags: [<?php echo $albumdbfields; ?> ] }); }); </script> <tr> <td colspan="2"> <span id="<?php echo $javaprefix; ?> album_custom_div" class="customText" style="display:<?php echo $dsp; ?> "> <?php echo gettext('custom fields:'); ?> <input id="<?php echo $javaprefix; ?> customalbumsort" name="<?php echo $prefix; ?> customalbumsort" type="text" value="<?php echo $cvt; ?> "></input> </span> </td> </tr> </table> <?php echo "\n</td>"; echo "\n</tr>"; echo "\n<tr>"; echo "\n<td align=\"right\" valign=\"top\">" . gettext("Sort images by:") . " </td>"; echo "\n<td>"; // script to test for what is selected $javaprefix = 'js_' . preg_replace("/[^a-z0-9_]/", "", strtolower($prefix)); ?> <table> <tr> <td> <select id="sortselect" name="<?php echo $prefix; ?> sortby" onchange="update_direction(this,'<?php echo $javaprefix; ?> image_direction_div','<?php echo $javaprefix; ?> image_custom_div')"> <?php if (is_null($album->getParent())) { $globalsort = gettext("gallery default image sort order"); } else { $globalsort = gettext("parent album image sort order"); } echo "\n<option value =''>{$globalsort}</option>"; $cvt = $type = strtolower($album->get('sort_type')); generateListFromArray(array($type), $sort, false, true); ?> </select> </td> <td> <?php if ($type == 'manual' || $type == '') { $dsp = 'none'; } else { $dsp = 'block'; } echo "\n<span id=\"" . $javaprefix . "image_direction_div\" style=\"display:" . $dsp . "\">"; echo " " . gettext("Descending") . " <input type=\"checkbox\" name=\"" . $prefix . "image_sortdirection\" value=\"1\""; if ($album->getSortDirection('image')) { echo "CHECKED"; } echo ">"; echo '</span>'; $flip = array_flip($sort); if (empty($type) || isset($flip[$type])) { $dsp = 'none'; } else { $dsp = 'block'; } ?> </td> </tr> <script type="text/javascript"> $(function () { $('#<?php echo $javaprefix; ?> customimagesort').tagSuggest({ tags: [<?php echo $imagedbfields; ?> ] }); }); </script> <tr> <td colspan="2"> <span id="<?php echo $javaprefix; ?> image_custom_div" class="customText" style="display:<?php echo $dsp; ?> "> <?php echo gettext('custom fields:'); ?> <input id="<?php echo $javaprefix; ?> customimagesort" name="<?php echo $prefix; ?> customimagesort" type="text" value="<?php echo $cvt; ?> "></input> </span> </td> </tr> </table> <?php echo "\n</td>"; echo "\n</tr>"; echo "\n<tr>"; echo "\n<td align=\"right\" valign=\"top\"></td><td><input type=\"checkbox\" name=\"" . $prefix . "allowcomments\" value=\"1\""; if ($album->getCommentsAllowed()) { echo "CHECKED"; } echo "> " . gettext("Allow Comments") . " "; echo "<input type=\"checkbox\" name=\"" . $prefix . "Published\" value=\"1\""; if ($album->getShow()) { echo "CHECKED"; } echo "> " . gettext("Published") . " "; echo "</td>\n</tr>"; if (is_null($album->getParent())) { echo "\n<tr>"; echo "\n<td align=\"right\" valign=\"top\">" . gettext("Album theme:") . " </td> "; echo "\n<td>"; echo "\n<select id=\"album_theme\" class=\"album_theme\" name=\"" . $prefix . "album_theme\" "; if (!($_zp_loggedin & (ADMIN_RIGHTS | THEMES_RIGHTS))) { echo "DISABLED "; } echo ">"; $themes = $gallery->getThemes(); $oldtheme = $album->getAlbumTheme(); if (empty($oldtheme)) { echo "<option value = \"\" selected=\"SELECTED\" />"; } else { echo "<option value = \"\" />"; } echo "</option>"; foreach ($themes as $theme => $themeinfo) { echo "<option value = \"{$theme}\""; if ($oldtheme == $theme) { echo "selected = \"SELECTED\""; } echo "\t/>"; echo $themeinfo['name']; echo "</option>"; } echo "\n</select>"; echo "\n</td>"; echo "\n</tr>"; } echo "\n</table>\n</td>"; echo "\n<td valign=\"top\">"; $bglevels = array('#fff', '#f8f8f8', '#efefef', '#e8e8e8', '#dfdfdf', '#d8d8d8', '#cfcfcf', '#c8c8c8'); /* **************** Move/Copy/Rename ****************** */ ?> <label for="a-<?php echo $prefix; ?> move" style="padding-right: .5em"> <input type="radio" id="a-<?php echo $prefix; ?> move" name="a-<?php echo $prefix; ?> MoveCopyRename" value="move" onclick="toggleAlbumMoveCopyRename('<?php echo $prefix; ?> ', 'movecopy');"/> <?php echo gettext("Move"); ?> </label> <label for="a-<?php echo $prefix; ?> copy" style="padding-right: .5em"> <input type="radio" id="a-<?php echo $prefix; ?> copy" name="a-<?php echo $prefix; ?> MoveCopyRename" value="copy" onclick="toggleAlbumMoveCopyRename('<?php echo $prefix; ?> ', 'movecopy');"/> <?php echo gettext("Copy"); ?> </label> <label for="a-<?php echo $prefix; ?> rename" style="padding-right: .5em"> <input type="radio" id="a-<?php echo $prefix; ?> rename" name="a-<?php echo $prefix; ?> MoveCopyRename" value="rename" onclick="toggleAlbumMoveCopyRename('<?php echo $prefix; ?> ', 'rename');"/> <?php echo gettext("Rename Folder"); ?> </label> <div id="a-<?php echo $prefix; ?> movecopydiv" style="padding-top: .5em; padding-left: .5em; display: none;"> <?php echo gettext("to"); ?> : <select id="a-<?php echo $prefix; ?> albumselectmenu" name="a-<?php echo $prefix; ?> albumselect" onChange=""> <option value="" selected="selected">/</option> <?php foreach ($mcr_albumlist as $fullfolder => $albumtitle) { $singlefolder = $fullfolder; $saprefix = ""; $salevel = 0; $selected = ""; if ($album->name == $fullfolder) { continue; } // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu. while (strstr($singlefolder, '/') !== false) { $singlefolder = substr(strstr($singlefolder, '/'), 1); $saprefix = " " . $saprefix; $salevel++; } echo '<option value="' . $fullfolder . '"' . ($salevel > 0 ? ' style="background-color: ' . $bglevels[$salevel] . ';"' : '') . "{$selected}>" . $saprefix . $singlefolder . "</option>\n"; } ?> </select> <p style="text-align: right;"> <a href="javascript:toggleAlbumMoveCopyRename('<?php echo $prefix; ?> ', '');"><?php echo gettext("Cancel"); ?> </a> </p> </div> <div id="a-<?php echo $prefix; ?> renamediv" style="padding-top: .5em; padding-left: .5em; display: none;"> <?php echo gettext("to"); ?> : <input name="a-<?php echo $prefix; ?> renameto" type="text" size="35" value="<?php echo basename($album->name); ?> "/><br /> <p style="text-align: right; padding: .25em 0px;"> <a href="javascript:toggleAlbumMoveCopyRename('<?php echo $prefix; ?> ', '');"><?php echo gettext("Cancel"); ?> </a> </p> </div> <br/><br /> <?php echo gettext("Tags:"); $tagsort = getTagOrder(); tagSelector($album, 'tags_' . $prefix, false, $tagsort); echo "\n</td>\n</tr>"; echo "\n</table>"; echo "\n<table>"; if ($album->isDynamic()) { echo "\n<tr>"; echo "\n<td> </td>"; echo "\n<td align=\"right\" valign=\"top\" width=\"150\">" . gettext("Dynamic album search:") . "</td>"; echo "\n<td>"; echo "\n<table class=\"noinput\">"; echo "\n<tr><td >" . urldecode($album->getSearchParams()) . "</td></tr>"; echo "\n</table>"; echo "\n</td>"; echo "\n</tr>"; } echo "\n<tr>"; echo "\n<td> </td>"; echo "\n<td align=\"right\" valign=\"top\" width=\"150\">" . gettext("Thumbnail:") . " </td> "; echo "\n<td>"; $showThumb = getOption('thumb_select_images'); if ($showThumb) { echo "\n<script type=\"text/javascript\">updateThumbPreview(document.getElementById('thumbselect'));</script>"; } echo "\n<select id=\"\""; if ($showThumb) { echo " class=\"thumbselect\" onChange=\"updateThumbPreview(this)\""; } echo " name=\"" . $prefix . "thumb\">"; $thumb = $album->get('thumb'); echo "\n<option"; if ($showThumb) { echo " class=\"thumboption\" value=\"\" style=\"background-color:#B1F7B6\""; } if ($thumb === '1') { echo " selected=\"selected\""; } echo ' value="1">' . gettext('most recent'); echo '</option>'; echo "\n<option"; if ($showThumb) { echo " class=\"thumboption\" value=\"\" style=\"background-color:#B1F7B6\""; } if (empty($thumb) && $thumb !== '1') { echo " selected=\"selected\""; } echo ' value="">' . gettext('randomly selected'); echo '</option>'; if ($album->isDynamic()) { $params = $album->getSearchParams(); $search = new SearchEngine(); $search->setSearchParams($params); $images = $search->getImages(0); $thumb = $album->get('thumb'); $imagelist = array(); foreach ($images as $imagerow) { $folder = $imagerow['folder']; $filename = $imagerow['filename']; $imagelist[] = '/' . $folder . '/' . $filename; } if (count($imagelist) == 0) { $subalbums = $search->getAlbums(0); foreach ($subalbums as $folder) { $newalbum = new Album($gallery, $folder); if (!$newalbum->isDynamic()) { $images = $newalbum->getImages(0); foreach ($images as $filename) { $imagelist[] = '/' . $folder . '/' . $filename; } } } } foreach ($imagelist as $imagepath) { $list = explode('/', $imagepath); $filename = $list[count($list) - 1]; unset($list[count($list) - 1]); $folder = implode('/', $list); $albumx = new Album($gallery, $folder); $image = newImage($albumx, $filename); $selected = $imagepath == $thumb; echo "\n<option"; if ($showThumb) { echo " class=\"thumboption\""; echo " style=\"background-image: url(" . $image->getThumb() . "); background-repeat: no-repeat;\""; } echo " value=\"" . $imagepath . "\""; if ($selected) { echo " selected=\"selected\""; } echo ">" . $image->getTitle(); echo " ({$imagepath})"; echo "</option>"; } } else { $images = $album->getImages(); if (count($images) == 0 && count($album->getSubalbums()) > 0) { $imagearray = array(); $albumnames = array(); $strip = strlen($album->name) + 1; $subIDs = getAllSubAlbumIDs($album->name); if (!is_null($subIDs)) { foreach ($subIDs as $ID) { $albumnames[$ID['id']] = $ID['folder']; $query = 'SELECT `id` , `albumid` , `filename` , `title` FROM ' . prefix('images') . ' WHERE `albumid` = "' . $ID['id'] . '"'; $imagearray = array_merge($imagearray, query_full_array($query)); } foreach ($imagearray as $imagerow) { $filename = $imagerow['filename']; $folder = $albumnames[$imagerow['albumid']]; $imagepath = substr($folder, $strip) . '/' . $filename; if (substr($imagepath, 0, 1) == '/') { $imagepath = substr($imagepath, 1); } $albumx = new Album($gallery, $folder); $image = newImage($albumx, $filename); if (is_valid_image($filename)) { $selected = $imagepath == $thumb; echo "\n<option"; if (getOption('thumb_select_images')) { echo " class=\"thumboption\""; echo " style=\"background-image: url(" . $image->getThumb() . "); background-repeat: no-repeat;\""; } echo " value=\"" . $imagepath . "\""; if ($selected) { echo " selected=\"selected\""; } echo ">" . $image->getTitle(); echo " ({$imagepath})"; echo "</option>"; } } } } else { foreach ($images as $filename) { $image = newImage($album, $filename); $selected = $filename == $album->get('thumb'); if (is_valid_image($filename)) { echo "\n<option"; if (getOption('thumb_select_images')) { echo " class=\"thumboption\""; echo " style=\"background-image: url(" . $image->getThumb() . "); background-repeat: no-repeat;\""; } echo " value=\"" . $filename . "\""; if ($selected) { echo " selected=\"selected\""; } echo ">" . $image->getTitle(); if ($filename != $image->getTitle()) { echo " ({$filename})"; } echo "</option>"; } } } } echo "\n</select>"; echo "\n</td>"; echo "\n</tr>"; echo "\n</table>"; echo "\n<input type=\"submit\" value=\"" . gettext("save album") . "\" />"; }
/** * Show the content of an media album with .flv/.mp4/.mp3 movie/audio files only as a playlist or as separate players with Flowplayer 3 * Important: The Flowplayer 3 plugin needs to be activated to use this plugin. This plugin shares all settings with this plugin, too. * * You can either show a 'one player window' playlist or show all items as separate players paginated. See the examples below. * (set in the settings for thumbs per page) on one page (like on a audio or podcast blog). * * There are two usage modes: * * a) 'playlist' * The playlist is meant to replace the 'next_image()' loop on a theme's album.php. * It can be used with a special 'album theme' that can be assigned to media albums with with .flv/.mp4/.mp3s, although Flowplayer 3 also supports images * Replace the entire 'next_image()' loop on album.php with this: * <?php flowplayerPlaylist("playlist"); ?> * * This produces the following html: * <div class="wrapper"> * <a class="up" title="Up"></a> * <div class="playlist"> * <div class="clips"> * <!-- single playlist entry as an "template" --> * <a href="${url}">${title}</a> * </div> * </div> * <a class="down" title="Down"></a> * </div> * </div> * This is styled by the css file 'playlist.css" that is located within the 'zp-core/plugins/flowplayer3_playlist/flowplayer3_playlist.css' by default. * Alternatively you can style it specifically for your theme. Just place a css file named "flowplayer3_playlist.css" in your theme's folder. * * b) 'players' * This displays each audio/movie file as a separate player on album.php. * If there is no videothumb image for an mp3 file existing only the player control bar is shown. * Modify the 'next_image()' loop on album.php like this: * <?php * while (next_image()): * flowplayerPlaylist("players"); * endwhile; * ?> * Of course you can add further functions to b) like printImageTitle() etc., too. * * @param string $option The mode to use "players", "playlist" or "playlist-mp3". "playlist-mp3" is the same as "playlist" except that only the controlbar is shown (if you are too lazy for custom video thumbs and don't like the empty screen) * @param string $albumfolder For "playlist" mode only: To show a playlist of an specific album directly on another page (for example on index.php). Note: Currently it is not possible to have several playlists on one page */ function flowplayerPlaylist($option = "playlist", $albumfolder = "") { global $_zp_current_image, $_zp_current_album, $_zp_flash_player; $curdir = getcwd(); chdir(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/flowplayer3'); $filelist = safe_glob('flowplayer-*.swf'); $swf = array_shift($filelist); $filelist = safe_glob('flowplayer.audio-*.swf'); $audio = array_shift($filelist); $filelist = safe_glob('flowplayer.controls-*.swf'); $controls = array_shift($filelist); chdir($curdir); $playlistwidth = getOption('flow_player3_playlistwidth'); $playlistheight = getOption('flow_player3_playlistheight'); switch ($option) { case 'playlist': case 'playlist-mp3': $splashimage = getOption('flow_player3_playlistsplashimage'); if ($option == 'playlist-mp3') { $playlistheight = FLOW_PLAYER_MP3_HEIGHT; $splashimage = 'none'; } if (empty($albumfolder)) { $albumname = $_zp_current_album->name; } else { $albumname = $albumfolder; } $album = new Album(new Gallery(), $albumname); if (getOption("flow_player3_playlistautoplay") == 1) { $autoplay = 'true'; } else { $autoplay = 'false'; } $playlist = $album->getImages(); // slash image fetching $videoobj = new Video($album, $playlist[0]); $albumfolder = $album->name; $splashimagerwidth = $playlistwidth; $splashimageheight = $playlistheight; $videoThumbImg = ''; if ($splashimage != 'none') { switch ($splashimage) { case 'albumthumb': $albumthumbobj = $album->getAlbumThumbImage(); getMaxSpaceContainer($splashimagerwidth, $splashimageheight, $albumthumbobj, true); $albumthumb = $albumthumbobj->getCustomImage(null, $splashimagerwidth, $splashimageheight, null, null, null, null, true); $videoThumbImg = '<img src="' . pathurlencode($albumthumb) . '" alt="" />'; break; case 'firstentry': getMaxSpaceContainer($splashimagerwidth, $splashimageheight, $videoobj, true); $videoThumb = $videoobj->getCustomImage(null, $splashimagerwidth, $splashimageheight, null, null, null, null, true); $videoThumbImg = '<img src="' . pathurlencode($videoThumb) . '" alt="" />'; break; } } if ($album->getNumImages() != 0) { if (getOption('flow_player3_playlistnumbered')) { $liststyle = 'ol'; } else { $liststyle = 'div'; } echo '<div class="flowplayer3_playlistwrapper"> <a id="player' . $album->get('id') . '" class="flowplayer3_playlist" style="display:block; width: ' . $playlistwidth . 'px; height: ' . $playlistheight . 'px;"> ' . $videoThumbImg . ' </a> <script type="text/javascript"> // <!-- <![CDATA[ $(function() { $("div.playlist").scrollable({ items:"' . $liststyle . '.clips' . $album->get('id') . '", vertical:true, next:"a.down", prev:"a.up", mousewheel: true }); flowplayer("player' . $album->get('id') . '","' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/flowplayer3/' . $swf . '", { plugins: { audio: { url: "' . $audio . '" }, controls: { url: "' . $controls . '", backgroundColor: "' . getOption('flow_player3_controlsbackgroundcolor') . '", autoHide: "' . getOption('flow_player3_playlistautohide') . '", timeColor:"' . getOption('flow_player3_controlstimecolor') . '", durationColor: "' . getOption('flow_player3_controlsdurationcolor') . '", progressColor: "' . getOption('flow_player3_controlsprogresscolor') . '", progressGradient: "' . getOption('flow_player3_controlsprogressgradient') . '", bufferColor: "' . getOption('flow_player3_controlsbuffercolor') . '", bufferGradient: "' . getOption('fflow_player3_controlsbuffergradient') . '", sliderColor: "' . getOption('flow_player3_controlsslidercolor') . '", sliderGradient: "' . getOption('flow_player3_controlsslidergradient') . '", buttonColor: "' . getOption('flow_player3_controlsbuttoncolor') . '", buttonOverColor: "' . getOption('flow_player3_controlsbuttonovercolor') . '", scaling: "' . getOption('flow_player3_scaling') . '", playlist: true } }, canvas: { backgroundColor: "' . getOption('flow_player3_backgroundcolor') . '", backgroundGradient: "' . getOption('flow_player3_backgroundcolorgradient') . '" },'; $list = ''; foreach ($playlist as $item) { $image = newImage($album, $item); $coverimagerwidth = getOption('flow_player3_playlistwidth'); $coverimageheight = getOption('flow_player3_playlistheight'); getMaxSpaceContainer($coverimagerwidth, $coverimageheight, $image, true); $cover = $image->getCustomImage(null, $coverimagerwidth, $coverimageheight, null, null, null, null, true); $ext = strtolower(strrchr($item, ".")); if ($ext == ".flv" || $ext == ".mp3" || $ext == ".mp4") { $list .= '{ url:"' . ALBUM_FOLDER_WEBPATH . $album->name . '/' . $item . '", autoPlay: ' . $autoplay . ', title: "' . $image->getTitle() . ' <small>(' . $ext . ')</small>", autoBuffering: ' . $autoplay . ', coverImage: { url: "' . urlencode($cover) . '", scaling: "fit" } },'; } // if ext end } // foreach end echo 'playlist: [' . substr($list, 0, -1) . '] }); flowplayer("player' . $album->get('id') . '").playlist("' . $liststyle . '.clips' . $album->get('id') . ':first", {loop:true}); }); // ]]> --> </script>'; ?> <div class="wrapper"> <a class="up" title="Up"></a> <div class="playlist playlist<?php echo $album->get('id'); ?> "> <<?php echo $liststyle; ?> class="clips clips<?php echo $album->get('id'); ?> "> <!-- single playlist entry as an "template" --> <?php if ($liststyle == 'ol') { ?> <li> <?php } ?> <a href="${url}">${title}</a> <?php if ($liststyle == 'ol') { ?> </li> <?php } ?> </<?php echo $liststyle; ?> > </div> <a class="down" title="Down"></a> </div> </div><!-- flowplayer3_playlist wrapper end --> <?php } // check if there are images end break; case 'players': $_zp_flash_player->printPlayerConfig('', '', imageNumber()); break; } // switch end }