public function action() { $user = $this->hasAuthorative(); $plugId = $this->_http->getParam('Plugin'); $field = $this->_http->getParam('Field'); $action = $this->_http->getParam('Action'); $controllers = $this->_generic->getTranslatedController('SLS_Bo', 'EditPlugin'); if (empty($plugId) || SLS_PluginsManager::isExists($plugId) === false) $this->dispatch('SLS_Bo', 'Plugins'); $plugin = new SLS_PluginsManager($plugId); $xmlPlug = $plugin->getXML(); if (empty($field) || empty($action)) $this->redirect($controllers['controller']."/".$controllers['scontroller']."/Plugin/".$plugId.".sls"); $xpath = "//".str_replace("|||", "/", str_replace("|$|", "]", str_replace("$|$", "[", $field))); $clonable = array_shift($xmlPlug->getTags($xpath."/@clonable")); if ($clonable != 1) $this->redirect($controllers['controller']."/".$controllers['scontroller']."/Plugin/".$plugId.".sls"); $nodeName = SLS_String::substrBeforeLastDelimiter($xpath, "["); if ($action == "del" && count($xmlPlug->getTags($nodeName)) > 1) { $xmlPlug->deleteTags($xpath, 1); } if ($action == "add") { $node = new SLS_XMLToolbox($xmlPlug->getNode($xpath)); $parent = SLS_String::substrBeforeLastDelimiter($xpath, "/"); $xmlPlug->appendXMLNode($xpath, $node->getXml('noHeader'), 1, "after"); $newIndex = SLS_String::substrBeforeLastDelimiter(SLS_String::substrAfterLastDelimiter($xpath, "["), "]"); $newIndex++; $newNode = SLS_String::substrBeforeLastDelimiter($xpath, "[")."[".$newIndex."]"; if ($xmlPlug->countChilds($newNode) == 0) $xmlPlug->setTag($newNode, "", false); else $xmlPlug = $this->removeRecursiveValues($newNode, $xmlPlug); $xmlPlug->setTagAttributes($newNode, array("alias"=>uniqid())); } $plugin->saveXML($xmlPlug); $this->redirect($controllers['controller']."/".$controllers['scontroller']."/Plugin/".$plugId.".sls"); }