mirror of https://github.com/MISP/MISP
chg: [generic_picker] all view using the generic_picker now use the
generic_picker view elements - WIPpull/4041/head
parent
7cfe1d87a9
commit
1a2edf05b1
|
@ -1580,26 +1580,22 @@ class AttributesController extends AppController
|
|||
$selectedAttributeIds = array();
|
||||
}
|
||||
|
||||
App::uses('TextColourHelper', 'View/Helper');
|
||||
$textColourHelper = new TextColourHelper(new View());
|
||||
$tagTemplate = '<span href="#" class="tagComplete" style="background-color:{{=it.background}}; color:{{=it.color}}">{{=it.name}}</span>';
|
||||
$galaxyTemplate = '<span href="#" class="tagComplete" style="background-color:{{=it.background}}; color:{{=it.color}}">{{=it.name}}</span>';
|
||||
|
||||
// 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 .= '<i style="float:right; font-size: smaller;">{{=it.description}}</i>';
|
||||
} else {
|
||||
$clusterTemplate .= '<it class="fa fa-info-circle" style="float:right;" title="{{=it.description}}"></it>';
|
||||
}
|
||||
if ($cluster['synonyms_string'] !== "") {
|
||||
$clusterTemplate .= '<div class="apply_css_arrow" style="padding-left: 5px; font-size: smaller;"><i>{{=it.synonyms_string}}</i></div>';
|
||||
}
|
||||
|
||||
$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'
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
|
|
@ -114,29 +114,19 @@ class GalaxiesController extends AppController
|
|||
);
|
||||
foreach ($galaxies as $galaxy) {
|
||||
if ($galaxy['Galaxy']['id'] != -1) {
|
||||
// construct option template
|
||||
$galaxyTemplate = '<it class="fa fa-{{=it.icon}}" style="width: 22px;"></it>';
|
||||
$galaxyTemplate .= '{{=it.name}}';
|
||||
if (strlen($galaxy['Galaxy']['description']) < 50) {
|
||||
$galaxyTemplate .= '<i style="float:right; font-size: smaller;">{{=it.description}}</i>';
|
||||
} else {
|
||||
$galaxyTemplate .= '<it class="fa fa-info-circle" style="float:right;" title="{{=it.description}}"></it>';
|
||||
}
|
||||
|
||||
$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 .= '<i style="float:right; font-size: smaller;">{{=it.description}}</i>';
|
||||
$name = $cluster['value'];
|
||||
$optionName = $cluster['value'];
|
||||
if ($cluster['synonyms_string'] !== '') {
|
||||
$synom = __('Synonyms: ') . $cluster['synonyms_string'];
|
||||
$optionName .= $cluster['synonyms_string'] !== '' ? ' (' . $cluster['synonyms_string'] . ')' : '';
|
||||
} else {
|
||||
$clusterTemplate .= '<it class="fa fa-info-circle" style="float:right;" title="{{=it.description}}"></it>';
|
||||
$synom = '';
|
||||
}
|
||||
if ($cluster['synonyms_string'] !== "") {
|
||||
$clusterTemplate .= '<div class="apply_css_arrow" style="padding-left: 5px; font-size: smaller;"><i>{{=it.synonyms_string}}</i></div>';
|
||||
}
|
||||
|
||||
$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';
|
||||
|
|
|
@ -62,24 +62,14 @@ class ObjectTemplatesController extends AppController
|
|||
|
||||
$items = array();
|
||||
foreach($templates_raw as $template) {
|
||||
$template = $template['ObjectTemplate'];
|
||||
$chosenTemplate = '<span href="#">{{=it.name}}</span>';
|
||||
if (strlen($template['description']) < 80) {
|
||||
$chosenTemplate .= '<i style="float:right; font-size: smaller;">{{=it.description}}</i>';
|
||||
} else {
|
||||
$chosenTemplate .= '<it class="fa fa-info-circle" style="float:right;" title="{{=it.description}}"></it>';
|
||||
}
|
||||
$chosenTemplate .= '<div class="apply_css_arrow" style="padding-left: 5px; margin-top: 5px; font-size: smaller;"><i>{{=it.metacateg}}</i></div>';
|
||||
|
||||
$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']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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 = '<span href="#" class="tagComplete" style="background-color:{{=it.background}}; color:{{=it.color}}">{{=it.name}}</span>';
|
||||
|
||||
$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 .= '<i style="float:right; font-size: smaller;">{{=it.expanded}}</i>';
|
||||
} else {
|
||||
$tagTemplate .= '<it class="fa fa-info-circle" style="float:right;" title="{{=it.expanded}}"></it>';
|
||||
}
|
||||
}
|
||||
if ($taxonomy_id === 'collections') {
|
||||
$tagTemplate .= '<div class="apply_css_arrow" style="padding-left: 5px; margin-top: 5px; font-size: smaller;"><i>{{=it.includes}}</i></div>';
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
if (is_array($name)) {
|
||||
if (isset($name['label'])) {
|
||||
$label = $name['label'];
|
||||
$name = $name['name'];
|
||||
$background_color = isset($label['background']) ? h($label['background']) : '#ffffff';
|
||||
$color = isset($label['background']) ? $this->TextColour->getTextColour($label['background']) : '#0088cc';
|
||||
?>
|
||||
<span href="#" class="tagComplete" style="background-color:<?php echo $background_color; ?>; color:<?php echo $color; ?>">
|
||||
<?php echo $name ?>
|
||||
</span>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo h($name);
|
||||
}
|
||||
} else {
|
||||
echo h($name);
|
||||
}
|
|
@ -117,9 +117,6 @@ function redrawChosenWithTemplate($select, $chosenContainer) {
|
|||
var res = "";
|
||||
if (template !== undefined && template !== '') {
|
||||
var template = atob(template);
|
||||
// var temp = doT.template(template);
|
||||
// var templateData = JSON.parse(atob($option.data('templatedata')));
|
||||
// res = temp(templateData);
|
||||
$item.html(template);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -105,7 +105,7 @@ class GenericPickerHelper extends AppHelper {
|
|||
if (isset($templateParam['preIcon'])) {
|
||||
$template .= $this->_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']));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue