FirewallOptionSection.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\Select;
  5. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Switcher;
  6. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\BoxSection;
  7. use ModulesGarden\Servers\ProxmoxCloudVps\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. //policy_out
  54. $field = new Select("customconfigoption[firewalOptionPolicyIn]");
  55. $this->addField($field);
  56. //policy_out
  57. $field = new Select("customconfigoption[firewalOptionPolicyOut]");
  58. $this->addField($field);
  59. }
  60. public function addField($field){
  61. $total = count($this->leftSection->getFields()) + count($this->rightSection->getFields());
  62. if($total % 2 == 0){
  63. $this->leftSection->addField($field);
  64. }else{
  65. $this->rightSection->addField($field);
  66. }
  67. return $this;
  68. }
  69. }