<?

class DailyMotion
{
	var $dom, $idvideo, $title, $video;

	function videoTitle()
	{
		return $this->title;
	}
	
	function pagination()
	{
		return true;
	}
		
	function tag($tag, $page = 1) 
	{
		if ($page <= 0) $page = 1;
		
		$tag = str_replace(' ', '+', $tag);
		$feed = ('http://www.dailymotion.com/rss/tag/'.$tag.'/'.$page);
		$this->dom = getFeed($feed);
	}
	
	function video($id) 
	{
		$this->idvideo = $id;
	}
	
	function player()
	{
		?>
		<embed src="http://www.dailymotion.com/swf/<?=$this->idvideo?>" 
			width="425" height="355" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> 
		</embed>
		<?
	}

	function view($tag)
	{
		$videos = $this->dom->getElementsByTagName("item");
	
		$j = 0;
		foreach ($videos as $video)
		{
			$id = $video->getElementsByTagName("id")->item(0)->textContent;
			
			if ($j == 0)
				$this->idvideo = $id;
			
			echo '<div class="video">';
				$title = $video->getElementsByTagName("title")->item(0)->textContent;
				echo '<p><a href="'.BASE_URL.'/2/video/'.$tag.'/'.$id.'.html">'.$title.'</a></p>';
				
				$foto = $video->getElementsByTagNameNS("http://search.yahoo.com/mrss", "thumbnail");
				
				$foto = $foto->item(0)->getAttribute("url");
				$tiempo = $video->getElementsByTagName("content");
				$tiempo = $tiempo->item(0)->getAttribute("duration");
				
				$i = 0;
				echo '<div class="img">';
					echo '<a href="'.BASE_URL.'/2/video/'.$tag.'/'.$id.'.html"><img src="'.$foto.'" alt="'.$title.'" class="fotometacafe" /></a>';
				echo '</div>';
				
				echo '<p class="links"><a href="'.BASE_URL.'/2/video/'.$tag.'/'.$id.'.html">'._VIEW.'</a> '._DURATION.': '.minutes($tiempo).'</p>';
				
				$tags = $video->getElementsByTagNameNS("http://www.itunes.com/dtds/podcast-1.0.dtd", "keywords")->item(0)->textContent;
				$tags = explode(",", $tags);
				
				echo '<div class="tags">'; echo 'tags: ';
				foreach ($tags as $palabra)
				{
					echo '<a href="'.BASE_URL.'/2/tag/'.$palabra.'.html">'.$palabra.'</a> ';
				}
				echo '</div>';
				
			echo '</div>';
			
			$j++;
		}
	}	
	
	function videoInfo()
	{
	}
	
}

?>