update search module
authorGautier Thibault <gthibault@universcine.com>
Tue, 20 Apr 2010 18:30:24 +0200
changeset 72 b1bc73ec3bcc
parent 71 77de27265833
child 73 008defa5256d
update search module
web/thdProject/apps/frontend/modules/search/actions/components.class.php
web/thdProject/apps/frontend/modules/search/actions/viewSearchListAction.class.php
web/thdProject/apps/frontend/modules/search/templates/_searchList.php
web/thdProject/apps/frontend/modules/search/templates/_selectedFilm.php
web/thdProject/apps/frontend/modules/search/templates/viewSearchListSuccess.php
--- a/web/thdProject/apps/frontend/modules/search/actions/components.class.php	Tue Apr 20 17:30:13 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/search/actions/components.class.php	Tue Apr 20 18:30:24 2010 +0200
@@ -7,7 +7,31 @@
   }
   
   public function executeSelectedFilm() {
-	
+	// Get image filename
+    $images = $this->film->getImages();
+    $this->imageFilename = null;
+
+    if ($images) {
+      $image = $images[0];
+      $this->imageFilename = $image->getFile();
+    }
+    
+    // Get Tags
+    $tags = $this->film->getTagsArray();
+    $this->tagList = null;
+    if ($tags) {
+    	$this->tagList = $tags;
+    }
+    
+
+    // Get video filename
+    $videos = $this->film->getVideos();
+    $this->videoFilename = null;
+
+    if ($videos) {
+      $video = $videos[0];
+      $this->videoFilename = $video->getFile();
+    }
   }  
     
   
--- a/web/thdProject/apps/frontend/modules/search/actions/viewSearchListAction.class.php	Tue Apr 20 17:30:13 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/search/actions/viewSearchListAction.class.php	Tue Apr 20 18:30:24 2010 +0200
@@ -9,7 +9,7 @@
     $this->filter = (string) $request->getParameter('filter', 'all');
     $pageNb = (int) $this->getRequestParameter('page_nb', 1);
     $this->pageIndex = $pageNb -1;
-    $this->pageNbItems = 10;
+    $this->pageNbItems = 11;
     $this->indexNbItems = 2;
     $this->videoPath = sfConfig::get('app_player_videoPath');
     
@@ -26,7 +26,9 @@
 
     if(!empty($primaryKeys))
     {
-      $this->searchFilms = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys);       
+     
+      $this->searchFilms = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys);
+      $this->selectedFilm = $this->searchFilms->getFirst();     
     }
     else
     {
--- a/web/thdProject/apps/frontend/modules/search/templates/_searchList.php	Tue Apr 20 17:30:13 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/search/templates/_searchList.php	Tue Apr 20 18:30:24 2010 +0200
@@ -2,12 +2,15 @@
 	<ul class="film-list">
   <?php
   foreach($searchFilms as $item):
+  if ($item != $selectedFilm){
     $tagFilmUri = url_for('@editor?ref='.$item->getRef().'&film_slug='.$item->getSlugUrl());
   ?>
     <li class="film-item">
       <?php include_component('partials', 'filmItem', Array('film' => $item, 'actionUri' => $tagFilmUri)); ?>
       <div class="tag-action"><a href="<?php echo $tagFilmUri ?>" class="link-button">Tagger le film</a></div>
     </li>
-  <?php endforeach; ?>
+  <?php
+  }
+   endforeach; ?>
   </ul>
 </div>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/search/templates/_selectedFilm.php	Tue Apr 20 17:30:13 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/search/templates/_selectedFilm.php	Tue Apr 20 18:30:24 2010 +0200
@@ -1,64 +1,106 @@
-<div id="player">
-<script>
-function launchSelected(video) {
-	  var video = video;
-	  $f("player-ba", "flashes/flowplayer-3.1.0.swf", {
-			// configuration for a clip
-			clip: {
-				autoPlay: true,
-		    	autoBuffering: true,
-		    	scaling: 'fit',
-				// url of the file
-				url: video
-			},
-			// setup controlbar to use skins
-			plugins: {
-			  	controls: conf.skins.universcine
-			}
-	  });
-	}
-</script>  	
-	<div id="player-ba" class="player-ba" style="background:transparent url('images/test/anna_m/capt720.jpg') no-repeat;">
-		<div class="infos">
-	    	<a href="http://embryon/videos/001009_l-humanite.f4v" onclick="launchSelected(this.href);return false;" class="title">Anna M</a><br/><span class="film-infos">De <b>Michel Spinosa</b></span>
-	    </div>
-	    <div id="play">
-			<a href="http://embryon/videos/001009_l-humanite.f4v" onclick="launchSelected(this.href);return false;"><img src="images/buttons/btn_play.png"/></a>
-	    </div>	    
-	     <div class="tags">
-	    	<span class="head">
-		    <i>Tags liés au film :</i>
-			</span>
-			<ul class="item-list tag-list">   
-			 <li class="tag-score-<?php echo $tag['score']; ?>">
-			    <a href="">anna</a>
-			  </li><li class="tag-score-5">
-			    <a href="">Jalousie</a>
-			  </li><li class="tag-score-3">
-			    <a href="">erotomanie</a>
-			  </li><li class="tag-score-2">
-			    <a href="">violence</a>
-			  </li>
-			  <li class="tag-score-<?php echo $tag['score']; ?>">
-			    <a href="">anna</a>
-			  </li><li class="tag-score-5">
-			    <a href="">Jalousie</a>
-			  </li><li class="tag-score-3">
-			    <a href="">erotomanie</a>
-			  </li><li class="tag-score-2">
-			    <a href="">violence</a>
-			  </li>
-			  <li class="tag-score-<?php echo $tag['score']; ?>">
-			    <a href="">anna</a>
-			  </li><li class="tag-score-5">
-			    <a href="">Jalousie</a>
-			  </li><li class="tag-score-3">
-			    <a href="">erotomanie</a>
-			  </li><li class="tag-score-2">
-			    <a href="">violence</a>
-			  </li>
-			</ul>
-	    </div>	    
-	</div>
-	<div id="player-action"><a href="" class="button">Taggez l'extrait</a> <a href="" class="button">Voir le film</a></div>	
-</div>
\ No newline at end of file
+<script type="text/javascript">
+    // Charge le player
+    flowplayer("player", "<?php echo flash_path('flowplayer-3.1.2.swf') ?>",
+               {
+                   clip: {url: "<?php echo video_path($filmVideo['file']); ?>",
+                          autoPlay: false,
+                          autoBuffering: true,
+                          onSeek: function() {
+                              playerSeek();
+                          }
+                         },
+
+                   plugins: {
+
+                       content: {url: "<?php echo flash_path('flowplayer.content-3.1.0.swf') ?>",
+                                 backgroundColor: 'transparent',
+                                 display: 'none',
+                                 style: {p: {fontSize: 15}}
+                                }
+
+                   },
+
+                   onLoad: function() {
+                       playerLoaded(this);
+                   },
+
+                   onUnload: function() {
+                       playerUnloaded(this);
+                   },
+                   onError: function(code,msg) {
+                       alert(msg);
+                   },
+               });
+
+
+               function loadSegments() {
+
+                   if ($f().getClip() == undefined) {
+                       window.setTimeout("loadSegments()",2000);
+                       return false;
+                   }
+
+                   var duration = Math.round($f().getClip().fullDuration*10) * 100;
+
+
+                   var segments = tagTool.segments;
+
+                   for (seg in segments) {
+                       var segd = segments[seg].sout - segments[seg].sin;
+                       var percent = Math.round(segd * 100 / duration);
+                       var offset = Math.round(segments[seg].sin * 100 / duration);
+                       var c = $('#seg_container_template').clone().removeAttr("id");
+                       $("#segments").append(c);
+                       $("span", c).html('<strong>' + tagTool.segments[seg].tag +'</strong> par ' + segments[seg].user);
+                       $("#seg_0", c).css({'margin-left': offset+'%', 'width': percent+'%'})
+                       .attr('id', 'seg_' + seg)
+                       .click(function() {
+                           seg_id = $(this).attr("id");
+                           seg_id = seg_id.substr(seg_id.indexOf('_') + 1);
+                           tagTool.playSegment(seg_id, $("#pauseAfter").val());
+                       });
+                       c.show();
+                   }
+               }
+
+
+               function playerSeek() {
+                   tagTool.rebuildCurrentTags(tagTool.player.getTime() * 1000);
+               }
+
+
+               function playerLoaded(player) {
+
+                   // Charge les tags
+    				
+
+                   tagTool.player = $f("player");
+                   tagTool.showTagInPage = false;
+
+               }
+    </script>
+<div id="player-<?php echo $film->getRef(); ?>" class="player-ba" style="background:transparent url('<?php echo film_image_path($imageFilename); ?>') no-repeat;">
+<div class="infos">
+	<a href="<?php echo $actionUri; ?>" class="title"><?php echo $film->getTitle(); ?></a><br/><span class="film-infos">De <?php echo thd_render_flat_list($film->getDirectorsArray(), 'name'); ?></span>
+</div>
+<img src="<?php echo image_path('buttons/btn_play.png'); ?>"/ id="play"></a>
+<div class="tags">
+    <ul class="item-list tag-list">
+    <li><span class="head">
+      <i>Tags liés au film :</i>
+	    </span></li>
+	    <?php 
+		    foreach($film->getTagsArray() as $item) {
+		    	if($item){ 
+		    	$tag = $item;
+		    	echo '<li class="tag-score-'.$tag['score'].'"><a href="">'.$tag.'</a>
+		      </li>';
+		        
+		    }
+	    } ?>
+	     
+	 </ul>
+</div>
+</div>
+<div class="tag-action"><a href="<?php echo $actionUri ?>" class="link-button">Tagger le film</a></div>
+
--- a/web/thdProject/apps/frontend/modules/search/templates/viewSearchListSuccess.php	Tue Apr 20 17:30:13 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/search/templates/viewSearchListSuccess.php	Tue Apr 20 18:30:24 2010 +0200
@@ -1,4 +1,7 @@
+<?php
+  $tagFilmUri = url_for('@editor?ref='.$selectedFilm->getRef().'&film_slug='.$selectedFilm->getSlugUrl());
+?>
 <h3 class="head">Résultats pour : <i><?php echo $text; ?></i></h3>  
-<?php include_component( "search", "selectedFilm") ?>
-<?php include_partial('search/searchList', array('filter' => 'all', 'filmCount' => '10', 'searchFilms' => $searchFilms, 'pageIndex' => $pageIndex, 'pageNbItems' => $pageNbItems)); ?>	
+<?php include_component( "search", "selectedFilm", array('film' => $selectedFilm, 'actionUri' => $tagFilmUri)) ?>
+<?php include_partial('search/searchList', array('selectedFilm' => $selectedFilm, 'filter' => 'all', 'filmCount' => '10', 'searchFilms' => $searchFilms, 'pageIndex' => $pageIndex, 'pageNbItems' => $pageNbItems)); ?>