# HG changeset patch # User clebeaupin # Date 1272495472 -7200 # Node ID 9845ed787b8838a987c5ed72bc48d75b631d7999 # Parent 4bf8ee3cba88ddbaa4414b50d6cd7c473dab1b17 Fix IE7 problem. Improve tag generation diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/apps/frontend/modules/homepage/actions/components.class.php --- a/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -6,15 +6,9 @@ } public function executeTagList() { - // FIXME: Dummy value - $this->tagList = Array(); - $this->tag = Array('score' => 3); - // Get Tags in Segment list - $query = Doctrine_Query::create() - ->from('ThdSegment S') - ->limit(5); - $this->tagsList = $query->execute(); - + // Get global tag cloud + // Only display 10 tags + $this->tagCloud = ThdUtil::processTagCloud(ThdUtil::getGlobalTagCloud(20), 20); } public function executeRandomFilm() { diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/apps/frontend/modules/homepage/templates/_tagList.php --- a/web/thdProject/apps/frontend/modules/homepage/templates/_tagList.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/apps/frontend/modules/homepage/templates/_tagList.php Thu Apr 29 00:57:52 2010 +0200 @@ -1,14 +1,10 @@

Navigation par tag :

\ No newline at end of file diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/apps/frontend/modules/partials/actions/components.class.php --- a/web/thdProject/apps/frontend/modules/partials/actions/components.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/apps/frontend/modules/partials/actions/components.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -38,7 +38,7 @@ // Get Tag cloud // Only display 10 tags - $this->tagCloud = ThdUtil::getTagCloud($this->film->getTagCloud(), 10); + $this->tagCloud = ThdUtil::processTagCloud($this->film->getTagCloud(), 10); // Get video filename $videos = $this->film->getVideos(); diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php --- a/web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php Thu Apr 29 00:57:52 2010 +0200 @@ -1,15 +1,13 @@
-
- +
\ No newline at end of file diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/apps/frontend/modules/test/actions/actions.class.php --- a/web/thdProject/apps/frontend/modules/test/actions/actions.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/apps/frontend/modules/test/actions/actions.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -91,4 +91,9 @@ die(); return sfView::NONE; } + + public function executeCloud(sfWebRequest $request) { + var_dump(ThdUtil::getGlobalTagCloud(2)); + die(); + } } \ No newline at end of file diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/config/doctrine/schema.yml --- a/web/thdProject/config/doctrine/schema.yml Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/config/doctrine/schema.yml Thu Apr 29 00:57:52 2010 +0200 @@ -119,8 +119,8 @@ unsigned: 1 notnull: true relations: - ThdSegment: { onDelete: CASCADE, local: segment_id, foreign: id } - ThdTag: { onDelete: CASCADE, local: tag_id, foreign: id } + ThdSegment: { onDelete: CASCADE, local: segment_id, foreign: id, foreignAlias: segment_tags } + ThdTag: { onDelete: CASCADE, local: tag_id, foreign: id, foreignAlias: segment_tags } ThdTag: tableName: thd_tag columns: diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/core/ThdUtil.php --- a/web/thdProject/lib/core/ThdUtil.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/core/ThdUtil.php Thu Apr 29 00:57:52 2010 +0200 @@ -34,22 +34,65 @@ return ($a['count'] > $b['count']) ? -1 : 1; } - static public function getTagCloud($tagCloud, $nbItems, $maxScore=5) { + static public function processTagCloud($tagCloud, $nbItems, $maxScore=5) { $newTagCloud = $tagCloud; uasort($newTagCloud , 'ThdUtil::cmpTagCloud'); + + // Apply limit $newTagCloud = array_slice($newTagCloud, 0, $nbItems); + if (count($newTagCloud) == 0) return Array(); + + // Get first tag. Assume it has a score of 5 + $tagsByScore = Array(); + $firstTagCount = $newTagCloud[0]['count']; + $scoreRatio = $maxScore/$firstTagCount; + + foreach ($newTagCloud as $index=>$item) { + $score = (int) ceil($item['count']*$scoreRatio); + $newItem = Array( + 'tag' => $item['tag'], + 'count' => $score); - // Apply maxScore ratio - if ($newTagCloud) { - // Get first tag. Assume it has a score of 5 - $firstTagCount = $newTagCloud[0]['count']; - $scoreRatio = $maxScore/$firstTagCount; + if (!isset($tagsByScore[$score])) { + $tagsByScore[$score] = Array(); + } + + $tagsByScore[$score][] = $newItem; + } - foreach ($newTagCloud as $index=>$item) { - $newTagCloud[$index]['count'] = (int) ceil($item['count']*$scoreRatio); + // Sort tags in random way + $newTagCloud = Array(); + + foreach (range($maxScore, 1) as $scoreIndex=>$score) { + if (!isset($tagsByScore[$score])) continue; + + foreach ($tagsByScore[$score] as $itemIndex=>$item) { + $cloudIndex = ($itemIndex*$maxScore) + $scoreIndex; + $newTagCloud[$cloudIndex] = $item; } } + ksort($newTagCloud); return $newTagCloud; } + + static public function getGlobalTagCloud($limit=10) { + $tags = Array(); + + // Create query + $query = Doctrine_Query::create() + ->select("count(T.id), T.tag") + ->from('ThdTag T') + ->leftJoin('T.segment_tags ST') + ->groupBy("T.id") + ->orderBy("count(T.id) DESC") + ->limit($limit); + + foreach ($query->execute() as $item) { + $tags[] = Array('tag' => $item->getTag(), 'count' => (int) $item->count); + } + + return $tags; + + } } diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/ThdFilm.class.php --- a/web/thdProject/lib/model/doctrine/ThdFilm.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/ThdFilm.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -88,26 +88,39 @@ public function getTagCloud() { $tags = Array(); - foreach ($this->getTags() as $tag) { - $score = (isset($tags[$tag])) ? $tags[$tag]+1 : 1; - $tags[$tag] = $score; + // Create query + $query = Doctrine_Query::create() + ->select("count(T.id), T.tag") + ->from('ThdTag T') + ->leftJoin('T.segment_tags ST') + ->leftJoin('ST.ThdSegment S') + ->leftJoin('S.ThdVideo V') + ->leftJoin('V.ThdFilm F') + ->where("F.id='{$this->getId()}'") + ->groupBy("T.id"); + + foreach ($query->execute() as $item) { + $tags[] = Array('tag' => $item->getTag(), 'count' => (int) $item->count); } - // Convert to final structure - $newTags = Array(); - - foreach ($tags as $tag=>$count) { - $newTags[] = Array('tag' => $tag, 'count' => $count); - } - - return $newTags; + return $tags; } public function getTags() { $tags = Array(); - foreach ($this->getThdVideos() as $item) { - $tags = array_merge($tags, $item->getTags()); + // Create query + $query = Doctrine_Query::create() + ->select("ST.*, T.*") + ->from('ThdSegmentTag ST') + ->leftJoin('ST.ThdTag T') + ->leftJoin('ST.ThdSegment S') + ->leftJoin('S.ThdVideo V') + ->leftJoin('V.ThdFilm F') + ->where("F.id='{$this->getId()}'"); + + foreach ($query->execute() as $item) { + $tags[] = $item->getThdTag()->getTag(); } return $tags; @@ -116,11 +129,9 @@ public function getDistinctTags() { $tags = Array(); - foreach ($this->getThdVideos() as $item) { - foreach ($item->getDistinctTags() as $tag) { - if (in_array($tag, $tags)) continue; - $tags[] = $tag; - } + foreach ($this->getTags() as $tag) { + if (in_array($tag, $tags)) continue; + $tags[] = $tag; } return $tags; diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/ThdSegment.class.php --- a/web/thdProject/lib/model/doctrine/ThdSegment.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/ThdSegment.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -12,25 +12,19 @@ $this->creation_date = strftime('%Y-%m-%d %H:%M:%S'); } - - public function getThdTags() { - $objs = Array(); - $query = Doctrine_Query::create() - ->from('ThdSegmentTag') - ->where("segment_id='{$this->getId()}'"); - - foreach ($query->execute() as $item) { - $objs[] = $item->getThdTag(); - } - - return $objs; - } - public function getTags() { $tags = Array(); - foreach ($this->getThdTags() as $item) { - $tags[] = $item->getTag(); + // Create query + $query = Doctrine_Query::create() + ->select("ST.*, T.*") + ->from('ThdSegmentTag ST') + ->leftJoin('ST.ThdTag T') + ->leftJoin('ST.ThdSegment S') + ->where("S.id='{$this->getId()}'"); + + foreach ($query->execute() as $item) { + $tags[] = $item->getThdTag()->getTag(); } return $tags; @@ -39,8 +33,7 @@ public function getDistinctTags() { $tags = Array(); - foreach ($this->getThdTags() as $item) { - $tag = $item->getTag(); + foreach ($this->getTags() as $tag) { if (in_array($tag, $tags)) continue; $tags[] = $tag; } diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/ThdVideo.class.php --- a/web/thdProject/lib/model/doctrine/ThdVideo.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/ThdVideo.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -26,18 +26,20 @@ return $segmentObj; } - public function getThdSegments() { - $query = Doctrine_Query::create() - ->from('ThdSegment') - ->where("video_id='{$this->getId()}'"); - return $query->execute()->getData(); - } - public function getTags() { $tags = Array(); - foreach ($this->getThdSegments() as $item) { - $tags = array_merge($tags, $item->getTags()); + // Create query + $query = Doctrine_Query::create() + ->select("ST.*, T.*") + ->from('ThdSegmentTag ST') + ->leftJoin('ST.ThdTag T') + ->leftJoin('ST.ThdSegment S') + ->leftJoin('S.ThdVideo V') + ->where("V.id='{$this->getId()}'"); + + foreach ($query->execute() as $item) { + $tags[] = $item->getThdTag()->getTag(); } return $tags; @@ -46,11 +48,9 @@ public function getDistinctTags() { $tags = Array(); - foreach ($this->getThdSegments() as $item) { - foreach ($item->getDistinctTags() as $tag) { - if (in_array($tag, $tags)) continue; - $tags[] = $tag; - } + foreach ($this->getTags() as $tag) { + if (in_array($tag, $tags)) continue; + $tags[] = $tag; } return $tags; diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdFilm.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdFilm.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdFilm.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -81,7 +81,8 @@ public function setUp() { - $this->hasMany('ThdImage as images', array( + parent::setUp(); + $this->hasMany('ThdImage as images', array( 'local' => 'id', 'foreign' => 'film_id')); diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdImage.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdImage.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdImage.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -30,7 +30,8 @@ public function setUp() { - $this->hasOne('ThdFilm', array( + parent::setUp(); + $this->hasOne('ThdFilm', array( 'local' => 'film_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdSegment.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdSegment.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdSegment.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -60,7 +60,8 @@ public function setUp() { - $this->hasOne('ThdVideo', array( + parent::setUp(); + $this->hasOne('ThdVideo', array( 'local' => 'video_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); @@ -70,7 +71,7 @@ 'foreign' => 'id', 'onDelete' => 'CASCADE')); - $this->hasMany('ThdSegmentTag', array( + $this->hasMany('ThdSegmentTag as segment_tags', array( 'local' => 'id', 'foreign' => 'segment_id')); } diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdSegmentTag.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdSegmentTag.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdSegmentTag.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -31,7 +31,8 @@ public function setUp() { - $this->hasOne('ThdSegment', array( + parent::setUp(); + $this->hasOne('ThdSegment', array( 'local' => 'segment_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdTag.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdTag.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdTag.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -37,7 +37,8 @@ public function setUp() { - $this->hasMany('ThdSegmentTag', array( + parent::setUp(); + $this->hasMany('ThdSegmentTag as segment_tags', array( 'local' => 'id', 'foreign' => 'tag_id')); } diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdUser.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdUser.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdUser.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -24,7 +24,8 @@ public function setUp() { - $this->hasMany('ThdSegment as segments', array( + parent::setUp(); + $this->hasMany('ThdSegment as segments', array( 'local' => 'id', 'foreign' => 'user_id')); } diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/lib/model/doctrine/base/BaseThdVideo.class.php --- a/web/thdProject/lib/model/doctrine/base/BaseThdVideo.class.php Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/base/BaseThdVideo.class.php Thu Apr 29 00:57:52 2010 +0200 @@ -34,7 +34,8 @@ public function setUp() { - $this->hasOne('ThdFilm', array( + parent::setUp(); + $this->hasOne('ThdFilm', array( 'local' => 'film_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/web/css/base.css --- a/web/thdProject/web/css/base.css Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/web/css/base.css Thu Apr 29 00:57:52 2010 +0200 @@ -63,7 +63,7 @@ font-weight: normal; color: #FFFFFF; padding: 1px 10px 8px 10px; - height: 30px; + height: 17px; border: none; background: url("../images/buttons/bg_btn.png") repeat-x; text-transform: uppercase; @@ -85,13 +85,14 @@ font-family: arial, verdana, sans-serif; font-weight: normal; color: #FFFFFF; - padding: 1px 10px 8px 10px; - height: 30px; + padding: 2px 10px 4px 10px; + height: 24px; border: none; background: url("../images/buttons/bg_btn.png") repeat-x; text-transform: uppercase; cursor: pointer; overflow: hidden; + vertical-align: bottom; } diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/web/css/flashplayer.css --- a/web/thdProject/web/css/flashplayer.css Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/web/css/flashplayer.css Thu Apr 29 00:57:52 2010 +0200 @@ -80,36 +80,49 @@ margin: 0; padding: 0; display: block; + position: relative; text-align:center; cursor: pointer; } .player-item-mini { - width:337px; + width:338px; height:190px; } +.player-item-mini .infos, +.player-item-mini .tags { + width: 330px; +} + .player-item-big { width:720px; height:410px; } +.player-item-big .infos, +.player-item-big .tags { + width: 712px; +} + .player-item .infos a.title { font-size: 20px; font-weight: normal; font-family: georgia; color: #FFFFFF; } + .player-item .infos { - position: relative; + position: absolute; top:0px; + left: 0px; height:30px; background:#000; opacity:0.8; + filter:alpha(opacity=80); color:#999999; - margin: 0; text-align:left; - padding:4px 4px; + padding:4px; font-family:arial,"bitstream vera sans","trebuchet ms"; font-size:12px; z-index: 1000; @@ -117,24 +130,29 @@ .player-item .infos .film-infos { font-size:11px; } +.player-item .play-button { + position: absolute; + top: 40%; +} + .player-item-mini .play-button { - position: relative; - top: 30px; + left: 150px; } .player-item-big .play-button { - position: relative; - top: 150px; + left: 320px; } .player-item .tags { - position:relative; - top: 19px; + position: absolute; + left: 0px; + bottom: 0px; height:55px; background:#000; + padding: 4px; opacity:0.8; + filter:alpha(opacity=80); color:#FFFFFF; - margin: 33px 0px 0px 0px; text-align:left; font-family:arial,"bitstream vera sans","trebuchet ms"; font-size:14px; @@ -142,14 +160,6 @@ z-index: 1000; } -.player-item-mini .tags { - top: 19px; -} - -.player-item-big .tags { - top: 218px; -} - .player-item .tags .head { padding: 5px; font-size: 12px; @@ -159,7 +169,6 @@ color: #FFFFFF; } - /* Tags */ .player-item ul.tag-list:after { content: "."; diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/web/css/layout.css --- a/web/thdProject/web/css/layout.css Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/web/css/layout.css Thu Apr 29 00:57:52 2010 +0200 @@ -13,9 +13,10 @@ /* HEADER ===================== */ #header { position: relative; - width: 100%; + width: 1280px; height: 120px; background: #000000; + z-index: 0; } #header #universcinethd { @@ -61,21 +62,14 @@ #header-user { position: absolute; top: 7px; - right: 100px; + left: 1010px; + z-index: 100; } -#header-user .main { - position: absolute; - top: 0px; - right: 0px; - width: 272px; -} - -#header-user .login, -#header-user .profile { - position: relative; - height: 113px; - right: 0; +#header-user .login { + clear: both; + height: 113px; + padding: 0 20px; } #header-user .register a { @@ -89,8 +83,7 @@ background: transparent url("../images/layout/bg_login.png") repeat-x; } -#header-user .login .head, -#header-user .login .error { +#header-user .login .head { display: block; font-family: Georgia,"Times New Roman",Times,serif; font-size: 16px; @@ -99,94 +92,25 @@ } #header-user .login .head { -padding: 10px 0; -text-align:center; + padding: 10px 0; + text-align:center; color: #EFEFEF; } -#header-user .login .error { - color: #ff0000; -} - #header-user .login .buttons { text-align: center; padding: 12px 5px; } -#header-user .login label { - color: #ffffff; - text-transform: lowercase; -} - -#header-user .login .field input { - border: 0; -} - -#header-user .retrieve-password { - position: absolute; - top: 112px; - right: 120px; -} - -#header-user .retrieve-password a { - color: #ffffff; - font-weight: bold; -} - -#header-user .profile { - background: transparent url("/images/layout/bg_login.png") repeat-x; -} - -#header-user .display-name { - display: block; - text-align: right; -} - -#header-user .display-name span { - display: block; - padding: 2px 7px 0px 7px; - background: #990000; - color: #ffffff; - font-weight: bold; - font-size: 12px; - height: 20px; -} - -#header-user .profile .avatar, -#header-user .profile .community-list1 { - display: block; - position: absolute; - top: 15px; -} - -#header-user .profile .avatar { - left: 7px; -} - -#header-user .profile .community-list1 { - left: 60px; -} - -#header-user .profile .community-list1 a { - font-size: 11px; - color: #777777; -} - -#header-user .global-action-list { - position: absolute; - top: 55px; - left: 0px; -} - - /* NAVIGATION====== */ #navigation { -position: relative; + position: relative; width: 1280px; - padding: 5px; + padding: 5px 0; top: 24px; background:#000000; opacity:0.5; + filter:alpha(opacity=50); } #navigation:after { content: "."; @@ -215,6 +139,10 @@ } +#content-wrapper { + margin-top: 30px; +} + /* BODY============== */ #global { @@ -267,7 +195,17 @@ #sidebar { float: left; width:380px; - padding: 15px; + padding: 0 15px; +} + +#sidebar h3, +#content h3 { + margin-top: 0; +} + +#search { + margin-top: 20px; + clear: both; } #search form input.field { @@ -286,7 +224,7 @@ /* RIGHT HOMEPAGE===== */ #content { float: left; - margin: 15px; + padding: 0 15px; } .select-action{ diff -r 4bf8ee3cba88 -r 9845ed787b88 web/thdProject/web/js/segmentation/segments.js --- a/web/thdProject/web/js/segmentation/segments.js Wed Apr 28 20:06:59 2010 +0200 +++ b/web/thdProject/web/js/segmentation/segments.js Thu Apr 29 00:57:52 2010 +0200 @@ -14,7 +14,7 @@ }, markOut: function() { - player = $f(); + var player = $f(); player.pause(); this.mkout = Math.round(player.getTime() * 10) / 10; $("#btPlaySegment").removeAttr("disabled");