CreateForm.php 3.4 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. use ProductService;
  30. public function initContent() {
  31. $this->initIds('createForm');
  32. $this->setFormType('create');
  33. $this->setProvider(new BackupProvider());
  34. $backupFilesLimit = $this->configuration()->getBackupMaxFiles();
  35. if ($this->isWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) && $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) != "-1")
  36. {
  37. $backupFilesLimit = $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES);
  38. }
  39. if($backupFilesLimit == "-1"){
  40. $backupFilesLimit = null;
  41. }
  42. if ($this->configuration()->isBackupRouting() && $backupFilesLimit) {
  43. sl("lang")->addReplacementConstant("backupFilesLimit" , $backupFilesLimit);
  44. $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.'));
  45. $this->setInternalAlertMessageRaw(true);
  46. }
  47. $this->initFields();
  48. $this->loadDataToForm();
  49. }
  50. public function getAllowedActions() {
  51. return ['create'];
  52. }
  53. private function initFields() {
  54. //compress
  55. $field = new Select('compress');
  56. $field->setAvailableValues([
  57. //"0" => sl("lang")->tr("None"),
  58. //"lzo" => sl("lang")->tr("LZO (fast)"),
  59. //"gzip" => sl("lang")->tr("GZIP (good)"),
  60. "zstd" => sl("lang")->abtr("ZSTD (fast and good)")
  61. ]);
  62. $field->setDefaultValue('zstd');
  63. $field->addClass('hidden');
  64. $this->addField($field);
  65. //mode
  66. $field = new Select('mode');
  67. $field->addClass('hidden');
  68. $field->setAvailableValues([
  69. "snapshot" => sl("lang")->tr("Snapshot"),
  70. "suspend" => sl("lang")->tr("Suspend"),
  71. // "stop" => sl("lang")->tr("Stop")
  72. "stop" => "Shutdown"
  73. ]);
  74. $field->setDefaultValue('snapshot');
  75. $this->addField($field);
  76. }
  77. }