<?php include ("header.php");
if (isset($_GET['option'])) $archiveoption = $_GET['option'];
else $archiveoption = 'random';
$archivecount = 12;
?>

<div id="main">

	<div class="center_albums">
		
		<div id="headline">
			<h3>
				<!-- ZP 1.4.6: html_encode(getGalleryIndexURL()) remplace htmlspecialchars(getGalleryIndexURL(false)) -->
				<a href="<?php echo html_encode(getGalleryIndexURL()); ?>" title="<?php echo gettext('Albums Index'); ?>"><?php echo getGalleryTitle(); ?></a>
				<?php echo " &raquo; <em>".gettext("Archive")."</em> &raquo; ";
					switch ($archiveoption) {
						case "random":
						echo gettext('Random Images');
					break;
						case "popular":
						echo gettext('Popular Images');
					break;
						case "latest":
						echo gettext('Latest Images');
					break;
						case "latest-date":
						echo gettext('Latest Images');
					break;
						case "latest-mtime":
						echo gettext('Latest Images');
					break;
						case "mostrated":
						echo gettext('Most Rated Images');
					break;
						case "toprated":
						echo gettext('Top Rated Images');
					break;
					}
				?>
			</h3>
		</div>

	</div> <!-- /center_albums -->
	
	<p class="clear"></p>
	
	<div class="center_search">
	
	<?php 
	if (($archiveoption) != 'random') {
		$images = getImageStatistic($archivecount,$archiveoption);
		foreach ($images as $image) {
		//print_r($image);
		//echo '<br>';
		//$a = html_encode($image->getImageLink());
		// /zenphoto/index.php?album=bouquetins&image=2008-08-30_Bouquetin_9284.jpg
		//$a = htmlspecialchars($image->getFullImage());
		// /zenphoto/albums/bouquetins/2008-08-30_Bouquetin_9284.jpg
		//echo $a;
		?>
		<div class="album">
		
			<div class="thumb">
			<div class="album-tools">
				<?php if (!isImageVideo())  { ?>
					<a class="album-tool" rel="zoom" href="<?php echo htmlspecialchars($image->getFullImage()); ?>" title="<?php echo html_encode($image->getTitle());?>"><img src="<?php echo $_zp_themeroot; ?>/images/search.png" alt="Zoom Image" /></a>
				<?php } ?>
			</div>
				<!-- ZP 1.4.6: getLink() remplace getImageLink() -->
				<a class="wraptocenter" href="<?php echo html_encode($image->getLink()); ?>" title="<?php echo html_encode($image->getTitle()); ?>">
					<img src="<?php echo html_encode($image->getCustomImage(getOption('thumb_size'),null,null,null,null,null,null,true)); ?>" alt="<?php echo html_encode($image->getTitle()); ?>" />
				</a>
			</div>
			<p style="clear: both; "></p>
		</div> 
		<?php
			}
		}
	else {
		for ($i=1; $i<=$archivecount; $i++) { 
			$randomImage = getRandomImages(); 
			if (is_object($randomImage) && $randomImage->exists) {
				//$randomImageURL = html_encode(getURL($randomImage));
				$randomImageURL = html_encode($randomImage->getLink());   // ZP 1.4.6
				//preprint($randomImage);
				$filename = $randomImage->getFileName();
				$album = $randomImage->getAlbumName();
				//echo $randomImageURL;
				//echo getImageThumb($randomImageURL); 
				
				// getFullImage()
				//echo $randomImage->getAlbumName();
				//echo "bla" . $randomImage->encwebpath();
				//echo "getFullImage: " . $randomImage->getFullImage();
				//echo "b: " . $randomImage->encwebpath();
				//echo "getFullImageURL: " . $randomImage->getFullImageURL();
				
				?>

				<div class="album">
					<div class="thumb">
			<div class="album-tools">
				<?php if (!isImageVideo())  { ?>
					<a class="album-tool" rel="zoom" href="<?php echo htmlspecialchars($randomImage->getFullImageURL()); ?>" title="<?php echo html_encode($randomImage->getTitle());?>"><img src="<?php echo $_zp_themeroot; ?>/images/search.png" alt="Zoom Image" /></a>
				<?php } ?>
			</div>
						<a class="wraptocenter" href="<?php echo html_encode($randomImage->getLink()); ?>" title="<?php echo html_encode($randomImage->getTitle()); ?>">
							<?php //printThumbs($randomImageURL); ?>
							<img src="<?php echo html_encode($randomImage->getCustomImage(getOption('thumb_size'),null,null,null,null,null,null,true)); ?>" alt="<?php echo html_encode($randomImage->getTitle()); ?>" />
							<!--img src="zp-core/i.php?a='.$album.'&i='.$filename.'&s=thumb" class="img_archive" /-->
						</a>
					</div>
	
					<p style="clear: both; "></p>
				</div> 
			<?php }
			}
		}
	?>
					
	</div> <!-- /center_search -->


	<div id="sidebar">
		<?php printSearchForm( '','searchform','',gettext('OK'),"$_zp_themeroot/images/drop.gif",null,null,"$_zp_themeroot/images/reset.gif" ); ?>
		<p class="titreBar"><?php echo gettext('Date Archive'); ?></p>
			<?php printAllDates('archive-menu','year','month','desc'); ?>
		<p class="titreBar margeTop"><?php echo gettext('Archive'); ?></p>
			<ul id="listArchive">
			<li><a href="?p=archive&amp;option=popular"><?php echo gettext('most popular images'); ?></a></li>
			<li><a href="?p=archive&amp;option=latest"><?php echo gettext('latest uploaded images'); ?></a></li>
			<li><a href="?p=archive&amp;option=latest-date"><?php echo gettext('latest uploaded, but fetched by date'); ?></a></li>
			<!-- Uploaded time -> mtime -->
			<li><a href="?p=archive&amp;option=latest-mtime"><?php echo gettext('latest uploaded, but fetched by mtime'); ?></a></li>
			<li><a href="?p=archive&amp;option=mostrated"><?php echo gettext('most voted'); ?></a></li>
			<li><a href="?p=archive&amp;option=toprated"><?php echo gettext('best voted'); ?></a></li>
			<li><a href="?p=archive&amp;option=random"><?php echo gettext('random'); ?></a></li>
			</ul>
		<p class="titreBar margeTop"><?php echo gettext('Popular Tags'); ?></p>
			<div id="tag_cloud">
				<?php printAllTagsAs('cloud','hor-list','results',false,true,$maxfontsize = 1.4,$maxcount = 100, $mincount = 5,$limit = 20, $minfontsize = 0.6); ?>
			</div>		
	</div>
		
	
	
	<div class="paging">
	<?php if ( (getPrevPageURL()) || (getNextPageURL()) ) { ?>
	<?php //printPageListWithNav( gettext('&lsaquo; Previous'),gettext('Next &rsaquo;'),false,'true','pagelist','',true,'5' ); ?>
	<?php } ?>
	<?php if (function_exists('printAlbumMenu')) { ?>
		<div id="albumjump">
			<?php printAlbumMenu('jump',true); ?>
		</div>
	<?php } ?>
	</div>

</div>

<?php include("footer.php"); ?>