setup_webapp.php 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary" id="btn-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. <div class="container animate__animated animate__fadeIn">
  18. <?php if (!empty($WebappInstaller->getOptions())): ?>
  19. <form id="vstobjects" method="POST" name="v_setup_webapp">
  20. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  21. <input type="hidden" name="ok" value="true">
  22. <div class="form-container">
  23. <h1 class="form-title"><?= sprintf(_("Install %s"), $WebappInstaller->info()["name"]) ?></h1>
  24. <?php show_alert_message($_SESSION); ?>
  25. <?php if (!$WebappInstaller->isDomainRootClean()): ?>
  26. <div class="alert alert-info" role="alert">
  27. <i class="fas fa-info"></i>
  28. <div>
  29. <p class="u-mb10"><?= _("Data loss warning!") ?></p>
  30. <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>
  31. <p><?php echo sprintf(_("Please make sure ~/web/%s/public_html is empty!"), $v_domain); ?></p>
  32. </div>
  33. </div>
  34. <?php endif; ?>
  35. <div class="u-mt20">
  36. <?php foreach ($WebappInstaller->getOptions() as $form_name => $form_control): ?>
  37. <?php
  38. $f_name = $WebappInstaller->formNs() . '_' . $form_name;
  39. $f_type = $form_control;
  40. $f_value = '';
  41. if (isset($form_control['label'])) {
  42. $f_label = htmlentities($form_control['label']);
  43. } else {
  44. $f_label = ucwords(str_replace(['.','_'], ' ', $form_name));
  45. }
  46. $f_placeholder = '';
  47. if (is_array($form_control)) {
  48. $f_type = (!empty($form_control['type']))?$form_control['type']:'text';
  49. $f_value = (!empty($form_control['value']))?$form_control['value']:'';
  50. $f_placeholder = (!empty($form_control['placeholder']))?$form_control['placeholder']:'';
  51. }
  52. $f_value = htmlentities($f_value);
  53. $f_label = htmlentities($f_label);
  54. $f_name = htmlentities($f_name);
  55. $f_placeholder = htmlentities($f_placeholder);
  56. ?>
  57. <div class="u-mb10">
  58. <?php if ($f_type != "boolean"): ?>
  59. <label for="<?= $f_name ?>" class="form-label">
  60. <?= $f_label ?>
  61. <?php if ($f_type === "password"): ?> / <a href="javascript:applyRandomStringToTarget('<?= $f_name ?>');" class="form-link"><?= _("generate") ?></a> <?php endif; ?>
  62. </label>
  63. <?php endif; ?>
  64. <?php if (in_array($f_type, ['select']) && count($form_control['options']) ):?>
  65. <select class="form-select" name="<?=$f_name?>" id="<?=$f_name?>">
  66. <?php foreach ($form_control['options'] as $key => $option){
  67. if(is_numeric($key)){
  68. $key = $option;
  69. }
  70. ?>
  71. <?php $selected = (!empty($form_control['value']) && $key == $form_control['value'])?'selected':''?>
  72. <option value="<?=$key?>" <?=$selected?>><?=htmlentities($option)?></option>
  73. <?php }; ?>
  74. </select>
  75. <?php elseif (in_array($f_type, ["boolean"])): ?>
  76. <div class="form-check">
  77. <?php $checked = !empty($f_value) ? "checked" : ""; ?>
  78. <input class="form-check-input" type="checkbox" name="<?= $f_name ?>" id="<?= $f_name ?>" <?= $checked ?> value="true">
  79. <label for="<?= $f_name ?>"><?= $f_label ?></label>
  80. </div>
  81. <?php else: ?>
  82. <input type="text" class="form-control" name="<?= $f_name ?>" id="<?= $f_name ?>" placeholder="<?= $f_placeholder ?>" value="<?= $f_value ?>">
  83. <?php endif; ?>
  84. </div>
  85. <?php endforeach; ?>
  86. </div>
  87. </div>
  88. </form>
  89. <?php endif; ?>
  90. </div>