sketch.php 5.2 KB

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