FirewallOptionSection.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Admin\Product\Sections;
  3. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
  4. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Switcher;
  5. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\BoxSection;
  6. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\HalfPageSection;
  7. class FirewallOptionSection extends BoxSection implements AdminArea
  8. {
  9. // protected $id = 'clientNotificationSection';
  10. // protected $name = 'clientNotificationSection';
  11. // protected $title = 'clientNotificationSection';
  12. /**
  13. * @var HalfPageSection
  14. */
  15. private $leftSection;
  16. /**
  17. * @var HalfPageSection
  18. */
  19. private $rightSection;
  20. public function initContent()
  21. {
  22. $this->initIds('firewallOptionSection');
  23. $this->leftSection = new HalfPageSection('leftSection');
  24. $this->rightSection = new HalfPageSection('rightSection');
  25. $this->addSection($this->leftSection)
  26. ->addSection($this->rightSection);
  27. $this->initFields();
  28. }
  29. private function initFields()
  30. {
  31. //enable
  32. $field = new Switcher("customconfigoption[firewalOptionEnable]");
  33. $this->addField($field);
  34. //dhcp
  35. $field = new Switcher("customconfigoption[firewalOptionDhcp]");
  36. $field->setDefaultValue("on");
  37. $this->addField($field);
  38. //ndp
  39. $field = new Switcher("customconfigoption[firewalOptionNdp]");
  40. $field->setDefaultValue("on");
  41. $this->addField($field);
  42. //radv
  43. $field = new Switcher("customconfigoption[firewalOptionRadv]");
  44. $this->addField($field);
  45. //macfilter
  46. $field = new Switcher("customconfigoption[firewalOptionMacfilter]");
  47. $field->setDefaultValue("on");
  48. $this->addField($field);
  49. //ipfilter
  50. $field = new Switcher("customconfigoption[firewalOptionIpfilter]");
  51. $this->addField($field);
  52. }
  53. public function addField($field){
  54. $total = count($this->leftSection->getFields()) + count($this->rightSection->getFields());
  55. if($total % 2 == 0){
  56. $this->leftSection->addField($field);
  57. }else{
  58. $this->rightSection->addField($field);
  59. }
  60. return $this;
  61. }
  62. }