element.html.twig 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. {% if display_edit_actions is not defined %}
  2. {% set display_edit_actions = true %}
  3. {% endif %}
  4. {% if display_player is not defined %}
  5. {% set display_player = true %}
  6. {% endif %}
  7. {% if display_comments is not defined %}
  8. {% set display_comments = true %}
  9. {% endif %}
  10. {% if his_group is not defined %}
  11. {% set his_group = false %}
  12. {% endif %}
  13. {% if display_autoplay is not defined %}
  14. {% set display_autoplay = false %}
  15. {% endif %}
  16. {% if tag_ids_json is not defined %}
  17. {% set tag_ids_json = '[]' %}
  18. {% endif %}
  19. <table>
  20. <tr>
  21. <td class="element_thumbnail">
  22. {% if element.embed %}
  23. <a href="#" class="a_thumbnail {% if display_player %}element_open element_embed_open_link{% endif %} {% if element.embed and display_player %}embed{% else %}noembed{% endif %}">
  24. <img class="play" style="display: none;" src="{{ asset('bundles/muzichcore/img/1328283150_media-playback-start.png') }}" alt="" />
  25. <img
  26. class="element_thumbnail"
  27. {% if element.thumbnailUrl %}
  28. src="{{ element.thumbnailUrl }}"
  29. {% else %}
  30. src="{{ asset('bundles/muzichcore/img/nothumb.png') }}"
  31. {% endif %}
  32. title="{{ 'element.show.open_embed'|trans({}, 'elements') }}"
  33. alt=""
  34. />
  35. </a>
  36. {% else %}
  37. <a href="{{ element.url }}" class="a_thumbnail element_open {% if element.embed %}embed{% else %}noembed{% endif %}" target="_blank">
  38. <img class="open" style="display: none;" src="{{ asset('bundles/muzichcore/img/1328283201_emblem-symbolic-link.png') }}" alt="" />
  39. <img
  40. class="element_thumbnail"
  41. {% if element.thumbnailUrl %}
  42. src="{{ element.thumbnailUrl }}"
  43. {% else %}
  44. src="{{ asset('bundles/muzichcore/img/nothumb.png') }}"
  45. {% endif %}
  46. title="{{ 'element.show.open_embed'|trans({}, 'elements') }}"
  47. alt=""
  48. />
  49. </a>
  50. {% endif %}
  51. <ul class="element_thumb_actions">
  52. <li class="score">
  53. {{ element.points|format_score }}
  54. </li>
  55. <li class="vote thumb">
  56. {% if app.user %}
  57. {% if element.owner.id != app.user.id %}
  58. {% if element.hasVoteGood(app.user.id) %}
  59. <a class="vote" href="{{ path('ajax_element_remove_vote_good', {
  60. 'element_id' : element.id,
  61. 'token' : app.user.getPersonalHash(element.id)
  62. }) }}" title="{{ 'element.vote.good'|trans({}, 'elements') }}">
  63. <img src="{{ asset('img/icon_thumb_red.png') }}" alt="vote" />
  64. </a>
  65. {% else %}
  66. <a class="vote" href="{{ path('ajax_element_add_vote_good', {
  67. 'element_id' : element.id,
  68. 'token' : app.user.getPersonalHash(element.id)
  69. }) }}" title="{{ 'element.vote.good'|trans({}, 'elements') }}">
  70. <img src="{{ asset('img/icon_thumb.png') }}" alt="vote" />
  71. </a>
  72. {% endif %}
  73. {% else %}
  74. <img src="{{ asset('img/icon_thumb_gray.png') }}" alt="vote" />
  75. {% endif %}
  76. {% else %}
  77. <a href="#" class="mustbeconnected">
  78. <img src="{{ asset('img/icon_thumb.png') }}" alt="vote" />
  79. </a>
  80. {% endif %}
  81. </li>
  82. <li class="star">
  83. {% if app.user %}
  84. {% if element.hasFavoriteUser(app.user.id) %}
  85. <a class="favorite_link" href="{{ path('favorite_remove', { 'id': element.id, 'token': app.user.personalHash(element.id) }) }}" >
  86. <img id="favorite_{{ element.id }}_is" src="{{ asset('img/icon_star_2_red.png') }}" title="{{ 'element.favorite.remove'|trans({}, 'elements') }}" alt="{{ 'element.favorite.remove'|trans({}, 'elements') }}"/>
  87. </a>
  88. {% else %}
  89. <a class="favorite_link" href="{{ path('favorite_add', { 'id': element.id, 'token': app.user.personalHash(element.id) }) }}" >
  90. <img id="favorite_{{ element.id }}_isnot" src="{{ asset('img/icon_star_2.png') }}" title="{{ 'element.favorite.add'|trans({}, 'elements') }}" alt="{{ 'element.favorite.add'|trans({}, 'elements') }}" />
  91. </a>
  92. {% endif %}
  93. {% else %}
  94. <a class="mustbeconnected" href="#" >
  95. <img src="{{ asset('img/icon_star_2.png') }}" title="{{ 'element.favorite.add'|trans({}, 'elements') }}" alt="{{ 'element.favorite.add'|trans({}, 'elements') }}" />
  96. </a>
  97. {% endif %}
  98. </li>
  99. </ul>
  100. </td>
  101. <td class="element_content">
  102. <ul class="element_links_actions" class="gradient">
  103. <li class="element_link">
  104. <a title="{{ 'element.link'|trans({}, 'elements') }}" class="element_link" href="{{ element.url }}" target="_blank">
  105. <img src="{{ asset('/img/icon_link.png') }}" alt="link" />
  106. </a>
  107. </li>
  108. {% if display_autoplay and element|can_autoplay %}
  109. <li class="element_autoplay">
  110. <a title="{{ 'element.autoplay.title'|trans({}, 'elements') }}"
  111. data-element_id="{{ element.id }}"
  112. class="autoplay_link"
  113. {% if autoplay_context == 'home' %}
  114. href="{{ path('elements_get_filter_data_autoplay', {
  115. 'element_id' : element.id,
  116. 'type' : 'filter'
  117. }) }}"
  118. {% endif %}
  119. {% if autoplay_context == 'show_user' %}
  120. href="{{ path('elements_get_filter_data_autoplay_show', {
  121. 'element_id' : element.id,
  122. 'show_type' : 'user',
  123. 'show_id' : viewed_user.id,
  124. 'data' : tag_ids_json
  125. }) }}"
  126. {% endif %}
  127. {% if autoplay_context == 'show_group' %}
  128. href="{{ path('elements_get_filter_data_autoplay_show', {
  129. 'element_id' : element.id,
  130. 'show_type' : 'group',
  131. 'show_id' : group.id,
  132. 'data' : tag_ids_json
  133. }) }}"
  134. {% endif %}
  135. {% if autoplay_context == 'favorite_my' %}
  136. href="{{ path('elements_get_filter_data_autoplay_favorite', {
  137. 'element_id' : element.id,
  138. 'show_type' : 'user',
  139. 'show_id' : app.user.id,
  140. 'data' : tag_ids_json
  141. }) }}"
  142. {% endif %}
  143. {% if autoplay_context == 'favorite_user' %}
  144. href="{{ path('elements_get_filter_data_autoplay_favorite', {
  145. 'element_id' : element.id,
  146. 'show_type' : 'user',
  147. 'show_id' : viewed_user.id,
  148. 'data' : tag_ids_json
  149. }) }}"
  150. {% endif %}
  151. target="_blank"
  152. >
  153. <img src="{{ asset('/img/1361037350_control_play.png') }}" alt="playlist" />
  154. </a>
  155. </li>
  156. {% endif %}
  157. {% if app.user %}
  158. {% if app.user.id != element.owner.id %}
  159. {% if display_edit_actions %}
  160. <li class="element_propose_tags">
  161. <a title="{{ 'element.proposition_tags.link_title'|trans({}, 'userui') }}"
  162. class="element_propose_tags"
  163. href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
  164. <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
  165. </a>
  166. </li>
  167. <li class="element_reshare">
  168. <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}"
  169. class="element_reshare"
  170. href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
  171. <img src="{{ asset('/img/icon_reload.png') }}" alt="re" />
  172. </a>
  173. </li>
  174. <li class="element_report">
  175. <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}"
  176. class="element_report"
  177. href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash(element.id)}) }}">
  178. <img src="{{ asset('/img/icon_alert.png') }}" alt="report" />
  179. </a>
  180. </li>
  181. {% endif %}
  182. {% endif %}
  183. {% if app.user.id == element.owner.id %}
  184. {% if display_edit_actions %}
  185. {% if element.hasTagProposition %}
  186. <li class="element_view_propositions_link">
  187. <a title="{{ 'element.view_propositions.link'|trans({}, 'elements') }}" class="element_view_propositions_link"
  188. href="{{ path('ajax_element_proposed_tags_view', {'element_id' : element.id}) }}"
  189. >
  190. <img src="{{ asset('bundles/muzichcore/img/1333493527_tag_add.png') }}" alt="tags proposition" />
  191. </a>
  192. </li>
  193. {% endif %}
  194. <li class="element_edit_link">
  195. <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link"
  196. href="{{ path('element_edit', {'element_id' : element.id}) }}"
  197. >
  198. <img src="{{ asset('/img/icon_pen.png') }}" alt="edit" />
  199. </a>
  200. </li>
  201. <li class="element_remove_link">
  202. <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link"
  203. href="{{ path('element_remove', {'element_id' : element.id, 'token':app.user.getPersonalHash(element.id)}) }}"
  204. >
  205. <img src="{{ asset('/img/icon_close_2.png') }}" alt="delete" />
  206. </a>
  207. </li>
  208. {% endif %}
  209. {% endif %}
  210. {% else %}
  211. <li class="element_propose_tags">
  212. <a title="{{ 'element.proposition_tags.link_title'|trans({}, 'userui') }}"
  213. class="mustbeconnected"
  214. href="#">
  215. <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
  216. </a>
  217. </li>
  218. <li class="element_reshare">
  219. <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}"
  220. class="mustbeconnected"
  221. href="#">
  222. <img src="{{ asset('/img/icon_reload.png') }}" alt="re" />
  223. </a>
  224. </li>
  225. <li class="element_report">
  226. <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}"
  227. class="mustbeconnected"
  228. href="#">
  229. <img src="{{ asset('/img/icon_alert.png') }}" alt="report" />
  230. </a>
  231. </li>
  232. {% endif %}
  233. {% if his_group %}
  234. <li class="remove_from_group">
  235. <a title="{{ 'element.group.remove_from.title'|trans({'%group_name%':group.name}, 'elements') }}"
  236. class="element_remove_from_group_link"
  237. href="{{ path('element_remove_from_group', {
  238. 'element_id' : element.id,
  239. 'group_id' : group.id,
  240. 'token' : app.user.getPersonalHash('remove_from_group_'~element.id)
  241. }) }}">
  242. <img src="{{ asset('/img/1360779431_Remove_gray.png') }}" alt="remove from group" />
  243. </a>
  244. </li>
  245. {% endif %}
  246. <li>
  247. <a
  248. class="add_to_playlist"
  249. href="{{ path('playlists_add_element_prompt', { 'element_id' : element.id }) }}"
  250. title="{{ 'playlist.add_this_element'|trans({}, 'elements') }}"
  251. >
  252. <img src="{{ asset('/img/icon_add_2.png') }}" alt="add to playlist" />
  253. </a>
  254. </li>
  255. </ul>
  256. <span class="element_name">
  257. {% if element.embed %}
  258. <a href="#" class="element_open element_name_embed_open_link">
  259. {{ element.name }}
  260. </a>
  261. {% else %}
  262. <a href="{{ element.url }}" class="element_open" target="_blank">
  263. {{ element.name }}
  264. </a>
  265. {% endif %}
  266. </span>
  267. <br />
  268. {% autoescape false %}
  269. {% if element.group and no_group_name is not defined%}
  270. {{ 'element.name.whoandgroup'|trans({
  271. '%owner_url%' : path('show_user', {'slug': element.owner.slug}),
  272. '%owner_name%' : element.owner.name,
  273. '%group_url%' : path('show_group', {'slug': element.group.slug}),
  274. '%group_name%' : element.group.name
  275. }, 'elements') }}
  276. {% else %}
  277. {{ 'element.name.who'|trans({
  278. '%owner_url%' : path('show_user', {'slug': element.owner.slug}),
  279. '%owner_name%' : element.owner.name
  280. }, 'elements') }}
  281. {% endif %}
  282. {{ element.created.date|date_or_relative_date }}
  283. {% if element.parent %}
  284. {{ 'element.name.reshare'|trans({
  285. '%owner_url%' : path('show_user', {'slug': element.parent.owner.slug}),
  286. '%owner_name%' : element.parent.owner.name
  287. }, 'elements') }}
  288. {% endif %}
  289. {% endautoescape %}
  290. <div class="loader">
  291. <img class="element_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
  292. </div>
  293. {% if element.tags|length %}
  294. <ul class="element_tags">
  295. {% for tag in element.tags %}
  296. <li class="element_tag">
  297. <a id="element_tag_{{ tag.id }}" href="#"
  298. class="element_tag button {% if app.user %}{% if app.user.haveTagsFavorite(tag.id) %}element_tag_large_for_fav_still{% endif %}{% endif %}"
  299. >
  300. {{ tag.name }}
  301. </a>
  302. {% if app.user %}
  303. {% if app.user.haveTagsFavorite(tag.id) %}
  304. <img class="tag_to_favorites" src="{{ asset('/img/icon_heart.png') }}"
  305. alt="add-to-favorites"
  306. title="{{ 'element.tag.isfav.title'|trans({'%tagname%':tag.name}, 'elements') }}"
  307. />
  308. {% else %}
  309. <a
  310. href="{{ path('ajax_tag_add_to_favorites', {
  311. 'tag_id' : tag.id,
  312. 'token' : app.user.getPersonalHash(tag.id)
  313. }) }}"
  314. class="tag_to_favorites"
  315. style="display: none;"
  316. title="{{ 'element.tag.addtofav.title'|trans({}, 'elements') }}"
  317. >
  318. <img class="tag_add_to_favorites" src="{{ asset('/img/icon_heart.png') }}" alt="add-to-favorites"/>
  319. </a>
  320. {% endif %}
  321. {% else %}
  322. <a
  323. href="#"
  324. class="tag_to_favorites mustbeconnected"
  325. style="display: none;"
  326. title="{{ 'element.tag.addtofav.title'|trans({}, 'elements') }}"
  327. >
  328. <img class="tag_add_to_favorites" src="{{ asset('/img/icon_heart.png') }}" alt="add-to-favorites"/>
  329. </a>
  330. {% endif %}
  331. </li>
  332. {% endfor %}
  333. </ul>
  334. {% endif %}
  335. <a href="#" class="button element_open element_embed_close_link" style="display: none;">
  336. {{ 'element.show.close_embed'|trans({}, 'elements') }}
  337. </a>
  338. {% if display_comments %}
  339. {% autoescape false %}
  340. {% if element.comments|length > 1 %}
  341. <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
  342. {{ 'element.comments.hideare'|trans({}, 'elements') }}
  343. </a>
  344. <a href="#comments_{{ element.id }}" class="display_comments">
  345. {{ 'element.comments.thereare'|trans({'%count%':element.comments|length}, 'elements') }}
  346. </a>
  347. {% elseif element.comments|length == 1 %}
  348. <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
  349. {{ 'element.comments.hideis'|trans({}, 'elements') }}
  350. </a>
  351. <a href="#comments_{{ element.id }}" class="display_comments">
  352. {{ 'element.comments.thereis'|trans({}, 'elements') }}
  353. </a>
  354. {%endif %}
  355. {% endautoescape %}
  356. {% if app.user %}
  357. <a href="#add_comment_{{ element.id }}" class="add_comment">
  358. {{ 'element.comments.add'|trans({}, 'elements') }}
  359. </a>
  360. {% else %}
  361. <a href="#" class="mustbeconnected add_comment_disabled">
  362. {{ 'element.comments.add'|trans({}, 'elements') }}
  363. </a>
  364. {% endif %}
  365. {% endif %}
  366. </td>
  367. </tr>
  368. </table>
  369. {% if ids_display is defined %}
  370. {% if ids_display == event_const('TYPE_TAGS_PROPOSED') %}
  371. {% include 'MuzichCoreBundle:Element:tag.propositions.html.twig' with {
  372. 'propositions' : element.getTagsProposition,
  373. 'element_id' : element.id
  374. } %}
  375. {% endif %}
  376. {% endif %}
  377. {% if display_player %}
  378. <div id="embed_{{ element.id }}" class="element_embed" style="display: none;"></div>
  379. {% endif %}
  380. {% if display_comments %}
  381. <div class="comments" style="display: none;">
  382. <ul class="comments">
  383. {% if element.comments|length %}
  384. {% for comment in element.comments %}
  385. {% include "MuzichCommentBundle:Comment:li.comment.html.twig" with {'element_id' : element.id} %}
  386. {% endfor %}
  387. {% endif %}
  388. </ul>
  389. <div class="comments_loader">
  390. <img class="comments_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
  391. </div>
  392. {% if app.user %}
  393. <form
  394. action="{{ path('ajax_add_comment', {'element_id':element.id, 'token':app.user.getPersonalHash(element.id)}) }}"
  395. method="post"
  396. name="add_comment"
  397. style="display: none;"
  398. class="add_comment"
  399. >
  400. {% include "MuzichCommentBundle:Comment:form.html.twig" with {
  401. 'submit_value' : 'element.comments.add_submit'|trans({}, 'elements'),
  402. 'cancel_value' : 'element.comments.add_cancel'|trans({}, 'elements'),
  403. 'following' : element.userFollowComments(app.user.id),
  404. 'own' : (app.user.id == element.owner.id)
  405. } %}
  406. </form>
  407. {% endif %}
  408. <a href="#add_comment_{{ element.id }}" class="add_comment">
  409. {{ 'element.comments.add'|trans({}, 'elements') }}
  410. </a>
  411. </div>
  412. {% endif %}