sketch.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php require_once __DIR__.DIRECTORY_SEPARATOR.'header.php';
  2. try {
  3. if (!isset($_['id']) || !is_numeric($_['id'])) {
  4. throw new Exception("Sketch non spécifié");
  5. }
  6. $sketch = Sketch::getById($_['id']);
  7. if (!$sketch || $sketch->id == 0) {
  8. throw new Exception("Sketch inexistant");
  9. }
  10. if (!$sketch->public && $myUser->id != $sketch->owner) {
  11. throw new Exception("Sketch privé, demandez à son propriétaire de le rendre publique");
  12. }
  13. ?>
  14. <div class="row" id="sketch" data-id="<?php echo $sketch->id;
  15. ?>">
  16. <div class="col-md-4">
  17. <h5 id="sketchTitle"><input onblur="save_sketch_title(this);" type="text" value="<?php echo htmlspecialchars(html_entity_decode($sketch->label));
  18. ?>"/></h5>
  19. </div>
  20. <div class="col-md-8">
  21. <ul class="sketchOptions">
  22. <li onclick="window.location='action.php?action=export_sketch&amp;id=<?php echo $sketch->id;
  23. ?>';" title="Exporter"><i class="fa fa-share-square-o"></i></li>
  24. <li id="importResource" title="Envoyer des fichiers"><i class="fa fa-files-o"></i></li>
  25. <li onclick="toggle_embed_sketch();" title="Partager"><i class="fa fa-code"></i></li>
  26. <li onclick="toggle_share_sketch(this);" title="Rendre <?php echo $sketch->public==0?'Public':'Privé';
  27. ?>"><i class="fa <?php echo $sketch->public==0?'fa-eye-slash':'fa-eye';
  28. ?>"></i></li>
  29. <li id="download" onclick="window.location='action.php?action=download_sketch&amp;id=<?php echo $sketch->id;
  30. ?>'" title="Télécharger"><i class="fa fa-arrow-circle-o-down"></i></li>
  31. </ul>
  32. </div>
  33. </div>
  34. <div class="row">
  35. <div class="col-md-3" id="resourceMenu">
  36. <?php if ($myUser->id == $sketch->owner) : ?>
  37. <div class="btn-group" style="margin:10px auto;">
  38. <button onclick="add_resource();" type="button" class="btn btn-primary"><i class="fa fa-plus"></i> Ajouter une ressource</button>
  39. <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
  40. <span class="caret"></span>
  41. <span class="sr-only">Toggle Dropdown</span>
  42. </button>
  43. <ul class="dropdown-menu" role="menu">
  44. <?php foreach (Type::all() as $uid=>$type): ?>
  45. <li><a onclick="add_resource('<?php echo $uid;
  46. ?>');"><?php echo $type['label'];
  47. ?></a></li>
  48. <?php endforeach;
  49. ?>
  50. </ul>
  51. </div>
  52. <?php endif;
  53. ?>
  54. <div class="list-group resources" id="resources">
  55. <a class="list-group-item" style="display:none;" data-id="{{id}}" onclick="select_resource($(this).attr('data-id'));">
  56. <h4 class="list-group-item-heading">{{label}}</h4>
  57. <p class="list-group-item-text">Type : <code>{{type}}</code></p>
  58. <div class="resources-options"><i class="fa fa-pencil" onclick="edit_resource(this,event);"></i> <i onclick="delete_resource(this,event);" class="fa fa-times"></i></div>
  59. </a>
  60. </div>
  61. </div>
  62. <div class="col-md-9" id="resourceContent">
  63. <div class="jumbotron">
  64. <div class="jumbotron-contents" id="resource">
  65. <h2 style="margin:0 0 5px 0;">Aucune ressource sélectionnée</h2>
  66. <div class="preloader"></div>
  67. <p>Ce tableau est tristement vide... :(</p>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <!-- Resource edition -->
  73. <div id="editResourceMeta" class="modal fade" role="dialog" data-action="save_resource" data-id="">
  74. <div class="modal-dialog">
  75. <!-- Modal content-->
  76. <div class="modal-content">
  77. <div class="modal-header">
  78. <button type="button" class="close" data-dismiss="modal">&times;</button>
  79. <h4 class="modal-title">Edition ressource</h4>
  80. </div>
  81. <div class="modal-body">
  82. <label for="type">Type</label>
  83. <select class="form-control" id="type">
  84. <?php foreach (Type::all() as $uid=>$type): ?>
  85. <option value="<?php echo $uid;
  86. ?>"><?php echo $type['label'];
  87. ?></option>
  88. <?php endforeach;
  89. ?>
  90. </select>
  91. <label for="label">Libellé</label>
  92. <input class="form-control" type="text" id="label"/>
  93. </div>
  94. <div class="modal-footer">
  95. <button type="button" class="btn btn-primary" onclick="save_resource();" data-dismiss="modal">Enregistrer</button>
  96. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- Resource edition -->
  102. <div id="embedModal" class="modal fade" role="dialog" data-action="save_resource" data-id="">
  103. <div class="modal-dialog">
  104. <!-- Modal content-->
  105. <div class="modal-content">
  106. <div class="modal-header">
  107. <button type="button" class="close" data-dismiss="modal">&times;</button>
  108. <h4 class="modal-title">Copier coller le code suivant</h4>
  109. </div>
  110. <div class="modal-body">
  111. <label><input id="enableSideBar" checked="checked" onchange="get_embeded_code();" type="checkbox"> Afficher la barre de menu</label>
  112. <br/>
  113. <label for="code">Code</label>
  114. <textarea class="form-control"></textarea>
  115. </div>
  116. <div class="modal-footer">
  117. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <?php
  123. } catch (Exception $e) {
  124. $_SESSION['error'] = $e->getMessage();
  125. header('location: index.php');
  126. }
  127. require_once __ROOT__.'footer.php' ?>