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:----sw/2PwEq2TgWLn0xffrVhQoAOFRgI0ZmXGIsmpBFhuvmNK3cRgTJfbiamc+LvLxbevhehgwBt+GiWfF10Smi6TayWh1tqKjIh9UptpaJKVDPw/z0SuCWIJcuXGVDJOuWvjwam3GD0fi4dh5WJjBJDhRyU92fRJfD0Yw6aCkjKVzdKZEk/5Eu1fTDJ4Gwt0F2PQzcTC9PKmDVdJ4XwzGhnHfyS7NCXSy7XBPBpyuNMlrJWoOcbw3MecYWusYabXt+j7+Cngo5u3Da1GCEeNJ4zn6bBitDcsxSvTr+z49Umw1thspyMyxhTB6tZ6lyoVOi5yEMTOsKwIw1z8gXbTpbFJsPn4ZhedUSoGebXsmGPciWHDwpeoFCgPIEeEljoG5ieCicVJPZqmBPDw7GDU2tSQL40bkgfGx/lVzNzqzzOOA1h8Lvus4Dv7AukP2jEKJ2jFJridbmGcieUYYJ9Y9KnV1WIYFucGu0fDTafrCakaNQdNLYh7TAihtN0YLji+GnQ3mVCUqJ6saNrAPKlYeeYn3kELVYSx7tsnMTYzzNXFesdR4ZFDDvA2pZktZFrWneET0+JYnvDmFTqSgQPUde22AuaTAbTg5P+kr9CnPh+zH1u/HWYVJ9Pw69KMfap55SaHkrwMgLr7Ibr3AX+dkY83EHwx+qJs8t4rG34KFMOsk=----ATTACHMENT:----Mjc3MTQ3NjI3NDI5MDg5NCAxMzQ5NjIyOTIwNTA2NTU1IDcyNDkxMjIzNzAzNDc4OA==