FirewallOptionSection.php 2.4 KB

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