DatatableTabsContainer.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\UI;
  3. use ModulesGarden\Servers\ProxmoxCloudVps\Core\DependencyInjection;
  4. /**
  5. * Description of Conteiner
  6. *
  7. * @author inbs
  8. */
  9. class DatatableTabsContainer extends Container
  10. {
  11. protected $name = 'datatableTabsContainer';
  12. protected $data = [];
  13. protected $topLine = [];
  14. protected $internalLine = [];
  15. protected $defaultTemplateName = 'tabContainerRight';
  16. public function setName($name)
  17. {
  18. $this->name = $name;
  19. return $this;
  20. }
  21. public function addElement($element)
  22. {
  23. if (is_string($element))
  24. {
  25. $element = DependencyInjection::get($element);
  26. }
  27. $id = $element->getId();
  28. if (!isset($this->elements[$id]))
  29. {
  30. $this->elements[$id] = $element;
  31. if ($element instanceof \ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AjaxElementInterface)
  32. {
  33. $this->mainContainer->addAjaxElement($this->elements[$id]);
  34. }
  35. }
  36. return $this;
  37. }
  38. /**
  39. * @param array $data
  40. * @return $this
  41. */
  42. public function setData(array $data = [])
  43. {
  44. $this->data = $data;
  45. $this->updateData();
  46. return $this;
  47. }
  48. protected function updateData()
  49. {
  50. foreach ($this->data as $key => $value)
  51. {
  52. if (property_exists($this, $key))
  53. {
  54. $this->$key = $value;
  55. }
  56. }
  57. $this->data = [];
  58. return $this;
  59. }
  60. public function getHtml()
  61. {
  62. $this->runInitContentProcess();
  63. if ($this->html === '')
  64. {
  65. $this->buildHtml();
  66. }
  67. return $this->html;
  68. }
  69. }