<?php
$fs = new Ofthedead_Filter_Slug();
//Zend_Debug::dump($this->videos);

?>
<div class="videos <?= $this->containerClass ?>">
	<header>
		<h1>Videos</h1>
	</header>
<?php foreach ($this->videos as $videoEntry): ?>

	<?php

	//Zend_Debug::dump($videoEntry);
	$watchUrl = $this->url(array(
					'videoId'=>$videoEntry->getVideoId(),
					'key'=>$fs->filter($videoEntry->getVideoTitle())),
					'videos-view',true);
	$duree = new Zend_Date( array('second'=>$videoEntry->getVideoDuration() ));
	?>
	<article>
		<header>
			<h2><a href="<?= $watchUrl ?>"><?= $videoEntry->getVideoTitle() ?></a></h2>
			<?php /*<span class="meta">
				<?= $this->translate('#vue %d fois#', $videoEntry->getVideoViewCount()) ; ?>
				 - <?= $duree->toString("HH:mm:ss") ?>
			</span> */ ?>
		</header>
		
	<?php if($this->showVideoInList) : ?>
		<div class="video-wrapper">

			<div class="video-container">

				<iframe id="player<?= $videoEntry->getVideoId() ?>" type="text/html" width="100%" height="auto"
	  			src="http://www.youtube.com/embed/<?= $videoEntry->getVideoId() ?>?enablejsapi=1&origin=<?= $this->serverUrl() ?>"
	  frameborder="0"></iframe>
  			</div>
  		</div>
	<?php else:


		$videoThumbnails = $videoEntry->getVideoThumbnails();
		$tn = null;
		$tn = $videoThumbnails[0]['url'];
		/*if(count($videoThumbnails) > 1)		{ $tn = $videoThumbnails[1]['url']; }
		elseif(count($videoThumbnails)== 1) { $tn = $videoThumbnails[0]['url']; }*/
		?>
		<?php if(!is_null($tn)): ?>
		<img src="<?= $tn ?>" alt="<?= $videoEntry->getVideoTitle() ?>" class="videoTn" />
		<?php endif; ?>		
		<?= $videoEntry->getVideoDescription()?'<div>'.$videoEntry->getVideoDescription().'</div>':''; ?>
		<footer>
			<a href="<?= $watchUrl ?>"><?= $this->translate('#watch the video#') ?></a>
		</footer>
	<?php endif; ?>
	</article>
<?php endforeach; ?>
</div>