items.html.twig 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. {% macro display(items, category_id, allow_edit, _c) %}
  2. {% set edit_img = 'edit.png'|img(22, 'Edit'|get_lang) %}
  3. {% set visible_img = 'visible.png'|img(22, 'Invisible'|get_lang) %}
  4. {% set invisible_img = 'invisible.png'|img(22, 'Visible'|get_lang) %}
  5. {% set delete_img = 'delete.png'|img(22, 'Delete'|get_lang) %}
  6. {% set baseurl = _p.web_self ~ '?' ~ (_p.web_cid_query ? _p.web_cid_query ~ '&' : '') %}
  7. <div class="panel-group" id="accordion-list-{{ category_id }}" role="tablist" aria-multiselectable="true">
  8. {% for item in items %}
  9. <div class="panel panel-default">
  10. <div class="panel-heading" role="tab" id="heading-item-{{ item.id }}">
  11. {% if allow_edit %}
  12. <div class="pull-right">
  13. <a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
  14. {{ edit_img }}
  15. </a>
  16. {% if item.isVisible %}
  17. <a href="{{ baseurl ~ {'action':'hide_item', 'id':item.id}|url_encode }}">
  18. {{ visible_img }}
  19. </a>
  20. {% else %}
  21. <a href="{{ baseurl ~ {'action':'show_item', 'id':item.id}|url_encode }}">
  22. {{ invisible_img }}
  23. </a>
  24. {% endif %}
  25. <a href="{{ baseurl ~ {'action':'delete_item', 'id':item.id}|url_encode }}"
  26. class="btn-delete">
  27. {{ delete_img }}
  28. </a>
  29. </div>
  30. {% endif %}
  31. <h5 class="panel-title">
  32. <a href="#collapse-{{ item.id }}" class="collapsed" role="button"
  33. data-parent="#accordion-list-{{ category_id }}"
  34. data-toggle="collapse" aria-expanded="false" aria-controls="collapse-{{ item.id }}">
  35. {{ item.title }}
  36. </a>
  37. </h5>
  38. {% if _c is empty %}
  39. {% if item.session %}
  40. <div class="clearfix">
  41. {{ 'Course'|get_lang ~ ': ' ~ item.session.name ~ ' (' ~ item.course.title ~ ')' }}
  42. </div>
  43. {% elseif not item.session and item.course %}
  44. <div class="clearfix">
  45. {{ 'Course'|get_lang ~ ': ' ~ item.course.title }}<br>
  46. </div>
  47. {% endif %}
  48. {% endif %}
  49. </div>
  50. <div id="collapse-{{ item.id }}" class="panel-collapse collapse" role="tabpanel"
  51. aria-labelledby="heading-item-{{ item.id }}">
  52. <div class="panel-body">
  53. {{ item.content }}
  54. </div>
  55. </div>
  56. <div class="panel-footer">
  57. {{ 'CreationDate'|get_lang ~ ': ' ~ item.creationDate|date_to_time_ago }}
  58. {% if item.creationDate != item.updateDate %}
  59. &centerdot;
  60. {{ 'UpdateDate'|get_lang ~ ': ' ~ item.updateDate|date_to_time_ago }}
  61. {% endif %}
  62. </div>
  63. </div>
  64. {% endfor %}
  65. </div>
  66. {% endmacro %}