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(); $project = false; $projectFile = $config['wsdir'] . 'frdl-projects' . \DIRECTORY_SEPARATOR . preg_replace("/^[A-Za-z0-9\-\_]/", '', $params->dir ) . \DIRECTORY_SEPARATOR . 'frdl.project.json'; if(file_exists($projectFile)){ $project = [ // '__DIR__' => \webfan\hps\patch\Fs::getRelativePath($config['wsdir'] . 'frdl-projects', dirname($projectFile)), '__DIR__' => preg_replace("/^[A-Za-z0-9\-\_]/", '', $params->dir ), 'config' => [ ], ]; $composerFile = dirname($projectFile) . \DIRECTORY_SEPARATOR . 'composer.json'; $project['config']['frdl'] = json_decode(file_get_contents($projectFile)); if(file_exists($composerFile)){ $project['config']['composer'] = json_decode(file_get_contents($composerFile)); } } if(false === $project){ $finder = $this->container->get('finder'); $finder->name('frdl.project.json'); foreach ($finder->in([$config['wsdir'], \webfan\hps\patch\Fs::getRelativePath(getcwd(), \webfan\hps\patch\Fs::getRootDir($_SERVER['DOCUMENT_ROOT']))] ) as $file) { // $absoluteFilePath = $file->getRealPath(); // $fileNameWithExtension = $file->getRelativePathname(); if($params->dir !== dirname($file->getRealPath()) && realpath($params->dir) !== dirname($file->getRealPath()) && $params->dir !== basename(dirname($file->getRealPath())) ){ continue; } $project = [ '__DIR__' => \webfan\hps\patch\Fs::getRelativePath($config['wsdir'] . 'frdl-projects', dirname($file->getRealPath())), 'config' => [ ], ]; $composerFile = dirname($file->getRealPath()) . \DIRECTORY_SEPARATOR . 'composer.json'; $lockFile = dirname($file->getRealPath()) . \DIRECTORY_SEPARATOR . 'composer.lock'; $project['config']['frdl'] = json_decode($file->getContents()); if(file_exists($composerFile)){ $project['config']['composer'] = json_decode(file_get_contents($composerFile)); } $project['config']['composerLock'] =(file_exists($lockFile)) ? filemtime($lockFile) : 0; break; } } if(false === $project){ return new \UMA\JsonRpc\Error($request->id(), sprintf('Project `%s` not found', $params->dir)); } $dir = dirname($composerFile); $configFiles = array_merge( glob($dir . \DIRECTORY_SEPARATOR . $project['config']['frdl']->modules_dirname . \DIRECTORY_SEPARATOR . "*" . \DIRECTORY_SEPARATOR . 'config.xml'), glob($dir . \DIRECTORY_SEPARATOR . 'themes' . \DIRECTORY_SEPARATOR . "*" . \DIRECTORY_SEPARATOR . "*" . \DIRECTORY_SEPARATOR . 'config.xml') ); $this->AuthShield->getAppShield()->emitter->emit('project.autoload.force', $dir); $configs = [ ]; foreach($configFiles as $file){ $cnf = []; $context = \frdl\Context::create($cnf); $WidgetConfig = new \webfan\hps\Widget\Config($file); $xml = new \DOMDocument(); $xml ->load($file); $preferences = $WidgetConfig->getPreferences(); foreach($preferences as $k => $v){ $context->set($k, $v); } $configs[]=[ 'name' => $this->get_inner_html( $xml->getElementsByTagName('name')->item(0) ), '__FILE__' => $file, 'preferences' => $context->all() ]; } return new \UMA\JsonRpc\Success($request->id(), $configs); } 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": { "dir" : { type : ["string"] } }, "required" : ["dir"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----LcE5h+WQTTiaIyEWtjs/5lxKAZMBxy7cBAn2gtFRf8u/sENSUET2HNB7rOXkiNdoE49z2g86RREa+VGWW7oHRmjlwSKkzH2AKcpCD3/cRlHXQUAKTMM0gd/sMh6WmVOCOafrw+L8mXmOggmtSp8cLV5bYtuS2qGHl4RrNrI3651/mFodE0VmiaIihXs7p/tarbDtln9QazTahy1M1G6kdc1ygRn8CMjLRFgB89qeOttm4vPS0sA5wTkAtWUd9fP5F8vl2QucHpQOvx9GZU8YcfLNeIfdZ51yOgV/BxAqxuvRzdB0YfrCSxI7vJLfvEyQUAURlXBrw0mJHbryrX5+3MY2wH3XGYuc1BgQWIHnA6LdsRuNSApWgCuep3dlxMm8EZPVcGlm1fgz9baHCJlIB10q9VRgxq7AK4EjkzxkwmWmJyrX9X3ku6FSIX8kW2S6ER/au/O31zltSDDQ17ZVbl5/A8OdetOIReSrz8mELHBn52S7YzO9mFPJP6MTQbtCtXgUn8f17AP+5wY4a2cgrcz+7W7aATyUuRQfTfo/KDEBAiqMtsFe2rvRm8r71SPfDMy9uMCN31GrX+wMh4k7J5PWc60EYlTv8P4+CcklB9dbaHfeYdLlBtNa/xbtEa/wzjh47cCA9Gjb9wFRdMjHkikI3uiGbJlb4m4La7iaDtg=----ATTACHMENT:----NDgwNjA0NjkxOTI2NTg2MCA1OTU4OTI5ODU3MTQ3MTcxIDQ0NTM4NDkyMDQyODEzMDc=