public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $plugId = $this->_http->getParam('Plugin'); $reload = $this->_http->getParam('reload', 'post'); $controllers = $this->_generic->getTranslatedController('SLS_Bo', 'Plugins'); if(SLS_PluginsManager::isExists($plugId) === false) $this->redirect($controllers['controller']."/".$controllers['scontroller']); $plugin = new SLS_PluginsManager($plugId); $xmlPlug = $plugin->getXML(); if (!$plugin->isCustomizable()) $this->redirect($controllers['controller']."/".$controllers['scontroller']); $xml->startTag("plugin_infos"); $xml->addFullTag('name', $plugin->_name); $xml->addFullTag('code', $plugin->_code); $xml->addFullTag('id', $plugin->_id); $xml->addFullTag('version', $plugin->_version); $xml->endTag("plugin_infos"); if ($reload == 'true') { $errors = array(); $form_memory = array(); $form_memory = $this->recoverFormValues("//plugin", $xmlPlug, $form_memory); $xml->startTag("memory"); foreach ($form_memory as $key=>$field) { $xml->startTag("values"); $xml->addFullTag("name", $key, true); $xml->addFullTag("value", $field['value'], true); $xml->endTag("values"); $xpath = $field['xpath']; $index = SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterLastDelimiter($xpath, "["), "]"); $xpathNoIndex = SLS_String::substrBeforeLastDelimiter($xpath, "["); if (SLS_String::endsWith($key, "_alias")) { if (count($xmlPlug->getTags($xpathNoIndex."[position() != ".$index." and @alias='".$field['value']."']")) != 0) $errors[] = array_shift($xmlPlug->getTags($xpath."/@label"))." alias ".$GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_E_UNIQUE']; else $xmlPlug->setTagAttributes($xpath, array("alias"=>$field['value'])); } else { $is_null = (array_shift($xmlPlug->getTags($xpath."/@null")) == "1") ? true : false; switch (array_shift($xmlPlug->getTags($xpath."/@type"))) { case "string" : if (!SLS_String::validateString($field['value']) && !$is_null) $errors[] = array_shift($xmlPlug->getTags($xpath."/@label"))." ".$GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_E_TYPE']; else $xmlPlug->setTag($xpath, $field['value']); break; case "password" : if (isset($field['value'])) $xmlPlug->setTag($xpath, SLS_Security::encrypt($field['value'], $this->_generic->getSiteConfig("privateKey"))); break; case "int" : if (!is_int($field['value']) && !$is_null) $errors[] = array_shift($xmlPlug->getTags($xpath."/@label"))." ".$GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_E_TYPE']; else $xmlPlug->setTag($xpath, $field['value']); break; case "float" : if (!is_float($field['value']) && !$is_null) $errors[] = array_shift($xmlPlug->getTags($xpath."/@label"))." ".$GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_E_TYPE']; else $xmlPlug->setTag($xpath, $field['value']); break; case "select" : $values = explode("|||", array_shift($xmlPlug->getTags($xpath."/@values"))); if (!in_array($field['value'], $values)) $errors[] = array_shift($xmlPlug->getTags($xpath."/@label"))." ".$GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_E_CONTENT']; else $xmlPlug->setTag($xpath, $field['value']); break; default: break; } } } $xml->endTag("memory"); if (!empty($errors)) { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } else { $xml->addFullTag("success", "ok", true); $plugin->saveXML($xmlPlug); } } $xml->addFullTag("fields", $plugin->getFields()->getXML('noHeader'), false); $this->saveXML($xml); }