Fix template bugs
authorclebeaupin
Wed, 24 Mar 2010 14:27:53 +0100
changeset 20 be2cac1028d8
parent 19 96ecedbe89de
child 21 8a048c4acbda
Fix template bugs
web/thdProject/apps/frontend/config/app.yml
web/thdProject/apps/frontend/config/factories.yml
web/thdProject/apps/frontend/config/settings.yml
web/thdProject/apps/frontend/config/view.yml
web/thdProject/apps/frontend/modules/editor/actions/components.class.php
web/thdProject/apps/frontend/modules/editor/templates/_player.php
web/thdProject/apps/frontend/modules/homepage/actions/components.class.php
web/thdProject/apps/frontend/modules/homepage/templates/_lastTaggedList.php
web/thdProject/apps/frontend/modules/homepage/templates/_mostTaggedList.php
web/thdProject/apps/frontend/modules/partials/templates/_header.php
web/thdProject/lib/helper/ThdHtmlHelper.php
web/thdProject/lib/model/doctrine/ThdFilm.class.php
web/thdProject/web/css/flashplayer.css
web/thdProject/web/css/layout.css
web/thdProject/web/js/uc.utils.js
--- a/web/thdProject/apps/frontend/config/app.yml	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/config/app.yml	Wed Mar 24 14:27:53 2010 +0100
@@ -5,7 +5,7 @@
       uploads: "/Users/ymh/dev/workspace/mosatags/web/thdProject/web/uploads"
       format: ".csv"
     
-   player:
-     videoPath: "videos/"
+   video:
+     root_uri: "http://atalante.ucthd/web/thdProject/web/videos"
 
 #dev:
--- a/web/thdProject/apps/frontend/config/factories.yml	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/config/factories.yml	Wed Mar 24 14:27:53 2010 +0100
@@ -31,6 +31,14 @@
       generate_shortest_url:            true
       extra_parameters_as_query_string: true
 
+  request:
+    class: sfWebRequest
+    param:
+      logging:           %SF_LOGGING_ENABLED%
+      path_info_array:   SERVER
+      path_info_key:     PATH_INFO
+      relative_url_root: /web/thdProject/web
+
 #all:
 #  controller:
 #    class: sfFrontWebController
--- a/web/thdProject/apps/frontend/config/settings.yml	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/config/settings.yml	Wed Mar 24 14:27:53 2010 +0100
@@ -27,6 +27,7 @@
     # Output escaping settings
     escaping_strategy:      false            # Determines how variables are made available to templates. Accepted values: on, off.
     escaping_method:        ESC_SPECIALCHARS # Function or helper used for escaping. Accepted values: ESC_RAW, ESC_ENTITIES, ESC_JS, ESC_JS_NO_ENTITIES, and ESC_SPECIALCHARS.
+    standard_helpers:       [Partial, Cache, Form, ThdHtml]
 
 #all:
 #  .actions:
--- a/web/thdProject/apps/frontend/config/view.yml	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/config/view.yml	Wed Mar 24 14:27:53 2010 +0100
@@ -11,7 +11,7 @@
 
   stylesheets:    [frontend.css, /css/player.css]
 
-  javascripts:    [jquery1.3.1.js, uc.utils.js, uc.input.js, uc.player.js,]
+  javascripts:    [jquery1.3.1.js, uc.utils.js]
 
   has_layout:     on
   layout:         layout
--- a/web/thdProject/apps/frontend/modules/editor/actions/components.class.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/editor/actions/components.class.php	Wed Mar 24 14:27:53 2010 +0100
@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 class editorComponents extends sfComponents
 {
@@ -7,8 +7,8 @@
   }
   public function executePlayer() {
 	$ref = $this->getRequestParameter('ref');
-  	$film_slug = $this->getRequestParameter('film_slug');	
-  	
+  	$film_slug = $this->getRequestParameter('film_slug');
+
   	// retrieve infos in database
   	$query = Doctrine_Query::create()
       ->from('ThdFilm F')
@@ -16,14 +16,16 @@
       ->leftJoin('F.videos V')
       ->where("F.ref='{$ref}'");
     $this->film = $query->execute()->getFirst();
-	
-	// retrieve video infos
-  	$this->videos = $this->film->getVideos();
-      
+	  if (!$this->film) return sfView::NONE;
+
+	  // retrieve video infos
+	  $videos = $this->film->getVideos();
+	  $this->filmVideo = ($videos) ? $videos[0] : null;
+
   	return sfView::SUCCESS;
   }
-  
+
   public function executeSegmentList() {
 
-  }  
+  }
 }
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Mar 24 14:27:53 2010 +0100
@@ -1,41 +1,29 @@
-<?php
-	$ref = $film->getRef();
-	$slug = $film->getSlugUrl();
-	
-	//video file
-	$video_file = $videos[0]['file'];
-	
-	// directors list
-	$json = $film->getDirectors();
-    $directors = json_decode($json, true);
-    $directorsList = $directors['name'];
-?>
 <script type="text/javascript">
     // Charge le player
-    flowplayer("player", "../../../flashes/flowplayer-3.1.2.swf",
+    flowplayer("player", "<?php echo flash_path('/flashes/flowplayer-3.1.2.swf') ?>",
                {
-                   clip: {url: "http://localhost/thd/web/videos/<?php echo $video_file; ?>.f4v",
+                   clip: {url: "<?php echo video_path($filmVideo['file'].'.f4v'); ?>",
                           autoPlay: false,
                           autoBuffering: true,
                           onSeek: function() {
                               playerSeek();
                           }
                          },
-                   
+
                    plugins: {
-                       
-                       content: {url: "http://localhost/thd/web/flashes/flowplayer.content-3.1.0.swf",
+
+                       content: {url: "<?php echo flash_path('/flashes/flowplayer.content-3.1.0.swf') ?>",
                                  backgroundColor: 'transparent',
                                  display: 'none',
                                  style: {p: {fontSize: 15}}
                                 }
-                       
+
                    },
-                   
+
                    onLoad: function() {
                        playerLoaded(this);
                    },
-                   
+
                    onUnload: function() {
                        playerUnloaded(this);
                    },
@@ -44,16 +32,16 @@
                    },
                });
 
-               
+
                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;
 
@@ -80,26 +68,26 @@
                    tagTool.rebuildCurrentTags(tagTool.player.getTime() * 1000);
                }
 
-               
+
                function playerLoaded(player) {
-               	
+
                    // Charge les tags
     				$("#segmentMarkerButtons").css("opacity",1);
                     $("#btMarkIn").removeAttr("disabled");
-                    $.getJSON("<?php echo url_for("@segmentListJson?ref=$ref&film_slug=$slug");?>", "", function(data) {
+                    $.getJSON("<?php echo url_for("@segmentListJson?ref={$film->getRef()}&film_slug={$film->getSlugUrl()}");?>", "", function(data) {
                         tagTool.segments = data;
-                        tagTool.setupHandlers($f("player"));                        
+                        tagTool.setupHandlers($f("player"));
                         window.setTimeout("loadSegments()", 2000);
                     });
- 
+
                    tagTool.player = $f("player");
                    tagTool.showTagInPage = false;
 
                }
     </script>
 <div id="editor">
-	<h2><?php 
-	
+	<h2><?php
+
 		echo $film->getTitle();
 		// original title if exist
 
@@ -108,13 +96,10 @@
 			echo " <span class=\"ost\">{".$film->getOriginalTitle()."}</span>";
 		}
 	?>
-	<span class="film-infos">De 
-	<?php 
-	
-    echo $directorsList;
-     ?></span></h2>		
+	<span class="film-infos">De
+  <?php echo thd_render_flat_list($film->getDirectors(), 'name'); ?></span></h2>
 	<div class="section">
-		<div id="player" class="player-ba"></div>		
+		<div id="player" class="player-ba"></div>
 		<p id="segmentMarkerButtons" style="text-align:center;opacity:0.5">
 			<button type="button" id="btMarkIn"  disabled onClick="segmentMarker.markIn()">
 			  Marquer le début
@@ -126,7 +111,7 @@
 			  Lire la séquence
 			</button>
 		 </p>
-		 <form action="<?php echo url_for("@addFilmSegment?ref=$ref&film_slug=$slug");?>" method="post" id="segmentForm" class="ajax" style="display: none;">
+		 <form action="<?php echo url_for("@addFilmSegment?ref={$film->getRef()}&film_slug={$film->getSlugUrl()}");?>" method="post" id="segmentForm" class="ajax" style="display: none;">
 		    <h3>Enregistrer votre segment</h3>
 		    <p>Vous aller créer un segment, entre <span id="mkin">0</span> et <span id="mkout">0</span>.</p>
 		    <p style="text-align: center;">
@@ -135,10 +120,10 @@
 		      <input type="hidden" name="xtid" value="<?php echo extract.id;?>" />
 		      <input type="hidden" name="timein" id="frmIn" value="0" />
 		      <input type="hidden" name="timeout" id="frmOut" value="0" />
-		      <input type="hidden" name="ref" id="refFilm" value="<?php echo $ref."_".$slug; ?>" />
-		      <input type="hidden" name="film" id="Film" value="<?php echo $title; ?>" />
+		      <input type="hidden" name="ref" id="refFilm" value="<?php echo $film->getRef()."_".$film->getSlugUrl(); ?>" />
+		      <input type="hidden" name="film" id="Film" value="<?php echo $film->getTitle(); ?>" />
 		      <input type="submit" value="Enregistrer" />
 		    </p>
 		 </form>
-	</div>	
+	</div>
 </div>
--- a/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php	Wed Mar 24 14:27:53 2010 +0100
@@ -19,19 +19,23 @@
   }
 
   public function executeLastTaggedList() {
-	$query = Doctrine_Query::create()
-      ->from('ThdFilm F')
-      ->leftJoin('F.images I ')
-      ->leftJoin('F.videos V')
-      //->where("cu.code='{$culture}' AND mo.code='{$module}' AND ms.code='{$section}'")
-      ->orderBy('F.id DESC')
-      ->limit(0,10);
+    // FIXME: Dummy value
+    $this->tag = Array('score' => 3);
+  	$query = Doctrine_Query::create()
+        ->from('ThdFilm F')
+        ->leftJoin('F.images I ')
+        ->leftJoin('F.videos V')
+        //->where("cu.code='{$culture}' AND mo.code='{$module}' AND ms.code='{$section}'")
+        ->orderBy('F.id DESC')
+        ->limit(0,10);
     $this->lastTaggedFilms = $query->execute();
     $this->videoPath = sfConfig::get('app_player_videoPath');
 
   }
   public function executeMostTaggedList() {
-	$query = Doctrine_Query::create()
+    // FIXME: Dummy value
+    $this->tag = Array('score' => 3);
+	  $query = Doctrine_Query::create()
       ->from('ThdFilm F')
       ->leftJoin('F.images I ')
       ->leftJoin('F.videos V')
--- a/web/thdProject/apps/frontend/modules/homepage/templates/_lastTaggedList.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/templates/_lastTaggedList.php	Wed Mar 24 14:27:53 2010 +0100
@@ -1,27 +1,25 @@
 <div id="lastTagged-list">
 	<h3 class="head">Les derniers films taggés</h3>
 	<ul>
-	<?php 
-	foreach($lastTaggedFilms as $item): 
+	<?php
+	foreach($lastTaggedFilms as $item):
 		$ref = $item->getRef();
 		$slug = $item->getSlugUrl();
 		$title = $item->getTitle();
-		
+
 		// image file
 		$image_file = $item->getImages();
 		// image file
 		$video_file = $item->getVideos();
-		// directors list
-		$directors = json_decode($item->getDirectors(), true);
 	?>
-	<li>	
+	<li>
 		<div id="player-<?php echo $ref; ?>" class="player-item" style="background:transparent url('posters/<?php echo $image_file[0]['file'].".jpg"; ?>') no-repeat;" href="<?php echo 	$videoPath.$video_file[0]['file'].".f4v";?>">
 			<div class="infos">
-		    	<a href="<?php echo url_for('@editor?ref='.$ref.'&film_slug='.$slug); ?>" class="title" target="_top"><?php echo $title; ?></a> <span class="film-infos">De <?php echo $directors['name']; ?></span>
+		    	<a href="<?php echo url_for('@editor?ref='.$ref.'&film_slug='.$slug); ?>" class="title" target="_top"><?php echo $title; ?></a> <span class="film-infos">De <?php echo thd_render_flat_list($item->getDirectors(), 'name'); ?></span>
 		    </div>
 		    <img src="images/buttons/btn_play.png"/ id="play"></a>
-		     <div class="tags">		    	
-				<ul class="item-list tag-list">   
+		     <div class="tags">
+				<ul class="item-list tag-list">
 				<li><span class="head">
 			    <i>Tags liés au film :</i>
 				</span></li>
@@ -42,12 +40,12 @@
 				    <a href="">erotomanie</a>
 				  </li><li class="tag-score-2">
 				    <a href="">violence</a>
-				  </li>				 
+				  </li>
 				</ul>
-		    </div>	    
+		    </div>
 		</div>
-		
+
 	</li>
 	<?php endforeach; ?>
-	</ul>	
-</div>	
\ No newline at end of file
+	</ul>
+</div>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/homepage/templates/_mostTaggedList.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/templates/_mostTaggedList.php	Wed Mar 24 14:27:53 2010 +0100
@@ -1,27 +1,26 @@
 <div id="mostTagged-list">
 	<h3 class="head">Les films les plus taggés</h3>
 	<ul>
-	<?php 
-	foreach($mostTaggedFilms as $item): 
+	<?php
+	foreach($mostTaggedFilms as $item):
 		$ref = $item->getRef();
 		$slug = $item->getSlugUrl();
 		$title = $item->getTitle();
-		
+
 		// image file
 		$image_file = $item->getImages();
 		// image file
 		$video_file = $item->getVideos();
-		// directors list
-		$directors = json_decode($item->getDirectors(), true);
+
 	?>
-	<li>	
+	<li>
 		<div id="playerMostTagged-<?php echo $ref; ?>" class="player-item" style="background:transparent url('posters/<?php echo $image_file[0]['file'].".jpg"; ?>') no-repeat;" href="<?php echo 	$videoPath.$video_file[0]['file'].".f4v";?>"">
 			<div class="infos">
-		    	<a href="<?php echo url_for('@editor?ref='.$ref.'&film_slug='.$slug); ?>" class="title"><?php echo $title; ?></a> <span class="film-infos">De <?php echo $directors['name']; ?></span>
+		    	<a href="<?php echo url_for('@editor?ref='.$ref.'&film_slug='.$slug); ?>" class="title"><?php echo $title; ?></a> <span class="film-infos">De <?php echo thd_render_flat_list($item->getDirectors(), 'name'); ?></span>
 		    </div>
 		    <img src="images/buttons/btn_play.png"/ id="play"></a>
-		     <div class="tags">		    	
-				<ul class="item-list tag-list">   
+		     <div class="tags">
+				<ul class="item-list tag-list">
 				<li><span class="head">
 			    <i>Tags liés au film :</i>
 				</span></li>
@@ -42,11 +41,11 @@
 				    <a href="">erotomanie</a>
 				  </li><li class="tag-score-2">
 				    <a href="">violence</a>
-				  </li>				 
+				  </li>
 				</ul>
-		    </div>	    
-		</div>	
+		    </div>
+		</div>
 	</li>
 	<?php endforeach; ?>
-	</ul>	
-</div>	
\ No newline at end of file
+	</ul>
+</div>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/partials/templates/_header.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/partials/templates/_header.php	Wed Mar 24 14:27:53 2010 +0100
@@ -1,5 +1,5 @@
 <div id="universcinethd">
-	<h1 id="logo"><a href="" title="UniversCiné">UniversCiné</a></h1>
+	<h1 id="logo"><a href="<?php echo url_for('@homepage'); ?>" title="UniversCiné">UniversCiné</a></h1>
 </div>
 <div id="partners"> avec le concours de <a class="logo-partner" href="http://www.iri.centrepompidou.fr">iri</a> <a class="logo-partner">| Sony CSL</a> <a class="logo-partner">| Cap Digital</a></div>
 <div id="baseline"><cite>le site du cinéma indépendant</cite></div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/lib/helper/ThdHtmlHelper.php	Wed Mar 24 14:27:53 2010 +0100
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Helper used to generate a list of items (object or dictionnary)
+ *
+ * @param Array $items
+ * @param string $nameAccessor
+ * @param string $uriAccessor
+ * @param string $itemClass
+ * @param string $glue
+ */
+function thd_render_flat_list($items, $nameAccessor, $uriAccessor='', $itemClass='', $glue=', ') {
+  $itemsHtml = Array();
+
+  foreach ($items as $key=>$item) {
+    $itemName = '';
+    $itemUri = '';
+    $itemHtml = '';
+    $itemClasses = '';
+
+    if (is_array($item)) {
+      $itemName = $item[$nameAccessor];
+      $itemUri = $uriAccessor ? $item[$uriAccessor]: '';
+    } else {
+      $itemName = $item->$nameAccessor();
+      $itemUri = $uriAccessor ? $item->$uriAccessor() : '';
+    }
+
+    if ($itemClass) {
+      $itemClasses = ' class="'.$itemClass.'"';
+    }
+
+    if ($itemUri) {
+      $itemHtml = strtr(
+        '<a href="%uri%"%classes%>%name%</a>',
+        Array('%name%' => $itemName, '%uri%' => $itemUri, '%classes%' => $itemClasses));
+    } else {
+      $itemHtml = strtr(
+        '<span%classes%>%name%</span>',
+        Array('%name%' => $itemName, '%classes%' => $itemClasses));
+    }
+
+    $itemsHtml[] = $itemHtml;
+  }
+
+  return implode($glue, $itemsHtml);
+}
+
+function flash_path($source, $absolute = false) {
+  return _compute_public_path($source, 'flashes', 'swf', $absolute);
+}
+
+function video_path($source) {
+  return sfConfig::get('app_video_root_uri').'/'.$source;
+}
\ No newline at end of file
--- a/web/thdProject/lib/model/doctrine/ThdFilm.class.php	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/lib/model/doctrine/ThdFilm.class.php	Wed Mar 24 14:27:53 2010 +0100
@@ -8,7 +8,7 @@
 
     public function getSolrDocumentFields()
     {
-        // keys of this array are fields' name of solr's schema.xml 
+        // keys of this array are fields' name of solr's schema.xml
         $type = "ThdFilm";
         $fields = array('type'           => $type,
                         'id'             => $this->getId(),
@@ -27,5 +27,22 @@
     {
         $this->uniqueid = UUID::generate(UUID::UUID_TIME, UUID::FMT_STRING, "mosatags");
     }
-	
+
+    protected function decodeJsonData($attr) {
+      $data = $this->getData();
+      return json_decode($data[$attr], true);
+    }
+
+    public function getDirectors() {
+      return $this->decodeJsonData('directors');
+    }
+
+    public function getActors() {
+      return $this->decodeJsonData('actors');
+    }
+
+    public function getProductionCountries() {
+      return $this->decodeJsonData('production_countries');
+    }
+
 }
--- a/web/thdProject/web/css/flashplayer.css	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/web/css/flashplayer.css	Wed Mar 24 14:27:53 2010 +0100
@@ -13,7 +13,7 @@
 .player-ba .infos {
   position: relative;
   height:40px;
-  background:#000 url(../images/global/gradient/h80.png) repeat-x;
+  background:#000;
   opacity:0.7;
   color:#FFFFFF;
   margin: 0;	
@@ -29,7 +29,7 @@
   position:relative;
   top: 130px;
   height:70px;
-  background:#000 url(../images/global/gradient/h80.png) repeat-x;
+  background:#000;
   opacity:0.7;
   color:#FFFFFF;
   margin: 83px 0px 0px 0px;
@@ -95,7 +95,7 @@
   position: relative;
   top:0px;
   height:30px;
-  background:#000 url(../images/global/gradient/h80.png) repeat-x;
+  background:#000;
   opacity:0.8;
   color:#999999;
   margin: 0;	
@@ -117,7 +117,7 @@
   position:relative;
   top: 22px;
   height:55px;
-  background:#000 url(../images/global/gradient/h80.png) repeat-x;
+  background:#000;
   opacity:0.8;
   color:#FFFFFF;
   margin: 33px 0px 0px 0px;
--- a/web/thdProject/web/css/layout.css	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/web/css/layout.css	Wed Mar 24 14:27:53 2010 +0100
@@ -65,7 +65,7 @@
   width: 1280px;
   padding: 5px;
   top: 10px;
-  background:#000000 url(../img/global/gradient/h80.png) repeat-x;
+  background:#000000;
   opacity:0.5;
 }
 #navigation:after {
--- a/web/thdProject/web/js/uc.utils.js	Wed Mar 24 12:39:52 2010 +0100
+++ b/web/thdProject/web/js/uc.utils.js	Wed Mar 24 14:27:53 2010 +0100
@@ -1,4 +1,4 @@
-uc = uc || {};
+var uc = uc || {};
 uc.utils = uc.utils || {};
 
 uc.utils.centeredContainer = function(html_container) {