add reflexonomy search
authorymh <ymh.work@gmail.com>
Tue, 20 Apr 2010 09:33:41 +0200
changeset 64 554e8a2144fa
parent 63 75a7a9d56840
child 65 971621d37b74
add reflexonomy search
web/thdProject/apps/frontend/config/routing.yml
web/thdProject/apps/frontend/modules/reflex/actions/actions.class.php
web/thdProject/apps/frontend/modules/reflex/actions/components.class.php
web/thdProject/apps/frontend/modules/reflex/config/view.yml
web/thdProject/apps/frontend/modules/reflex/templates/_player.php
web/thdProject/apps/frontend/modules/reflex/templates/_suggestionFilmList.php
web/thdProject/apps/frontend/modules/reflex/templates/_tagNavigator.php
web/thdProject/apps/frontend/modules/reflex/templates/indexSuccess.php
web/thdProject/apps/frontend/modules/search/actions/viewTagListAction.class.php
web/thdProject/apps/frontend/modules/tag/templates/_tagNavigator.php
web/thdProject/test/functional/frontend/reflexActionsTest.php
--- a/web/thdProject/apps/frontend/config/routing.yml	Fri Apr 16 20:03:37 2010 +0200
+++ b/web/thdProject/apps/frontend/config/routing.yml	Tue Apr 20 09:33:41 2010 +0200
@@ -49,13 +49,12 @@
 ########
 # TAGGING
 ########  
-  
+
 tagging:
   url: /tagging/:tag/:page_nb
-  param: { module: tag, action: index, tag:all, page_nb: 1 }
+  param: { module: tag, action: index, tag: all, page_nb: 1 }
   requirements: { page_nb: \d+ }
   
-    
 ########
 # FILMS
 ########
@@ -69,9 +68,18 @@
   url:   /top-des-films/:page/:page_nb
   param: { module: films, action: viewTopFilmList, page: page, page_nb: 1 }
   
-  
-      
+ 
+#########
+# REFLEXONOMIES
+#########
+
+searchReflex:
+  url: /reflex/:film_uniqueid/:tag/:direction/:distance
+  param: { module: reflex, action: index, tag: all, direction: more, distance: 5 }
+  requirements: { direction: more|less, distance: \d+ }   
     
+
+
 default_index:
   url:   /:module
   param: { action: index }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/actions/actions.class.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * reflex actions.
+ *
+ * @package    thd
+ * @subpackage reflex
+ * @author     Your name here
+ * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
+ */
+class reflexActions extends sfActions
+{
+ /**
+  * Executes index action
+  *
+  * @param sfRequest $request A request object
+  */
+  public function executeIndex(sfWebRequest $request)
+  {
+  	///reflex/:film_uniqueid/:tag/:direction
+  	// Parse request parameters
+    $format = $request->getRequestFormat();
+    $this->film_uniqueid = (string) $request->getParameter('film_uniqueid');   
+    $this->tag = (string) $request->getParameter('tag');
+    $this->direction = (string) $request->getParameter('direction');
+    $this->distance = (int)$request->getParameter('distance');
+    
+    $this->distance = $this->distance * ($this->direction=='more'?1.0:-1.0) / 100.0;
+
+    $sonyengine = SonyengineClient::getInstance();
+    $result = $client->engineFind($this->film_uniqueid,$this->tag,$this->distance,true);
+    foreach($results as $res)
+    {
+      $primaryKeys[] = $res['id'];
+    }
+
+    if(!empty($primaryKeys))
+    {
+      $this->mostTaggedFilms = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys);       
+    }
+    else
+    {
+      $this->mostTaggedFilms = array();
+    }
+    
+    return sfView::SUCCESS;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/actions/components.class.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,31 @@
+<?php 
+
+class reflexComponents extends sfComponents
+{
+  
+  public function executeReflexNavigator() {
+	
+  }
+  
+  public function executePlayer() {
+	$ref = '013002';
+  	$film_slug = 'apres-lui';
+
+  	// retrieve infos in database
+  	$query = Doctrine_Query::create()
+      ->from('ThdFilm F')
+      ->leftJoin('F.images I ')
+      ->leftJoin('F.videos V')
+      ->where("F.ref='{$ref}'");
+    $this->film = $query->execute()->getFirst();
+	  if (!$this->film) return sfView::NONE;
+
+	  // retrieve video infos
+	  $videos = $this->film->getVideos();
+	  $this->filmVideo = ($videos) ? $videos[0] : null;
+
+  	return sfView::SUCCESS;
+  }
+
+ 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/config/view.yml	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,10 @@
+all:
+  
+  stylesheets:    [ /css/flashplayer.css, search.css ]
+
+  javascripts:   [ /js/flowplayer/flowplayer-3.1.0.min.js, /js/flowplayer/uc.flowplayer.config.js]
+ 
+  
+  components: 
+    sideBar: [ tag, tagNavigator ]
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/templates/_player.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,98 @@
+<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="editor">
+	<h1><?php
+
+		echo $film->getTitle();
+		// original title if exist
+
+		if($film->getOriginalTitle()!= null)
+		{
+			echo " <span class=\"ost\">{".$film->getOriginalTitle()."}</span>";
+		}
+	?>
+	<span class="film-infos">De <?php echo thd_render_flat_list($film->getDirectorsArray(), 'name'); ?></span></h1>
+	<div class="section">
+		<div id="player" class="player-ba"></div>	
+	<div class="tag-action"><a href="" class="link-button">Tagger le film</a></div>
+	</div>
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/templates/_suggestionFilmList.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,15 @@
+<div id="suggestionFilm-list">
+	<h3 class="head">Les films suivants</h3>
+	<ul>
+	
+	<?php
+	foreach($mostTaggedFilms as $item):
+		$tagFilmUri = url_for('@editor?ref='.$item->getRef().'&film_slug='.$item->getSlugUrl());
+	?>
+	<li>
+		<?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; ?>
+	</ul>
+</div>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/templates/_tagNavigator.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,12 @@
+<div id="tagNavigator-list">
+	<h3>Autres Tags  associés à cet extrait</h3>
+	<ul>
+		<li>			
+			<div><span class="tag"><a href="<?php echo "" ?>">-</a>tristesse<a href="<?php echo "" ?>">+</a></span></div>
+		</li>
+		<!-- tag activated -->
+		<li>
+			<div class="tagActivated"><a href="">Enterrement <div class="btnClose">X</div></a></div>
+		</li>
+	</ul>
+</div>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/reflex/templates/indexSuccess.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,3 @@
+<h3 class="head">Résultats de la recherche reflexonomique</i></h3> 
+<?php include_component( "tag", "player" ) ?>
+<?php include_partial('tag/suggestionFilmList', array('filter' => 'all', 'filmCount' => '10', 'mostTaggedFilms' => $mostTaggedFilms, 'pageIndex' => $pageIndex, 'pageNbItems' => $pageNbItems)); ?> 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/search/actions/viewTagListAction.class.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,38 @@
+<?php
+
+class viewTagListAction extends sfAction {
+
+  public function execute($request) {
+  	
+  	// Parse request parameters
+    $format = $request->getRequestFormat();
+    $this->tag = (string) $request->getParameter('tag');   
+    $pageNb = (int) $this->getRequestParameter('page_nb', 1);
+    $this->pageIndex = $pageNb -1;
+    $this->pageNbItems = 10;
+    $this->indexNbItems = 2;
+
+    
+    $solr = uvmcSolrServicesManager::getInstance()->getService();
+    $response = $solr->search("tags:".$this->tag, $this->pageIndex * $this->pageNbItems, $this->pageNbItems);
+
+    $results = unserialize($response->getRawResponse());              
+
+    $primaryKeys = array();
+    foreach($results['response']['docs'] as $doc)
+    {
+      $primaryKeys[] = $doc['id'];
+    }
+
+    if(!empty($primaryKeys))
+    {
+      $this->mostTaggedFilms = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys);       
+    }
+    else
+    {
+      $this->mostTaggedFilms = array();
+    }
+    
+    return sfView::SUCCESS;
+  }
+}
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/tag/templates/_tagNavigator.php	Fri Apr 16 20:03:37 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/tag/templates/_tagNavigator.php	Tue Apr 20 09:33:41 2010 +0200
@@ -2,7 +2,7 @@
 	<h3>Autres Tags  associés à cet extrait</h3>
 	<ul>
 		<li>			
-			<div class="tag">tristesse</div>			
+			<div><span class="tag"><a href="<?php echo url_for('@searchReflex?film_uniqueid=&tag=tristesse&direction=less&distance=5'); ?>">-</a>tristesse<a href="<?php echo "" ?>">+</a></span></div>
 		</li>
 		<!-- tag activated -->
 		<li>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/test/functional/frontend/reflexActionsTest.php	Tue Apr 20 09:33:41 2010 +0200
@@ -0,0 +1,19 @@
+<?php
+
+include(dirname(__FILE__).'/../../bootstrap/functional.php');
+
+$browser = new sfTestFunctional(new sfBrowser());
+
+$browser->
+  get('/reflex/index')->
+
+  with('request')->begin()->
+    isParameter('module', 'reflex')->
+    isParameter('action', 'index')->
+  end()->
+
+  with('response')->begin()->
+    isStatusCode(200)->
+    checkElement('body', '!/This is a temporary page/')->
+  end()
+;