CreateForm.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.03.19)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Backup\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  21. use ModulesGarden\ProxmoxAddon\App\Enum\Cloud\ConfigurableOption;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Backup\Providers\BackupProvider;
  23. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
  24. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\BaseForm;
  25. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Select;
  26. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
  27. class CreateForm extends BaseForm implements ClientArea
  28. {
  29. use ProductService;
  30. public function initContent()
  31. {
  32. $this->initIds('createBackupForm');
  33. $this->setFormType('create');
  34. $this->setProvider(new BackupProvider());
  35. $backupFilesLimit = $this->configuration()->getBackupMaxFiles();
  36. if ($this->isWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) && $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) != "-1")
  37. {
  38. $backupFilesLimit = $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES);
  39. }
  40. if($backupFilesLimit == "-1"){
  41. $backupFilesLimit = null;
  42. }
  43. if ($this->configuration()->isBackupRouting() && $backupFilesLimit)
  44. {
  45. sl("lang")->addReplacementConstant("backupFilesLimit" , $backupFilesLimit);
  46. $this->setInternalAlertMessage( sl("lang")->tr('Your routing backup limit is :backupFilesLimit:. When you exceed this limit, the last backup will be replaced with a new one.'));
  47. $this->setInternalAlertMessageRaw(true);
  48. }
  49. $this->initFields();
  50. $this->loadDataToForm();
  51. }
  52. public function getAllowedActions()
  53. {
  54. return ['create'];
  55. }
  56. private function initFields()
  57. {
  58. //compress
  59. $field = new Select('compress');
  60. $field->setAvailableValues([
  61. "0" => sl("lang")->tr("None"),
  62. "lzo" => sl("lang")->tr("LZO (fast)"),
  63. "gzip" => sl("lang")->tr("GZIP (good)"),
  64. "zstd" => sl("lang")->abtr("ZSTD (fast and good)")
  65. ]);
  66. $field->setDefaultValue('zstd');
  67. $this->addField($field);
  68. //mode
  69. $field = new Select('mode');
  70. $field->setAvailableValues([
  71. "snapshot" => sl("lang")->tr("Snapshot"),
  72. "suspend" => sl("lang")->tr("Suspend"),
  73. "stop" => sl("lang")->tr("Stop")
  74. ]);
  75. $this->addField($field);
  76. }
  77. }