<?php

// force UTF-8 Ø
if (!defined('WEBPATH')) die();
?>
<!DOCTYPE html>
<html>
<head>
<?php zp_apply_filter('theme_head'); ?>
<title><?php printBareGalleryTitle(); ?> <?php echo gettext("Slideshow"); ?></title>
	<meta http-equiv="content-type" content="text/html; charset=<?php echo LOCAL_CHARSET; ?>" />
	<link rel="Shortcut Icon" href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/photoblog/images/favicon.ico" type="image/x-icon" />
	<?php if (getOption('sweetTitles')) { ?>
		<script type="text/javascript" src="http://<?php echo $_SERVER['HTTP_HOST']; ?>/js/sweet-titles/js/addEvent.js"></script>
		<script type="text/javascript" src="http://<?php echo $_SERVER['HTTP_HOST']; ?>/js/sweet-titles/js/sweetTitles.js"></script>
		<link rel="stylesheet" href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/js/sweet-titles/css/sweetTitles.css" type="text/css" />
	<?php } ?>
	<link rel="stylesheet" href="<?php echo $_zp_themeroot; ?>/css/theme.css" type="text/css" />
	<link rel="stylesheet" href="<?php echo $_zp_themeroot; ?>/css/slideshow.css" type="text/css" />
</head>
<body>
	<?php zp_apply_filter('theme_body_open'); ?>
	<?php
	function printSlideShow_MOD($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true) {
		global $_myFavorites, $_zp_conf_vars;
		if (!isset($_POST['albumid']) AND ! is_object($albumobj)) {
			return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
		}
		//getting the image to start with
		if (!empty($_POST['imagenumber']) AND ! is_object($imageobj)) {
			$imagenumber = sanitize_numeric($_POST['imagenumber']) - 1; // slideshows starts with 0, but zp with 1.
		} elseif (is_object($imageobj)) {
			$imagenumber = $imageobj->getIndex();
		} else {
			$imagenumber = 0;
		}
		// set pagenumber to 0 if not called via POST link
		if (isset($_POST['pagenr'])) {
			$pagenumber = sanitize_numeric($_POST['pagenr']);
		} else {
			$pagenumber = 1;
		}
		// getting the number of images
		if (!empty($_POST['numberofimages'])) {
			$numberofimages = sanitize_numeric($_POST['numberofimages']);
		} elseif (is_object($albumobj)) {
			$numberofimages = $albumobj->getNumImages();
		} else {
			$numberofimages = 0;
		}
		if ($imagenumber < 2 || $imagenumber > $numberofimages) {
			$imagenumber = 0;
		}
		//getting the album to show
		if (!empty($_POST['albumid']) && !is_object($albumobj)) {
			$albumid = sanitize_numeric($_POST['albumid']);
		} elseif (is_object($albumobj)) {
			$albumid = $albumobj->getID();
		} else {
			$albumid = 0;
		}

		if (isset($_POST['preserve_search_params'])) { // search page
			$search = new SearchEngine();
			$params = sanitize($_POST['preserve_search_params']);
			$search->setSearchParams($params);
			$searchwords = $search->getSearchWords();
			$searchdate = $search->getSearchDate();
			$searchfields = $search->getSearchFields(true);
			$page = $search->page;
			$returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
			$albumobj = new AlbumBase(NULL, false);
			$albumobj->setTitle(gettext('Search'));
			$albumobj->images = $search->getImages(0);
		} else {
			if (isset($_POST['favorites_page'])) {
				$albumobj = $_myFavorites;
				$returnpath = $_myFavorites->getLink($pagenumber);
			} else {
				$albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
				$albumobj = newAlbum($albumq['folder']);
				if (empty($_POST['imagenumber'])) {
					$returnpath = $albumobj->getLink($pagenumber);
				} else {
					$image = newImage($albumobj, sanitize($_POST['imagefile']));
					$returnpath = $image->getLink();
				}
			}
		}


		echo slideshow::getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber);
	}
 ?>
	<div id="slideshowpage">
		<?php // /zp_extension/slideshow.php
		// printSlideShow($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true)
		/*
		* @param bool $heading set to true (default) to emit the slideshow breadcrumbs in flash mode
	 	* @param bool $speedctl controls whether an option box for controlling transition speed is displayed
	 	* @param obj $albumobj The object of the album to show the slideshow of. If set this overrides the POST data of the printSlideShowLink()
	 	* @param obj $imageobj The object of the image to start the slideshow with. If set this overrides the POST data of the printSlideShowLink(). If not set the slideshow starts with the first image of the album.
	 	* @param int $width The width of the images (jQuery mode). If set this overrides the size the slideshow_width plugin option that otherwise is used.
	 	* @param int $height The heigth of the images (jQuery mode). If set this overrides the size the slideshow_height plugin option that otherwise is used.
	 	* @param bool $crop Set to true if you want images cropped width x height (jQuery mode only)
	 	* @param bool $shuffle Set to true if you want random (shuffled) order
	 	* @param bool $linkslides Set to true if you want the slides to be linked to their image pages (jQuery mode only)
	 	* @param bool $controls Set to true (default) if you want the slideshow controls to be shown (might require theme CSS changes if calling outside the slideshow.php page) (jQuery mode only)
		*/
		//printSlideShow(true,false); // OK
		printSlideShow_Mod(true,false);
		//printSlideShow(false,false);
		
		// /zp_extension/slideshow2.php
		// printSlideShow($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true)
		/*
		* @param bool $heading set to true (default) to emit the slideshow breadcrumbs in flash mode
	 	* @param bool $speedctl controls whether an option box for controlling transition speed is displayed
	 	* @param obj $albumobj The object of the album to show the slideshow of. If set this overrides the POST data of the printSlideShowLink()
	 	* @param obj $imageobj The object of the image to start the slideshow with. If set this overrides the POST data of the printSlideShowLink(). If not set the slideshow starts with the first image of the album.
	 	* @param int $width The width of the images (jQuery mode). If set this overrides the size the slideshow_width plugin option that otherwise is used.
	 	* @param int $height The heigth of the images (jQuery mode). If set this overrides the size the slideshow_height plugin option that otherwise is used.
	 	* @param bool $crop Set to true if you want images cropped width x height (jQuery mode only)
	 	* @param bool $shuffle Set to true if you want random (shuffled) order
	 	* @param bool $linkslides Set to true if you want the slides to be linked to their image pages (jQuery mode only)
	 	* @param bool $controls Set to true (default) if you want the slideshow controls to be shown (might require theme CSS changes if calling outside the slideshow.php page) (jQuery mode only)
		*/
		//printSlideShow(true,false); ?>
		
		<?php //voir la vitesse printSlideShow(true,true); ?>
	</div>
<?php zp_apply_filter('theme_body_close'); ?>

</body>
</html>