| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace ModulesGarden\Servers\ProxmoxVps\Core\UI;
- use \ModulesGarden\Servers\ProxmoxVps\Core\Helper;
- use ModulesGarden\Servers\ProxmoxVps\Core\ModuleConstants;
- /**
- * Main Vuew Controler
- * @author Sławomir Miśkowicz <slawomir@modulesgarden.com>
- */
- class ViewAjax extends View
- {
- protected $elements = [];
- protected $namespace = '';
- public function __construct($template = null)
- {
- $this->setTemplate($template);
- $this->mainContainer = new \ModulesGarden\Servers\ProxmoxVps\Core\UI\MainContainerAjax();
- }
- /**
- * Adds elements to the root element
- */
- public function addElement($element)
- {
- return $this;
- }
- public function validateAcl($isAdmin)
- {
- $this->mainContainer->valicateACL($isAdmin);
- return $this;
- }
- public function setNamespace($namespace)
- {
- $this->namespace = $namespace;
- $this->mainContainer->setNamespaceAjax($this->namespace);
- return $this;
- }
- /**
- * Generates all responses for UI elements
- */
- public function getResponse()
- {
- return $this->mainContainer->getAjaxResponse();
- }
- /**
- * @param $namespace
- * @return |null
- */
- public function initAjaxElementContext($namespace)
- {
- $this->setNamespace($namespace);
- if(!$this->isValidNamespace(Helper\convertStringToNamespace($namespace)))
- {
- return null;
- }
- $this->mainContainer->addElement(Helper\convertStringToNamespace($namespace));
- }
- /**
- * @param $namespace
- * @return bool
- */
- public function isValidNamespace($namespace)
- {
- if(strpos($namespace, ModuleConstants::getRootNamespace()) === false)
- {
- return false;
- }
- return true;
- }
- }
|