From 49a4c37eb6f04394697d8ceff82bedbff5ef47ea Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 18 Jun 2021 10:03:03 +0200 Subject: [PATCH] chg: [requestProcessor:localTool] Extendable view with specific local tool action templates --- .../GenericRequestProcessor.php | 3 ++- .../LocalToolRequestProcessor.php | 3 ++- .../templates/LocalTool/GenericRequest.php | 13 ++++-------- .../IncomingConnectionRequest.php | 21 +++++++++++++++++++ 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 libraries/default/RequestProcessors/templates/LocalTool/MispConnector/IncomingConnectionRequest.php diff --git a/libraries/default/RequestProcessors/GenericRequestProcessor.php b/libraries/default/RequestProcessors/GenericRequestProcessor.php index 1bfd974..dc07fff 100644 --- a/libraries/default/RequestProcessors/GenericRequestProcessor.php +++ b/libraries/default/RequestProcessors/GenericRequestProcessor.php @@ -66,8 +66,9 @@ class GenericRequestProcessor public function render($request=[], Cake\Http\ServerRequest $serverRequest) { - $processingTemplate = $this->getProcessingTemplate(); $viewVariables = $this->getViewVariables($request); + $this->updateProcessingTemplate($request); + $processingTemplate = $this->getProcessingTemplate(); $builder = new ViewBuilder(); $builder->disableAutoLayout() ->setClassName('Monad') diff --git a/libraries/default/RequestProcessors/LocalToolRequestProcessor.php b/libraries/default/RequestProcessors/LocalToolRequestProcessor.php index e5160bf..315c574 100644 --- a/libraries/default/RequestProcessors/LocalToolRequestProcessor.php +++ b/libraries/default/RequestProcessors/LocalToolRequestProcessor.php @@ -31,8 +31,9 @@ class LocalToolRequestProcessor extends GenericRequestProcessor return parent::create($requestData); } - protected function assignProcessingTemplate($connectorName) + protected function updateProcessingTemplate($request) { + $connectorName = $request->connector['connector']; $processingTemplatePath = sprintf('%s/%s/%s.php', $this->scope, $connectorName, $this->action); $file = new File($this->processingTemplatesDirectory . DS . $processingTemplatePath); if ($file->exists()) { diff --git a/libraries/default/RequestProcessors/templates/LocalTool/GenericRequest.php b/libraries/default/RequestProcessors/templates/LocalTool/GenericRequest.php index 514dc6f..093cd80 100644 --- a/libraries/default/RequestProcessors/templates/LocalTool/GenericRequest.php +++ b/libraries/default/RequestProcessors/templates/LocalTool/GenericRequest.php @@ -91,18 +91,13 @@ $form = $this->element('genericElements/Form/genericForm', [ 'raw' => true, 'data' => [ 'model' => 'Inbox', - 'fields' => [ - [ - 'field' => 'is_discard', - 'type' => 'checkbox', - 'default' => false - ] - ], + 'fields' => [], 'submit' => [ 'action' => $this->request->getParam('action') ] ] ]); +$localToolHTML = $this->fetch('content', sprintf('
%s
', $form)); $requestData = $this->Bootstrap->collapse( [ @@ -112,10 +107,10 @@ $requestData = $this->Bootstrap->collapse( sprintf('
%s
', json_encode($request['data'], JSON_PRETTY_PRINT)) ); -$bodyHtml = sprintf('
%s
%s
%s
', +$bodyHtml = sprintf('
%s
%s
%s', $table, $requestData, - $form + $localToolHTML ); echo $this->Bootstrap->modal([ diff --git a/libraries/default/RequestProcessors/templates/LocalTool/MispConnector/IncomingConnectionRequest.php b/libraries/default/RequestProcessors/templates/LocalTool/MispConnector/IncomingConnectionRequest.php new file mode 100644 index 0000000..904d39d --- /dev/null +++ b/libraries/default/RequestProcessors/templates/LocalTool/MispConnector/IncomingConnectionRequest.php @@ -0,0 +1,21 @@ +extend('LocalTool/GenericRequest'); +$form = $this->element('genericElements/Form/genericForm', [ + 'entity' => null, + 'ajax' => false, + 'raw' => true, + 'data' => [ + 'model' => 'Inbox', + 'fields' => [ + [ + 'field' => 'is_discard', + 'type' => 'checkbox', + 'default' => false + ] + ], + 'submit' => [ + 'action' => $this->request->getParam('action') + ] + ] +]); +echo sprintf('
%s
', $form); \ No newline at end of file