sketch.php 5.0 KB

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