page.sheet.sketch.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. global $myUser;
  3. require_once(__DIR__.SLASH.'Sketch.class.php');
  4. require_once(__DIR__.SLASH.'ResourceType.class.php');
  5. $sketch = Sketch::provide();
  6. if(!$sketch) throw new Exception("Sketch supprimé ou inexistant");
  7. if(!$sketch->state && $sketch->creator != $myUser->login) throw new Exception("Sketch privé");
  8. $sketchClasses = $sketch->creator != $myUser->login ? "readonly":"editable";
  9. if(isset($_['embeded']) && $_['embeded'] == 1) $sketchClasses .= ' embeded';
  10. if(isset($_['sidebar']) && $_['sidebar'] == 0) $sketchClasses .= ' no-sidebar';
  11. ?>
  12. <div class="hackpoint <?php echo $sketchClasses; ?>">
  13. <div id="sketch-form" class="sketch-form" data-action="hackpoint_sketch_save" data-id="<?php echo $sketch->id; ?>">
  14. <!-- resources bar -->
  15. <div id="resources-toolbar">
  16. <div class="resources-menu-container">
  17. <ul id="resources" data-entity-search="hackpoint_resource_search">
  18. <li data-id="{{id}}" class="hidden" onclick="hackpoint_resource_edit(this);">
  19. <i class="far fa-trash-alt delete-resource" onclick="hackpoint_resource_delete(this,event)" ></i>
  20. <i class="{{type.icon}}"></i>
  21. <h3 data-tooltip data-tooltip data-placement="right" title="Double cliquer pour modifier" ondblclick="hackpoint_resource_title_edit(event,this);"><span>{{label}}</span><input type="text" value="{{label}}" class="hidden"></h3>
  22. <small style="background:{{type.background}};color:{{type.color}}">{{type.label}}</small>
  23. </li>
  24. </ul>
  25. </div>
  26. <div class="btn-group dropright w-100 resource-dropdown">
  27. <button type="button" class="btn btn-dark btn-add-resource" data-tooltip data-placement="right" title="Ajouter une ressource" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  28. <i class="fas fa-plus"></i>
  29. </button>
  30. <div class="dropdown-menu">
  31. <?php foreach(ResourceType::types(null,true) as $type): ?>
  32. <a class="dropdown-item pointer" onclick="hackpoint_resource_save(this)" data-slug="<?php echo $type['uid']; ?>"><i class="<?php echo $type['icon']; ?>"></i> <?php echo $type['label']; ?><br/><small class="text-muted"><?php echo $type['description']; ?></small></a>
  33. <?php endforeach; ?>
  34. </div>
  35. </div>
  36. </div>
  37. <div id="sketch-workspace">
  38. <div class="row">
  39. <div class="col-md-8">
  40. <h3 class="m-0"><input id="label" name="label" class="form-control-plaintext d-inline-block w-50 pt-0 editable-input" placeholder="Nom du sketch ici" onblur="hackpoint_sketch_save();" value="<?php echo $sketch->label; ?>" type="text"></h3>
  41. </div>
  42. <div class="col-md-4">
  43. <!-- toolbar -->
  44. <div class="btn-toolbar right" role="toolbar" aria-label="Action">
  45. <div class="btn-group mr-2" role="group" aria-label="First group">
  46. <div class="btn text-muted"><span class="sketch-preloader"><i class="far fast-spin fas fa-circle-notch"></i> Sauvegarde...</span></div>
  47. </div>
  48. <div class="btn-group mr-2" role="group" aria-label="Properties">
  49. <label for="state" class="input-group-text pointer m-0" data-tooltip data-placement="bottom" title="Rendre publique/privé">
  50. <input id="state" name="state" class="form-control editable-input" onclick="hackpoint_sketch_save();" <?php echo $sketch->state?'checked="checked"':''; ?> type="checkbox" data-type="checkbox"> Publique
  51. </label>
  52. </div>
  53. <div class="btn-group" role="group" aria-label="Save" >
  54. <div class="dropdown">
  55. <div onclick="" class="btn btn-success" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-cogs"></i></div>
  56. <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
  57. <div class="dropdown-item pointer" onclick="hackpoint_sketch_share();"><i class="fas fa-share-alt"></i> Partager</div>
  58. <div class="dropdown-item pointer" onclick="hackpoint_sketch_download();"><i class="far fa-file-archive"></i> Télécharger</div>
  59. <div class="btn btn-delete-sketch dropdown-item" title="Supprimer" onclick="hackpoint_sketch_delete(this);"><i class="far fa-trash-alt"></i> Supprimer</div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <input type="text" id="comment" name="comment" onblur="hackpoint_sketch_save();" class="form-control-plaintext text-muted m-0 input-sm editable-input" value="<?php echo $sketch->comment; ?>">
  67. <div id="sketch-editor"></div>
  68. </div>
  69. </div>
  70. </div>
  71. <!-- MODALES -->
  72. <!-- Modale partage -->
  73. <div id="share-sketch-modal" class="hidden" data-id="">
  74. <div class="modalize-header">
  75. <h4 class="text-uppercase font-weight-light"><i class="fas fa-share-alt"></i> Gestion des partages</h4>
  76. </div>
  77. <div class="modalize-content">
  78. <p>Vous pouvez intégrer ce sketch sur votre site web avec le code ci-dessous.<br/>
  79. <span class="font-weight-bold text-warning">nb :</span> Le sketch doit être en visibilité publique
  80. pour que les internautes puissent le consulter.</p>
  81. <label><input type="checkbox" data-type="checkbox" class="share-menu-mode form-control"> n'afficher que la ressource courante </label>
  82. <textarea class="form-control share-input"></textarea>
  83. <div class="hidden shareCode"><a href="{{url}}?module=hackpoint&page=sheet.sketch&id={{sketch}}#resource={{resource}}"><small>Voir en taille réelle</small></a><br/><iframe frameborder="0" width="100%" align="center" height="400px" src="{{url}}?module=hackpoint&page=sheet.sketch&id={{sketch}}&embeded=1&sidebar={{menu}}#resource={{resource}}"></iframe></div>
  84. <div class="modalize-footer">
  85. <div class="btn btn-dark" data-close>Fermer</div>
  86. </div>
  87. </div>
  88. </div>