Add my tags, Fix js on IE, List segments on player
authorclebeaupin
Wed, 28 Apr 2010 14:36:49 +0200
changeset 86 4ddb2636237b
parent 85 315aef7270fc
child 87 640852e46afa
child 88 6161de0c8ffa
Add my tags, Fix js on IE, List segments on player
web/thdProject/apps/frontend/config/routing.yml
web/thdProject/apps/frontend/modules/account/actions/viewMyTagListAction.class.php
web/thdProject/apps/frontend/modules/account/config/view.yml
web/thdProject/apps/frontend/modules/account/templates/loginUserForm.php
web/thdProject/apps/frontend/modules/account/templates/viewMyTagListSuccess.php
web/thdProject/apps/frontend/modules/editor/actions/segmentListJsonAction.class.php
web/thdProject/apps/frontend/modules/editor/actions/viewVideoSegmentListAction.class.php
web/thdProject/apps/frontend/modules/editor/templates/_player.php
web/thdProject/apps/frontend/modules/editor/templates/_segmentList.php
web/thdProject/apps/frontend/modules/editor/templates/segmentListJsonSuccess.php
web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php
web/thdProject/web/js/segmentation/tagtool.js
web/thdProject/web/js/uc.common.js
--- a/web/thdProject/apps/frontend/config/routing.yml	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/apps/frontend/config/routing.yml	Wed Apr 28 14:36:49 2010 +0200
@@ -3,6 +3,10 @@
   url:   /
   param: { module: homepage, action: index }
   
+########  
+# ACCOUNT
+########
+  
 loginUser:
   url: /connexion
   param: { module: account, action: loginUser}
@@ -14,6 +18,10 @@
 openidLogin:
   url: /open-id/connexion
   param: { module: account, action: openidLogin}
+  
+viewMyTagList:
+  url: /mes-tags
+  param: { module: account, action: viewMyTagList}
 
 ########  
 #SEGMENT EDITOR
@@ -28,8 +36,8 @@
   param: { module: editor, action: editVideoSegment }
     
 segmentListJson:
-  url: /editeur/:film_slug/list-segment
-  param: { module: editor, action: segmentListJson}
+  url: /editeur/:film_slug/segments
+  param: { module: editor, action: viewVideoSegmentList }
   requirements: {ref: \d+}
   
   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/actions/viewMyTagListAction.class.php	Wed Apr 28 14:36:49 2010 +0200
@@ -0,0 +1,28 @@
+<?php
+
+class viewMyTagListAction extends sfAction {
+
+  public function execute($request) {
+    // Get pager information
+    $pageNb = (int) $this->getRequestParameter('page_nb', 1);
+    $this->pageIndex = $pageNb -1;
+    $this->pageNbItems = 10;
+    $this->routeUri = '@viewMyTagList';
+
+    // Initialize query
+    $query = Doctrine_Query::create()
+        ->from('ThdFilm F')
+        ->leftJoin('F.videos V')
+        ->leftJoin('V.segments S')
+        ->leftJoin('S.ThdUser U')
+        ->where("U.uniqueid = '{$this->getUser()->getUid()}'")
+        ->orderBy('S.creation_date DESC');
+    $this->itemCount = $query->count();
+    $this->pageCount = (int) ceil($this->itemCount/$this->pageNbItems);
+    $this->films = $query->offset($this->pageIndex*$this->pageNbItems)->limit($this->pageNbItems)->execute();
+
+    if ($this->pageIndex*$this->pageNbItems > $this->itemCount) {
+      $this->forward404();
+    }
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/config/view.yml	Wed Apr 28 14:36:49 2010 +0200
@@ -0,0 +1,4 @@
+viewMyTagListSuccess:
+  components: 
+    sideBar: [ homepage, sideBar ]
+  
--- a/web/thdProject/apps/frontend/modules/account/templates/loginUserForm.php	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/account/templates/loginUserForm.php	Wed Apr 28 14:36:49 2010 +0200
@@ -1,5 +1,5 @@
 <div id="register">
-  <div class="head"><h3>Pas encore inscrit ?</div>
+  <div class="head"><h3>Pas encore inscrit ?</h3></div>
   <div class="infos">Bienvenue dans le projet UniversCiné THD.<br/><br/>Ce site entre dans le cadre d'un projet de recherche sur le très haut débit réunissant trois acteurs autour de ce site :<br/><a href="http://www.universcine.com">UniversCiné</a>, <a href="http://ww.iri.centrepompidou.com">l'iri</a>, <a href="http://www.csl.sony.fr">Sony CSL</a> et <a href="http://www.capdigital.com">Cap digital</a></div>
   <div class="access">
     <form action="<?php echo url_for('@loginUser'); ?>" method="post">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/templates/viewMyTagListSuccess.php	Wed Apr 28 14:36:49 2010 +0200
@@ -0,0 +1,2 @@
+<h3>Mes films taggés&nbsp;(<?php echo $itemCount; ?>)</h3>
+<?php include_partial('films/filmList', Array('films' => $films, 'pageIndex' => $pageIndex, 'pageCount' => $pageCount, 'itemCount' => $itemCount, 'routeUri' => $routeUri)); ?>
--- a/web/thdProject/apps/frontend/modules/editor/actions/segmentListJsonAction.class.php	Wed Apr 28 14:00:37 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-<?php
-
-class segmentListJsonAction extends sfAction
-{
-  public function execute($request)
-  { 
-	header("Content-type: text/x-json");
-	$segments = '';
-	$this->ref = $this->getRequestParameter('ref');
-	$this->film_slug = $this->getRequestParameter('film_slug');
-	
-	// Get File segmentation Path
-	$this->path = sfConfig::get('app_storage_uploads');
-	$this->format = sfConfig::get('app_storage_format');
-	$file = $this->path.$this->ref."_".$this->film_slug.$this->format;
-	
-	
-	//Check if file exist
-	if (file_exists($file)) {
-		$fp = fopen($file, "r");
-		while (($data = fgetcsv($fp)) != FALSE) {
-		  $line = "{sin: " . $data[0] .
-		    ",sout: " . $data[1] .
-		    ",tag: '" . $data[2] . "'" .
-		    ",user: '" . $data[3] . "'}";
-		
-		  $lines[] = $line;
-		}
-		$segments = "[" . join($lines,',') . "]";
-	}
-	
-	// Render json
-	echo $segments;
-  }
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/editor/actions/viewVideoSegmentListAction.class.php	Wed Apr 28 14:36:49 2010 +0200
@@ -0,0 +1,34 @@
+<?php
+
+class viewVideoSegmentListAction extends sfAction
+{
+  public function execute($request)
+  {
+	$this->filmSlug = $this->getRequestParameter('film_slug');
+
+	// Get segments
+  $query = Doctrine_Query::create()
+    ->from('ThdSegment S')
+    ->leftJoin('S.ThdVideo V')
+    ->leftJoin('V.ThdFilm F')
+    ->where("F.slug_url = '{$this->filmSlug}'")
+    ->orderBy('S.creation_date DESC');
+
+
+	//Check if file exist
+	$segments = Array();
+
+	foreach ($query->execute() as $segment) {
+    $segments[] = Array(
+      'in' => $segment->getStart(), 'out' => $segment->getEnd(),
+      'tags' => $segment->getTags(), 'user' => $segment->getThdUser()->getUniqueid()
+    );
+	}
+
+	// Render json
+	$this->getResponse()->setHttpHeader('Content-type', 'application/json');
+  $this->getResponse()->setHttpHeader('Cache-Control', 'no-cache, no-store, max-age=0');
+  return $this->renderText(json_encode($segments));
+
+  }
+}
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Apr 28 14:36:49 2010 +0200
@@ -28,7 +28,7 @@
                    },
                    onError: function(code,msg) {
                        alert(msg);
-                   },
+                   }
                });
 
 
@@ -44,19 +44,22 @@
 
                    var segments = tagTool.segments;
 
-                   for (seg in segments) {
-                       var segd = segments[seg].sout - segments[seg].sin;
+                   for (var seg in segments) {
+                       var segd = parseInt(segments[seg]['out']) - parseInt(segments[seg]['in']);
                        var percent = Math.round(segd * 100 / duration);
-                       var offset = Math.round(segments[seg].sin * 100 / duration);
+                       var offset = Math.round(parseInt(segments[seg]['in']) * 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);
+                       $("span", c).html('<strong>' + tagTool.segments[seg].tags.join(', ') +'</strong> par ' + segments[seg].user);
+                       $("#seg_0", c).css({'margin-left': offset+'%', 'width': percent+'%'});
+                       c.attr('id', 'seg_' + seg);
+
+
+                       $(".segtimeline", c).each(function() {
+                    	   var seg_id = seg;
+                         $(this).click(function() {
                            tagTool.playSegment(seg_id, $("#pauseAfter").val());
+                         });
                        });
                        c.show();
                    }
@@ -73,7 +76,7 @@
                    // Charge les tags
     				$("#segmentMarkerButtons").css("opacity",1);
                     $("#btMarkIn").removeAttr("disabled");
-                    $.getJSON("<?php echo url_for("@segmentListJson?ref={$film->getRef()}&film_slug={$film->getSlugUrl()}");?>", "", function(data) {
+                    $.getJSON("<?php echo url_for("@segmentListJson?film_slug={$film->getSlugUrl()}");?>", "", function(data) {
                         tagTool.segments = data;
                         tagTool.setupHandlers($f("player"));
                         window.setTimeout("loadSegments()", 2000);
--- a/web/thdProject/apps/frontend/modules/editor/templates/_segmentList.php	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/editor/templates/_segmentList.php	Wed Apr 28 14:36:49 2010 +0200
@@ -7,7 +7,7 @@
 		    <div class="seg_container" id="seg_container_template" style="display: none">
 		      <span class="tagname">Tag</span>
 		      <div class="segtimeline">
-		        <div id="seg_0">.</div>
+		        <div id="seg_0">&nbsp;</div>
 		      </div>
 		    </div>
 		</div>
--- a/web/thdProject/apps/frontend/modules/editor/templates/segmentListJsonSuccess.php	Wed Apr 28 14:00:37 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-<?php
-/*
- * Created on 15 sept. 2009
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
-?>
--- a/web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php	Wed Apr 28 14:36:49 2010 +0200
@@ -4,7 +4,7 @@
 	  <form class="table-form<?php if (isset($classes)) echo ' '.$classes; ?>" method="post" action="<?php echo url_for('@logoutUser')?>">
 	    <span class="head">Bienvenue sur UniversCine THD</span>
 	    <ul>
-	      <li><a href=""class ="link-action">Voir mes tags</a></li>
+	      <li><a href="<?php echo url_for('@viewMyTagList'); ?>"class ="link-action">Voir mes tags</a></li>
 	    </ul>
 	    <div class="buttons">
 	      <?php echo uc_render_submit_button('se déconnecter'); ?>
--- a/web/thdProject/web/js/segmentation/tagtool.js	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/web/js/segmentation/tagtool.js	Wed Apr 28 14:36:49 2010 +0200
@@ -11,11 +11,11 @@
     stopOnSegment: false,
 
     playSegment: function(seg, pause) {
-
-        if (pause == "on")
-            this.stopOnSegment = this.segments[seg].sout;
-
-        this.player.seek(this.segments[seg].sin / 1000);
+        if (pause == "on") {
+            this.stopOnSegment = parseInt(this.segments[seg]['out']);
+        }
+        
+        this.player.seek(parseInt(this.segments[seg]['in']) / 1000);
     },
 
     displayTags: function() {
@@ -51,8 +51,8 @@
     rebuildCurrentTags: function(position) {
         this.currentTags = new Array();
         for (seg in this.segments) {
-            if (this.segments[seg].sin < position && this.segments[seg].sout > position) {
-                this.currentTags.push(this.segments[seg].tag);
+            if (parseInt(this.segments[seg]['in']) < position && parseInt(this.segments[seg]['out']) > position) {
+                this.currentTags.push(this.segments[seg]['tags'].join(', '));
             }
         }
         this.displayTags();
@@ -62,9 +62,9 @@
 
         cuepoints = new Array();
         for (seg in this.segments) {
-            cuepoint = {time: this.segments[seg].sin, tag: this.segments[seg].tag};
+            cuepoint = {time: parseInt(this.segments[seg]['in']), tag: this.segments[seg]['tags'].join(', ')};
             cuepoints.push(cuepoint);
-            cuepoint = {time: this.segments[seg].sout, tag: this.segments[seg].tag, out: 'true'};
+            cuepoint = {time: parseInt(this.segments[seg]['out']), tag: this.segments[seg]['tags'].join(', '), out: 'true'};
             cuepoints.push(cuepoint);
         }
         player.onCuepoint(cuepoints, function(clip, cuepoint) {
--- a/web/thdProject/web/js/uc.common.js	Wed Apr 28 14:00:37 2010 +0200
+++ b/web/thdProject/web/js/uc.common.js	Wed Apr 28 14:36:49 2010 +0200
@@ -3,8 +3,7 @@
 
 //Ajaxify content
 uc.common.ajaxify = function (timeout) {
-	if (timeout == null) timeout = 0;
-	
+	if (timeout == null) timeout = 0;	
 	uc.utils.ajaxifyLink(jQuery('a.ajax-post'), 'POST', function() {uc.common.ajaxify();});
 	uc.utils.ajaxifyLink(jQuery('a.ajax'), 'GET', function() {uc.common.ajaxify();});
 	uc.utils.ajaxifyLink(jQuery('.ajax a'), 'GET', function() {uc.common.ajaxify();});
@@ -32,7 +31,7 @@
 			clip: {
 				autoPlay: true,
 		    	autoBuffering: true,
-		    	scaling: 'fit',
+		    	scaling: 'fit'
 			},
 			// setup controlbar to use skins
 			plugins: {