page.factory.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. global $myUser;
  3. User::check_access('factory','read');
  4. require_once(__DIR__.SLASH.'Template.class.php');
  5. ?>
  6. <div id="factoryForm" data-action="factory_render">
  7. <div class="row">
  8. <div class="col-xl-7">
  9. <h6 class="text-muted font-weight-bold">PLUGIN</h6>
  10. <div class="shadow-sm bg-white p-2">
  11. <div class="input-group mb-2">
  12. <div class="input-group-prepend">
  13. <span class="input-group-text">Template</span>
  14. </div>
  15. <select class="form-control" id="template" onchange="factory_change_template(event);">
  16. <?php foreach(glob(Template::dir().'*') as $tpl): ?>
  17. <option value="<?php echo basename($tpl); ?>"><?php echo basename($tpl); ?></option>
  18. <?php endforeach; ?>
  19. </select>
  20. </div>
  21. <div class="input-group mb-2">
  22. <div class="input-group-prepend">
  23. <span class="input-group-text">Slug</span>
  24. </div>
  25. <input type="text" class="form-control" placeholder="Libellé technique du plugin" id="plugin">
  26. <div class="input-group-prepend">
  27. <span class="input-group-text">Libellé</span>
  28. </div>
  29. <input type="text" class="form-control" placeholder="Libellé visible pour les humains" id="pluginLabel">
  30. <input type="text" data-type="color" class="form-control input-group-append" value="#273c75" id="plugin-color">
  31. <input type="text" data-type="icon" class="form-control input-group-append" value="far fa-question-circle" id="plugin-icon">
  32. </div>
  33. <input type="text" class="form-control mt-2 form-control-sm" placeholder="Description courte (optionnel)" id="description">
  34. </div>
  35. <h6 class="text-muted font-weight-bold mt-2">ENTITE</h6>
  36. <div class="list-group shadow-sm">
  37. <span class="list-group-item p-2">
  38. <div class="input-group">
  39. <div class="input-group-prepend">
  40. <span class="input-group-text">Classe</span>
  41. </div>
  42. <input type="text" class="form-control entity-picker" placeholder="Nom physique de l'entité" id="entity">
  43. <div class="input-group-prepend">
  44. <span class="input-group-text">Libellé</span>
  45. </div>
  46. <input type="text" class="form-control" placeholder="Libellé visible pour les humains" id="entityLabel">
  47. </div>
  48. </span>
  49. <!-- champ d'entité -->
  50. <ul id="entity-fields" class="entity-fields">
  51. <li class="list-group-item field p-2">
  52. <div class="row">
  53. <div class="col-xl-4">
  54. <input type="text" class="form-control input-small fieldSlug" placeholder="slug">
  55. </div>
  56. <div class="col-xl-4">
  57. <input type="text" class="form-control input-small fieldLabel" placeholder="Libellé">
  58. </div>
  59. <div class="col-xl-4">
  60. <select class="form-control input-small fieldType" onchange="factory_change_type(this)">
  61. <?php foreach(Template::types() as $category=>$values): ?>
  62. <optgroup label="<?php echo $category; ?>">
  63. <?php foreach($values as $key=>$value): ?>
  64. <option value="<?php echo $key; ?>"><?php echo $value->label; ?></option>
  65. <?php endforeach; ?>
  66. </optgroup>
  67. <?php endforeach; ?>
  68. </select>
  69. <input type="text" data-type="entitypicker" onchange="factory_render()" class="form-control entity-picker hidden mt-1" >
  70. </div>
  71. </div>
  72. <ul class="field-menu">
  73. <li><i class="btn-move fas fa-arrows-alt text-muted"></i></li>
  74. <li onclick="factory_removeline(this)"><i class="btn-remove fas fa-times text-danger"></i></li>
  75. <li onclick="factory_addline(this)"><i class="btn-remove fas fa-plus text-success"></i></li>
  76. </ul>
  77. </li>
  78. </ul>
  79. </div>
  80. <br>
  81. <div id="factoryFilters">
  82. <h6 class="text-muted font-weight-bold">OPTIONS</h6>
  83. <ul class="list-group shadow-sm">
  84. <li class="hidden list-group-item">
  85. <label><input onchange="factory_render()" data-checked="{{default}}" type="checkbox" data-id="{{slug}}" data-type="checkbox">
  86. {{label}} <small class="text-muted"> - {{slug}}</small></label>
  87. </li>
  88. </ul>
  89. </div>
  90. <hr>
  91. <a href="#" class="pointer" onclick="$(this).next().toggleClass('hidden');">Voir les conventions de nommage</a>
  92. <div class="hidden">
  93. <h5>Conventions de nommage</h5>
  94. <ul>
  95. <li><strong>Méthode et fonctions</strong> <code>function get_users(){}</code> - Séparation par "_" et tout en minuscule <i>(Snake Case)</i></li>
  96. <li><strong>Classes</strong> <code>class MaClasse {}</code> - Séparation par camelCase et premiere lettre en majuscule <i>(Upper Camel Case / Pascal Case)</i></li>
  97. <li><strong>Variables</strong> <code>$maVariable</code> - Séparation par camelCase tout en minuscule <i>(Lower Camel Case / Camel Case)</i></li>
  98. <li><strong>Constantes</strong> <code>const MA_CONSTANTE</code> - Séparation par "_"tout en majuscule <i>(Screaming Snake Case)</i></li>
  99. <li><strong>Classes css et id css</strong> <code>.ma-classe {} #mon-id{}</code> - Séparation par tiret tout en minuscule <i>(Kebab Case)</i></li>
  100. <li><strong>Actions</strong> <code>case 'plugin_entite_action'</code> - Séparation par "_" en minuscule <i>(Snake Case)</i></li>
  101. </ul>
  102. </div>
  103. </div>
  104. <div class="col-xl-5 bg-white p-2 shadow-sm">
  105. <ul class="nav nav-pills" id="factoryParts">
  106. <li class="nav-item hidden">
  107. <a class="nav-link {{#active}}active{{/active}}" data-part="{{label}}" data-langage="{{syntax}}" href="#">{{label}}</a>
  108. </li>
  109. </ul>
  110. <div id="factory-generate-button" class="btn btn-primary mb-2 mt-2 float-left btn-sm" onclick="factory_render(event,1)"><i class="fas fa-cogs"></i> Générer</div>
  111. <div class="btn btn-dark ml-2 mb-2 mt-2 float-left btn-sm" onclick="copy_string($('#factoryCode').text(), $('#factoryCode'));"><i class="fas fa-copy"></i> Copier</div>
  112. <span id="factory-generate-message"></span>
  113. <div class="clear"></div>
  114. <pre><code id="factoryCode" onclick="select_text($('#factoryCode'),event)" class="php"></code></pre>
  115. </div>
  116. </div>
  117. </div>
  118. <br/>
  119. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai-sublime.min.css">
  120. <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  121. <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/php.min.js"></script>