1
0

setup_webapp.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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="main-form">
  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">
  19. <?php if (!empty($WebappInstaller->getOptions())) { ?>
  20. <form id="main-form" 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="u-mb20"><?= sprintf(_("Install %s"), $WebappInstaller->info()["name"]) ?></h1>
  25. <?php show_alert_message($_SESSION); ?>
  26. <?php if (!$WebappInstaller->isDomainRootClean()) { ?>
  27. <div class="alert alert-info u-mb10" 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. <?php foreach ($WebappInstaller->getOptions() as $form_name => $form_control) {
  37. $field_name = $WebappInstaller->formNs() . "_" . $form_name;
  38. $field_type = $form_control;
  39. $field_value = "";
  40. $field_label =
  41. isset($form_control["label"])
  42. ? htmlentities($form_control["label"])
  43. : ucwords(str_replace([".","_"], " ", $form_name));
  44. $field_placeholder = "";
  45. if (is_array($form_control)) {
  46. $field_type = !empty($form_control["type"]) ? $form_control["type"] : "text";
  47. $field_value = !empty($form_control["value"]) ? $form_control["value"] : "";
  48. $field_placeholder = !empty($form_control["placeholder"]) ? $form_control["placeholder"] : "";
  49. }
  50. $field_value = htmlentities($field_value);
  51. $field_label = htmlentities($field_label);
  52. $field_name = htmlentities($field_name);
  53. $field_placeholder = htmlentities($field_placeholder);
  54. ?>
  55. <div class="u-mb10">
  56. <?php if ($field_type != "boolean"): ?>
  57. <label for="<?= $field_name ?>" class="form-label">
  58. <?= $field_label ?>
  59. <?php if ($field_type == "password"): ?>
  60. <button type="button" title="<?= _("Generate") ?>" class="u-unstyled-button u-ml5 js-generate-password">
  61. <i class="fas fa-arrows-rotate icon-green"></i>
  62. </button>
  63. <?php endif; ?>
  64. </label>
  65. <?php endif; ?>
  66. <?php if ($field_type == "select" && count($form_control["options"])): ?>
  67. <select class="form-select" name="<?= $field_name ?>" id="<?= $field_name ?>">
  68. <?php foreach ($form_control["options"] as $key => $option):
  69. $key = !is_numeric($key) ? $key : $option;
  70. $selected = !empty($form_control["value"] && $key == $form_control["value"]) ? "selected" : ""; ?>
  71. <option value="<?= $key ?>" <?= $selected ?>>
  72. <?= htmlentities($option) ?>
  73. </option>
  74. <?php endforeach; ?>
  75. </select>
  76. <?php elseif ($field_type == "boolean"):
  77. $checked = !empty($field_value) ? "checked" : ""; ?>
  78. <div class="form-check">
  79. <input
  80. class="form-check-input"
  81. type="checkbox"
  82. name="<?= $field_name ?>"
  83. id="<?= $field_name ?>"
  84. value="true"
  85. <?= $checked ?>
  86. >
  87. <label for="<?= $field_name ?>">
  88. <?= $field_label ?>
  89. </label>
  90. </div>
  91. <?php else: ?>
  92. <?php if ($field_type == "password"): ?>
  93. <div class="u-pos-relative">
  94. <input
  95. type="text"
  96. class="form-control js-password-input"
  97. name="<?= $field_name ?>"
  98. id="<?= $field_name ?>"
  99. placeholder="<?= $field_placeholder ?>"
  100. >
  101. <div class="password-meter">
  102. <meter max="4" class="password-meter-input js-password-meter"></meter>
  103. </div>
  104. </div>
  105. <?php else: ?>
  106. <input
  107. type="text"
  108. class="form-control"
  109. name="<?= $field_name ?>"
  110. id="<?= $field_name ?>"
  111. placeholder="<?= $field_placeholder ?>"
  112. >
  113. <?php endif; ?>
  114. <?php endif; ?>
  115. </div>
  116. <?php } ?>
  117. </div>
  118. </form>
  119. <?php } ?>
  120. </div>
  121. <!-- End form -->