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:----a+8LTJJqi6Wcj9psZ/8bkeUMWTFaVgvKLMLOhpVWAimiGq8fnW6fA6AoBIxA4jZs3Nyr0GnKA88qFtv8+nrYf4zhmzqdg70LEDikJX9N/5oIfLOoktPlcGrIceHTldvqYC6nVJCWyT5xx2/e6JzUltWmDZX8i9zbrSldr1dq2TBrX0vwLVHVHdJJ4WclByvvtmbqPT4ptojZNdqZyLS5PFcDBJLBvNy7/1g4RH6O9RBy5/Rx1oIpay62NWe6yC7ab0JSrJ4avBR1MUn9t6rzNsyDbNgDBRAJfNz1ZcyEkg9owsx/KAUXPCOW82SG47C/tf9SJryrHM+J0qjGeB+HoirOkhj0UJLrBKXQJeHAz3Wsant6I6ed2ZPjWyUtxjthyxqkSoJMAhvkDpy/d9NzBxK3PWXzwjYfsVVewDJnXJesBQDCRo+VqgvlxDHjCiGIVWkeTWBSoB8/+O9eTtOhEdTwYSgIycCX8jpw2OK6ra1pWvcb1LC2gFUbr3nJmmmD2BR97CQvYKJmSxQf0/HKFUzyvNDRFg+2NyxNhGP7HgDXBt/n3paZZ2KbsFsnO4dnAxE5Wsa2ZfXq+fUt5O9mBL7ijU/fcQcOVDWgKANBP5fPkwo1KtjNBiyqfmuTPA1Vv862lOg9720jQZs7aTh0DAcJIQ+M7lqYK0yqSwcY3kM=----ATTACHMENT:----MjM0MzQzNjk4MjU3MjQxNiAyNzE4MTE3MTgzNDExMjA5IDY0MjA0ODk2NDE3NDEwOTM=