setup_webapp.php 4.4 KB

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