diff --git a/app/Controller/AttributesController.php b/app/Controller/AttributesController.php
index 83f530d76..02fb787f7 100644
--- a/app/Controller/AttributesController.php
+++ b/app/Controller/AttributesController.php
@@ -1580,26 +1580,22 @@ class AttributesController extends AppController
$selectedAttributeIds = array();
}
- App::uses('TextColourHelper', 'View/Helper');
- $textColourHelper = new TextColourHelper(new View());
- $tagTemplate = '{{=it.name}}';
- $galaxyTemplate = '{{=it.name}}';
-
// tags to remove
$tags = $this->Attribute->AttributeTag->getAttributesTags($this->Auth->user(), $id, $selectedAttributeIds);
$tagItemsRemove = array();
foreach ($tags as $k => $tag) {
$tagName = $tag['name'];
$tagItemsRemove[] = array(
- 'name' => h($tagName),
- 'value' => h($tag['id']),
- 'template' => $tagTemplate,
- 'templateData' => array(
- 'name' => h($tagName),
- 'background' => h(isset($tag['colour']) ? $tag['colour'] : '#ffffff'),
- 'color' => h(isset($tag['colour']) ? $textColourHelper->getTextColour($tag['colour']) : '#0088cc')
- ),
-
+ 'name' => $tagName,
+ 'value' => $tag['id'],
+ 'template' => array(
+ 'name' => array(
+ 'name' => $tagName,
+ 'label' => array(
+ 'background' => isset($tag['colour']) ? $tag['colour'] : '#ffffff'
+ )
+ ),
+ )
);
}
unset($tags);
@@ -1608,32 +1604,21 @@ class AttributesController extends AppController
$clusters = $this->Attribute->AttributeTag->getAttributesClusters($this->Auth->user(), $id, $selectedAttributeIds);
$clusterItemsRemove = array();
foreach ($clusters as $k => $cluster) {
- $clusterTemplate = '{{=it.name}}';
- if (strlen($cluster['description']) < 50) {
- $clusterTemplate .= '{{=it.description}}';
- } else {
- $clusterTemplate .= '';
- }
- if ($cluster['synonyms_string'] !== "") {
- $clusterTemplate .= '
{{=it.synonyms_string}}
';
- }
-
- $title = __('Synonyms: ') . h($cluster['synonyms_string']);
- $name = h($cluster['value']);
- $optionName = h($cluster['value']);
- $optionName .= $cluster['synonyms_string'] !== '' ? ' (' . h($cluster['synonyms_string']) . ')' : '';
+ $title = __('Synonyms: ') . $cluster['synonyms_string'];
+ $name = $cluster['value'];
+ $optionName = $cluster['value'];
+ $optionName .= $cluster['synonyms_string'] !== '' ? ' (' . $cluster['synonyms_string'] . ')' : '';
$clusterItemsRemove[] = array(
'name' => $optionName,
- 'value' => h($cluster['id']),
+ 'value' => $cluster['id'],
'additionalData' => array(
- 'event_id' => h($id),
+ 'event_id' => $id,
),
- 'template' => $clusterTemplate,
- 'templateData' => array(
+ 'template' => array(
'name' => $name,
- 'description' => h($cluster['description']),
- 'synonyms_string' => $title
+ 'infoExtra' => $cluster['description'],
+ 'infoContextual' => $title
)
);
}
@@ -1654,14 +1639,16 @@ class AttributesController extends AppController
foreach ($tags as $k => $tag) {
$tagName = $tag['name'];
$tagItemsAdd[] = array(
- 'name' => h($tagName),
- 'value' => h($tag['id']),
- 'template' => $tagTemplate,
- 'templateData' => array(
- 'name' => h($tagName),
- 'background' => h(isset($tag['colour']) ? $tag['colour'] : '#ffffff'),
- 'color' => h(isset($tag['colour']) ? $textColourHelper->getTextColour($tag['colour']) : '#0088cc')
- ),
+ 'name' => $tagName,
+ 'value' => $tag['id'],
+ 'template' => array(
+ 'name' => array(
+ 'name' => $tagName,
+ 'label' => array(
+ 'background' => isset($tag['colour']) ? $tag['colour'] : '#ffffff'
+ )
+ ),
+ )
);
}
diff --git a/app/Controller/GalaxiesController.php b/app/Controller/GalaxiesController.php
index f52bd9ee4..4cedbfef2 100644
--- a/app/Controller/GalaxiesController.php
+++ b/app/Controller/GalaxiesController.php
@@ -114,29 +114,19 @@ class GalaxiesController extends AppController
);
foreach ($galaxies as $galaxy) {
if ($galaxy['Galaxy']['id'] != -1) {
- // construct option template
- $galaxyTemplate = '';
- $galaxyTemplate .= '{{=it.name}}';
- if (strlen($galaxy['Galaxy']['description']) < 50) {
- $galaxyTemplate .= '{{=it.description}}';
- } else {
- $galaxyTemplate .= '';
- }
-
$items[] = array(
'name' => h($galaxy['Galaxy']['name']),
- 'value' => "/galaxies/selectCluster/" . h($target_id) . '/' . h($target_type) . '/' . h($galaxy['Galaxy']['id']),
- 'template' => $galaxyTemplate,
- 'templateData' => array(
- 'icon' => h($galaxy['Galaxy']['icon']),
- 'name' => h($galaxy['Galaxy']['name']),
- 'description' => h($galaxy['Galaxy']['description'])
+ 'value' => "/galaxies/selectCluster/" . $target_id . '/' . $target_type . '/' . $galaxy['Galaxy']['id'],
+ 'template' => array(
+ 'preIcon' => 'fa-' . $galaxy['Galaxy']['icon'],
+ 'name' => $galaxy['Galaxy']['name'],
+ 'infoExtra' => $galaxy['Galaxy']['description'],
)
);
} else { // attackMatrix
$items[] = array(
'name' => $galaxy['Galaxy']['name'],
- 'functionName' => "getMitreMatrixPopup('" . h($target_type) . "', '" . h($target_id) . "')",
+ 'functionName' => "getMitreMatrixPopup('" . $target_type . "', '" . $target_id . "')",
'isPill' => true,
'img' => "/img/mitre-attack-icon.ico",
);
@@ -159,12 +149,12 @@ class GalaxiesController extends AppController
$items = array();
$items[] = array(
'name' => __('All namespaces'),
- 'value' => "/galaxies/selectGalaxy/" . h($target_id) . '/' . h($target_type) . '/0'
+ 'value' => "/galaxies/selectGalaxy/" . $target_id . '/' . $target_type . '/0'
);
foreach ($namespaces as $namespace) {
$items[] = array(
- 'name' => h($namespace),
- 'value' => "/galaxies/selectGalaxy/" . h($target_id) . '/' . h($target_type) . '/' . h($namespace)
+ 'name' => $namespace,
+ 'value' => "/galaxies/selectGalaxy/" . $target_id . '/' . $target_type . '/' . $namespace
);
}
@@ -209,38 +199,30 @@ class GalaxiesController extends AppController
$items = array();
foreach ($clusters as $namespace => $cluster_data) {
foreach ($cluster_data as $k => $cluster) {
- $clusterTemplate = '{{=it.name}}';
- if (strlen($cluster['description']) < 50) {
- $clusterTemplate .= '{{=it.description}}';
+ $name = $cluster['value'];
+ $optionName = $cluster['value'];
+ if ($cluster['synonyms_string'] !== '') {
+ $synom = __('Synonyms: ') . $cluster['synonyms_string'];
+ $optionName .= $cluster['synonyms_string'] !== '' ? ' (' . $cluster['synonyms_string'] . ')' : '';
} else {
- $clusterTemplate .= '';
+ $synom = '';
}
- if ($cluster['synonyms_string'] !== "") {
- $clusterTemplate .= '{{=it.synonyms_string}}
';
- }
-
- $target_type = h($target_type);
- $target_id = h($target_id);
- $cluster_id = h($cluster['id']);
- $title = __('Synonyms: ') . h($cluster['synonyms_string']);
- $name = h($cluster['value']);
- $optionName = h($cluster['value']);
- $optionName .= $cluster['synonyms_string'] !== '' ? ' (' . h($cluster['synonyms_string']) . ')' : '';
- $items[] = array(
+ $itemParam = array(
'name' => $optionName,
- 'value' => h($cluster_id),
- 'title' => $title,
+ 'value' => $cluster['id'],
'additionalData' => array(
'target_id' => $target_id,
'target_type' => $target_type,
),
- 'template' => $clusterTemplate,
- 'templateData' => array(
+ 'template' => array(
'name' => $name,
- 'description' => h($cluster['description']),
- 'synonyms_string' => $title
+ 'infoExtra' => $cluster['description'],
)
);
+ if ($cluster['synonyms_string'] !== '') {
+ $itemParam['template']['infoContextual'] = $synom;
+ }
+ $items[] = $itemParam;
}
}
$onClickForm = 'quickSubmitGalaxyForm';
diff --git a/app/Controller/ObjectTemplatesController.php b/app/Controller/ObjectTemplatesController.php
index 1fc9f46ee..fcbd9147a 100644
--- a/app/Controller/ObjectTemplatesController.php
+++ b/app/Controller/ObjectTemplatesController.php
@@ -62,24 +62,14 @@ class ObjectTemplatesController extends AppController
$items = array();
foreach($templates_raw as $template) {
- $template = $template['ObjectTemplate'];
- $chosenTemplate = '{{=it.name}}';
- if (strlen($template['description']) < 80) {
- $chosenTemplate .= '{{=it.description}}';
- } else {
- $chosenTemplate .= '';
- }
- $chosenTemplate .= '{{=it.metacateg}}
';
-
$items[] = array(
'name' => $template['name'],
'value' => $template['id'],
- 'additionalData' => array('event_id' => h($event_id)),
- 'template' => $chosenTemplate,
- 'templateData' => array(
- 'name' => h($template['name']),
- 'description' => h($template['description']),
- 'metacateg' => __('Category') . ': ' . h($template['meta-category'])
+ 'additionalData' => array('event_id' => $event_id),
+ 'template' => array(
+ 'name' => $template['name'],
+ 'infoExtra' => $template['description'],
+ 'infoContextual' => $template['meta-category']
)
);
}
diff --git a/app/Controller/TagsController.php b/app/Controller/TagsController.php
index 6c6b81185..b43a3e1a1 100644
--- a/app/Controller/TagsController.php
+++ b/app/Controller/TagsController.php
@@ -722,55 +722,41 @@ class TagsController extends AppController
$this->set('scope', $scope);
$this->set('object_id', $id);
- App::uses('TextColourHelper', 'View/Helper');
- $textColourHelper = new TextColourHelper(new View());
+
+ if ($scope === 'attribute') {
+ $onClickForm = 'quickSubmitAttributeTagForm';
+ } elseif ($scope === 'tag_collection') {
+ $onClickForm = 'quickSubmitTagCollectionTagForm';
+ } else {
+ $onClickForm = 'quickSubmitTagForm';
+ }
$items = array();
foreach ($tags as $k => $tag) {
- $tagTemplate = '{{=it.name}}';
-
$tagName = $tag['name'];
$choice_id = $k;
if ($taxonomy_id === 'collections') {
$choice_id = 'collection_' . $choice_id;
}
- $onClickForm = 'quickSubmitTagForm';
- if ($scope === 'attribute') {
- $onClickForm = 'quickSubmitAttributeTagForm';
- }
- if ($scope === 'tag_collection') {
- $onClickForm = 'quickSubmitTagCollectionTagForm';
- }
-
- if (is_numeric($taxonomy_id) && $taxonomy_id > 0 && isset($expanded[$tag['id']])) {
- if (strlen($expanded[$tag['id']]) < 50) {
- $tagTemplate .= '{{=it.expanded}}';
- } else {
- $tagTemplate .= '';
- }
- }
- if ($taxonomy_id === 'collections') {
- $tagTemplate .= '{{=it.includes}}
';
- }
-
$itemParam = array(
- 'name' => h($tagName),
- 'value' => h($choice_id),
+ 'name' => $tagName,
+ 'value' => $choice_id,
'additionalData' => array(
- 'id' => h($id)
+ 'id' => $id
),
- 'template' => $tagTemplate,
- 'templateData' => array(
- 'name' => h($tagName),
- 'background' => h(isset($tag['colour']) ? $tag['colour'] : '#ffffff'),
- 'color' => h(isset($tag['colour']) ? $textColourHelper->getTextColour($tag['colour']) : '#0088cc'),
- 'expanded' => h($expanded[$tag['id']])
+ 'template' => array(
+ 'name' => array(
+ 'name' => $tagName,
+ 'label' => array(
+ 'background' => isset($tag['colour']) ? $tag['colour'] : '#ffffff'
+ )
+ ),
+ 'infoExtra' => $expanded[$tag['id']]
)
);
if ($taxonomy_id === 'collections') {
- $TagCollectionTag = __('Includes: ') . h($inludedTagListString[$tag['id']]);
- $itemParam['templateData']['includes'] = $TagCollectionTag;
+ $itemParam['template']['infoContextual'] = __('Includes: ') . $inludedTagListString[$tag['id']];
}
$items[] = $itemParam;
}
diff --git a/app/View/Elements/genericPickerElements/name.ctp b/app/View/Elements/genericPickerElements/name.ctp
new file mode 100644
index 000000000..1be575bc3
--- /dev/null
+++ b/app/View/Elements/genericPickerElements/name.ctp
@@ -0,0 +1,19 @@
+TextColour->getTextColour($label['background']) : '#0088cc';
+?>
+
+
+
+
+_View->element('genericPickerElements/pre_icon', array('preIcon' => $templateParam['preIcon']));
}
- $template .= h($templateParam['name']);
+ $template .= $this->_View->element('genericPickerElements/name', array('name' => $templateParam['name']));
if (isset($templateParam['infoExtra'])) {
$template .= $this->_View->element('genericPickerElements/info_extra', array('infoExtra' => $templateParam['infoExtra']));
}