AuthShield = $AuthShield; $this->container=(null!==$container) ? $container : $AuthShield->getAppShield()->getContainer(); } /** public function auth(\UMA\JsonRpc\Request $request){ return 'admin' === $this->container->get('webfan.app.fsm.user')->getCurrentState()->getName(); } * {@inheritdoc} */ public function __invoke(\UMA\JsonRpc\Request $request): \UMA\JsonRpc\Response { $params = $request->params(); $config = $this->AuthShield->getAppShield()->config->export(); if(!file_exists($params->file)){ return new \UMA\JsonRpc\Error($request->id(), sprintf('File `%s` not found', $params->file)); } $file2 = str_replace('config.xml', 'config.custom.xml', $params->file); $file = (file_exists($file2)) ? $file2 : $params->file; $f = rtrim(dirname(dirname(dirname($file))), \DIRECTORY_SEPARATOR.'/ ') .\DIRECTORY_SEPARATOR.'config'.\DIRECTORY_SEPARATOR.'module-configs'.\DIRECTORY_SEPARATOR.basename(dirname($file)).\DIRECTORY_SEPARATOR.'preferences.json'; $file4 = dirname($f).\DIRECTORY_SEPARATOR.'config.custom.xml'; if(file_exists($file4)){ file_put_contents($file2, file_get_contents($file4)); $file = $file2; } /* $f = rtrim(dirname(dirname(dirname($file))), \DIRECTORY_SEPARATOR.'/ ') .\DIRECTORY_SEPARATOR.'config'.\DIRECTORY_SEPARATOR.'module-configs'.\DIRECTORY_SEPARATOR.basename(dirname($file)).\DIRECTORY_SEPARATOR.'preferences.json'; $file4 = dirname($f).\DIRECTORY_SEPARATOR.'config.custom.xml'; $file = (file_exists($file4)) ? $file4 : $file; */ try{ $WidgetConfig = new \webfan\hps\Widget\Config($file); $preferences = $WidgetConfig->getPreferences(); $contents = $WidgetConfig->getContents(); $favicon = $WidgetConfig->getIcon(); $contents['css'] = implode("", $contents['css']); $contents['html'] = implode("", $contents['html']); $contents['javascript'] = implode('', $contents['javascript']); $xml = new \DOMDocument(); $xml ->load($file); $composer = json_decode(file_get_contents(dirname($file).\DIRECTORY_SEPARATOR.'composer.json')); $p = explode('/', $composer->name); $config = [ 'name' => $this->get_inner_html( $xml->getElementsByTagName('name')->item(0) ), 'vendor' => $p[0], 'package' => $p[1], 'description' => $this->get_inner_html( $xml->getElementsByTagName('description')->item(0) ), '__FILE__' => $params->file, 'module_directory' => dirname($params->file), 'preferences' => $preferences, 'contents' => $contents, 'favicon' => $favicon, ]; }catch(\Exception $e){ return new \UMA\JsonRpc\Error($request->id(), $e->getMessage()); } return new \UMA\JsonRpc\Success($request->id(), $config); } protected function get_inner_html( $node ) { $innerHTML= ''; $children = $node->childNodes; foreach ($children as $child) { $innerHTML .= $child->ownerDocument->saveXML( $child ); } return $innerHTML; } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "file" : { type : ["string"] } }, "required" : ["file"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----Bs+u9qR+4PtkpRZ/AlsGowKK9YFlkQ5OkrGGs09g3ta5/N67yxtFLc1w5AnBzEF+6CnK38gOcM0SEJy/g9YowmmLurnqxPFDCCAUzEzUuLoLtT3IkkTw6psNDEQge9sTLXymnvMN02ws05GF1YuVcCoL13Yy6JwFfCP5GAOPEN/4ms/TL6Dcv5s4N3nrIFfJ1XHTovhJcwfts9/LZ9CR/IeNCMksIe7lKa76dslxOvkc5iDM9XRcUpJ4Z+bYM3iaLknKZAmEgLA+qgiSVCIewi9ZwPzaeiYzwoZrvYpn6ulLB0DwshrujklrQaXitSnC9UcvfBMTHLWXr0sbr59/PXg7+bNLkjIg8SVuinDWJ4J9do9EoSdqkzwD6aI8Z+eOJANFTowKCJGa0sQio014I4HkAZjs92K3R8ype9iAxejgA8M0uB6v3/lGMyf1XAD/XtESDV1BV3L3AFAGiBf6P4Qn6pmqjp9sEK0ZNg7KpTM/QrQVhG2ngj3MCJOm0vKUNyhNdpSlqJu6eAv2TR5rnIbmL8bnPqe9J/YUWc/IgWZOrcjZlqoQIkrz4q3VPXUmXOaIS6RyqSLaO96k65w2zEVbhprRoxUCD3rBf2322I1pZ36lR9UJqI20ITOzGCIYpZWWJo7kwh47yA1OK+C+iDr1gXwfI5vdZ8+k6FFKrdA=----ATTACHMENT:----Mjk1MzYxOTczNjU2MjEgMjUxMTY4MTc2MDIxMjg2MiAxMzQ3Mzg2MzUyOTU2NTM2