Browse Source

Evolution #97: Présentation des elments

bastien 13 years ago
parent
commit
f3b91e638a

+ 2 - 2
app/Resources/translations/elements.fr.yml View File

19
     open_embed:         Afficher le lecteur
19
     open_embed:         Afficher le lecteur
20
     open_link:          Ouvrir la page
20
     open_link:          Ouvrir la page
21
   name:
21
   name:
22
-    who:                (envoyé par <a href="%owner_url%">%owner_name%</a>)
23
-    whoandgroup:        (envoyé par <a href="%owner_url%">%owner_name%</a> dans le groupe <a href="%group_url%">%group_name%</a>)
22
+    who:                envoyé par <a href="%owner_url%">%owner_name%</a>
23
+    whoandgroup:        envoyé par <a href="%owner_url%">%owner_name%</a> dans le groupe <a href="%group_url%">%group_name%</a>
24
   link:                 Ouvrir la page d'origine
24
   link:                 Ouvrir la page d'origine
25
   edit:
25
   edit:
26
     link:               Modifier
26
     link:               Modifier

+ 1 - 0
src/Muzich/CoreBundle/ElementFactory/ElementManager.php View File

131
     {
131
     {
132
       $site_factory = $this->getFactory();
132
       $site_factory = $this->getFactory();
133
       $this->element->setEmbed($site_factory->getEmbedCode());
133
       $this->element->setEmbed($site_factory->getEmbedCode());
134
+      $this->element->setThumbnailUrl($site_factory->getThumbnailUrl());
134
     }
135
     }
135
     
136
     
136
   }
137
   }

+ 14 - 0
src/Muzich/CoreBundle/ElementFactory/Site/YoutubeFactory.php View File

32
     
32
     
33
     return null;
33
     return null;
34
   }
34
   }
35
+  
36
+  public function getThumbnailUrl()
37
+  {
38
+    $url_object = $this->getCleanedUrl();
39
+    $url = null;
40
+    
41
+    // http://youtu.be/9hQVA2sloGc
42
+    if (preg_match("#\/([a-zA-Z0-9]+)#", $url_object, $chaines))
43
+    {
44
+      $url = 'http://img.youtube.com/vi/'.$chaines[1].'/default.jpg';
45
+    }
46
+    
47
+    return $url;
48
+  }
35
 }
49
 }
36
 
50
 
37
 ?>
51
 ?>

+ 18 - 0
src/Muzich/CoreBundle/ElementFactory/Site/YoutubecomFactory.php View File

36
     
36
     
37
     return null;
37
     return null;
38
   }
38
   }
39
+  
40
+  public function getThumbnailUrl()
41
+  {
42
+    $url_object = $this->getCleanedUrl();
43
+    $url = null;
44
+    
45
+    // '/watch?v=kOLQIV22JAs&feature=feedrec_grec_index'
46
+    if (preg_match("#(v\/|watch\?v=)([\w\-]+)#", $url_object, $chaines))
47
+    {
48
+      $url = 'http://img.youtube.com/vi/'.$chaines[2].'/default.jpg';
49
+    }
50
+    else if (preg_match("#(v=|watch\?v=)([\w\-]+)#", $url_object, $chaines))
51
+    {
52
+      $url = 'http://img.youtube.com/vi/'.$chaines[2].'/default.jpg';
53
+    }
54
+    
55
+    return $url;
56
+  }
39
 }
57
 }
40
 
58
 
41
 ?>
59
 ?>

+ 5 - 0
src/Muzich/CoreBundle/ElementFactory/Site/base/BaseFactory.php View File

43
     return str_replace('http://'.$this->element->getType(), '', $url);
43
     return str_replace('http://'.$this->element->getType(), '', $url);
44
   }
44
   }
45
   
45
   
46
+  public function getThumbnailUrl()
47
+  {
48
+    return null;
49
+  }
50
+  
46
 }
51
 }
47
 
52
 
48
 ?>
53
 ?>

+ 26 - 0
src/Muzich/CoreBundle/Entity/Element.php View File

118
    */
118
    */
119
   private $updated;
119
   private $updated;
120
   
120
   
121
+  /**
122
+   * @var string $thumbnail_url
123
+   *
124
+   * @ORM\Column(type="string", length=512, nullable=true)
125
+   */
126
+  protected $thumbnail_url;
121
 
127
 
122
   /**
128
   /**
123
    * Get id
129
    * Get id
358
   {
364
   {
359
       return $this->updated;
365
       return $this->updated;
360
   }
366
   }
367
+
368
+  /**
369
+   * Set thumbnail url
370
+   *
371
+   * @param string $thumbnail_url
372
+   */
373
+  public function setThumbnailUrl($thumbnail_url)
374
+  {
375
+      $this->thumbnail_url = $thumbnail_url;
376
+  }
377
+
378
+  /**
379
+   * Get thumbnail url
380
+   *
381
+   * @return datetime 
382
+   */
383
+  public function getThumbnailUrl()
384
+  {
385
+      return $this->thumbnail_url;
386
+  }
361
   
387
   
362
   /**
388
   /**
363
    * Etablie des relation vers des tags.
389
    * Etablie des relation vers des tags.

+ 112 - 80
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

1
-{% if element.getCountFavorite %}
2
-  <a class="favorite_link" href="{{ path('favorite_remove', { 'id': element.id, 'token': app.user.personalHash }) }}" >
3
-    <img src="{{ asset('bundles/muzichcore/img/favorite.png') }}" title="{{ 'element.favorite.remove'|trans({}, 'elements') }}" alt="{{ 'element.favorite.remove'|trans({}, 'elements') }}"/>
4
-  </a>
5
-{% else %}
6
-  <a class="favorite_link" href="{{ path('favorite_add', { 'id': element.id, 'token': app.user.personalHash }) }}" >
7
-    <img src="{{ asset('bundles/muzichcore/img/favorite_bw.png') }}" title="{{ 'element.favorite.add'|trans({}, 'elements') }}" alt="{{ 'element.favorite.add'|trans({}, 'elements') }}" />
8
-  </a>
9
-{% endif %}
10
-
11
-<span class="element_name">
12
-  {{ element.name }}
13
-</span> 
14
-
15
-{% autoescape false %}
16
-  {% if element.group and no_group_name is not defined%}
17
-    {{ 'element.name.whoandgroup'|trans({
18
-      '%owner_url%'  : path('show_user', {'slug': element.owner.slug}),
19
-      '%owner_name%' : element.owner.name,
20
-      '%group_url%'  : path('show_group', {'slug': element.group.slug}),
21
-      '%group_name%' : element.group.name
22
-    }, 'elements') }}
23
-  {% else %}
24
-    {{ 'element.name.who'|trans({
25
-      '%owner_url%'  : path('show_user', {'slug': element.owner.slug}),
26
-      '%owner_name%' : element.owner.name
27
-    }, 'elements') }}
28
-  {% endif %}
29
-{% endautoescape %}
1
+<table>
2
+  <tr>
3
+    <td class="element_thumbnail">
4
+      {% if element.embed %}
5
+        <a href="#" class="element_open element_embed_open_link">
6
+          <img 
7
+            {% if element.thumbnailUrl %}
8
+              src="{{ element.thumbnailUrl }}" 
9
+            {% else %}
10
+              src="{{ asset('bundles/muzichcore/img/nothumb.png') }}" 
11
+            {% endif %}
12
+            title="{{ 'element.show.open_embed'|trans({}, 'elements') }}" 
13
+            alt="open"
14
+          />
15
+        </a>
16
+      {% else %}
17
+        <a href="{{ element.url }}" class="element_open" target="_blank">
18
+          <img 
19
+            {% if element.thumbnailUrl %}
20
+              src="{{ element.thumbnailUrl }}" 
21
+            {% else %}
22
+              src="{{ asset('bundles/muzichcore/img/nothumb.png') }}" 
23
+            {% endif %}
24
+            title="{{ 'element.show.open_embed'|trans({}, 'elements') }}" 
25
+            alt="open"
26
+          />
27
+        </a>
28
+      {% endif %}
29
+    </td>
30
+    <td class="element_content">
31
+      
32
+      {% if element.getCountFavorite %}
33
+        <a class="favorite_link" href="{{ path('favorite_remove', { 'id': element.id, 'token': app.user.personalHash }) }}" >
34
+          <img src="{{ asset('bundles/muzichcore/img/favorite.png') }}" title="{{ 'element.favorite.remove'|trans({}, 'elements') }}" alt="{{ 'element.favorite.remove'|trans({}, 'elements') }}"/>
35
+        </a>
36
+      {% else %}
37
+        <a class="favorite_link" href="{{ path('favorite_add', { 'id': element.id, 'token': app.user.personalHash }) }}" >
38
+          <img src="{{ asset('bundles/muzichcore/img/favorite_bw.png') }}" title="{{ 'element.favorite.add'|trans({}, 'elements') }}" alt="{{ 'element.favorite.add'|trans({}, 'elements') }}" />
39
+        </a>
40
+      {% endif %}
41
+      
42
+      <span class="element_name">
43
+        {% if element.embed %}
44
+          <a href="#" class="element_open element_name_embed_open_link">
45
+            {{ element.name }}
46
+          </a>
47
+        {% else %}
48
+          <a href="{{ element.url }}" class="element_open" target="_blank">
49
+            {{ element.name }}
50
+          </a>
51
+        {% endif %}
52
+      </span> 
53
+      
54
+      <a title="{{ 'element.link'|trans({}, 'elements') }}" class="element_link" href="{{ element.url }}" target="_blank">
55
+        <img src="{{ asset('bundles/muzichcore/img/1324917097_link.png') }}" alt="link" />
56
+      </a>
57
+      
58
+      {% if app.user.id == element.owner.id %}
59
+        <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link" 
60
+           href="{{ path('element_edit', {'element_id' : element.id})  }}" style="display: none;"
61
+        >
62
+          <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
63
+        </a>
30
 
64
 
65
+        <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
66
+           href="{{ path('element_remove', {'element_id' : element.id})  }}" style="display: none;"
67
+        >
68
+          <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
69
+        </a>
70
+      {% endif %}
71
+      
72
+      <br />
73
+      {% autoescape false %}
74
+        {% if element.group and no_group_name is not defined%}
75
+          {{ 'element.name.whoandgroup'|trans({
76
+            '%owner_url%'  : path('show_user', {'slug': element.owner.slug}),
77
+            '%owner_name%' : element.owner.name,
78
+            '%group_url%'  : path('show_group', {'slug': element.group.slug}),
79
+            '%group_name%' : element.group.name
80
+          }, 'elements') }}
81
+        {% else %}
82
+          {{ 'element.name.who'|trans({
83
+            '%owner_url%'  : path('show_user', {'slug': element.owner.slug}),
84
+            '%owner_name%' : element.owner.name
85
+          }, 'elements') }}
86
+        {% endif %}
87
+      {% endautoescape %}
88
+      
89
+      <div class="loader">
90
+        <img class="element_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
91
+      </div>
92
+      
93
+      {% if element.tags|length %}
94
+      <ul class="element_tags">
95
+        {% for tag in element.tags %} 
96
+          <li class="element_tag">
97
+            {{ tag.name }}
98
+          </li>
99
+        {% endfor %} 
100
+      </ul>
101
+      {% endif %}
102
+      
103
+      <br />
104
+      <a href="#" class="element_open element_embed_open_link element_embed_open_link_text">
105
+        {{ 'element.show.open_embed'|trans({}, 'elements') }}
106
+      </a>
107
+      <a href="#" class="element_open element_embed_close_link" style="display: none;">
108
+        {{ 'element.show.close_embed'|trans({}, 'elements') }}
109
+      </a>
110
+      
111
+    </td>
112
+  </tr>
113
+</table>
31
 
114
 
32
-<a title="{{ 'element.link'|trans({}, 'elements') }}" class="element_link" href="{{ element.url }}" target="_blank">
33
-  <img src="{{ asset('bundles/muzichcore/img/1324917097_link.png') }}" alt="link" />
34
-</a>
35
-
36
-{% if app.user.id == element.owner.id %}
37
-  <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link" 
38
-     href="{{ path('element_edit', {'element_id' : element.id})  }}" style="display: none;"
39
-  >
40
-    <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
41
-  </a>
42
-
43
-  <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
44
-     href="{{ path('element_remove', {'element_id' : element.id})  }}" style="display: none;"
45
-  >
46
-    <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
47
-  </a>
48
-{% endif %}
49
-
50
-<div class="loader">
51
-  <img class="element_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
52
-</div>
53
-  
54
 {% if element.embed %}
115
 {% if element.embed %}
55
   {% autoescape false %}
116
   {% autoescape false %}
56
     <div id="embed_{{ element.id }}" class="element_embed" style="display: none;">
117
     <div id="embed_{{ element.id }}" class="element_embed" style="display: none;">
58
     </div>
119
     </div>
59
   {% endautoescape %}
120
   {% endautoescape %}
60
 {% endif %}
121
 {% endif %}
61
-
62
-<div>
63
-
64
-  {% if element.embed %}
65
-    <a href="#" class="element_open element_embed_close_link" style="display: none;">
66
-      {{ 'element.show.close_embed'|trans({}, 'elements') }}
67
-    </a>
68
-    <a href="#" class="element_open element_embed_open_link">
69
-      {{ 'element.show.open_embed'|trans({}, 'elements') }}
70
-    </a>
71
-  {% else %}
72
-    <a href="{{ element.url }}" class="element_open" target="_blank">
73
-      {{ 'element.show.open_link'|trans({}, 'elements') }}
74
-    </a>
75
-  {% endif %}
76
-
77
-  {% if element.tags|length %}
78
-  <ul class="element_tags">
79
-    {% for tag in element.tags %} 
80
-      <li class="element_tag">
81
-        {{ tag.name }}
82
-      </li>
83
-    {% endfor %} 
84
-  </ul>
85
-  {% else %}
86
-  <br />
87
-  {% endif %}
88
-
89
-</div>

+ 20 - 2
web/bundles/muzichcore/css/main.css View File

387
 
387
 
388
 li.element
388
 li.element
389
 {
389
 {
390
+  list-style: none outside none;
390
   margin-top: 5px;
391
   margin-top: 5px;
391
   margin-bottom: 5px;
392
   margin-bottom: 5px;
392
   padding: 5px;
393
   padding: 5px;
394
 
395
 
395
 li.element a.favorite_link
396
 li.element a.favorite_link
396
 {
397
 {
397
-  float: right;
398
+  position: relative;
399
+  top: 0px;
400
+  left: 455px;
398
 }
401
 }
399
 
402
 
400
 li.element a.element_open
403
 li.element a.element_open
401
 {
404
 {
402
-  float: right;
403
   font-weight: bold;
405
   font-weight: bold;
404
 }
406
 }
405
 
407
 
408
   text-align: center;
410
   text-align: center;
409
 }
411
 }
410
 
412
 
413
+li.element td.element_content
414
+{
415
+  vertical-align: top;
416
+  padding-left: 5px;
417
+}
418
+
419
+li.element span.element_name
420
+{
421
+  margin-left: -20px;
422
+}
423
+
424
+#container li.element span.element_name a
425
+{
426
+  color: black;
427
+}
428
+
411
 ul.elements li.even
429
 ul.elements li.even
412
 {
430
 {
413
   background-color: #d9f7ff;
431
   background-color: #d9f7ff;

BIN
web/bundles/muzichcore/img/nothumb.png View File


+ 29 - 10
web/bundles/muzichcore/js/muzich.js View File

187
 
187
 
188
   // Affichage un/des embed
188
   // Affichage un/des embed
189
   $('a.element_embed_open_link').live("click", function(){
189
   $('a.element_embed_open_link').live("click", function(){
190
-     $(this).parent().parent('li.element').find('a.element_embed_open_link').hide();
191
-     $(this).parent().parent('li.element').find('a.element_embed_close_link').show();
192
-     $(this).parent().parent('li.element').find('div.element_embed').show();
190
+    
191
+     li = $(this).parent('td').parent('tr').parent().parent().parent('li.element');
192
+     
193
+     li.find('a.element_embed_close_link').show();
194
+     li.find('a.element_embed_open_link_text').hide();
195
+     li.find('div.element_embed').show();
196
+     
197
+     return false;
198
+  });
199
+  
200
+  $('a.element_name_embed_open_link').live("click", function(){
201
+    
202
+     li = $(this).parent('span').parent('td').parent('tr').parent().parent().parent('li.element');
203
+     
204
+     li.find('a.element_embed_close_link').show();
205
+     li.find('a.element_embed_open_link_text').hide();
206
+     li.find('div.element_embed').show();
207
+     
193
      return false;
208
      return false;
194
   });
209
   });
195
 
210
 
196
   // Fermeture du embed si demandé
211
   // Fermeture du embed si demandé
197
   $('a.element_embed_close_link').live("click", function(){
212
   $('a.element_embed_close_link').live("click", function(){
198
-     $(this).parent().parent('li.element').find('a.element_embed_open_link').show();
199
-     $(this).parent().parent('li.element').find('a.element_embed_close_link').hide();
200
-     $(this).parent().parent('li.element').find('div.element_embed').hide();
213
+    
214
+     li = $(this).parent('td').parent('tr').parent().parent().parent('li.element');
215
+    
216
+     li.find('div.element_embed').hide();
217
+     li.find('a.element_embed_open_link_text').show();
218
+     $(this).hide();
219
+     
201
      return false;
220
      return false;
202
   });
221
   });
203
 
222
 
306
     cancelAnswer : "Non",
325
     cancelAnswer : "Non",
307
     onYes: function(link){
326
     onYes: function(link){
308
       
327
       
309
-      li = link.parent('li.element');
328
+      li = link.parent('td').parent('tr').parent().parent().parent('li.element');
310
       li.find('img.element_loader').show();
329
       li.find('img.element_loader').show();
311
       $.getJSON(link.attr('href'), function(response){
330
       $.getJSON(link.attr('href'), function(response){
312
         if (response.status == 'success')
331
         if (response.status == 'success')
322
       return false;
341
       return false;
323
     },
342
     },
324
     onOpen: function(link){
343
     onOpen: function(link){
325
-      li = link.parent('li.element');
344
+      li = link.parent('td').parent('tr').parent().parent().parent('li.element');
326
       li.find('a.element_edit_link').addClass('mustBeDisplayed');
345
       li.find('a.element_edit_link').addClass('mustBeDisplayed');
327
       li.find('a.element_remove_link').addClass('mustBeDisplayed');
346
       li.find('a.element_remove_link').addClass('mustBeDisplayed');
328
     },
347
     },
329
     onClose: function(link){
348
     onClose: function(link){
330
-      li = link.parent('li.element');
349
+      li = link.parent('td').parent('tr').parent().parent().parent('li.element');
331
       li.find('a.element_edit_link').removeClass('mustBeDisplayed');
350
       li.find('a.element_edit_link').removeClass('mustBeDisplayed');
332
       li.find('a.element_remove_link').removeClass('mustBeDisplayed');
351
       li.find('a.element_remove_link').removeClass('mustBeDisplayed');
333
       li.find('a.element_edit_link').hide();
352
       li.find('a.element_edit_link').hide();
340
   $('a.element_edit_link').live('click', function(){
359
   $('a.element_edit_link').live('click', function(){
341
     
360
     
342
     link = $(this);
361
     link = $(this);
343
-    li = link.parent('li.element');
362
+    li = link.parent('td').parent('tr').parent().parent().parent('li.element');
344
     // On garde en mémoire l'élément édité en cas d'annulation
363
     // On garde en mémoire l'élément édité en cas d'annulation
345
     elements_edited[li.attr('id')] = li.html();
364
     elements_edited[li.attr('id')] = li.html();
346
     div_loader = li.find('div.loader');
365
     div_loader = li.find('div.loader');