setup_webapp.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a
  6. class="button button-secondary"
  7. id="btn-back"
  8. href="/add/webapp/?domain=<?= htmlentities($v_domain) ?>"
  9. >
  10. <i class="fas fa-arrow-left icon-blue"></i>
  11. <?= _("Back") ?>
  12. </a>
  13. </div>
  14. <div class="toolbar-buttons">
  15. <button type="submit" class="button" form="vstobjects">
  16. <i class="fas fa-floppy-disk icon-purple"></i>
  17. <?= _("Save") ?>
  18. </button>
  19. </div>
  20. </div>
  21. </div>
  22. <!-- End toolbar -->
  23. <!-- Begin form -->
  24. <div class="container animate__animated animate__fadeIn">
  25. <?php if (!empty($WebappInstaller->getOptions())) { ?>
  26. <form id="vstobjects" method="POST" name="v_setup_webapp">
  27. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  28. <input type="hidden" name="ok" value="true">
  29. <div class="form-container">
  30. <h1 class="form-title"><?= sprintf(_("Install %s"), $WebappInstaller->info()["name"]) ?></h1>
  31. <?php show_alert_message($_SESSION); ?>
  32. <?php if (!$WebappInstaller->isDomainRootClean()) { ?>
  33. <div class="alert alert-info" role="alert">
  34. <i class="fas fa-info"></i>
  35. <div>
  36. <p class="u-mb10"><?= _("Data loss warning!") ?></p>
  37. <p class="u-mb10"><?= _("Your web folder already has files uploaded to it. The installer will overwrite your files and / or the installation might fail.") ?></p>
  38. <p><?php echo sprintf(_("Please make sure ~/web/%s/public_html is empty!"), $v_domain); ?></p>
  39. </div>
  40. </div>
  41. <?php } ?>
  42. <div class="u-mt20">
  43. <?php
  44. foreach ($WebappInstaller->getOptions() as $form_name => $form_control) {
  45. $field_name = $WebappInstaller->formNs() . "_" . $form_name;
  46. $field_type = $form_control;
  47. $field_value = "";
  48. $field_label =
  49. isset($form_control["label"])
  50. ? htmlentities($form_control["label"])
  51. : ucwords(str_replace([".","_"], " ", $form_name));
  52. $field_placeholder = "";
  53. if (is_array($form_control)) {
  54. $field_type = !empty($form_control["type"]) ? $form_control["type"] : "text";
  55. $field_value = !empty($form_control["value"]) ? $form_control["value"] : "";
  56. $field_placeholder = !empty($form_control["placeholder"]) ? $form_control["placeholder"] : "";
  57. }
  58. $field_value = htmlentities($field_value);
  59. $field_label = htmlentities($field_label);
  60. $field_name = htmlentities($field_name);
  61. $field_placeholder = htmlentities($field_placeholder);
  62. ?>
  63. <div
  64. x-data="{
  65. value: '<?= !empty($field_value) ? $field_value : "" ?>'
  66. }"
  67. class="u-mb10"
  68. >
  69. <?php if ($field_type != "boolean"): ?>
  70. <label for="<?= $field_name ?>" class="form-label">
  71. <?= $field_label ?>
  72. <?php if ($field_type == "password") { ?>
  73. /
  74. <button
  75. x-on:click="value = randomString()"
  76. class="form-link"
  77. type="button"
  78. >
  79. <?= _("generate") ?>
  80. </button>
  81. <?php } ?>
  82. </label>
  83. <?php endif; ?>
  84. <?php if ($field_type == 'select' && count($form_control['options'])) { ?>
  85. <select class="form-select" name="<?= $field_name ?>" id="<?= $field_name ?>">
  86. <?php
  87. foreach ($form_control['options'] as $key => $option) {
  88. $key = !is_numeric($key) ? $key : $option;
  89. $selected = !empty($form_control['value'] && $key == $form_control['value']) ? 'selected' : '';
  90. ?>
  91. <option
  92. value="<?= $key ?>"
  93. <?= $selected ?>
  94. >
  95. <?= htmlentities($option) ?>
  96. </option>
  97. <?php } ?>
  98. </select>
  99. <?php
  100. } elseif ($field_type == "boolean") {
  101. $checked = !empty($field_value) ? "checked" : "";
  102. ?>
  103. <div class="form-check">
  104. <input
  105. class="form-check-input"
  106. type="checkbox"
  107. name="<?= $field_name ?>"
  108. id="<?= $field_name ?>"
  109. value="true"
  110. <?= $checked ?>
  111. >
  112. <label for="<?= $field_name ?>">
  113. <?= $field_label ?>
  114. </label>
  115. </div>
  116. <?php } else { ?>
  117. <input
  118. x-model="value"
  119. type="text"
  120. class="form-control"
  121. name="<?= $field_name ?>"
  122. id="<?= $field_name ?>"
  123. placeholder="<?= $field_placeholder ?>"
  124. >
  125. <?php } ?>
  126. </div>
  127. <?php } ?>
  128. </div>
  129. </div>
  130. </form>
  131. <?php } ?>
  132. </div>
  133. <!-- End form -->