CreateForm.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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\ProxmoxVps\App\UI\Backup\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
  21. use ModulesGarden\Servers\ProxmoxVps\App\Enum\ConfigurableOption;
  22. use ModulesGarden\Servers\ProxmoxVps\App\UI\Backup\Providers\BackupProvider;
  23. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Helpers\AlertTypesConstants;
  24. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\ClientArea;
  25. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\BaseForm;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Select;
  27. use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\sl;
  28. class CreateForm extends BaseForm implements ClientArea
  29. {
  30. use ProductService;
  31. public function initContent()
  32. {
  33. $this->initIds('createForm');
  34. $this->setFormType('create');
  35. $this->setProvider(new BackupProvider());
  36. $backupFilesLimit = $this->configuration()->getBackupMaxFiles();
  37. if ($this->isWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) && $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) != "-1")
  38. {
  39. $backupFilesLimit = $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES);
  40. }
  41. if($backupFilesLimit == "-1"){
  42. $backupFilesLimit = null;
  43. }
  44. if ($this->configuration()->isBackupRouting() && $backupFilesLimit)
  45. {
  46. sl("lang")->addReplacementConstant("backupFilesLimit" , $backupFilesLimit);
  47. $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.'));
  48. $this->setInternalAlertMessageRaw(true);
  49. }
  50. $this->initFields();
  51. $this->loadDataToForm();
  52. }
  53. public function getAllowedActions()
  54. {
  55. return ['create'];
  56. }
  57. private function initFields()
  58. {
  59. //compress
  60. $field = new Select('compress');
  61. $field->setAvailableValues([
  62. "0" => sl("lang")->tr("None"),
  63. "lzo" => sl("lang")->tr("LZO (fast)"),
  64. "gzip" => sl("lang")->tr("GZIP (good)"),
  65. "zstd" => sl("lang")->abtr("ZSTD (fast and good)")
  66. ]);
  67. $field->setDefaultValue('zstd');
  68. $this->addField($field);
  69. //mode
  70. $field = new Select('mode');
  71. $field->setAvailableValues([
  72. "snapshot" => sl("lang")->tr("Snapshot"),
  73. "suspend" => sl("lang")->tr("Suspend"),
  74. "stop" => sl("lang")->tr("Stop")
  75. ]);
  76. $this->addField($field);
  77. }
  78. }