ViewAjax.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace ModulesGarden\Servers\ZimbraEmail\Core\UI;
  3. use \ModulesGarden\Servers\ZimbraEmail\Core\Helper;
  4. /**
  5. * Main Vuew Controler
  6. * @author Sławomir Miśkowicz <slawomir@modulesgarden.com>
  7. */
  8. class ViewAjax extends View
  9. {
  10. protected $elements = [];
  11. protected $namespace = '';
  12. public function __construct($template = null)
  13. {
  14. $this->setTemplate($template);
  15. $this->mainContainer = new \ModulesGarden\Servers\ZimbraEmail\Core\UI\MainContainerAjax();
  16. }
  17. /**
  18. * Adds elements to the root element
  19. */
  20. public function addElement($element)
  21. {
  22. return $this;
  23. }
  24. public function validateAcl($isAdmin)
  25. {
  26. $this->mainContainer->valicateACL($isAdmin);
  27. return $this;
  28. }
  29. public function setNamespace($namespace)
  30. {
  31. $this->namespace = $namespace;
  32. $this->mainContainer->setNamespaceAjax($this->namespace);
  33. return $this;
  34. }
  35. /**
  36. * Generates all responses for UI elements
  37. */
  38. public function getResponse()
  39. {
  40. return $this->mainContainer->getAjaxResponse();
  41. }
  42. public function initAjaxElementContext($namespace)
  43. {
  44. $this->setNamespace($namespace);
  45. $this->mainContainer->addElement(Helper\convertStringToNamespace($namespace));
  46. }
  47. }