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:----IGJnUSld2hYLzXXSjJtEZJhd5oNdcPN1bjLKG+e3hcXzZocgLhde8sUjIzYvFc8r36Uc8E1YQpzgg4m/H42mPtCCACDVx1Z868LEUguO+Zd68TssHenUKmSBzXJHpo4oFK233M1E8ta5llPPuNanzm+bibPENljcbB/09QEZrh9wJPeSD+YOhno/c14RqxDipuWtLOGIuOHSBh/kNNlBBTPEk+FagejuFnEOxYno0IYwma9J2S9QbfIj47TT1SQ6Le7ypUx/aq2dCl7Abmk/zIa7pBTzD1m7Y/ayqzyhduEwC3c2OnZvoC6aBwH1Y9f1Vx7zdircHsVGzoyODbbFi5vZsFD7r1IQ98VkLDpwJbq7ZuddPK+wG9+dvb6KYNR6q9cdVdNtcfBvrHb5RKQ9yVoS4ppvJurT048N4ECJ+CJ3diqhuJ+XifFohsvqu6pULhE8n3F3O1+S0vQ/hSakPX0ZfHmstg0VXN6W0oF9B/hahs3S7BjJDH7HqgvVKXIM1qgpAio29Nh4mPIK02ZCgG/itMa9cOXrcQC2B6jD3I44yEfLE1Y2UJfKZag4/chF6MhGWkS9HB4LKk9FNATKlTTqGw8RklVPMOs8PoiV1EwxGGaTzqMLFG7gq3nKZBY8Vo39jd3QF+eDHGFItH0S3+eBmZAFc50fJkZMgxghjQE=----ATTACHMENT:----ODQ2NzYxNDkxNTQ3MTI0MyAxMDg2NjU4MDgyMjIwODU0IDE2MjI4NDY3NDE5ODA0NTc=