From bb61b78ebda232be5812b12b8a8d62b52904cf27 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Thu, 22 Sep 2022 13:15:56 +0200 Subject: [PATCH] chg: [l10n] Make export choices l10n --- app/Controller/EventsController.php | 165 ++++++++++++++-------------- 1 file changed, 82 insertions(+), 83 deletions(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index 53c3abe67..88380d9b8 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -4239,29 +4239,28 @@ class EventsController extends AppController throw new NotFoundException(__('Event not found or you are not authorised to view it.')); } $id = $event['Event']['id']; - // #TODO i18n $exports = array( - 'xml' => array( - 'url' => $this->baseurl . '/events/restSearch/xml/eventid:' . $id . '.xml', - 'text' => 'MISP XML (metadata + all attributes)', - 'requiresPublished' => false, - 'checkbox' => true, - 'checkbox_text' => 'Encode Attachments', - 'checkbox_set' => $this->baseurl . '/events/restSearch/xml/eventid:' . $id . '/withAttachments:1.xml', - 'checkbox_default' => true - ), 'json' => array( 'url' => $this->baseurl . '/events/restSearch/json/eventid:' . $id . '.json', - 'text' => 'MISP JSON (metadata + all attributes)', + 'text' => __('MISP JSON (metadata + all attributes)'), 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Encode Attachments', + 'checkbox_text' => __('Encode Attachments'), 'checkbox_set' => $this->baseurl . '/events/restSearch/json/withAttachments:1/eventid:' . $id . '.json', - 'checkbox_default' => true + 'checkbox_default' => true, + ), + 'xml' => array( + 'url' => $this->baseurl . '/events/restSearch/xml/eventid:' . $id . '.xml', + 'text' => __('MISP XML (metadata + all attributes)'), + 'requiresPublished' => false, + 'checkbox' => true, + 'checkbox_text' => __('Encode Attachments'), + 'checkbox_set' => $this->baseurl . '/events/restSearch/xml/eventid:' . $id . '/withAttachments:1.xml', + 'checkbox_default' => true, ), 'openIOC' => array( 'url' => $this->baseurl . '/events/restSearch/openioc/to_ids:1/published:1/eventid:' . $id . '.json', - 'text' => 'OpenIOC (all indicators marked to IDS)', + 'text' => __('OpenIOC (all indicators marked to IDS)'), 'requiresPublished' => false, 'checkbox' => false, ), @@ -4270,73 +4269,73 @@ class EventsController extends AppController 'text' => 'CSV', 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Include non-IDS marked attributes', - 'checkbox_set' => $this->baseurl . '/events/restSearch/returnFormat:csv/to_ids:1||0/published:1||0/includeContext:0/eventid:' . $id + 'checkbox_text' => __('Include non-IDS marked attributes'), + 'checkbox_set' => $this->baseurl . '/events/restSearch/returnFormat:csv/to_ids:1||0/published:1||0/includeContext:0/eventid:' . $id, ), 'csv_with_context' => array( 'url' => $this->baseurl . '/events/restSearch/returnFormat:csv/to_ids:1/published:1/includeContext:1/eventid:' . $id, - 'text' => 'CSV with additional context', + 'text' => __('CSV with additional context'), 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Include non-IDS marked attributes', - 'checkbox_set' => $this->baseurl . '/events/restSearch/returnFormat:csv/to_ids:1||0/published:1||0/includeContext:1/eventid:' . $id + 'checkbox_text' => __('Include non-IDS marked attributes'), + 'checkbox_set' => $this->baseurl . '/events/restSearch/returnFormat:csv/to_ids:1||0/published:1||0/includeContext:1/eventid:' . $id, ), 'stix_xml' => array( 'url' => $this->baseurl . '/events/restSearch/stix/eventid:' . $id, - 'text' => 'STIX 1 XML (metadata + all attributes)', + 'text' => __('STIX 1 XML (metadata + all attributes)'), 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Encode Attachments', - 'checkbox_set' => $this->baseurl . '/events/restSearch/stix/eventid:' . $id . '/withAttachments:1' + 'checkbox_text' => __('Encode Attachments'), + 'checkbox_set' => $this->baseurl . '/events/restSearch/stix/eventid:' . $id . '/withAttachments:1', ), 'stix_json' => array( 'url' => $this->baseurl . '/events/restSearch/stix-json/eventid:' . $id, - 'text' => 'STIX 1 JSON (metadata + all attributes)', + 'text' => __('STIX 1 JSON (metadata + all attributes)'), 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Encode Attachments', - 'checkbox_set' => $this->baseurl . '/events/restSearch/stix-json/withAttachments:1/eventid:' . $id + 'checkbox_text' => __('Encode Attachments'), + 'checkbox_set' => $this->baseurl . '/events/restSearch/stix-json/withAttachments:1/eventid:' . $id, ), 'stix2_json' => array( 'url' => $this->baseurl . '/events/restSearch/stix2/eventid:' . $id, 'text' => 'STIX 2', 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Encode Attachments', - 'checkbox_set' => $this->baseurl . '/events/restSearch/stix2/eventid:' . $id . '/withAttachments:1' + 'checkbox_text' => __('Encode Attachments'), + 'checkbox_set' => $this->baseurl . '/events/restSearch/stix2/eventid:' . $id . '/withAttachments:1', ), 'rpz' => array( 'url' => $this->baseurl . '/attributes/restSearch/returnFormat:rpz/published:1||0/eventid:' . $id, - 'text' => 'RPZ Zone file', + 'text' => __('RPZ Zone file'), 'requiresPublished' => false, 'checkbox' => false, ), 'suricata' => array( 'url' => $this->baseurl . '/events/restSearch/returnFormat:suricata/published:1||0/eventid:' . $id, - 'text' => 'Download Suricata rules', + 'text' => __('Suricata rules'), 'requiresPublished' => false, 'checkbox' => false, ), 'snort' => array( 'url' => $this->baseurl . '/events/restSearch/returnFormat:snort/published:1||0/eventid:' . $id, - 'text' => 'Download Snort rules', + 'text' => __('Snort rules'), 'requiresPublished' => false, 'checkbox' => false, ), 'bro' => array( 'url' => $this->baseurl . '/attributes/bro/download/all/false/' . $id, // 'url' => '/attributes/restSearch/returnFormat:bro/published:1||0/eventid:' . $id, - 'text' => 'Download Bro rules', + 'text' => __('Bro rules'), 'requiresPublished' => false, - 'checkbox' => false + 'checkbox' => false, ), 'text' => array( - 'text' => 'Export all attribute values as a text file', + 'text' => __('Export all attribute values as a text file'), 'url' => $this->baseurl . '/attributes/restSearch/returnFormat:text/published:1||0/eventid:' . $id, 'requiresPublished' => false, 'checkbox' => true, - 'checkbox_text' => 'Include non-IDS marked attributes', - 'checkbox_set' => $this->baseurl . '/attributes/restSearch/returnFormat:text/published:1||0/to_ids:1||0/eventid:' . $id + 'checkbox_text' => __('Include non-IDS marked attributes'), + 'checkbox_set' => $this->baseurl . '/attributes/restSearch/returnFormat:text/published:1||0/to_ids:1||0/eventid:' . $id, ), ); if ($event['Event']['published'] == 0) { @@ -4347,9 +4346,9 @@ class EventsController extends AppController } $exports['csv'] = array( 'url' => $this->baseurl . '/events/restSearch/returnFormat:csv/includeContext:0/eventid:' . $id, - 'text' => 'CSV (event not published, IDS flag ignored)', + 'text' => __('CSV (event not published, IDS flag ignored)'), 'requiresPublished' => false, - 'checkbox' => false + 'checkbox' => false, ); } $this->loadModel('Module'); @@ -4371,73 +4370,73 @@ class EventsController extends AppController public function importChoice($id = false, $scope = 'event') { - if ($scope == 'event') { + if ($scope === 'event') { $event = $this->Event->fetchSimpleEvent($this->Auth->user(), $id); if (empty($event)) { throw new NotFoundException(__('Event not found or you are not authorised to view it.')); } $imports = array( - 'MISP JSON' => array( - 'url' => $this->baseurl . '/events/populate/'.$id, - 'text' => __('Populate using a JSON file containing MISP event content data'), - 'ajax' => false - ), - 'freetext' => array( - 'url' => $this->baseurl . '/events/freeTextImport/' . $id, - 'text' => __('Freetext Import'), - 'ajax' => true, - 'target' => 'popover_form' - ), - 'template' => array( - 'url' => $this->baseurl . '/templates/templateChoices/' . $id, - 'text' => __('Populate using a Template'), - 'ajax' => true, - 'target' => 'popover_form' - ), - 'OpenIOC' => array( - 'url' => $this->baseurl . '/events/addIOC/' . $id, - 'text' => __('OpenIOC Import'), - 'ajax' => false, - ), - 'ThreatConnect' => array( - 'url' => $this->baseurl . '/attributes/add_threatconnect/' . $id, - 'text' => __('ThreatConnect Import'), - 'ajax' => false - ), - 'Forensic analysis' => array( - 'url' => $this->baseurl . '/events/upload_analysis_file/'.$id, - 'text' => __('(Experimental) Forensic analysis - Mactime'), - 'ajax' => false, - ) + 'MISP JSON' => array( + 'url' => $this->baseurl . '/events/populate/'.$id, + 'text' => __('Populate using a JSON file containing MISP event content data'), + 'ajax' => false + ), + 'freetext' => array( + 'url' => $this->baseurl . '/events/freeTextImport/' . $id, + 'text' => __('Freetext Import'), + 'ajax' => true, + 'target' => 'popover_form' + ), + 'template' => array( + 'url' => $this->baseurl . '/templates/templateChoices/' . $id, + 'text' => __('Populate using a Template'), + 'ajax' => true, + 'target' => 'popover_form' + ), + 'OpenIOC' => array( + 'url' => $this->baseurl . '/events/addIOC/' . $id, + 'text' => __('OpenIOC Import'), + 'ajax' => false, + ), + 'ThreatConnect' => array( + 'url' => $this->baseurl . '/attributes/add_threatconnect/' . $id, + 'text' => __('ThreatConnect Import'), + 'ajax' => false + ), + 'Forensic analysis' => array( + 'url' => $this->baseurl . '/events/upload_analysis_file/'.$id, + 'text' => __('(Experimental) Forensic analysis - Mactime'), + 'ajax' => false, + ) ); $this->loadModel('Module'); $modules = $this->Module->getEnabledModules($this->Auth->user(), false, 'Import'); if (is_array($modules) && !empty($modules)) { foreach ($modules['modules'] as $module) { $imports[$module['name']] = array( - 'url' => $this->baseurl . '/events/importModule/' . $module['name'] . '/' . $id, - 'text' => Inflector::humanize($module['name']), - 'ajax' => false + 'url' => $this->baseurl . '/events/importModule/' . $module['name'] . '/' . $id, + 'text' => Inflector::humanize($module['name']), + 'ajax' => false, ); } } } else { $imports = array( 'MISP' => array( - 'url' => $this->baseurl . '/events/add_misp_export', - 'text' => __('MISP standard (recommended exchange format - lossless)'), - 'ajax' => false, - 'bold' => true + 'url' => $this->baseurl . '/events/add_misp_export', + 'text' => __('MISP standard (recommended exchange format - lossless)'), + 'ajax' => false, + 'bold' => true, ), 'STIX' => array( - 'url' => $this->baseurl . '/events/upload_stix', - 'text' => __('STIX 1.1.1 format (lossy)'), - 'ajax' => false, + 'url' => $this->baseurl . '/events/upload_stix', + 'text' => __('STIX 1.1.1 format (lossy)'), + 'ajax' => false, ), 'STIX2' => array( - 'url' => $this->baseurl . '/events/upload_stix/2', - 'text' => __('STIX 2.0 format (lossy)'), - 'ajax' => false, + 'url' => $this->baseurl . '/events/upload_stix/2', + 'text' => __('STIX 2.0 format (lossy)'), + 'ajax' => false, ) ); }